Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to use BAPI_SALESORDER_CHANGE to update custom fields in VBAP

Hi All,

I have added the following two custom fields in VBAK and VBAP tables and i'm trying to use BAPI_SALESORDER_CHANGE to update these custom fields. I have added these fieilds to structures BAPE_VBAP, BAPE_VBAPX, VBAPKOM and VBAPKOMX, BAPE_VBAK, BAPE_VBAKX, VBAKKOM and VBAKKOMX.

When i call the BAPI from my program, it updates the custom fields at header level as well as VBAK table. However, the custom fields at line item level or VBAP table do not get updated. Below is a code snippet from the program. Can anyone please help me with this issue?

ZZACKSTAT TYPE C

ZZACKDATE TYPE DATS


                    ls_ord-updateflag = lc_u.
                    ls_ext-structure = lc_bape_vbak.
                    ls_ext-valuepart1+0(10) = ls_vbak-vbeln.
                    ls_ext-valuepart4+139(1) = lc_3.
                    ls_ext-valuepart4+140(8) = sy-datum.
                    APPEND ls_ext TO lt_ext.
                    CLEAR:ls_ext.
                    ls_ext-structure = lc_bape_vbakx.
                    ls_ext-valuepart1+0(10) = ls_vbak-vbeln.
                    ls_ext-valuepart1+44(1) = lc_x.
                    ls_ext-valuepart1+45(1) = lc_x.
                    APPEND ls_ext TO lt_ext.
                    CLEAR:ls_ext.

                    LOOP AT lt_vbap INTO ls_vbap WHERE vbeln = ls_vbak-vbeln.
                      ls_ext-structure = lc_bape_vbap.
                      ls_ext-valuepart1+0(10) = ls_vbap-vbeln.
                      ls_ext-valuepart1+10(6) = ls_vbap-posnr.
                      ls_ext-valuepart4+227(1) = lc_3.
                      ls_ext-valuepart4+228(8) = sy-datum.

                      APPEND ls_ext TO lt_ext.
                      CLEAR:ls_ext.
                      ls_ext-structure = lc_bape_vbapx.
                      ls_ext-valuepart1+0(10) = ls_vbap-vbeln.
                      ls_ext-valuepart1+10(6) = ls_vbap-posnr.
                      ls_ext-valuepart1+50(1) = lc_x.    
                      ls_ext-valuepart1+51(1) = lc_x.    
                      APPEND ls_ext TO lt_ext.
                      CLEAR:ls_ext.
                      ls_item-itm_number =  ls_vbap-posnr.
                      APPEND ls_item TO lt_item.
                      CLEAR: ls_item.

                      ls_itemx-itm_number = ls_vbap-posnr.
                      ls_itemx-updateflag = lc_u.
                      APPEND ls_itemx TO lt_itemx.
                      CLEAR: ls_itemx, ls_vbap.
                    ENDLOOP.

                    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
                      EXPORTING
                        salesdocument    = ls_vbak-vbeln
                        order_header_inx = ls_ord
                      TABLES
                        return           = lt_ret
                        order_item_in    = lt_item
                        order_item_inx   = lt_itemx
                        extensionin      = lt_ext.

                    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Tags:
Former Member
Former Member replied

Hi Ankit/Jaffer,

Thanks for your valuable inputs.

@Ankit - I'm not using valuepart1 because i have other custom fields in VBAP table and when i calculated the offset of the new fields with reference to BAPIPAREX structure, these fields fall in valuepart4 of BAPIPAREX.

The issue was that VBAPKOMX structure had fewer fields when compared to VBAPKOM. I debugged the BAPI and observed that standard code assigns custom fields from VBAPKOM to VBAP based on their position in the structure and hence VBAPKOM and VBAPKOMX should have the exact same fields in the same sequence.

Issue resolved.

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question