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

Difference between loop within user-exit und test in se37

Former Member
0 Likes
1,240

Hi there,

I have some trouble with a certain user exit and the procedure it contains.

I am using the user exit EXIT_SAPLV56U_004 to modify delivery note data, partner role to be exact. In this exit I call bapi BAPI_OUTB_DELIVERY_CHANGE. This is the code of the user exit:

DATA:
z_header_data LIKE bapiobdlvhdrchg,
z_header_control LIKE bapiobdlvhdrctrlchg.

DATA: BEGIN OF itab_zheaderpartner,
      UPD_MODE_PARTN TYPE BAPIDLVPARTNERCHG-UPD_MODE_PARTN,
      DELIV_NUMB TYPE BAPIDLVPARTNERCHG-DELIV_NUMB,
      ITM_NUMBER TYPE BAPIDLVPARTNERCHG-ITM_NUMBER,
      PARTN_ROLE TYPE BAPIDLVPARTNERCHG-PARTN_ROLE,
      PARTNER_NO TYPE BAPIDLVPARTNERCHG-PARTNER_NO,
      ADDRESS_NO TYPE BAPIDLVPARTNERCHG-ADDRESS_NO,
      DESC_PARTN TYPE BAPIDLVPARTNERCHG-DESC_PARTN,
      MANUAL_ADDR TYPE BAPIDLVPARTNERCHG-MANUAL_ADDR,
      SCA_CODE TYPE BAPIDLVPARTNERCHG-SCA_CODE,
END OF itab_zheaderpartner.

DATA z_header_partner LIKE itab_zheaderpartner OCCURS 10 with
header line.

*DATA z_header_partner TYPE TABLE OF BAPIDLVPARTNERCHG WITH HEADER LINE.

DATA: itab_del_change_BAPIRET2 like BAPIRET2.
DATA: itab_commit_BAPIRET2 like BAPIRET2.

DATA z_del_change_BAPIRET2 LIKE itab_del_change_BAPIRET2 OCCURS 10 with
header line.

DATA z_commit_BAPIRET2 LIKE itab_commit_BAPIRET2 OCCURS 10 with
header line.

loop at i_xvttp.

z_header_partner-upd_mode_partn = 'U'.
z_header_partner-deliv_numb = i_xvttp-vbeln.
z_header_partner-partn_role = 'SP'.
z_header_partner-partner_no = i_xvttk-tdlnr.

z_header_data-deliv_numb = i_xvttp-vbeln.
z_header_control-deliv_numb = i_xvttp-vbeln.
z_header_control-no_lock = 'Y'.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
  EXPORTING
    header_data = z_header_data
    header_control = z_header_control
    delivery = i_xvttp-vbeln
*   techn_control =
  TABLES
    header_partner = z_header_partner
*   header_partner_addr =
*   header_deadlines =
*   item_data =
*   item_control =
*   item_serial_no =
*   supplier_cons_data =
*   extension1 =
*   extension2 =
    return = z_del_change_BAPIRET2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    WAIT = 'X'
  IMPORTING
    RETURN = z_commit_BAPIRET2.

endloop.

Continued in the second post ... Sorry for that but if i try to put it in one post, there is a display failure

10 REPLIES 10
Read only

Former Member
0 Likes
1,169

As far as I can tell the code runs well, but no data gets modified in the VBAP. I also think I have found the source of the problem, but I do not understand what exactly goes wrong.

In the BAPI there is the following source code where the partner roles should be changed:

FORM partner_upd_fill
        TABLES   it_header_partner STRUCTURE bapidlvpartnerchg
                 it_header_partner_addr STRUCTURE bapidlvpartnaddrchg
        CHANGING ct_partner_update TYPE shp_partner_update_t.

  DATA cs_partner_update TYPE shp_partner_update.
  DATA ls_header_partner TYPE bapidlvpartnerchg.

  <b>LOOP AT it_header_partner INTO ls_header_partner.</b>
    CLEAR cs_partner_update.
    cs_partner_update-updkz_par = ls_header_partner-upd_mode_partn.
    cs_partner_update-vbeln_vl  = ls_header_partner-deliv_numb.
*     = IT_HEADER_PARTNER-ITM_NUMBER
    cs_partner_update-parvw     = ls_header_partner-partn_role.
    cs_partner_update-parnr     = ls_header_partner-partner_no.
