P. 1
Bapi Md61 Final

Bapi Md61 Final

|Views: 85|Likes:
Published by Anupam Samanta

More info:

Published by: Anupam Samanta on Sep 12, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

09/05/2013

pdf

text

original

*&---------------------------------------------------------------------* *& Report zbdc_md61 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT

ZBDC_MD61. TABLES: PBHI, PBIM. *DATA : BEGIN OF BDCDATA1 OCCURS 0. * INCLUDE STRUCTURE BDCDATA. *DATA : END OF BDCDATA1. *DATA : SLNO(2) TYPE N, * CHECK TYPE P DECIMALS 2. *DATA : COUNTER(2) TYPE N. *DATA : SCREEN(3) TYPE N. *DATA : P_MODE TYPE C. *DATA : ASPLN01(20) TYPE C, * ASPLN02(20) TYPE C, * ASPLN03(20) TYPE C, * ASMATNR(18) TYPE C. *********// STRUCTURE DEFINITION //******** *TYPES : BEGIN OF TYPE, * PBDNR(10), * WERKS(4), * VERSB(2), * DATVE(10), * DATBE(10), * MATNR(18), * PLN01(13), * PLN02(13), * PLN03(13), * END OF TYPE. *TYPES : BEGIN OF TY_ITAB_MD61_BAPI_COMFIELD, * MATERIAL TYPE BAPISITEMR-MATERIAL, * PLANT TYPE BAPISITEMR-PLANT, * REQ_TYP TYPE BAPISITEMR-REQU_TYPE, * VER TYPE BAPISITEMR-VERSION, * ACTIVE TYPE BAPISITEMR-VERS_ACTIV, * REQNO TYPE BAPISITEMR-REQ_NUMBER, * END OF TY_ITAB_MD61_BAPI_COMFIELD. * *TYPES : BEGIN OF TY_ITAB_MD61_BAPI_PLAN, * DATE_TY TYPE BAPISSHDIN-DATE_TYPE, * REQ_DAT TYPE BAPISSHDIN-REQ_DATE, * REQ_QTY TYPE BAPISSHDIN-REQ_QTY, * UNIT TYPE BAPISSHDIN-UNIT, * END OF TY_ITAB_MD61_BAPI_PLAN. ********// INTERNAL TABLE DECLARATION //******** *DATA: ITABMD61 TYPE STANDARD TABLE OF TYPE INITIAL SIZE 0, * WAMD61 LIKE LINE OF ITABMD61. *DATA: ITABMD611 TYPE STANDARD TABLE OF TYPE INITIAL SIZE 0, * WAMD611 LIKE LINE OF ITABMD611. *DATA: ITABPBHI TYPE STANDARD TABLE OF PBHI INITIAL SIZE 0, * WAPBHI LIKE LINE OF ITABPBHI.

