Tuesday, April 19, 2011

Passing Posting Key in BAPI_ACC_DOCUMENT_POST for Posting in F-02

Three simple steps to Pass Posting key in BAPI_ACC_DOCUMENT_POST for posting in F-02 for vendor GL.

1. Fill in your EXTENSION table like this

* first 3 character represent item number
* next 2 character represent posting key
CLEAR: gt_extension.
gt_extension(3) = sy-index(3).
gt_extension+3(2) = 'New Posting Key'.
APPEND gt_extension.

2. Create an ZFM similar to SAMPLE_INTERFACE_RWBAPI01 and put the following codes:

LOOP AT extension.
READ TABLE it_accit WITH KEY posnr = extension(3).
IF sy-subrc IS INITIAL.
it_accit-bschl = extension+3(2).
MODIFY it_accit INDEX sy-tabix.
ENDIF.
ENDLOOP.

3.
-> Go to TCode "FIBF".
-> Go to Settings -> Products -> ... of a customer
-> Create a new entry and check the box to activate the product
Product =
Text    =
RFC     = blank
Check the activation box

-> Go to Settings -> Process Modules -> ... of a customer
-> Create a new entry by specifying the name of the function module name and product name created earlier.
Process = RWBAPI01
Ctr     = blank
Appl    = blank
FM      =
Product =

Apppending Extensions from Program and call BAPI:

W_EXTENSION1-FIELD1 = W_ACCOUNTGL-ITEMNO_ACC+7(3).
CONCATENATE W_EXTENSION1-FIELD1 WA_ITAB-NEWBS INTO W_EXTENSION1-FIELD1.
APPEND W_EXTENSION1 TO I_EXTENSION1.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    DOCUMENTHEADER          = W_DOCHEADER
*   CUSTOMERCPD             =
*   CONTRACTHEADER          =
 IMPORTING
*   OBJ_TYPE                =
   OBJ_KEY                 = L_OBJ_KEY
*   OBJ_SYS                 =
  TABLES
   ACCOUNTGL               = I_ACCOUNTGL
   ACCOUNTRECEIVABLE       = I_ACCOUNTRECEIVABLE
   ACCOUNTPAYABLE          = I_ACCOUNTPAYABLE
   ACCOUNTTAX              = I_ACCOUNTTAX
    CURRENCYAMOUNT          = I_CURRENCYAMOUNT
*   CRITERIA                =
*   VALUEFIELD              =
   EXTENSION1              = I_EXTENSION1
    RETURN                  = I_RETURN
*   PAYMENTCARD             =
*   CONTRACTITEM            =
*   EXTENSION2              = I_EXTENSION2
*   REALESTATE              =
*   ACCOUNTWT               =
          .

No comments:

Post a Comment