Application Development and Automation 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: 
Read only

some fields are not updated using BAPI_MATERIAL_SAVEDATA

KLH
Explorer
0 Likes
4,250

Hi, we've been trying to use the BAPI_MATERIAL_SAVEDATA in creating new materials. But there are some fields that are not being updated to MARA and MARC:

total shelf life - MARA-MHDHB

min rem shelf life - MARA-MHDRZ

minimum lot. size - MARC-BSTMI

Here's the part of the code that uses BAPI..

   bapi_mara-matl_group = gs_data-matkl.

   bapi_mara-division   = gs_data-spart.

   bapi_mara-net_weight = gs_data-ntgew.

   bapi_mara-unit_of_wt = gs_data-gewei.

   bapi_mara-base_uom   = gs_data-meins.

   bapi_mara-po_unit    = gs_data-bstme.

   bapi_mara-net_weight = gs_data-ntgew.

   bapi_mara-unit_of_wt = gs_data-gewei.

   bapi_mara-base_uom   = gs_data-meins.

   bapi_mara-matl_group = gs_data-matkl.

   bapi_mara-division   = gs_data-spart.

   bapi_mara-batch_mgmt = gs_data-xchpf.

   bapi_mara-minremlife = gs_data-mhdrz.

   bapi_mara-shelf_life = gs_data-mhdhb.

   bapi_mara-pur_status = gs_data-mstae.

   bapi_mara-sal_status = gs_data-mstav.

   bapi_mara-pvalidfrom = gs_data-mstde.

   bapi_mara-svalidfrom = gs_data-mstdv.

   bapi_mara-trans_grp  = gs_data-tragr.

   PERFORM: chk_flds USING bapi_mara-matl_group CHANGING bapi_marax-matl_group,

            chk_flds USING bapi_mara-division   CHANGING bapi_marax-division,

            chk_flds USING bapi_mara-net_weight CHANGING bapi_marax-net_weight,

            chk_flds USING bapi_mara-unit_of_wt CHANGING bapi_marax-unit_of_wt,

            chk_flds USING bapi_mara-base_uom   CHANGING bapi_marax-base_uom,

            chk_flds USING bapi_mara-po_unit    CHANGING bapi_marax-po_unit,

            chk_flds USING bapi_mara-net_weight CHANGING bapi_marax-net_weight,

            chk_flds USING bapi_mara-unit_of_wt CHANGING bapi_marax-unit_of_wt,

            chk_flds USING bapi_mara-base_uom   CHANGING bapi_marax-base_uom,

            chk_flds USING bapi_mara-matl_group CHANGING bapi_marax-matl_group,

            chk_flds USING bapi_mara-division   CHANGING bapi_marax-division,

            chk_flds USING bapi_mara-batch_mgmt CHANGING bapi_marax-batch_mgmt,

            chk_flds USING bapi_mara-minremlife CHANGING bapi_marax-minremlife,

            chk_flds USING bapi_mara-shelf_life CHANGING bapi_marax-shelf_life,

            chk_flds USING bapi_mara-pur_status CHANGING bapi_marax-pur_status,

            chk_flds USING bapi_mara-sal_status CHANGING bapi_marax-sal_status,

            chk_flds USING bapi_mara-pvalidfrom CHANGING bapi_marax-pvalidfrom,

            chk_flds USING bapi_mara-svalidfrom CHANGING bapi_marax-svalidfrom,

            chk_flds USING bapi_mara-trans_grp  CHANGING bapi_marax-trans_grp.

   bapi_marc-plant      = '1100'.

   bapi_marc-availcheck = '02'.

   bapi_marc-batch_mgmt = gs_data-xchpf.

   bapi_marc-minlotsize = gs_data-bstmi.

   bapi_marcx-plant     = '1100'.

   PERFORM chk_flds USING bapi_marc-availcheck CHANGING bapi_marcx-availcheck.

   PERFORM chk_flds USING bapi_marc-batch_mgmt CHANGING bapi_marcx-batch_mgmt.

   PERFORM chk_flds USING bapi_marc-minlotsize CHANGING bapi_marcx-minlotsize.


*   Call BAPI for material creation

     CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

       EXPORTING

         headdata            = bapimathead

         clientdata          = bapi_mara

         clientdatax         = bapi_marax

         salesdata           = bapi_mvke

         salesdatax          = bapi_mvkex

         plantdata           = bapi_marc

         plantdatax          = bapi_marcx

       IMPORTING

         return              = it_return

       TABLES

         materialdescription = gt_makt

         unitsofmeasure      = gt_marm

         unitsofmeasurex     = gt_marmx

         returnmessages      = it_return

         extensionin         = it_extension

         extensioninx        = it_extensionx.

     READ TABLE it_return WITH KEY type = 'S' id = 'M3' number = '800'.

     IF sy-subrc EQ 0.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

           wait   = 'X'.

       MESSAGE i002 WITH gs_data-matnr

                         'you may proceed with the creation of Procurement Data'.

*     Call Worflow

       PERFORM call_workflow.

*     Back to selection screen

       SET SCREEN 0.

     ELSE.

       CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

       lc_refnr = gs_data-matnr+8(10).

       LOOP AT it_return ASSIGNING FIELD-SYMBOL(<lfs_return>) WHERE type = 'E'.

         PERFORM add_msg USING lc_refnr

                               lc_bdcnr

                               <lfs_return>

                      CHANGING lt_buzei.

       ENDLOOP.



Thanks for your help!

5 REPLIES 5
Read only

Former Member
0 Likes
2,607

Hi ,

Check for the error messages in both the return and returnmessages . it will help in resolving the issue.

Can you provide which error you are getting...

regards,

Praphul

Read only

0 Likes
2,607

Hi Praphul,


Unfortunately, it does not return an error message. Most of the fields get updated.

Maybe some other fields are related to the fields not updated?

Thanks,

Keith

Read only

0 Likes
2,607

Hi Keith,

Once I had debugged this BAPI for some requirement.

This BAPI calls FM 'MATERIAL_MAINTAIN_DARK' to create material.

The MARA table is updated in FM MARA_ARRAY_UPDATE. You can put the break-point in this FM and check the values which is being updated or inserted in MARA.

Same for MARC table , FM is MARC_ARRAY_UPDATE.

Also, Try to execute the MM01 to check whether material is getting created with the data you are providing in the BAPI.

Regards,

Praphul

Read only

0 Likes
2,607

Hi Praphul, Thanks for your advice.. It seems the problem was with our data.. Thanks!

Best regards,

Keith

Read only

JL23
Active Contributor
0 Likes
2,607

use MM01 at least once to know where those fields are.

You can only maintain fields that are not hidden and are  included in view maintenance through this BAPI as the BAPI does not just write records into a table (then it would be a direct input instead of BAPI)

E.g. the shelf life fields are at the storage location view.

Your code does not show any values, so we cannot know if you process the storage location view at all.

Fields on the MRP1 views are open or not ready for input depending on other fields and their values.