'AM60X-PBDNR' WAMD61-PBDNR. 'AM60X-PBDAW' 'X'. * IF MODE_N = 'X'. *END-OF-SELECTION. *INITIALIZATION. * ENDIF.*DATA: ITAB_MD61_BAPI_COMFIELD TYPE STANDARD TABLE OF TY_ITAB_MD61_BAPI_COMFIELD INITIAL SIZE 0. * P_MODE = 'N'. WA_ITAB_PBHI LIKE LINE OF ITAB_PBHI. *SELECTION-SCREEN END OF BLOCK GROUP. 'RM60X-DATVE' WAMD61-DATVE. *PERFORM CHECK USING 'MATNR' 'WERKS' 'PBDNR'. *********// CHANGE MODE //******** *START-OF-SELECTION. *SORT ITABMD61 BY PBDNR. * CALL FUNCTION 'UPLOAD' * EXPORTING * FILENAME = 'D:\' * FILETYPE = 'DAT' * TABLES DATA_TAB = ITABMD61. *********// SELECTION SCREEN BEGINS //******** *SELECTION-SCREEN BEGIN OF BLOCK GROUP WITH FRAME TITLE TXT. WA_ITAB_PBIM LIKE LINE OF ITAB_PBIM. * perform bdc_dynpro using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using * PERFORM BDC_FIELD using 'SAPMM60X' '0100'. * SLNO = 0. 'BDC_OKCODE' '/00'. . 'BDC_CURSOR' 'RM60X-DATBE'. * TXT = 'SELECT MODE'. * ELSE. * LOOP AT ITABMD61 INTO WAMD61. ITAB_PBIM TYPE STANDARD TABLE OF PBIM INITIAL SIZE 0. *DATA: * * *DATA: * ITAB_PBHI TYPE STANDARD TABLE OF PBHI INITIAL SIZE 0. * COUNTER = 1. 'AM60X-WERKS' WAMD61-WERKS. * *SELECT MATNR WERKS PBDNR INTO CORRESPONDING FIELDS OF TABLE ITAB_PBIM FROM PBI M * FOR ALL ENTRIES IN ITABMD61 WHERE MATNR = ITABMD61-MATNR. * MODE_A RADIOBUTTON GROUP MODE . * WA_ITAB_MD61_BAPI_COMFIELD LIKE LINE OF ITAB_MD61_BAPI_COMFIELD. 'AM60X-MATAW' ''. * WA_ITAB_MD61_BAPI_PLAN LIKE LINE OF ITAB_MD61_BAPI_PLAN. *FORM BDC_MAIN. 'RM60X-VERSB' 'GP'. * P_MODE = 'A'. *DELETE ADJACENT DUPLICATES FROM ITABMD61 COMPARING PBDNR WERKS. *PARAMETERS: MODE_N RADIOBUTTON GROUP MODE DEFAULT 'X'. * *DATA: ITAB_MD61_BAPI_PLAN TYPE STANDARD TABLE OF TY_ITAB_MD61_BAPI_PLAN INITIAL SIZE 0. *ITABMD611[] = ITABMD61[].

* CONCATENATE 'RM60X-PLN01(' slno ')' INTO ASPLN01.* PERFORM BDC_FIELD using 'RM60X-DATBE' WAMD61-DATBE. * LOOP AT ITABMD611 INTO WAMD611 WHERE PBDNR = WAMD61-PBDNR AND WERKS = WAM D61-WERKS. * PERFORM BDC_FIELD USING ASPLN02 WAMD611-PLN02. "' 600 0'. * CONCATENATE 'PBPT-MATNR(0' slno ')' INTO ASMATNR. * CONCATENATE 'PBPT-MATNR(0' slno ')' INTO ASMATNR. * PERFORM BDC_DYNPRO using 'SAPLM60E' '0200'. * CONCATENATE 'PBPT-MATNR(' slno ')' INTO ASMATNR. * SLNO = 0. * PERFORM BDC_FIELD USING ASMATNR WAMD611-MATNR. * SLNO = SLNO + 1. * IF SLNO > 9. * CONCATENATE 'RM60X-PLN01(0' slno ')' INTO ASPLN01. * CONCATENATE 'PBPT-MATNR(' slno ')' INTO ASMATNR. * PERFORM BDC_FIELD USING ASPLN01 WAMD611-PLN01. * CONCATENATE 'RM60X-PLN02(' slno ')' INTO ASPLN02. * CONCATENATE 'RM60X-PLN01(' slno ')' INTO ASPLN01. * IF COUNTER >= 18. * SLNO = SLNO + 1. "' 700 0'. * PERFORM BDC_FIELD USING ASMATNR WAMD611-MATNR. * ENDIF. * ENDIF. * PERFORM bdc_dynpro using 'SAPLM60E' '0200'. * PERFORM bdc_field using 'BDC_OKCODE' '/00'. * CONCATENATE 'RM60X-PLN01(0' slno ')' INTO ASPLN01. * CONCATENATE 'RM60X-PLN02(' slno ')' INTO ASPLN02. * CONCATENATE 'RM60X-PLN02(0' slno ')' INTO ASPLN02. * PERFORM BDC_FIELD USING ASPLN01 WAMD611-PLN01. * CONCATENATE 'RM60X-PLN03(' slno ')' INTO ASPLN03. * ELSEIF ( SCREEN > 100 AND SCREEN < 200 ) OR * ( SCREEN > 200 AND SCREEN < 300 ) OR * ( SCREEN > 300 AND SCREEN < 400 ) OR * ( SCREEN > 400 AND SCREEN < 500 ). * IF COUNTER >= 1 AND COUNTER < 18. * IF SLNO > 9. . * PERFORM BDC_FIELD using 'BDC_OKCODE' '=P+'. * PERFORM BDC_FIELD USING ASPLN03 WAMD611-PLN03. * * IF SCREEN = 100 OR SCREEN = 200 OR SCREEN = 300 OR SCREEN = 400 OR SCRE EN = 500. * * SCREEN = ( COUNTER / 18 ) * 100. "' 5 000'. * CONCATENATE 'RM60X-PLN02(0' slno ')' INTO ASPLN02. ** PERFORM bdc_field using 'BDC_CURSOR' 'RM60X-PLN03'. * ENDIF. * ENDIF. "' 500 0'. "' 6 000'. * CONCATENATE 'RM60X-PLN03(0' slno ')' INTO ASPLN03. * ELSE. * PERFORM BDC_FIELD USING ASPLN02 WAMD611-PLN02. * ELSE. * CONCATENATE 'RM60X-PLN03(0' slno ')' INTO ASPLN03. * PERFORM BDC_FIELD using 'RM60X-ENTLU' 'M'. ** SLNO = 0. * CONCATENATE 'RM60X-PLN03(' slno ')' INTO ASPLN03.

