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: 

How to fill BAPI_ACC_DOCUMENT_POST with several accounts.

0 Kudos

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

4 REPLIES 4

former_member200345
Contributor
0 Kudos

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.

0 Kudos

Hi,

I try this code but there are errors.

The statement 'MOVE src TO dst" requires that the operands "dst" and "src" are convertible.

On this line - "MOVE ext_value TO <l_struc>."

Bite them repaired but I can not.

If you know how to fix or bypass line will

Regards,

gustav

0 Kudos

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

0 Kudos

Hi, Vijaymadhur.

I know what means the structure c_accit in your code.

Thank you,

gustav