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

Question on BAPI_Agreements

Former Member
0 Likes
761

Hi All

i am trying to create rebate agreements in SD, but encounter problems with the BAPI_Agreements. The problem occures when i create a loop to create multiple rebates...so in other words, i am calling the bapi multiple times. the error seems to have on the function module AGR_FILL_DEFAULT, which tries to assign a value to a field symbol but the field symbol is not defined. as i said, this only happens on the second round of the loop.

i have tried clearing the GT_TB61 object using a field symbol, i have tried COMMIT and WAIT, even the BAPI Commit functions...nothing seems to help.

it seems like that there is something wrong with calling the function module multiple times.

please assist <removed by moderator>

Edited by: Thomas Zloch on Nov 19, 2010 11:36 AM - priority normalized

Edited by: Rajesh Dookkoo on Dec 20, 2010 11:22 AM

2 REPLIES 2
Read only

Former Member
0 Likes
485

I'm running into this same issue. I've isolated it here:


 IF NOT sv_bon_enh_available IS INITIAL AND
         ( sv_bon_enh_target_assign_done IS INITIAL OR
           NOT i_new_reference IS INITIAL ).
        ASSIGN COMPONENT 'BON_ENH_VAKEY' OF STRUCTURE
               c_konadb TO <g_kona_bon_enh_vakey>.
        IF sy-subrc NE 0.
          CLEAR sv_bon_enh_available.
        ENDIF.
        ASSIGN COMPONENT 'BON_ENH_INDIRECT' OF STRUCTURE
               c_konadb TO <g_kona_bon_enh_indirect>.
        IF sy-subrc NE 0.
          CLEAR sv_bon_enh_available.
        ENDIF.
        ASSIGN COMPONENT 'BON_ENH_PERIOD_S' OF STRUCTURE
               c_konadb TO <g_kona_bon_enh_period_s>.
        IF sy-subrc NE 0.
          CLEAR sv_bon_enh_available.
        ENDIF.
        sv_bon_enh_target_assign_done = 'X'.
      ENDIF.
      IF NOT sv_bon_enh_available IS INITIAL.
        <g_kona_bon_enh_vakey> = <g_t6b1_bon_enh_vakey>.
        <g_kona_bon_enh_indirect> = <g_t6b1_bon_enh_indirect>.
        <g_kona_bon_enh_period_s> = <g_t6b1_bon_enh_period_s>.

Those are lines 83-106 of FM agr_fill_default, which is called by BAPI_AGREEMENTS.

In the sixth line up (101), sv_bon_enh_taget_assign_done is set to 'X'. This flag doesn't get reset after the function module executes, so in the next iteration of the loop, it skips lines 86-100, leaving the g_kona_bon_enh field symbols unassigned, and causing the short dump.

I have no idea how to fix this. Ideas, anyone?

Read only

0 Likes
485

To answer my own question, sv_bon_enh_taget_assign_done is declared as static, so SAP obviously meant for the FM to work this way. It seems the issue stems from calling BAPI_AGREEMENTS within a loop. Rather than creating the agreements one at a time by iterating through the loop, if we load all of the agreements into an internal table and pass that, they are all created at once and the shortdump is avoided.