'AND PLANT:' . * ELSEIF P_MODE EQ 'A'. WA_ITAB_PBIM-PBDNR . * APPEND BDCDATA1. * COUNTER = COUNTER + 1. "' 7 000'. * WRITE : /'DATA UPLOADED IN TABLE FOR TESTPLAN:'. * BDCDATA1-DYNPRO = DYNPRO. CHECK. WA_ITAB_PBIM-MATNR. insert a field * ** FORM BDC_FIELD **----------------------------------------------------------------* *FORM BDC_FIELD USING FNAM FVAL. * CLEAR : COUNTER. * BDCDATA1-PROGRAM = PROGRAM. * WRITE : /'DATA UPLOADED IN TABLE FOR TESTPLAN:'. * PERFORM BDC_FIELD using 'BDC_CURSOR' 'PBPT-MATNR(01)'. WAMD61-PBDNR. * BDCDATA1-DYNBEGIN = 'X'. * WRITE: / 'CHECK MATERIAL :'. * ENDIF. * WRITE: / 'CHECK PLANT :'.'ALREADY EXISTS'. * CLEAR BDCDATA1. * WRITE: / 'TEST PLAN :'. * CALL TRANSACTION 'MD61' USING BDCDATA1 MODE P_MODE. * ENDIF. * IF WA_ITAB_PBIM-MATNR <> MATNR. WAMD61-PBDNR. * *FORM CHECK USING MATNR WERKS PBDNR. WA_ITAB_PBIM-WERKS. * ENDFORM. *END-OF-SELECTION.WAMD61-WERKS . * CLEAR : WAMD611. * ELSE. * * IF P_MODE EQ 'N'. SLNO. * * *FORM BDC_DYNPRO USING PROGRAM DYNPRO. 'AND PLANT:' . * ELSEIF WA_ITAB_PBIM-WERKS <> WERKS. * ENDLOOP. * ENDIF. * PERFORM BDC_MAIN. * APPEND BDCDATA1. "End BDC_DYNPRO **----------------------------------------------------------------* ** In the batch input data. . * * DELETE ITABMD61 WHERE PBDNR = WAMD61-PBDNR AND WERKS = WAMD61-WERKS. *LOOP AT ITAB_PBIM INTO WA_ITAB_PBIM.WAMD61-WERKS . * REFRESH BDCDATA1. * ENDLOOP. * BDCDATA1-FNAM = FNAM. * BDCDATA1-FVAL = FVAL. * PERFORM BDC_FIELD using 'BDC_OKCODE' '=SICH'. * ELSE. * CLEAR BDCDATA1. *ENDFORM. *ENDFORM.* PERFORM BDC_FIELD USING ASPLN03 WAMD611-PLN03. * ENDIF. * CLEAR BDCDATA1. * IF WA_ITAB_PBIM-MATNR <> MATNR OR WA_ITAB_PBIM-WERKS <> WERKS OR WA_ITAB_PB IM-PBDNR = PBDNR. * PERFORM BDC_DYNPRO using 'SAPLM60E' '0200'.

REQ_QTY8 TYPE CHAR13. TYPES: BEGIN OF TY_EXCELDATA. REQ_QTY6 TYPE CHAR13. REQ_QTY11 TYPE CHAR13. SELECTION-SCREEN POSITION 1.*ENDLOOP. REQ_QTY7 TYPE CHAR13. * *>>*<< Selection_Screen SELECTION-SCREEN BEGIN OF BLOCK block-0 WITH FRAME TITLE text-003. TY_RETURN TYPE STANDARD TABLE OF BAPIRETURN1. lc_req_number TYPE bapisitemr-req_number. SELECTION-SCREEN BEGIN OF LINE. lc_month TYPE dlymo. DATA: ls_raw_data TYPE truxs_t_text_data. LT_REQUIREMENT_SCHEDULE TYPE ty_requirement_schedule. END OF TY_EXCELDATA. DATA: lc_days TYPE dlydy. DATA: ITAB_PBIM TYPE STANDARD TABLE OF PBIM INITIAL SIZE 0. *ENDFORM. REQ_QTY9 TYPE CHAR13. . REQ_QTY3 TYPE CHAR13. CC_VERS_ACTIV TYPE VERVS VALUE 'X'. ls_exceldata TYPE ty_exceldata. REQ_QTY1 TYPE CHAR13. WA_ITAB_PBIM LIKE LINE OF ITAB_PBIM. * *>>*<< Variables DATA: LT_EXCELDATA TYPE STANDARD TABLE OF ty_exceldata. REQ_QTY10 TYPE CHAR13. PARAMETERS: P_PBDNR TYPE PBDNR OBLIGATORY. TYPES: TY_REQUIREMENT_SCHEDULE TYPE STANDARD TABLE OF BAPISSHDIN. ls_requirement_item TYPE bapisitemr. "bapisshdin. *DATA: ITAB_PBHI TYPE STANDARD TABLE OF PBHI INITIAL SIZE 0. CC_UNIT TYPE MEINS VALUE 'EA'. REQ_QTY5 TYPE CHAR13. REQ_QTY2 TYPE CHAR13. REQ_QTY12 TYPE CHAR13. *>>*<< Constants CONSTANTS: CC_REQU_TYP TYPE BEDAE VALUE 'LSF'. <FS_COMP> TYPE ANY. ls_return TYPE bapireturn1. REQ_QTY4 TYPE CHAR13. * p_bedae TYPE rm60x-bedae DEFAULT 'LSF' NO-DISPLAY. LT_RETURN TYPE TY_RETURN. CC_YEAR TYPE T5A4A-DLYYR VALUE 0. MATERIAL TYPE CHAR18. DATA: GI_EXCEL_ROW TYPE SY-TABIX. TYPE-POOLS:TRUXS. "bapireturn1. * WA_ITAB_PBHI LIKE LINE OF ITAB_PBHI. P_WERKS TYPE WERKS_D . *>>*<< Filed Symbols FIELD-SYMBOLS: <FS_LS> TYPE ANY.