*    = IT_HEADER_PARTNER-ADDRESS_NO
*    = IT_HEADER_PARTNER-DESC_PARTN
*    = IT_HEADER_PARTNER-MANUAL_ADDR

    IF ls_header_partner-manual_addr = gc_true.
      PERFORM partner_address_chg_fill
                      TABLES   it_header_partner_addr
                      USING    ls_header_partner-address_no
                      CHANGING cs_partner_update.
    ENDIF.
    APPEND cs_partner_update TO ct_partner_update.
  ENDLOOP.

ENDFORM.                    " PARTNER_UPD_FILL

In the loop marked in boldfaced letters the data from it_header_partner should be copied to lt_header_partner. But this does not work when I use the code in the user exit.

But if I just run the bapi in SE37, the loop works perfectly and the VBAP gets modified.

Is there somebody who can help me with this ?

Thank you and kind regards,

strobbel

Edited by: strobbel on Sep 6, 2010 1:54 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,169

Hello,

What do you mean the LOOP doesn't work ? Are you sure the internal table it_header_partner is populated when you call the BAPI via the User Exit ?

Revert back with your observations.

BR,

Suhas

Statutory Warning: You shouldn't use any COMMIT statements within your user exit !!

Read only

0 Likes
1,169

hi suhas,

thx for your fast reply!

yes i'm absolutely sure that the it_header_partner is populated because i've debugged the user-exit routine. meanwhile that i've seen that the internal table is filled with the correct data.

do you have any idea why the loop doesn't fills the internal table ls_header_partner ?

thx for your help with the commit, i will delete it from the source code!

Edited by: strobbel on Sep 6, 2010 2:19 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,169

Hello Strobbel,

I see that you've defined z_header_partner with header line. You must be knowing that internal tables with header lines are obsolete and shouldn't be used.

Anyway fyi for int. tables with header lines the table name refers to the header line so i think you should use the square brackets to refer to the whole table structure.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
  EXPORTING
    header_data    = z_header_data
    header_control = z_header_control
    delivery       = i_xvttp-vbeln
  TABLES
    header_partner = z_header_partner[] "Use square brackets to pass the entire table
    return         = z_del_change_bapiret2.

BR,

Suhas

Read only

0 Likes
1,169

THX for your reply!

If i write the code like that (in square brackets), the it_header_partner is not filled

Edited by: strobbel on Sep 6, 2010 2:45 PM

Edited by: strobbel on Sep 6, 2010 2:46 PM

Read only

Former Member
0 Likes
1,169

Hi,

When you update the partner, Update the itm_number with '000000'.

I don't know if you can update the sold to party.

Delivery being related document, There may be an issue with data integrity etc. So, If you ask me, I will look for exits / events to update the delivery after the shipment is created.

Also, Don't commit within a user exit.

Hope it helps.

Sujay

Read only

0 Likes
1,169

Within the user-exit the itm_number is filled with '000000'.

I don't want to change the sold-to-party. I want to change the forwarding agent.

The user-exit doesn't changes anything at the creation of an delivery, the user-exit is with the creation of an transport over transaction vt01n.

Read only

Former Member
0 Likes
1,169

Hi Strobbel,

I don't see an issue with the loop endloop.

What was the return parameter on delivery?

Sujay

Read only

0 Likes
1,169

I've found out the problem

In my user-exit i had to change the definition of the z_header_partner table like that:

DATA z_header_partner LIKE TABLE OF BAPIDLVPARTNERCHG.

DATA itab_z_header_partner LIKE LINE OF z_header_partner.

After that i had to change the filling of the z_header_partner table like that:

loop at i_xvttp.

clear z_header_partner.

itab_z_header_partner-upd_mode_partn = 'U'.
itab_z_header_partner-deliv_numb = i_xvttp-vbeln.
itab_z_header_partner-partn_role = 'SP'.
itab_z_header_partner-partner_no = i_xvttk-tdlnr.
append itab_z_header_partner TO z_header_partner.

Read only

0 Likes
1,169

There is a Tabeltype for BAPIDLVPARTNERCHG

Nicer would be:


* Internal Table
DATA: z_header_partner      TYPE /spe/bapidlvpartnerchg_t.

* Work-area
DATA: itab_z_header_partner TYPE bapidlvpartnerchg.

This will give you the exact same result,

Edited by: Rob Postema on Sep 6, 2010 3:33 PM