Skip to Content

How to fill BAPI_ACC_DOCUMENT_POST with several accounts.

Hi,

i need help.

How to fill BAPI with several accounts together. I know how to fill struct. extension 1 and 2 but i dont know how exactly

I need to charge account 602630 on the side 'to give' BSCHL = 'H' and account hk315330 and at the same time account 538990 on the side 'gave' BSCHL = 'S' and account 323300.

BDCDATA i cant use.

Can you help or give me example.

my code ...

form prepare_tables.


data: count type i,
len type i,
off type i.

data: ls_accit type accit.
data: begin of it_ext2 occurs 0.
include structure bapiparex.
data: end of it_ext2.

refresh it_accountgl.
refresh it_currencyamount.
refresh it_ext.
* account key 40 is posted on the side to give - symbol S
* account key 50 is posted on the side gave - symbol H
loop at it_dat into wa_dat.
shift wa_dat-newko left deleting leading '0'.
count = count + 1.

if wa_dat-wrbtr > 0.
it_accountgl-de_cre_ind = 'S'.
it_currencyamount-amt_doccur = wa_dat-wrbtr.
it_currencyamount-currency = 'EUR'.
else.
case wa_dat-newko.
when '602902' or '602630' or '602659' or '602650'.
it_ext-field1 = it_currencyamount-itemno_acc = it_accountgl-itemno_acc = count.
it_ext-field2 = 'BSCHL'.
if wa_dat-vbund is initial.
it_ext-field3 = wa_dat-newbs4."
it_accountgl-de_cre_ind = 'S'."
else.
it_ext-field3 = wa_dat-newbs5."
it_accountgl-de_cre_ind = 'H'."
len = strlen( hk315990 ).
off = 10 - len.
it_accountgl-gl_account = '0000000000'.
it_accountgl-gl_account+off = hk315990.
endif.
append it_ext.
clear it_ext.

* it_ext-field1 = count.
* it_ext-field2 = 'XNEGP'.
* it_ext-field3 = 'X'.
* APPEND it_ext.
* CLEAR it_ext.

clear it_ext2.
* MOVE 'ACCIT' TO x_extension2-structure.
it_ext2-structure = 'ACCIT'.
ls_accit-posnr = count.
ls_accit-xnegp = 'X'.
move ls_accit to it_ext2-valuepart1.
append it_ext2.


* it_ext2-field1 = count.
* REPLACE FIRST OCCURRENCE OF REGEX '0*' IN wa_dat-newko WITH ''.
* len = STRLEN( wa_dat-newko ).
* off = 10 - len.
* it_ext2-field2 = '0000000000'.
* it_ext2-field2+off = wa_dat-newko.
* APPEND it_ext2.
* CLEAR it_ext2.

it_accountgl-tax_code = 'VV'.
if wa_dat-newko(1) = '6'.
if not wa_dat-prctr is initial.
it_accountgl-profit_ctr = wa_dat-prctr.
endif.
endif.
it_accountgl-costcenter = wa_dat-prctr.
it_accountgl-trade_id = wa_dat-vbund.
it_accountgl-item_text = wa_dat-text.

it_currencyamount-amt_doccur = wa_dat-wrbtr * ( -1 ).
it_currencyamount-currency = 'EUR'.
append it_currencyamount.
append it_accountgl.
endcase.
* APPEND it_currencyamount.
* APPEND it_accountgl.
endif.

.

.

.

.

.

.

.

endloop.


Thanks you for any help.

w/r

gustav

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jun 10, 2012 at 07:11 AM

    Hi, Check the below. This may be helpful for you.

    DATA: wa_extension TYPE bapiparex,
    ext_value(960) TYPE c,
    wa_accit TYPE accit,
    l_ref TYPE REF TO data.

    FIELD-SYMBOLS: <l_struc> TYPE ANY,
    <l_field> TYPE ANY.

    SORT c_extension2 BY structure.


    LOOP AT c_extension2 INTO wa_extension.
    AT NEW structure.
    CREATE DATA l_ref TYPE (wa_extension-structure).
    ASSIGN l_ref->* TO <l_struc>.
    ENDAT.
    CONCATENATE wa_extension-valuepart1 wa_extension-valuepart2
    wa_extension-valuepart3 wa_extension-valuepart4
    INTO ext_value.
    MOVE ext_value TO <l_struc>.
    ASSIGN COMPONENT 'POSNR' OF STRUCTURE <l_struc> TO <l_field>.
    READ TABLE c_accit WITH KEY posnr = <l_field>
    INTO wa_accit.
    IF sy-subrc IS INITIAL.
    IF wa_accit-blart EQ 'SA'.
    MOVE-CORRESPONDING <l_struc> TO wa_accit.
    MODIFY c_accit FROM wa_accit INDEX sy-tabix.
    ENDIF.
    ENDIF.
    ENDLOOP.

    Regards,

    Vijaymadhur.

    Add a comment
    10|10000 characters needed characters exceeded

    • For UNICODE system you cannot move easily data, try a syntax like

      FIELD-SYMBOLS: <cont1> TYPE c,

      <cont2> TYPE c,

      <cont3> TYPE c,

      <cont4> TYPE c,

      <struc> TYPE c.

      DATA: winput TYPE bapi_te_xxxx, " Structure for Extension data as defined in BAPI documentation

      woutput TYPE bapixxxx. " structure for the BAPI parameter ExtensionIn

      ASSIGN winput TO <struc> CASTING.

      ASSIGN woutput-valuepart1 TO <cont1> CASTING.

      ASSIGN woutput-valuepart2 TO <cont2> CASTING.

      ASSIGN woutput-valuepart3 TO <cont3> CASTING.

      ASSIGN woutput-valuepart4 TO <cont4> CASTING.

      TRY.

      <cont1> = <struc>.

      <cont2> = <struc>+240.

      <cont3> = <struc>+480.

      <cont4> = <struc>+720.

      CATCH cx_sy_range_out_of_bounds.

      ENDTRY.

      Regards,

      Raymond

  • Posted on Jun 11, 2012 at 12:50 PM

    Hi, Vijaymadhur.

    I know what means the structure c_accit in your code.

    Thank you,

    gustav

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.