Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Field on Document Header using BAPI for posting

Former Member
0 Kudos

Hi there.

I need to fill the BKPF-BRNCH field (the Branch Number header field in transaction FB01) to post a document by means of the BAPI_ACC_DOCUMENT_POST function module, but I haven't find the field in the DOCUMENTHEADER table, and I can't figure out how to fill it.

Can anyone help me...?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

U can use the extension structure in order to transfer fields not managed by BAPI structure.

The BAPI BAPI_ACC_DOCUMENT_POST manages the extensions by 2 different way:

- BTE RWBAPI01

- BADI acc_document

In both methods u need to fill the BAPI structure for extension: parameter EXTENSION1 (BTE) like BAPIACEXTC and EXTENSION2 (BADI) like BAPIPAREX and then read the data of the extension and transfered them to ACCIT structure in the method above.

This is an example from my old program using BTE:

  • Fill extension paramenter:

ZSDFI_BAPI_EXTENSION-ITEMNO_ACC = ITEMNO_ACC.
ZSDFI_BAPI_EXTENSION-ESENZIONE  = W_VENDOR-KIDNO.
.....................................................................................
MOVE ZSDFI_BAPI_EXTENSION TO EXTENSIONS.
APPEND EXTENSIONS.
........................................
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          DOCUMENTHEADER = BAPIACHE09
        TABLES
          ACCOUNTGL      = ACCOUNTGL
          ACCOUNTPAYABLE = ACCOUNTPAYABLE
          ACCOUNTTAX     = ACCOUNTTAX
          CURRENCYAMOUNT = CURRENCYAMOUNT
          EXTENSION1     = EXTENSIONS
          RETURN         = RETURN.

Where ZSDFI_BAPI_EXTENSION is dictionary structure with the new fields.

In the BTE function module I transfer the data to ACCIT:

TABLES: ZSDFI_BAPI_EXTENSION.

  DATA: _REPRF TYPE LFB1-REPRF.

  LOOP AT EXTENSION.
    MOVE EXTENSION TO ZSDFI_BAPI_EXTENSION.
    LOOP AT IT_ACCIT WHERE POSNR = ZSDFI_BAPI_EXTENSION-ITEMNO_ACC.
      IT_ACCIT-KIDNO      = ZSDFI_BAPI_EXTENSION-ESENZIONE.
      IT_ACCIT-ZLIFNR     = ZSDFI_BAPI_EXTENSION-ZLIFNR.
      IT_ACCIT-ZJ_3AKVGR6 = ZSDFI_BAPI_EXTENSION-CANALE.
      IT_ACCIT-J_3AKVGR8  = ZSDFI_BAPI_EXTENSION-NEGOZIO.
      IT_ACCIT-ZZAREAG    = ZSDFI_BAPI_EXTENSION-AREA_GEOGRAFICA.
      MODIFY IT_ACCIT.
    ENDLOOP.
  ENDLOOP.

Max

2 REPLIES 2

Former Member
0 Kudos

Hi

U can use the extension structure in order to transfer fields not managed by BAPI structure.

The BAPI BAPI_ACC_DOCUMENT_POST manages the extensions by 2 different way:

- BTE RWBAPI01

- BADI acc_document

In both methods u need to fill the BAPI structure for extension: parameter EXTENSION1 (BTE) like BAPIACEXTC and EXTENSION2 (BADI) like BAPIPAREX and then read the data of the extension and transfered them to ACCIT structure in the method above.

This is an example from my old program using BTE:

  • Fill extension paramenter:

ZSDFI_BAPI_EXTENSION-ITEMNO_ACC = ITEMNO_ACC.
ZSDFI_BAPI_EXTENSION-ESENZIONE  = W_VENDOR-KIDNO.
.....................................................................................
MOVE ZSDFI_BAPI_EXTENSION TO EXTENSIONS.
APPEND EXTENSIONS.
........................................
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          DOCUMENTHEADER = BAPIACHE09
        TABLES
          ACCOUNTGL      = ACCOUNTGL
          ACCOUNTPAYABLE = ACCOUNTPAYABLE
          ACCOUNTTAX     = ACCOUNTTAX
          CURRENCYAMOUNT = CURRENCYAMOUNT
          EXTENSION1     = EXTENSIONS
          RETURN         = RETURN.

Where ZSDFI_BAPI_EXTENSION is dictionary structure with the new fields.

In the BTE function module I transfer the data to ACCIT:

TABLES: ZSDFI_BAPI_EXTENSION.

  DATA: _REPRF TYPE LFB1-REPRF.

  LOOP AT EXTENSION.
    MOVE EXTENSION TO ZSDFI_BAPI_EXTENSION.
    LOOP AT IT_ACCIT WHERE POSNR = ZSDFI_BAPI_EXTENSION-ITEMNO_ACC.
      IT_ACCIT-KIDNO      = ZSDFI_BAPI_EXTENSION-ESENZIONE.
      IT_ACCIT-ZLIFNR     = ZSDFI_BAPI_EXTENSION-ZLIFNR.
      IT_ACCIT-ZJ_3AKVGR6 = ZSDFI_BAPI_EXTENSION-CANALE.
      IT_ACCIT-J_3AKVGR8  = ZSDFI_BAPI_EXTENSION-NEGOZIO.
      IT_ACCIT-ZZAREAG    = ZSDFI_BAPI_EXTENSION-AREA_GEOGRAFICA.
      MODIFY IT_ACCIT.
    ENDLOOP.
  ENDLOOP.

Max

Former Member
0 Kudos

Thanks for answering.

I have been investigating your solution.

The thing is, even inside the BTE function module, the field BRNCH isn't available in the DOCUMENTHEADER table. I'm being able, just like before with the BAPI standalone, to modifiy only fields from document positions, but not from the header (at least not the one I need).