Implement BADI ACC_DOCUMENT (code example)

Byfjourneau

Implement BADI ACC_DOCUMENT (code example)

When input parameters of Bapi ACC_DOCUMENT_POST do not enable to pass BKPF or BSEG fields, it is necessary to pass theses data to LT_EXTENTION2 table and implement the Badi ACC_DOCUMENT.

This code manage dynamically field affectation from LT_EXTENTION2 to corresponding fields.
To be added in class implementation of BADI ACC_DOCUMENT, method change.


METHOD if_ex_acc_document~change.

  DATA: wa_extension TYPE bapiparex,
        wa_accit     TYPE accit.

  DATA : lv_field_name  TYPE char100.        

  FIELD-SYMBOLS :  TYPE ANY,      
                   TYPE ACCIT.    

  LOOP AT c_extension2 INTO wa_extension.

    IF wa_extension-structure = 'BKPF'.
      CONCATENATE 'C_ACCHD-' wa_extension-valuepart2 INTO lv_field_name.
      ASSIGN (lv_field_name) TO .
      IF  IS ASSIGNED.
         = wa_extension-valuepart3.
      ENDIF.
    ENDIF.

    IF wa_extension-structure = 'BSEG'.
      READ TABLE c_accit ASSIGNING  WITH KEY posnr = wa_extension-valuepart1.
      IF sy-subrc IS INITIAL.

        CONCATENATE '-' wa_extension-valuepart2 INTO lv_field_name.
        ASSIGN (lv_field_name) TO .
        IF  IS ASSIGNED.
           = wa_extension-valuepart3.
        ENDIF.
      ENDIF.
    ENDIF.

  ENDLOOP.

ENDMETHOD.

Search tags : FI,

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