SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_fname1 TYPE localfile .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_rloc1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-005.
PARAMETERS p_group(12) OBLIGATORY DEFAULT 'ZBOM'.
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN END OF BLOCK a.
**WRITE the report header
TOP-OF-PAGE.
INCLUDE zheading.
*----------------------------------------------------------------------*
* Start of selection *
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Load Input file
PERFORM f_load_input_file.
* Create BDC records.
PERFORM create_bdc_records .
*&---------------------------------------------------------------------*
*& Form Create_BDC_records
*&---------------------------------------------------------------------*
* text:* perform the BDC for the records in the internal table
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_bdc_records .
DATA: v_stlnr LIKE mast-stlnr.
DATA: v_postp(1) VALUE 'D'.
IF NOT i_bom[] IS INITIAL.
** Open BDC session
PERFORM open_bdc_session.
SORT i_bom BY matnr werks posnr.
SELECT SINGLE stlnr INTO v_stlnr
FROM mast
WHERE matnr = i_bom-matnr
AND werks = i_bom-werks.
SELECT doknr dokar posnr stlnr
INTO TABLE i_stpo
FROM stpo
FOR ALL ENTRIES IN i_bom
WHERE postp = v_postp
AND posnr = i_bom-posnr
AND stlnr = v_stlnr.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-FMENG(01)'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
CONCATENATE 'RC29P-POSNR(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-posnr.
CONCATENATE 'RC29P-IDNRK(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-idnrk.
CONCATENATE 'RC29P-MENGE(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-menge.
CONCATENATE 'RC29P-MEINS(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-meins.
CONCATENATE 'RC29P-POSTP(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-postp.
CONCATENATE 'RC29P-FMENG(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-fmeng.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0130'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
* Check the Item category to direct the screen flow accordingly.
CASE i_bom-postp.
WHEN 'B'.
PERFORM item_text_insert.
WHEN 'Z'.
PERFORM item_text_insert.
WHEN 'T'.
PERFORM item_text_insert.
WHEN 'N'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-AUSCH'.
PERFORM bdc_field USING 'RC29P-AUSCH' i_bom-ausch.
* next screen
PERFORM item_text_insert.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0133'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RC29P-EKORG' ' '.
WHEN 'D'.
PERFORM bdc_field USING 'RC29P-DOKNR' i_stpo-doknr.
PERFORM bdc_field USING 'RC29P-DOKAR' i_stpo-dokar.
* next screen
PERFORM item_text_insert.
* When POSTP = X, L.
WHEN OTHERS.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-AUSCH'.
PERFORM bdc_field USING 'RC29P-AUSCH' i_bom-ausch.
* next screen
PERFORM item_text_insert.
ENDCASE.
g_counter = g_counter + 1.
* next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-POSNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE' '=FCBU'.
AT END OF matnr.
PERFORM insert_bdc_new.
ENDAT.
ENDLOOP.
CLEAR i_bom[].
PERFORM close_bdc_session.
** Release the BDC sessions created
PERFORM release_bdc.
ENDIF.
ENDFORM. " open_group
*&---------------------------------------------------------------------*
*& Form bdc_dynpro_start
*&---------------------------------------------------------------------*
* Initialize the screen
*----------------------------------------------------------------------*
* -->P_G_PROGRAM_1
* -->P_G_SCREEN
*----------------------------------------------------------------------*
FORM bdc_dynpro USING p_g_program_1
p_g_screen.
*&---------------------------------------------------------------------*
*& Form bdc_field
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
*&--------------------------------------------------------------------*
*& Form open_bdc_session
*&--------------------------------------------------------------------*
* Open the BDC session
*---------------------------------------------------------------------*
FORM open_bdc_session .
** Open BDC session and creat and update condition records
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " create_bdc_session
*&---------------------------------------------------------------------*
*& Form insert_screen_header
*&---------------------------------------------------------------------*
* Insert the Header data into the screens
*----------------------------------------------------------------------*
FORM insert_screen_header .
g_counter = 1.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29N-STLAL'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RC29N-MATNR' g_my_rec_in-matnr.
PERFORM bdc_field USING 'RC29N-WERKS' g_my_rec_in-werks.
PERFORM bdc_field USING 'RC29N-STLAN' g_my_rec_in-stlan.
PERFORM bdc_field USING 'RC29N-STLAL' g_my_rec_in-stlal.
PERFORM bdc_field USING 'RC29N-DATUV' g_my_rec_in-datuv.
* next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29K-BMENG'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RC29K-STKTX' g_my_rec_in-stktx.
PERFORM bdc_field USING 'RC29K-BMENG' g_my_rec_in-bmeng.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0111'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29K-LABOR'.
ENDFORM. " insert_screen_header
*&---------------------------------------------------------------------*
*& Form insert_bdc
*&---------------------------------------------------------------------*
* Insert the BDC session
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form close_bdc_session
*&---------------------------------------------------------------------*
* Close the BDC session
*----------------------------------------------------------------------*
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " close_bdc_session
*&---------------------------------------------------------------------*
*& Form f_load_input_file
*&---------------------------------------------------------------------*
* Load the file into the Internal table
*----------------------------------------------------------------------*
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.