SELECTION-SCREEN:COMMENT 1(79) text-010. SELECTION-SCREEN BEGIN OF BLOCK block-1 WITH FRAME TITLE text-001. *>>** << Start of Selection START-OF-SELECTION. any category *ENDLOOP. *LOOP AT LT_EXCELDATA INTO LS_EXCELDATA. * * Conversion exit for MATNR ."* Function to browse requi red excel file PERFORM selectfile CHANGING p_fname. COMMENT /1(79) text-014. *CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' * EXPORTING * input = ls_exceldata-MATERIAL " clike C field * IMPORTING * output = ls_exceldata-MATERIAL . *SELECT * FROM PBIM INTO CORRESPONDING FIELDS OF TABLE ITAB_PBIM * FOR ALL ENTRIES IN LT_EXCELDATA WHERE MATNR = LT_EXCELDATA-MATERIAL . * SHIFT LS_EXCELDATA-MATERIAL RIGHT DELETING TRAILING SPACE. SELECTION-SCREEN END OF BLOCK block-2. * OVERLAY LS_EXCELDATA-MATERIAL WITH '00000000'. PARAMETERS: p_datve TYPE datve DEFAULT sy-datum OBLIGATORY. COMMENT /1(79) text-011. *>>* *<< At Selection_Screen AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname."* Function to read data from excel file to internal table <intern> PERFORM UPLOADEXCELDATA. COMMENT /1(79) text-012. COMMENT /1(79) text-013.xls' OBLIGATORY. * SELECTION-SCREEN POSITION 40. PERFORM 1st_dayofweek. SELECTION-SCREEN END OF LINE. DELETE ADJACENT DUPLICATES FROM LT_EXCELDATA COMPARING MATERIAL. SELECTION-SCREEN END OF BLOCK block-0.SELECTION-SCREEN COMMENT 1(31) text-005. PARAMETERS:p_vervs TYPE vervs DEFAULT 'X' NO-DISPLAY. * MODIFY LT_EXCELDATA FROM LS_EXCELDATA-MATERIAL."* Get the 1st day of the week IF p_entlu EQ 'W'. *LOOP AT LT_EXCELDATA INTO LS_EXCELDATA. SELECTION-SCREEN COMMENT 42(10) text-006. SELECTION-SCREEN BEGIN OF BLOCK BLOCK-2 WITH FRAME TITLE text-004. gi_excel_row = SY-TABIX. LOOP AT LT_EXCELDATA INTO ls_exceldata. p_entlu TYPE rm60x-entlu DEFAULT 'M' OBLIGATORY. *PERFORM CHECK. SORT LT_EXCELDATA BY MATERIAL. PARAMETERS:p_fname TYPE localfile DEFAULT 'C:/. SELECTION-SCREEN END OF BLOCK BLOCK-1. *ENDLOOP. PARAMETERS: p_versb TYPE rm60x-versb DEFAULT 'GP' NO-DISPLAY. " clike Internal display of INPUT. * * Read the internal table data from excel file gi_excel_row = 0. TRANSLATE ls_exceldata-material TO UPPER CASE. "3 ENDIF.

* * Function to create independent requirement planning PERFORM create_requirement USING LT_REQUIREMENT_SCHEDULE ls_requirement_item CHANGING lt_return lc_req_number. * ENDIF. ENDIF. *ENDFORM. ** WRITE: / 'CHECK MATERIAL :'. ** ENDIF. *LOOP AT ITAB_PBIM INTO WA_ITAB_PBIM. ** ELSEIF WA_ITAB_PBIM-WERKS <> WERKS.'ALREADY EXISTS'. REFRESH:LT_REQUIREMENT_SCHEDULE. WA_ITAB_PBIM-WERKS. *ENDLOOP. ** ELSE. LS_EXCELDATA-MATERIAL-MATERIAL. IF lt_return IS INITIAL. *>> *FORM CHECK. * Check for existing Planning requirement PERFORM check_for_exist USING ls_exceldata-material CHANGING lt_return. WA_ITAB_PBIM-PBDNR . * * Requirement planning does not exists need to create it. ** WRITE: / 'CHECK PLANT :'. PERFORM read_data USING ls_exceldata CHANGING ls_requirement_item LT_REQUIREMENT_SCHEDULE. * ELSE. . ENDLOOP. PERFORM read_data USING ls_exceldata CHANGING ls_requirement_item LT_REQUIREMENT_SCHEDULE.* CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = ls_exceldata-material IMPORTING output = ls_exceldata-material. * IF WA_ITAB_PBIM-MATNR <> LS_EXCELDATA-MATERIAL. * Function to change requirement planning PERFORM change_requirement USING LT_REQUIREMENT_SCHEDULE ls_requirement_item CHANGING lt_return. ** EXIT. *&---------------------------------------------------------------------** *&Form SELECTFILE *&---------------------------------------------------------------------** * Function to browse excel file *----------------------------------------------------------------------* FORM selectfile CHANGING ic_filename TYPE localfile . ** WRITE: / 'TEST PLAN :'. lc_windowt TYPE string. REFRESH: LT_REQUIREMENT_SCHEDULE. ELSE." * Requirement planning exists need to update it. * CONTINUE. ** IF WA_ITAB_PBIM-MATNR <> MATNR. DATA:lc_subrc TYPE sy-subrc.

