Skip to Content
avatar image
Former Member

Update custom fields in MARA (BAPI_MATERIAL_SAVEDATA)

Hi experts,

I have a problem when trying to change data in the material master data (MARA). I have custom fields in the table MARA and I want to change them with the function BAPI_MATERIAL_SAVEDATA. All the data is changed except the custom fields. For this, I use the parameters EXTENSIONIN and EXTENSIONINX.

For instance, I have the custom field ZFIELD (CHAR3) in MARA's table and the material 99. And I sent the next value to the parameters for EXTENSION's tables...

* EXTENSIONIN (itab)
STRUCTURE               VALUEPART1
BAPI_TE_MARA            00000000000000099UPT

* EXTENSIONINX (itab)
STRUCTURE               VALUEPART1
BAPI_TE_MARA            00000000000000099X

I'm receiving the message "The material 99 has been created or extended" but my custom fields are not updated. If I change some other fields that are NOT custom, everything works fine and they are updated. But my problem is with the custom fields. What am I doing wrong? Do I need to change another parameter in order to indicate that I have custom fields? Please let me know.

Regards,

Isaac Meléndez

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 31, 2008 at 04:33 AM

    A stray doubt - is the MARA extension 'fully' active? May be worth checking CMOD SMOD etc where all the pre-activation steps are done.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sasanka,

      How can I check if MARA extension is "fully" active? The structures are active. Could you provide the steps, please?

      Regards,

      Isaac Meléndez

  • avatar image
    Former Member
    Jul 31, 2008 at 02:47 PM

    Hi,

    I found a post that solve my problem, thanks to all.

    The problem was something about configuration.

    > Hello,

    >

    > I was also facing the same problem, but I could bring the BAPI to work correctly.

    >

    > First, here my program:

    >

    > REPORT  zp601931_test_004.
    > DATA: ls_headdata      TYPE bapimathead,
    >       lt_extensionin   TYPE STANDARD TABLE OF bapiparex,
    >       ls_extensionin   LIKE LINE OF lt_extensionin,
    >       lt_extensioninx  TYPE STANDARD TABLE OF bapiparexx,
    >       ls_extensioninx  LIKE LINE OF lt_extensioninx,
    >       lt_messages      TYPE bapiret2_t,
    >       ls_bapi_te_mara  TYPE bapi_te_mara,
    >       ls_bapi_te_marax TYPE bapi_te_marax.
    > 
    > 
    > CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    >   EXPORTING
    >     input  = '2'
    >   IMPORTING
    >     output = ls_headdata-material.
    > 
    > ls_headdata-basic_view = 'X'.
    > 
    > ls_bapi_te_mara-material = ls_headdata-material.
    > * Here I want to write 4 in my Append Field !!!!!
    > ls_bapi_te_mara-zztest1 = '4'.
    > 
    > ls_bapi_te_marax-material         = ls_headdata-material.
    > ls_bapi_te_marax-zztest1          = 'X'.
    > 
    > ls_extensionin-structure         = 'BAPI_TE_MARA'.
    > ls_extensionin-valuepart1+0(18)  = ls_bapi_te_mara-material.
    > ls_extensionin-valuepart1+18(1)  = ls_bapi_te_mara-zztest1.
    > APPEND ls_extensionin TO lt_extensionin.
    > 
    > ls_extensioninx-structure         = 'BAPI_TE_MARAX'.
    > ls_extensioninx-valuepart1+0(18)  = ls_bapi_te_mara-material.
    > ls_extensioninx-valuepart1+18(1)  = ls_bapi_te_marax-zztest1.
    > APPEND ls_extensioninx TO lt_extensioninx.
    > 
    > CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    >   EXPORTING
    >     headdata       = ls_headdata
    >   TABLES
    >     returnmessages = lt_messages
    >     extensionin    = lt_extensionin
    >     extensioninx   = lt_extensioninx.
    > 
    > CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    >   EXPORTING
    >     wait = 'X'.
    > 
    > CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    >   EXPORTING
    >     i_structure_name = 'BAPIRET2'
    >   TABLES
    > 

    >

    > Of course, the structures BAPI_TE_MARA and BAPI_TE_MARAX were extended to match the append-field of structure MARA (here ZZTEST1)

    >

    > But, you'll need to do some customizing to get this code running properly.

    > So, call the transaction SPRO and open the activity "Logistics - General->Material Master->Field Selection->Assign Fields to Field Selection Groups"

    >

    > Click on "New Entries". Now you can fill the field "Field name" (I wrote MARA-ZZTEST2) and, VERY IMPORTANT, fill the field "Maint.status" with 'ABCDEFGKLPQSVXZ' (with F1 on this you'll get a description what that means).

    > So, now you can save this data and go back to the preceding screen.

    >

    > Now in the displayed list you should have your new field displayed, you now need to fill the field "Sel.Group" with a selection group number (I choose the 111). Now save, and everithing should now run.

    >

    > Regards

    > Dominique Delesse

    Thanks a lot Dominique.

    Regards,

    Isaac Meléndez

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 30, 2008 at 10:20 PM

    Hi,

    Please go through the function module documentation for the extension.

    did you use the data element BAPIUPDATE in the structure BAPI_TE_MARAX for the additional field..?

    Thanks

    Naren

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Check trhe code below . to populate the custom field

      gs_extension-structure = 'BAPE_VBAKX'. "should be mara struc

      ls_bape_vbakx-zztcode_id = 'X'. "mara custome field

      MOVE ls_bape_vbakx TO gs_extension-valuepart1. "#EC ENHOK

      pass gs_extension to BAPI

      Regards

      Vinay Kolla