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_MATERIAL_SAVEDATA - Extensionin with QUAN or CURR field

Tomas_Buryanek
Active Contributor
0 Kudos

Hello,

I have a problem updating appended field in MARC.

MARC-Z1 is data type CURR length 11, decimal places 2.

In BAPI_TE_MARC I created Z1 as CHAR14 (because BAPI_TE_* supports only CHAR fields). I tried cl_abap_container_utilities=>fill_container_, but no difference.

Other field Z2, which is CHAR, is updating OK with same code. And BAPI always return update OK, without error.

Also I tried to debug standard code and "PERFORM EXTENSIONIN_UEBERGEBEN" seems to work OK and it does fill TMARC_UEB-Z1 with correct value. But after that, I lost a track in CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'....

Any ideas where could be a problem or how to find it?

Example code:

APPEND INITIAL LINE TO lt_extensionin ASSIGNING <ls_extensionin>.
<ls_extensionin>-structure = 'BAPI_TE_MARC'.
ls_bapi_te_marc-plant = gc_werks_templ.
cl_abap_container_utilities=>fill_container_c(
  EXPORTING
    im_value               = l_z1 "CURR
  IMPORTING
    ex_container           = ls_bapi_te_marc-z1 "CHAR
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2 ).
<ls_extensionin>+30 = ls_bapi_te_marc.


APPEND INITIAL LINE TO lt_extensioninx ASSIGNING <ls_extensioninx>.
<ls_extensioninx>-structure = 'BAPI_TE_MARCX'.
ls_bapi_te_marcx-plant = gc_werks.
ls_bapi_te_marcx-z1 = 'X'.
<ls_extensioninx>+30 = ls_bapi_te_marcx.


CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' DESTINATION 'NONE'
  EXPORTING
    headdata     = ls_headdata
  IMPORTING
    return       = ls_return
  TABLES
    extensionin  = lt_extensionin
    extensioninx = lt_extensioninx.
-- Tomas --
1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

You don't use correctly the method, code should be similar to

ls_extensionin-structure = 'BAPI_TE_MARC'.
cl_abap_container_utilities=>fill_container_c(
  EXPORTING
    im_value               = ls_bapi_te_marc " structure of type bapi_te_marc
  IMPORTING
    ex_container           = ls_extensionin+30 " values 1-4
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2 ).

But as the documentation ask for character fields only, we can suppose that your current version of the BAPI won't be able to map fields, so the BAPI actually don't use this Unicode class. So you may consider using BAdI STANDARDMATERIAL_SAVE_DATA and map yourself data with method MAP_EXTENSIONIN from records with structure like BAPI_TE_E1<NAME>, e.g. BAPI_TE1_MARC.

5 REPLIES 5

raymond_giuseppi
Active Contributor

You don't use correctly the method, code should be similar to

ls_extensionin-structure = 'BAPI_TE_MARC'.
cl_abap_container_utilities=>fill_container_c(
  EXPORTING
    im_value               = ls_bapi_te_marc " structure of type bapi_te_marc
  IMPORTING
    ex_container           = ls_extensionin+30 " values 1-4
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2 ).

But as the documentation ask for character fields only, we can suppose that your current version of the BAPI won't be able to map fields, so the BAPI actually don't use this Unicode class. So you may consider using BAdI STANDARDMATERIAL_SAVE_DATA and map yourself data with method MAP_EXTENSIONIN from records with structure like BAPI_TE_E1<NAME>, e.g. BAPI_TE1_MARC.

0 Kudos

Result is same with both ways of method use.

But thank you for a BADI ! I will try implement it tomorrow and get back here 🙂 It could be working workaround for nonCHAR appended fields.

-- Tomas --

0 Kudos

BADI implementation did not help 😞

It is called after the standard EXTENSIONIN handling, which I mentioned in first post, and TMARC_UEB-Z1 is already correctly filled with decimal value (data type CURR) which should be updated to MARC. But again, value gets lost somewhere in/after MATERIAL_MAINTAIN_DARK. And result is initial value in MARC-Z1 (0.00).

Other appended field MARC-Z2 (data type CHAR) goes through same way and is updated correctly.

What do you mean with "BAPI actually don't use this Unicode class" ?

-- Tomas --

Did you use 44410 - Integrating customer-specific fields in the material master to Customize your appended fields (Are those fields displayed/editable on MM01/MM02 transactions)

Solved 🙂 I just found this post https://archive.sap.com/discussions/thread/986261 and came back to your comment.

Yes it was this customization - table T130F = SPRO "Logistics - General->Material Master->Field Selection->Assign Fields to Field Selection Groups" there I had to create entry for MARC-Z1. Thank you Raymond

-- Tomas --