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: 

BAPI Sales order custom field extension not updating properly

prasad_dix
Participant
0 Kudos
1,941

Hello experts,

I am trying to updates sales order header and item extensions using BAPI-> BAPI_SALESORDER_CREATEFROMDAT2 and table: extensionin.

I have appended all required structures already for VBAK and VBAP: The fields in VBAK has 4 text, 2 drop downs and few check boxes. e.g.: ZZPRO_NAME length 60, ZZPRO_END length 60. ZZCOMDOC_SUB length 60 and checkboxes ZZCOO length 1 etc. and it's corresponding X structure with char1 is also defined. And same in VBAP.

My code is like below:

      gs_extensionin          TYPE  bapiparex,
it_extensionin LIKE bapiparex OCCURS 0 WITH HEADER LINE,
wa_bape_vbak TYPE bape_vbak,
wa_bape_vbakx TYPE bape_vbakx,
wa_bape_vbak-zzpro_name = zzpro_name.
wa_bape_vbak-zzpro_end = zzpro_end.
wa_bape_vbak-zzld_clause = zzld_clause.
wa_bape_vbakx-zzpro_name = 'X'.
wa_bape_vbakx-zzpro_end = 'X'.
wa_bape_vbakx-zzld_clause = 'X'.
gs_extensionin-structure = 'BAPE_VBAK'.
gs_extensionin-valuepart1 = wa_bape_vbak.
APPEND gs_extensionin TO it_extensionin.
gs_extensionin-structure = 'BAPE_VBAKX'.
gs_extensionin-valuepart1 = wa_bape_vbakx.
APPEND gs_extensionin TO it_extensionin.


Then it_extensionin is passed to BAPI. However, it's only updating first two fields of extension and not all fields. The item level fields are not at all updating. I am writing them in a loop.

Is there any example which shows header and item level data update with multiple extension customized field?

I already saw other threads and also checked BAPI doc.

Any help appreciated,

Thanks,

Regards,

PD

4 REPLIES 4

raymond_giuseppi
Active Contributor
1,894

Are your customer field structures too wide ('4 text' of 60 chars?) longuer than 240, In this case

" Replace
gs_extensionin-valuepart1 = wa_bape_vbak.
" with
cl_abap_container_utilities=>fill_container_c(
  EXPORTING
    im_value               = wa_bape_vbak
  IMPORTING
    ex_container           = gs_extensionin+30
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2 ).

NB: For 'long' text fields, better define some custom 'long text'

0 Kudos
1,894

It's working great at header level except one field which on another tab of SO. Also same logic is not working at item level . The item level fields are not that long. They are three fields having length 8, 8, 1. I tried old simple append and your suggested method too. It is in a loop.

loop at <items>

wa_bape_vbap-posnr = ( it_ybapi_item_rpa-posnr * 10 ).
wa_bape_vbap-zzmfg_cdate = zzmfg_cdate.
wa_bape_vbap-zzprdat = zzprdat.
wa_bape_vbap-zzrepeat = zzrepeat.

gs_extensionin-structure = 'BAPE_VBAP'.
cl_abap_container_utilities=>fill_container_c(
EXPORTING
im_value = wa_bape_vbap
IMPORTING
ex_container = gs_extensionin+30
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2 ).

APPEND gs_extensionin TO it_extensionin.

clear gs_extensionin.

wa_bape_vbapx-posnr = ( it_ybapi_item_rpa-posnr * 10 ).
wa_bape_vbapx-zzmfg_cdate = 'X'.
wa_bape_vbapx-zzprdat = 'X'.
wa_bape_vbapx-zzrepeat = 'X'.

gs_extensionin-structure = 'BAPE_VBAPX'.
gs_extensionin-valuepart1 = wa_bape_vbapx.
APPEND gs_extensionin TO it_extensionin.
CLEAR gs_extensionin.

endloop.

1,739

​So the problem isn't not related to this part of the code.

Insure

  • You enhanced every required structures such as VBAPKOZ[X]
  • You pass similar values in BAPE_VBAP[X]-POSNR and SALES_ITEMS_IN[X]-ITM_NUMBER

You could also

  • Debug form ms_move_extensionin of function group vbak
  • Check for any active implementation of BADI_SD_SALESDOCU_BAPI (Custom) or BADI_SD_SALESDOCU_BAPI_INT (Sap)

0 Kudos
1,675

Hi @raymond_giuseppi It' working absolutely fine now. Thanks for your help. It's my mistake to populate data.