" UPLOADEXCELDATA *&---------------------------------------------------------------------* *& Form GET_DATE *&---------------------------------------------------------------------* * Program to get next date *----------------------------------------------------------------------* FORM get_date USING value(id_date_in) TYPE p0001-begda value(ii_days) TYPE t5a4a-dlydy value(ii_month) TYPE t5a4a-dlymo value(lc_years) TYPE t5a4a-dlyyr CHANGING ed_date_out TYPE p0001-begda. * * Display File Open Dialog control/screen to select excel file CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING window_title = lc_windowt default_filename = '*. " SELECTFILE *&---------------------------------------------------------------------* *& Form UPLOADEXCELDATA *&---------------------------------------------------------------------* * Function to upload excel file *----------------------------------------------------------------------* FORM UPLOADEXCELDATA. ENDFORM. * * Write path on input area READ TABLE lt_filetab INDEX 1 INTO ic_filename. ENDFORM. ENDFORM. lc_windowt = 'Select Source Excel File'(002).xlsx' multiselection = ' ' CHANGING file_table = lt_filetab rc = lc_subrc. " GET_DATE *&---------------------------------------------------------------------* *& Form CREATE_REQUIREMENT *&---------------------------------------------------------------------* . * FM to read data from excel file CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' EXPORTING i_tab_raw_data = ls_raw_data i_line_header = 'X' i_filename = p_fname TABLES i_tab_converted_data = LT_EXCELDATA. * FM to calculate next date by passing date and number of days or number of mont hs CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL' EXPORTING date = id_date_in days = ii_days months = ii_month years = lc_years IMPORTING calc_date = ed_date_out.DATA:lt_filetab TYPE filetable.

20 ls_return-me ssage. 'Error while creation Requirement of Material:'. ELSE. REFRESH: et_return. ENDFORM. es_requirement_item-vers_activ = p_vervs. ENDFORM. es_requirement_item-version = p_versb. DATA:ls_return TYPE bapireturn1.is _requirement_item-material. " READ_DATA * * . CALL FUNCTION 'BAPI_REQUIREMENTS_CREATE' EXPORTING requirements_item = is_requirement_item do_commit = 'X' IMPORTING reqmtsplannumber = ec_req_number TABLES requirements_schedule_in = it_requirement_schedule return = et_return. WRITE :/ gi_excel_row. WRITE:/ gi_excel_row.et_return. REFRESH:it_requirement_schedule. " CREATE_REQUIREMENT *&---------------------------------------------------------------------* *& Form READ_DATA *&---------------------------------------------------------------------* * Moving data to bapi required structures *----------------------------------------------------------------------* FORM read_data USING value(is_exceldata) TYPE ty_exceldata CHANGING es_requirement_item TYPE bapisitemr et_requirement_schedule TYPE ty_requirement_schedule. ENDIF. is_requirem ent_item-material. ls_return-number. IF et_return IS INITIAL. 'Requirements created For Material:'. * * Item details * es_requirement_item-requ_type = p_bedae. * Schedule data PERFORM read_schedule_data USING is_exceldata CHANGING et_requirement_schedule.* Calling BAPI to create independent requirement planning *----------------------------------------------------------------------* FORM create_requirement USING value(it_requirement_schedule) TYPE ty_requirement_schedule value(is_requirement_item) TYPE bapisitemr CHANGING et_return TYPE ty_return ec_req_number TYPE bapisitemr-req_number. es_requirement_item-material = is_exceldata-material. ENDLOOP. es_requirement_item-req_number = p_pbdnr. es_requirement_item-plant = p_werks. ENDIF. ls_return-id. LOOP AT et_return INTO ls_return. WRITE: ls_return-type.

