04-01-2009 9:27 AM
Hi Expert,
I want to upload data in FB01 without using BDC and LSMW. I want to use all posting key for posting the data. Could any body provide me the code using BAPI. My flat file has all the posting key for the operation.
Regards
Sanjay
04-01-2009 9:34 AM
search for "BAPI_ACC_DOCUMENT_POST", there is many examples around SDN and elsewhere.
Thomas
04-01-2009 9:34 AM
search for "BAPI_ACC_DOCUMENT_POST", there is many examples around SDN and elsewhere.
Thomas
04-01-2009 11:58 AM
Hi Thomas,
I searched the SDN and couldn't found any thread which deal with all type of posting. Whats i found, its related with particular posting key.
Regards
Sanjay
04-01-2009 12:14 PM
Hi Sanjay,
Here is one example showing BAPI_ACC_DOCUMENT_POST for posting vendor invoices. In the similar manner you can populate other tables like accountrecievables also. So by using the same BAPI you will be able to post a document with all possible conditions:
DATA: lt_glacct TYPE TABLE OF bapiacgl09,
lt_vendact TYPE TABLE OF bapiacap09,
lt_curramt TYPE TABLE OF bapiaccr09,
lt_return TYPE TABLE OF bapiret2.
DATA: lv_objtyp TYPE bapiache09-obj_type,
lv_objkey TYPE bapiache09-obj_key,
lv_objsys TYPE bapiache09-obj_sys,
wa_docheader TYPE bapiache09,
wa_glacct LIKE LINE OF lt_glacct,
wa_curramt LIKE LINE OF lt_curramt,
wa_vendact LIKE LINE OF lt_vendact,
wa_return LIKE LINE OF lt_return.
* Populate header data of document
wa_docheader-obj_type = 'REACI'.
wa_docheader-obj_key = '$'.
wa_docheader-obj_sys = 'T90CLNT090'.
wa_docheader-bus_act = 'RMRP'.
wa_docheader-comp_code = '1000'.
wa_docheader-username = sy-uname.
wa_docheader-header_txt = 'Upload using BAPI'.
wa_docheader-doc_date = '20090331'.
wa_docheader-pstng_date = '20090331'.
wa_docheader-fisc_year = '2009'.
wa_docheader-doc_type = 'RE'.
wa_vendact-itemno_acc = '0000000001'.
wa_vendact-vendor_no = '0000005200'.
wa_vendact-pmnttrms = '0001'.
wa_vendact-bline_date = '20090421'.
wa_vendact-item_text = 'Account payable'.
APPEND wa_vendact TO lt_vendact.
wa_glacct-itemno_acc = '0000000002'.
wa_glacct-gl_account = '0000089000'.
wa_glacct-item_text = 'GL account'.
APPEND wa_glacct TO lt_glacct.
wa_curramt-itemno_acc = '0000000001'.
wa_curramt-curr_type = '00'.
wa_curramt-currency = 'EUR'.
wa_curramt-amt_doccur = '-1000.00'.
APPEND wa_curramt TO lt_curramt.
CLEAR wa_curramt.
wa_curramt-itemno_acc = '0000000002'.
wa_curramt-curr_type = '00'.
wa_curramt-currency = 'EUR'.
wa_curramt-amt_doccur = '1000.00'.
APPEND wa_curramt TO lt_curramt.
CLEAR: wa_curramt,wa_glacct,wa_vendact.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = wa_docheader
IMPORTING
obj_type = lv_objtyp
obj_key = lv_objkey
obj_sys = lv_objsys
TABLES
accountgl = lt_glacct
accountpayable = lt_vendact
currencyamount = lt_curramt
return = lt_return.
IF sy-subrc EQ 0.
WRITE:/ lv_objtyp.
WRITE:/ lv_objkey.
WRITE:/ lv_objsys.
LOOP AT lt_return INTO wa_return.
WRITE:/ wa_return-message.
CLEAR wa_return.
ENDLOOP.
COMMIT WORK AND WAIT.
ENDIF.
Hope this solves your problem.
Regards,
Brajvir
04-01-2009 12:21 PM
04-01-2009 12:40 PM