on ‎2022 Mar 14 2:12 PM
Hi,
I have added a new field using in-app extensibility in VA02, now when I am trying to populate the value using BAPI_SALESORDER_CHANGE(with extension), it's not working.
Sample Code:
DATA: lv_vbeln TYPE bapivbeln-vbeln,
ls_order_in TYPE bapisdh1,
ls_order_inx TYPE bapisdh1x,
lt_return TYPE TABLE OF bapiret2,
ls_order_item_in TYPE bapisditm,
lt_order_item_in TYPE TABLE OF bapisditm,
lt_order_item_inx TYPE TABLE OF bapisditmx,
ls_order_item_inx TYPE bapisditmx,
ls_extensionin TYPE bapiparex,
lt_extensionin TYPE TABLE OF bapiparex,
ls_extensioninx TYPE bapiparex,
lt_extensioninx TYPE TABLE OF bapiparex.
"for bapi extension
DATA : gs_bape_vbap TYPE bape_vbap,
gs_bape_vbapx TYPE bape_vbapx,
lv_prmsorder TYPE char10.
gs_bape_vbap-zz1_prms_order_sdi = lv_prmsorder.
gs_bape_vbap-vbeln = lv_vbeln.
gs_bape_vbap-posnr = '000100'.
ls_extensionin-structure = 'BAPE_VBAP'.
*ls_extensionin-valuepart1 = gs_bape_vbap.
ls_extensionin+30 = gs_bape_vbap.
APPEND ls_extensionin TO lt_extensionin.
gs_bape_vbapx-zz1_prms_order_sdi = 'X'.
gs_bape_vbapx-vbeln = lv_vbeln.
gs_bape_vbapx-posnr = '000100'.
ls_extensioninx-structure = 'BAPE_VBAPX'.
*ls_extensioninx-valuepart1 = gs_bape_vbapx.
ls_extensioninx+30 = gs_bape_vbapx.
APPEND ls_extensioninx TO lt_extensioninx.
ls_order_item_in-itm_number = '000100'.
*ls_order_item_in-item_categ = '***'.
*ls_order_item_in-plant = '***'.
ls_order_item_inx-itm_number = '000100'.
ls_order_item_inx-updateflag = 'U'.
APPEND ls_order_item_in TO lt_order_item_in.
APPEND ls_order_item_inx TO lt_order_item_inx.
ls_order_inx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_vbeln
* order_header_in = ls_order_in
order_header_inx = ls_order_inx
TABLES
return = lt_return
order_item_in = lt_order_item_in
order_item_inx = lt_order_item_inx
extensionin = lt_extensionin
extensionex = lt_extensioninx.
IF sy-subrc IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
any leads will be appreciated.
Thank you.
Edit: Return table contains success messages, but not updating in the standard table(vbap).
Request clarification before answering.
Hi,
Update: I have added a custom field using the old approach (se51->sapmv45a->screen 8459(item)) and updated the required tables with a custom field.
My analysis is when you add a new custom field using in-app extensibility, structure VBAPKOM get updated with the new custom field but the VBAPKOZ structure doesn't get updated with a new custom field and if you try to append a new structure with a custom field directly in the VBAPKOZ structure then you get the duplicate error and reason for the error is structure VBAPKOM include append structure VBAPKOZ. And if you don't have the custom field details available in structures VBAPKOZ and VBAPKOZX, values will not be updated in the standard table(VBAP).
Also, I have read the documentation before using the BAPI and maintained values in all the required tables. Even after doing so values were not updated in the standard table(VBAP).
But the good news is I have found out the issue in my code, below is my analysis (please free to correct if I misunderstood anything):
When we use 'BAPI_SALESORDER_CHANGE', we need to populate extension structures like below:
gs_bape_vbap-zz1_prms_order = lv_prmsorder.
gs_bape_vbap-vbeln = lv_vbeln.
gs_bape_vbap-posnr = '000100'.
ls_extensionin-structure = 'BAPE_VBAP'.
ls_extensionin-valuepart1 = gs_bape_vbap.
APPEND ls_extensionin TO lt_extensionin.
clear ls_extensionin.
gs_bape_vbapx-zz1_prms_order = 'X'.
gs_bape_vbapx-vbeln = lv_vbeln.
gs_bape_vbapx-posnr = '000100'.
ls_extensionin-structure = 'BAPE_VBAPX'.
ls_extensionin-valuepart1 = gs_bape_vbapx.
APPEND ls_extensionin TO lt_extensionin.
clear ls_extensionin.
So, whenever you pass the values to the extension structures, pass values ls_extensionin-valuepart1.
and append it to lt_extension.
And to pass 'X' against the same field you need to append values in the same
extensionin table (not in extensioninx).
The explanation for the above logic is:
Why we need to pass the values to the extensionin table and not in extensioninx is:
Open 'BAPI_SALESORDER_CHANGE' -> open 'SD_SALESDOCUMENT_CHANGE' -> perform ms_move_extensionin (line 299) -> LVBAKF0C(include) -> put a breakpoint at line 2966 and check the data in the table extensionin (you should have 2 entries here if you are updating the value for 1 field) then if you check the case statement you will see that for both the structures 'bape_vbap' and 'bape_vbapx' code is written here only. So, I assume if you pass values of 'bape_vbapx' in extensioninx it will not append values in ex_vbapkomx, and apparently, it will not update the values in the standard table(vbap).
One more tip: if you want to check whether your code will update the values in the table or not then create implicit enhancement in ‘MV45AFZZ’->FORM USEREXIT_MOVE_FIELD_TO_VBAP -> write any test code and check if it gets triggered or not, if it does then values will be updated in the table if the system doesn’t trigger the above code, then my friend you need to check your code again.

