Application Development and Automation 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: 
Read only

BAPI post

Former Member
0 Likes
421

Hi All

I am trying to post some douments using BAPI.

It's showing docuemnt is posted when i check for its give document not found.

i am using below code

REPORT ZTEST5.

TABLES: bapiache08, bapiacgl08,bapiaccr08, bapiret2.

DATA: t_bapiache08 LIKE TABLE OF bapiache08 WITH HEADER LINE,

t_bapiacgl08 LIKE TABLE OF bapiacgl08 WITH HEADER LINE,

t_bapiaccr08 LIKE TABLE OF bapiaccr08 WITH HEADER LINE,

t_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE,

ct_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE.

t_bapiache08-obj_type = 'BKPFI'.

t_bapiache08-obj_key = '180000002132002006'.

t_bapiache08-obj_sys = 'ED6CLNT120'.

t_bapiache08-username = 'SUSUB'.

*t_bapiache08-header_txt = 'DOCUMENT POSTING'.

t_bapiache08-comp_code = '3200'.

*t_bapiache08-fisc_year = '2006'.

*t_bapiache08-doc_date = '20061109'.

t_bapiache08-pstng_date = '20061109'.

t_bapiache08-fis_period = '11'.

*t_bapiache08-doc_type = 'DR'.

t_bapiache08-compo_acc = ' '.

APPEND t_bapiache08.

t_bapiacgl08-itemno_acc = '0000000001'.

t_bapiacgl08-gl_account = '625200'.

t_bapiacgl08-comp_code = '3200'.

t_bapiacgl08-pstng_date = '20061109'.

t_bapiacgl08-doc_type = 'DR'.

t_bapiacgl08-fisc_year = '2006'.

t_bapiacgl08-fis_period = '11'.

t_bapiacgl08-stat_con = 'X'.

t_bapiacgl08-vendor_no = '500000'. "ACCOUNTING NO.FOR VENDOR/CREDITOR.

t_bapiacgl08-item_text = 'LINE ITEM TEXT BY VIN'.

APPEND t_bapiacgl08.

t_bapiaccr08-itemno_acc = '0000000001'.

t_bapiaccr08-currency_iso = 'AUD'.

t_bapiaccr08-amt_doccur = '2000'.

APPEND t_bapiaccr08.

CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

EXPORTING

documentheader = t_bapiache08

TABLES

accountgl = t_bapiacgl08

currencyamount = t_bapiaccr08

return = t_bapiret2.

LOOP AT t_bapiret2.

WRITE 😕 t_bapiret2-type, t_bapiret2-id, t_bapiret2-number,

t_bapiret2-message,t_bapiret2-parameter,

t_bapiret2-row, t_bapiret2-field, t_bapiret2-system.

ENDLOOP.

CLEAR T_BAPIRET2. REFRESH T_BAPIRET2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '

IMPORTING

return = ct_bapiret2.

LOOP AT ct_bapiret2.

WRITE 😕 ct_bapiret2-type, ct_bapiret2-id, ct_bapiret2-number,

ct_bapiret2-message,ct_bapiret2-log_no, ct_bapiret2-parameter,

ct_bapiret2-row, ct_bapiret2-field, ct_bapiret2-system.

ENDLOOP.

can you please notify where the problem has occured

Rgds

Raghav

2 REPLIES 2
Read only

Former Member
0 Likes
385

Hi Raghav

Can you let us know the messages in CT_BAPIRET2 after executing BAPI_TRANSACTION_COMMIT.

Also please check with time delay.

Kind Regards

Eswar

Read only

Former Member
0 Likes
385

hi

good

go through this link

http://download.microsoft.com/download/4/D/2/4D26B8CD-6ADF-4E1A-B85D-9AAA44E6C055/nav_tech_%20wp_biz...

-


go through this code and change your report accordingly

report z_test_bapi_gl_ac_doc LINE-SIZE 200.

----


  • Written By: Ram Manohar Tiwari

----


----


data:

obj_type like bapiache02-obj_type,

obj_key like bapiache02-obj_key,

obj_sys like bapiache02-obj_sys,

documentheader like bapiache08,

accountgl like bapiacgl08

occurs 0 with header line,

currencyamount like bapiaccr08

occurs 0 with header line,

return like bapiret2

occurs 0 with header line,

extension1 like bapiextc

occurs 0 with header line,

t_edidd like edidd occurs 0 with header line,

bapi_retn_info like bapiret2 occurs 0 with header line.

data: error_flag.

*documentheader-obj_type = 'BKPFF'.

*documentheader-obj_key = '18000000002002004'.

*documentheader-obj_type = 'BKPFF'.

*documentheader-obj_key = '180000000010002004'.

*documentheader-obj_sys = 'RD1CLNT200'.

documentheader-username = sy-uname.

documentheader-header_txt = 'Test using BAPI'.

documentheader-comp_code = '1000'.

*documentheader-ac_doc_no

*documentheader-fisc_year = '2005'.

documentheader-doc_date = sy-datum.

documentheader-pstng_date = sy-datum.

*documentheader-trans_date

*documentheader-fis_period

documentheader-doc_type = 'SA'.

*documentheader-ref_doc_no

*documentheader-compo_acc

*documentheader-reason_rev

accountgl-itemno_acc = '1'.

accountgl-gl_account = '0000160100'.

accountgl-comp_code = '1000'.

accountgl-pstng_date = sy-datum.

accountgl-doc_type = 'SA'.

accountgl-profit_ctr = '0000010000'.

append accountgl.

accountgl-itemno_acc = '2'.

accountgl-gl_account = '0000160100'.

accountgl-comp_code = '1000'.

accountgl-pstng_date = sy-datum.

accountgl-doc_type = 'SA'.

accountgl-profit_ctr = '0000010000'.

append accountgl.

*AC_DOC_NO

*FISC_YEAR

*FIS_PERIOD

*accountgl-STAT_CON = 'X'.

*REF_KEY_1

*REF_KEY_2

*REF_KEY_3

*CUSTOMER

*VENDOR_NO

*ALLOC_NMBR

*ITEM_TEXT

*BUS_AREA

*COSTCENTER

*ACTTYPE

*ORDERID

*ORIG_GROUP

*COST_OBJ

*PROFIT_CTR

*PART_PRCTR

*WBS_ELEMENT

*NETWORK

*ROUTING_NO

*ORDER_ITNO

currencyamount-itemno_acc = '1'.

currencyamount-currency = 'GBP'.

currencyamount-amt_doccur = '100.00'.

append currencyamount.

currencyamount-itemno_acc = '2'.

currencyamount-currency = 'GBP'.

currencyamount-amt_doccur = '-100.00'.

append currencyamount.

  • call BAPI-function in this system

call function 'BAPI_ACC_GL_POSTING_POST'

exporting

documentheader = documentheader

  • importing

  • obj_type = obj_type

  • obj_key = obj_key

  • obj_sys = obj_sys

tables

accountgl = accountgl

currencyamount = currencyamount

return = return

extension1 = extension1

exceptions

others = 1.

if sy-subrc <> 0.

message e999(re) with 'Problem occured'.

else.

loop at return.

if not return is initial.

clear bapi_retn_info.

move-corresponding return to bapi_retn_info.

if return-type = 'A' or return-type = 'E'.

error_flag = 'X'.

endif.

append bapi_retn_info.

endif.

endloop.

if error_flag = 'X'.

message e999(re) with 'Problem occured'.

rollback work.

else.

commit work.

endif.

endif.

thanks

mrutyun^