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: 

Post assest documents using BAPI_ACC_DOCUMENT_POST.

Former Member
0 Kudos

Greetings Experts.

I developed a report using BAPI_ACC_DOCUMENT_POST for posting documents for different posting keys through one input text file. I can able to post for vendor,customer,G/L accounts but for assest i cant. I searched in SCN but not found exact solution so am posting here... How can we post assest documents with posting keys (70 and 75) using the above said F.M? If we can't post using F.M,kindly suggest me how to overcome the scenario.. Thanks, Sai karthik.

3 REPLIES 3

paul_bakker2
Active Contributor
0 Kudos

Hi,

Friendly hint: If you post more information you might get more (and better) answers.

What error message(s) does the BAPI return when you try to post 'assest' documents?

What are 'assesst' documents?

cheers

Paul

0 Kudos

Hi Paul, Actually in BAPI we are having tables parameters for vendor,customer and G/L documents. But for asset and other type of documents no parameters to pass values to the BAPI. There is no error message i am getting to post here.So,how to overcome this scenario. Thanks, sai karthik.

Former Member
0 Kudos

Hi Saikarthik,

You need to implement the BADI BADI_ACC_DOCUMENT and method CHANGE in order to achieve your requirement.
Since this method will be invoked every time you post a documet in FI, you need to make sure it is only executed when you post documents via an input text file.

I have done a similar report in the past so let me tell you what you need to do.

The FM BAPI_ACC_DOCUMENT_POST receives a table as parameter called Extension2.This is where you need to focus.

So:

1.In your report, define your data:


Data: lt_extension2 type table of bapiparex,
           lw_extension2 type bapiparex.

2. Make sure your code is only executed for the input file:


lw_extension2-structure = 'TYPE'.
lw_extension2-valuepart1 = 'INPUT TEXT'.
append lw_extension2 to lt_extension2.

3. Define the posting keys:


case 'KOART' (account type).

when 'D'.
clear lw_extension2.
lw_extension2-structure = <item nr>.
lw_extension2-valuepart1 = 'BSCHL'. 
lw_extension2-valuepart2 = <posting key>. "75
append lw_extension2 to lt_extension2.

when 'S'.
clear lw_extension2.
lw_extension2-structure = <item nr>.
lw_extension2-valuepart1 = 'BSCHL'. 
lw_extension2-valuepart2 = <posting key>. "70
append lw_extension2 to lt_extension2.

endcase.

4. Call FM BAPI_ACC_DOCUMENT_POST


call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader     = lw_doc_header
*CUSTOMERCPD        =
*CONTRACTHEADER     =
importing
*OBJ_TYPE           =
obj_key             = lv_objkey             
*OBJ_SYS             =
tables
accountgl                = lt_account_gl
accountreceivable  =  lt_account_receivable
currencyamount     =  lt_curr_amount
return                     = lt_return
extension2             = lt_extension2.

5. In method IF_EX_ACC_DOCUMENT~CHANGE


  data: lw_extension2 type bapiparex,
        lw_c_accit type accit,
        lv_index type sy-tabix,
        lv_aux type string.

  read table c_extension2 with key structure = 'TYPE' into lw_extension2.

  if lw_extension2-valuepart1 = 'INPUT TEXT'.
    loop at c_accit into lw_c_accit.
      lv_index = sy-tabix.
      lv_aux = lw_c_accit-posnr.

      loop at c_extension2 into lw_extension2 where structure = lv_aux.
        case lw_extension2-valuepart1.
          when 'BSCHL'.
            lw_c_accit-bschl = lw_extension2-valuepart2.
          when 'FISTL'.
            lw_c_accit-fistl = lw_extension2-valuepart2.
        endcase.
      endloop.

      modify c_accit index lv_index from lw_c_accit." TRANSPORTING bschl.

    endloop.
  endif.


endmethod.

Try this and let me know if it worked.

Regards,

Tabrez