ELSE. p_bedae. LOOP AT et_return INTO ls_return. ENDIF. p_vervs. " CHANGE_REQUIREMENT *&---------------------------------------------------------------------* *& Form CHECK_FOR_EXIST *&---------------------------------------------------------------------* * Function to check for plannning existance *----------------------------------------------------------------------* FORM check_for_exist USING value(is_exceldata_material) TYPE ty_exceldata-material CHANGING et_return TYPE ty_return.*&---------------------------------------------------------------------* *& Form CHANGE_REQUIREMENT *&---------------------------------------------------------------------* * Function to change requirement planning *----------------------------------------------------------------------* FORM change_requirement USING value(it_requirement_schedule) TYPE ty_requirement_schedule value(is_requirement_item) TYPE bapisitemr CHANGING et_return TYPE ty_return . * REFRESH: et_return. lc_reqmtsplannumber LIKE bapisitemr-req_number. WRITE : / gi_excel_row. IF et_return IS INITIAL. WRITE: gi_excel_row. is_requireme nt_item-material. lc_vers_activ LIKE bapisitemr-vers_activ. ls_return-number. 'Error while updating Material:'. ENDFORM. p_versb.et_return. WRITE: ls_return-type. REFRESH:it_requirement_schedule. 20 ls_return-me ssage. ls_return-id. lc_material lc_plant lc_requirementstype lc_version lc_reqmtsplannumber lc_vers_activ = = = = = = is_requirement_item-material. . lc_version LIKE bapisitemr-version. ENDLOOP. is_requirement_it em-material. lc_plant LIKE bapisitemr-plant. 'Requirements updated For Material:'. p_werks. p_pbdnr. * Bapi to update the planning CALL FUNCTION 'BAPI_REQUIREMENTS_CHANGE' EXPORTING material = lc_material plant = lc_plant requirementstype = lc_requirementstype version = lc_version reqmtsplannumber = lc_reqmtsplannumber vers_activ = lc_vers_activ TABLES requirements_schedule_in = it_requirement_schedule return = et_return. DATA:ls_return TYPE bapireturn1. DATA: lc_material LIKE bapisitemr-material. lc_requirementstype LIKE bapisitemr-requ_type.

lc_reqmtsplannumber = p_pbdnr. ELSEIF p_entlu = 'W'.DATA: lc_material LIKE bapisitemr-material. ELSEIF p_entlu = 'M'. ENDIF. lc_data_type = '2'. DATA:lc_data_type TYPE prgrs. CALL FUNCTION 'BAPI_REQUIREMENTS_GETDETAIL' EXPORTING material = lc_material plant = lc_plant requirementstype = lc_requirementstype version = lc_version reqmtsplannumber = lc_reqmtsplannumber TABLES return = et_return. * lc_requirementstype = p_bedae. lc_version = p_versb. lc_plant LIKE bapisitemr-plant. lc_days = '00'. lc_data_type = '1'. lc_version LIKE bapisitemr-version. lc_month = '01'. "read_schedule_data *&---------------------------------------------------------------------* *& Form GET_SCHEDULE_DATA *&---------------------------------------------------------------------* . " CHECK_FOR_EXIST *&---------------------------------------------------------------------* *& Form READ_SCHEDULE_DATA *&---------------------------------------------------------------------* * Function to get schedule line items *----------------------------------------------------------------------* FORM read_schedule_data USING value(is_exceldata) TYPE ty_exceldata CHANGING et_requirement_schedule TYPE ty_requirement_schedule. ENDFORM. lc_days = '07'. lc_month = '00'. ENDFORM. lc_month = '00'. lc_requirementstype LIKE bapisitemr-requ_type. lc_days = '01'. lc_data_type = '3'. * Bapi to get details of the planning requirement * If return table is initial then requirement exists * else the requirement doesn't exists. lc_material = is_exceldata_material. IF p_entlu = 'D'. * Get schedule data PERFORM get_schedule_data USING is_exceldata lc_data_type lc_days lc_month CHANGING et_requirement_schedule. lc_reqmtsplannumber LIKE bapisitemr-req_number. lc_plant = p_werks.

