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: 

Custom field in MARC not updating via BAPI BAPI_MATERIAL_SAVEDATA.

ankesh_jindal4
Participant
0 Kudos

Hi

I need to add custom fields in MARA and MARC , for MARA custom fields are getting updated but for MARC even though BAPI is not returning any error but it is not getting update in MARC table.

I have already added fields in  BAPI_MARC &  BAPI_MARCX. & Functional guyz have done SPRO settings.

Adding my code below:-


WA_HEADDATA-MATERIAL = '5FRP349V'.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'

   EXPORTING

     INPUT  = WA_HEADDATA-MATERIAL

   IMPORTING

     OUTPUT = WA_HEADDATA-MATERIAL.

MOVE 'BAPI_TE_MARC' TO WA_EXTENSIONIN-STRUCTURE.

WA_EXTENSIONIN-VALUEPART1+5(8) 'ABCDEFGH'.

WA_EXTENSIONIN-VALUEPART1+0(4) = '1010'.

APPEND WA_EXTENSIONIN TO IT_EXTENSIONIN.

MOVE 'BAPI_TE_MARCX' TO WA_EXTENSIONINX-STRUCTURE.

WA_EXTENSIONINX-VALUEPART1+5(1) = 'X'.

WA_EXTENSIONINX-VALUEPART1+0(4) = '1010'.

APPEND WA_EXTENSIONINX TO IT_EXTENSIONINX.

WA_PLANTDATA-PLANT = '1010'.

WA_PLANTDATAX-PLANT = '1010'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

   EXPORTING

     HEADDATA     = WA_HEADDATA

     PLANTDATA    = WA_PLANTDATA

     PLANTDATAX   = WA_PLANTDATAX

   IMPORTING

     RETURN       = WA_RETURN

   TABLES

     EXTENSIONIN  = IT_EXTENSIONIN

     EXTENSIONINX = IT_EXTENSIONINX.

IF WA_RETURN-TYPE CA 'EA'.

   ROLLBACK WORK.

ELSE.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       WAIT = 'X'.

ENDIF.


Please suggest What I am doing wrong

Regards,

Ankesh

4 REPLIES 4

TanmayVerma
Active Participant
0 Kudos

Hi Ankesh,

The code looks correct. However please check if you are passing the correct offset. Check if the offset should be  VALUEPART1+4(1) = 'X'.   instead of +5(1). ( Since plant 1010 will occupy offsets from 0-3. ).

  1. WA_EXTENSIONINX-VALUEPART1+5(1) = 'X'
  2. WA_EXTENSIONINX-VALUEPART1+0(4) = '1010'

Also , you can try to fill the extension structure in below way.

*--assign the value to WA of type bapi_te_marc

ls_bapi_te_marcx-<field1> = '1010'.

ls_bapi_te_marcx-<field2> = 'X'.

*--call fill container to transfer values to valuepart1

CALL METHOD cl_abap_container_utilities=>fill_container_c

       EXPORTING

         im_value               = ls_bapi_te_marcx

       IMPORTING

         ex_container           = wa_extensioninx-valuepart1

       EXCEPTIONS

         illegal_parameter_type = 1

         OTHERS                 = 2.

~Tanmay

Former Member
0 Kudos

Hi,

Try passing WA_EXTENSIONINX-valuepart1 = 'X' only.

Hope this helps.

raymond_giuseppi
Active Contributor
0 Kudos

I agree with previous reply, also don't use those pre-unicode move, better use suggested method :


wa_extensionin-structure = 'BAPI_TE_MARC'.

bapi_te_marc-plant = wa_werks.

bapi_te_marc-zzfield1 = 'ABCDEFGH'.

cl_abap_container_utilities=>fill_container_c(

  EXPORTING

    im_value              = bapi_te_marc

  IMPORTING

    ex_container          = wa_extensionin-valuepart1 ).

wa_extensioninx-structure = 'BAPI_TE_MARCX'.

bapi_te_marcx-plant = wa_werks.

bapi_te_marcx-zzfield1 = abap_true.

cl_abap_container_utilities=>fill_container_c(

  EXPORTING

    im_value              = bapi_te_marcx

  IMPORTING

    ex_container          = wa_extensioninx-valuepart1 ).

Also, read  545626 - FAQ: Data transfer problems .

Regards,

Raymond

0 Kudos

Hi,

Try the below way.

WA_PLANTDATA-PLANT = '1010'

WA_PLANTDATAX-PLANT = 'X'. 

Regards,

S P R