Batch input with ABAP

Batch input with ABAP

Code example to update FI document – header info in FB02 :
(In that particular case, it should be better to use BAPI)


  DATA : lw_bdc_mode TYPE ctu_mode,
         li_bdcmess  TYPE TABLE OF bdcmsgcoll.

  CLEAR gt_bdcdata.

  " Selection screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0100'.
  PERFORM bdc_field       USING 'RF05L-BELNR'  pw_belnr.
  PERFORM bdc_field       USING 'RF05L-BUKRS'  pw_bukrs.
  PERFORM bdc_field       USING 'RF05L-GJAHR'  pw_gjahr.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '/00'.         " [Touch Enter]

  " Main screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0700'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=VK'.         " [Button to reach header]

  " Header Screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '1710'.
  PERFORM bdc_field       USING 'BKPF-XREF2_HD'   gv_value.      " Value to be changed
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=ENTR'.          " [Validate button]

  " Main screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0700'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=AE'.         " [Save button]

  lw_bdc_mode = 'N'. " <== set A in debug to display screen

  CALL TRANSACTION 'FB02'
    USING gt_bdcdata
    MODE lw_bdc_mode     " N : Screens not displayed
    UPDATE 'S'           " Save synchronous
    MESSAGES INTO li_bdcmess.

 " Get all transaction messages into li_bdcmess.

 

Forms used :


FORM bdc_dynpro USING pw_prog
                      pw_scr.

  DATA ls_bdcdata TYPE bdcdata.

  ls_bdcdata-program = pw_prog.
  ls_bdcdata-dynpro  = pw_scr.
  ls_bdcdata-dynbegin = 'X'.
  APPEND ls_bdcdata TO gt_bdcdata.

ENDFORM.                    "BDC_DYNPRO

FORM bdc_field USING pw_fnam
                     pw_fval.

  DATA ls_bdcdata TYPE bdcdata.

  ls_bdcdata-fnam  = pw_fnam.
  ls_bdcdata-fval  = pw_fval.
  APPEND ls_bdcdata TO gt_bdcdata.

ENDFORM.                    "BDC_FIELD

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply