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: 

Passing Reason Code by using bapi BAPI_ACC_DOCUMENT_POST

Former Member
0 Kudos

I am using BAPI_ACC_DOCUMENT_POST, i am getting below error

Field Reason code is a required field for G/L account

i googled the same error may time and every on suggest to use BADI ACC_DOCUMENT and  Create and pass the structure

please guide me how can i pass the same using BAPI_ACC_DOCUMENT_POST

I need to pass an additional value REASON CODE (RSTGR) in BSEG.

Please guide me step by step on how I can pass entered value in table EXTENSION2 into BSEG.

Many Thanks.

3 REPLIES 3

Former Member
0 Kudos

This message was moderated.

0 Kudos

Hi Rajendra,

I am assuming that due to the config of the GL account, it is asking for reason code otherwise reason code is not mandatory for this BAPI. Anyawy, to achieve what you are looking for, you have to first implement this BTE "BTE RWBAPI01". There are a lot of instructions on net on how to implement this BTE so you can figure it out from there, I will stick to the BAPI.

To pass the reason code, in your program you have to create a table for extension just like the tables for vendor, accountgl etc. Then you must concatenate and append the item number and reason code to "Field1" field of extension.

Eg: CONCATENATE lv_item_num 'XXX' INTO ls_extension-field1.

      APPEND lls_extension TO lt_extension.

Now when you run the BAPI using this table, the data will be captured in the Z function module you would have created for implementing the BTE. There you have to write the second piece of code.

Eg: LOOP AT lt_extension INTO wa_extension.

              READ it_accit WITH KEY POSNR = wa_extension+0(2).

              IF sy-subrc EQ 0.

                  

                    it_accit-rstgr = wa_extension+2(3).

                    MODIFY it_accit INDEX sy-tabix.

              ENDIF.

      ENDLOOP.

This should get the job done. Please note that the code snippet above is a pseudo code. Check all the fields and variables carefully and work accordingly.

Thanks,

Soumyajit

0 Kudos

Thanks Soumyajit for you help, i will update you once i go through your instructions.

actually i am using BAPI_ACC_DOCUMENT_POST Bapi in .net language (not ABAP), if any suggestion or example in .net it will help me a lot.

Thanks

Rajendra