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

Help BAPI_MATERIAL_SAVEDATA !?!?

Former Member
0 Likes
5,049

Hi Friends,

I've created a program that allow to change the <b>unit of measure</b> of a material master (add new unit <b>USE</b>). But wrong when I used BAPI BAPI_MATERIAL_SAVEDATA to do it. The message error as below:

"specify the conversion factors for the unit of measure <b>USE</b>"

Anyone can tell me why?

Thanks,

Gy

14 REPLIES 14
Read only

Former Member
0 Likes
3,214

Hi,

It is missing the table entry from MARM. (or it has an entry but marm-umrez and marm-umren are both 0)

If the conversion numerator is always 1:1 between the old UoM and the new UoM, you should just update MARA-MEINS.

Otherwise you should enter <b>USE</b> as an alternative UoM (Additional data in MM02) with the conversion factors via BatchInput or LSMW.

Rgds,

Barna

Read only

0 Likes
3,214

Thanks for you help,

I forgot fill the table marmx.

Gy

Read only

0 Likes
3,214

hi

I am also facingthis issue now ..

could you plse let me how do u solve it..

Read only

0 Likes
3,214

I think the answer was;


I forgot fill the table marmx.

Read only

0 Likes
3,214

I need ur help

what values ur passed in marmx.

Read only

0 Likes
3,214

All I did was read the reply and highlight the part you seemed to have missed.

Read only

0 Likes
3,214

what ever values you have filled against fields in MARM , you will find same fields in MARMX . you have to pass value 'X' to those fields in MARMX

Read only

0 Likes
3,214

I have filled as  below

  wa_marmx-alt_unit        = 'X'."wa_marm_ga-alt_unit.

  wa_marmx-alt_unit_iso    = 'X'."wa_marm_ga-alt_unit_iso.

  wa_marmx-numerator       = 'X'. "wa_marm_ga-numerator.

  wa_marmx-denominatr      = 'X'." wa_marm_ga-denominatr.

Read only

0 Likes
3,214

did you pass values for these 4 fields in structure MARM as well.???

Read only

0 Likes
3,214

yes

please chek the below code ..if possible.. plse

DATA : wa_matdes    TYPE    bapi_makt_ga,

         wa_clnt      TYPE    bapi_mara_ga,

         wa_makt_des  TYPE    bapi_makt.



  DATA : tb_clnt      TYPE STANDARD TABLE OF bapi_mara_ga,

         tb_makt_des  TYPE STANDARD TABLE OF bapi_makt,

         tb_matdes    TYPE STANDARD TABLE OF bapi_makt_ga,

*Begin of changes phaniram YADK931460

         tb_marm      TYPE STANDARD TABLE OF bapi_marm,

         wa_marm      TYPE bapi_marm,

         tb_marmx     TYPE STANDARD TABLE OF bapi_marmx,

         wa_marmx     TYPE bapi_marmx,

         tb_marm_ga   TYPE STANDARD TABLE OF bapi_marm_ga,

         wa_marm_ga   TYPE bapi_marm_ga.

*End of changes phaniram YADK931460



* Header Data.

  IF wa_mara-vpsta CA cn_k.

    wa_headdata-basic_view    =  cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_v.

    wa_headdata-sales_view    = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_e.

    wa_headdata-purchase_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_d.

    wa_headdata-mrp_view  = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_p.

    wa_headdata-forecast_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_a.

    wa_headdata-work_sched_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_f.

    wa_headdata-prt_view   =  cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_l.

    wa_headdata-storage_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_s.

    wa_headdata-warehouse_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_q.

    wa_headdata-quality_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_b.

    wa_headdata-account_view = cn_x.

  ENDIF.



  IF wa_mara-vpsta CA cn_g.

    wa_headdata-cost_view =  cn_x.

  ENDIF.



  wa_headdata-material      =  wa_mara-matnr.

  wa_headdata-ind_sector    =  wa_mara-mbrsh.

  wa_headdata-matl_type     =  wa_mara-mtart.