Cheers,
Tushar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't forget to add your fields to VBAPKOZ and VBAPKOZX, not only to BAPE_VBAP and BAPE_VBAPX. (read BAPI documentation)
CLEAR: wa_bape_vbap, wa_extensionin.
wa_bape_vbap-vbeln = in_vbeln.
wa_bape_vbap-posnr = in_posnr.
wa_bape_vbap-zzfield1 = in_field1.
wa_extensionin-structure = 'BAPE_VBAP'.
cl_abap_container_utilities=>fill_container_c(
EXPORTING
im_value = wa_bape_vbap
IMPORTING
ex_container = wa_extensionin+30 ).
APPEND wa_extensionin TO lt_extensionin.
CLEAR: wa_bape_vbap, wa_extensionin.
wa_bape_vbapx-vbeln = in_vbeln.
wa_bape_vbapx-posnr = in_posnr.
wa_bape_vbapx-zzfield1 = abap-true.
wa_extensionin-structure = 'BAPE_VBAPX'.
cl_abap_container_utilities=>fill_container_c(
EXPORTING
im_value = wa_bape_vbapx
IMPORTING
ex_container = wa_extensionin+30 ).
APPEND wa_extensionin TO lt_extensionin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raymond,
I have explained the issue I was facing when using in-app extensibility, requesting you to kindly go through my analysis and please correct me if I misunderstood anything.
I think in-app extensibility is designed for the key user who might not have much understanding of ABAP and if they want to add new fields/field to the application directly and update values in it from the app screen itself. But if you want to add a new custom field and update values in it using any inbound interface values or any other logic in the system then the in-app extensibility feature may fail there.
Please provide your suggestion on above.
Regards,
Tushar
Hi Tushar ,
Fields are added to VBAP via in-apps extensibility , so its available only in VBAPKOM not VBAPKOZ .
First of all, if the Refresh statement works fine , then atleast i can dig more if the custom fields are getting updated or not .
i am filling extension tables as below
CLEAR lw_bape_vbap.
lw_extension_in-structure = 'BAPE_VBAP' .
lw_bape_vbap-vbeln = <lf_ipdata>-column1 . "lv_so_no.
lw_bape_vbap-posnr = <lf_ipdata>-column2 . "lw_item_out-itm_number.
lw_bape_vbap-/bhci/augru_sdi = 'G09' . "<lf_ipdata>-column7 . "IC
CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = lw_bape_vbap
IMPORTING
ex_container = lw_extension_in-valuepart1.
APPEND lw_extension_in TO lit_extension_in.
CLEAR lw_extension_in.
CLEAR lw_bape_vbapx.
lw_extension_in-structure = 'BAPE_VBAPX' .
lw_bape_vbapx-vbeln = <lf_ipdata>-column1 . "lv_so_no.
lw_bape_vbapx-posnr = <lf_ipdata>-column2 . "lw_item_out-itm_number.
lw_bape_vbapx-/bhci/augru_sdi = abap_true . "IC
CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = lw_bape_vbapx
IMPORTING
ex_container = lw_extension_in-valuepart1.
APPEND lw_extension_in TO lit_extension_in.
CLEAR lw_extension_in.<br><br> CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_so_no "lit_sales_document
order_header_in = lw_header_in
order_header_inx = lw_header_inx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
TABLES
return = lit_return_in
order_item_in = lit_item_in
order_item_inx = lit_item_inx
schedule_lines = lit_schedules_in
schedule_linesx = lit_schedules_inx
extensionin = lit_extension_in
extensionex = lit_extension_in.Whatever data i am passing to BAPI , if i save that data as Test parameter for the BAPI and then execute in SE37 , the refresh statement is refreshing data from EXTENSIONEX only , but from my program its refreshing data from both EXTENSIONIN & EXTENSIONEX .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it worked now .
I just passed lit_extension_inx to Extensionex parameter ..
Data(lit_extension_inx) = lit_extension_in[] .
CALL FUNCTION 'BAPI_SALESORDER_CHANGE' EXPORTING
salesdocument = lv_so_no "lit_sales_document
order_header_in = lw_header_in
order_header_inx = lw_header_inx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
TABLES
return = lit_return_in
order_item_in = lit_item_in
order_item_inx = lit_item_inx
schedule_lines = lit_schedules_in
schedule_linesx = lit_schedules_inx
extensionin = lit_extension_in
extensionex = lit_extension_inx.
Hi All ,
I am passing the EXTENSIONIN & EXTENSIONEX tables to BAPI 'BAPI_SALESORDER_CHANGE' , inside this BAPI , its calling FM ' 'SD_SALESDOCUMENT_CHANGE' . Inside this FM i see data is present in EXTENSIONIN & EXTENSIONEX tables . but Inside this FM , at line 140 - REFRESH : extensionex,
Whenever this REFRESH statement is getting executed , its refreshing data from EXTENSIONEX as well from EXTENSIONIN too . Dont understand why its deleting EXTENSIONIN .
But if i am executing this BAPI 'BAPI_SALESORDER_CHANGE' in se37 , the same REFRESH statement inside FM ' 'SD_SALESDOCUMENT_CHANGE' , its refreshing data from EXTENSIONEX only , but not from EXTENSIONIN .
What could be the reason for this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think you should fill the extension structures as follows:
ls_extensionin-structure = 'BAPE_VBAP'.
ls_extensionin-valuepart1 = [New field name].
ls_extensionin-valuepart2 = [New field value].and for the extensionx
ls_extensionin-structure = 'BAPE_VBAP'.
ls_extensionin-valuepart1 = [New field name].
ls_extensionin-valuepart2 = abap_true.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.