ld_date_out TYPE begda. IF sy-index > 61. * CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' * EXPORTING* input = ls_requirement_schedule-unit * language = sy-langu * IMPORTING * output = ls_requirement_schedule-unit * EXCEPTIONS * unit_not_found = 1. * Loop will read data from work area horizontally and get next required quantity WHILE sy-subrc = 0. * Function to get next date by paasing the start date IF sy-index > 2. ld_date_in = p_datve. ls_requirement_schedule-req_qty = <fs_comp>.* * CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' * EXPORTING * input = ls_requirement_schedule-unit * language = sy-langu * IMPORTING * output = ls_requirement_schedule-unit * EXCEPTIONS * unit_not_found = 1. ls_requirement_schedule-date_type = ic_date_type. DATA:ls_requirement_schedule TYPE bapisshdin. ls_requirement_schedule-req_qty = is_exceldata-req_qty1. ENDWHILE. " GET_SCHEDULE_DATA *&---------------------------------------------------------------------* *& Form 1ST_DAYOFWEEK *&---------------------------------------------------------------------* . ld_date_in = ld_date_out. PERFORM get_date USING ld_date_in ic_days ic_month CC_YEAR CHANGING ld_date_out. ENDIF. ASSIGN COMPONENT sy-index OF STRUCTURE <fs_ls> TO <fs_comp>. * ls_requirement_schedule-unit = cc_unit. ls_requirement_schedule-req_date = ld_date_out. ls_requirement_schedule-date_type = ic_date_type. ENDFORM.EXIT. * ls_requirement_schedule-unit = cc_unit.* REad all schedule data from excel *----------------------------------------------------------------------* FORM get_schedule_data USING value(is_exceldata) TYPE ty_exceldata value(ic_date_type) TYPE prgrs value(ic_days) TYPE t5a4a-dlydy value(ic_month) TYPE t5a4a-dlymo CHANGING et_requirement_schedule TYPE ty_requirement_schedule . ls_requirement_schedule-req_date = p_datve. APPEND ls_requirement_schedule TO et_requirement_schedule. ENDIF. DATA: ld_date_in TYPE begda. ASSIGN is_exceldata TO <fs_ls>. APPEND ls_requirement_schedule TO et_requirement_schedule.

1. DATA:ld_datum TYPE sy-datum. ELSEIF ( lc_weekday = text-023 ). ld_datum = p_datve . ld_datum = p_datve . lc_weekday TYPE dtresr-weekday. ELSEIF ( lc_weekday = text-027 ). ld_datum = p_datve . ENDIF. ELSEIF ( lc_weekday = text-024 ). " 1ST_DAYOFWEEK . ld_datum = p_datve . ELSEIF ( lc_weekday = text-025 ).5. ld_datum = p_datve .4.* Frist day of the week *----------------------------------------------------------------------* FORM 1st_dayofweek . ld_datum = p_datve. MOVE ld_datum TO p_datve. ld_datum = p_datve . ENDFORM. * To get the firstday for the week IF lc_weekday = text-021.2. ELSEIF ( lc_weekday = text-022 ). * To get day based system date CALL FUNCTION 'DATE_TO_DAY' EXPORTING date = p_datve IMPORTING weekday = lc_weekday.6. ELSEIF ( lc_weekday = text-026 ).3.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->