* Material Description

  CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'

    DESTINATION va_dest

    EXPORTING

      material            = wa_mara-matnr

    IMPORTING

      clientdata          = wa_clnt

    TABLES

      materialdescription = tb_matdes

      unitsofmeasure      = tb_marm_ga.



  IF  tb_matdes  IS NOT INITIAL.

    LOOP  AT tb_matdes INTO wa_matdes.

      wa_makt_des-langu       = wa_matdes-langu.

      wa_makt_des-langu_iso   = wa_matdes-langu_iso.

      wa_makt_des-matl_desc   = wa_matdes-matl_desc.

      APPEND wa_makt_des TO tb_makt_des.

      CLEAR :wa_makt_des.

    ENDLOOP.

  ENDIF.

*Begin of changes phaniram YADK931460

  IF  tb_matdes  IS NOT INITIAL.

    LOOP  AT tb_marm_ga INTO wa_marm_ga.

      MOVE-CORRESPONDING wa_marm_ga TO wa_marm.

*Begin of change Phaniram YADK934080 04.09.2013

      IF wa_marm-alt_unit = 'NR'.

         wa_marm-del_flag = 'X'.

      ENDIF.



*End of change Phaniram YADK934080 04.09.2013

      APPEND wa_marm TO tb_marm.

      CLEAR :wa_marm_ga,wa_marm.

    ENDLOOP.

  ENDIF.



  wa_marmx-alt_unit        = 'X'."wa_marm_ga-alt_unit.

  wa_marmx-alt_unit_iso    = 'X'."wa_marm_ga-alt_unit_iso.

  wa_marmx-numerator       = 'X'. "wa_marm_ga-numerator.

  wa_marmx-denominatr      = 'X'." wa_marm_ga-denominatr.

  APPEND wa_marmx TO tb_marmx.

*Begin of changes phaniram YADK931460

*Clinet data

  IF wa_clnt    IS NOT INITIAL.

    MOVE-CORRESPONDING wa_clnt TO wa_clientdata.

    CLEAR wa_clnt.

  ENDIF.





* Client datax

* For clientdatx value assign purpose.

  ASSIGN wa_clientdatax TO <wa>.

  SELECT * FROM dd03l INTO TABLE tb_dd03l WHERE tabname = 'BAPI_MARAX'.

  IF sy-subrc IS INITIAL.

    LOOP AT tb_dd03l INTO wa_dd03l.

      ASSIGN COMPONENT wa_dd03l-fieldname OF STRUCTURE <wa> TO <comp>.

      <comp> = cn_x.

    ENDLOOP.

    MOVE-CORRESPONDING <wa> TO wa_clientdatax.

  ENDIF.





* Material Creation

  IF wa_headdata  IS NOT INITIAL AND

   wa_clientdata  IS NOT INITIAL.  .

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

      EXPORTING

        headdata            = wa_headdata

        clientdata          = wa_clientdata

        clientdatax         = wa_clientdatax

      IMPORTING

        return              = wa_sav_ret

      TABLES

        materialdescription = tb_makt_des

        unitsofmeasure      = tb_marm

        unitsofmeasurex     = tb_marmx.

  ENDIF.



  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

      wait = cn_x.

Read only

Former Member
0 Likes
3,214

Hi,

I hope this example is useful:

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
      HEADDATA        = w_headdata
    IMPORTING
      RETURN          = w_return
    TABLES
      UNITSOFMEASURE  = tb_unitsofmeasure
      UNITSOFMEASUREX = tb_unitsofmeasurex.

  IF w_return-type NE 'E' AND w_return-type NE 'A'.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT = abap_true.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ENDIF.

Regards

Ivan

Read only

ThangaPrakash
Active Contributor
0 Likes
3,214

Hello Gyroyl,

You can also check the conversion in the below path.

SPRO --> SAP NetWeaver --> General Settings --> Check Units of Measurement --> Choose UoM

Select USE and then click on more details.

Regards,

TP

Read only

0 Likes
3,214

Hi ,

In the BAPI_MATERIAL_SAVEDATA tables/parameters

UNITSOFMEASURE

UNITSOFMEASUREX we need to pass the alternate unit of measure in both itabs at runtime. The error message is little confusing .

Example :

WA_MARM-ALT_UNIT = WA_DATA-MEINH.

WA_MARMX-ALT_UNIT = WA_DATA-MEINH.

WA_MARMX-ALT_UNIT_ISO = WA_MARM-ALT_UNIT_ISO.

Regards,

Mahendra

Read only

0 Likes
3,214

Very helpful. Thank you very much