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

how to upload mm02 data using bapi

0 Likes
2,848

Hi guru,

i want to upload data in mm02.my text file is like

material no, language and description.

711 AR A12345

711 BG A12345

711 CA A12345

321 AR F12345

321 BG F12345

321 CA F12345

i wrote a code like

loop at itab into wa_ITAB.
    WA_HEADDATA-MATERIAL = wa_itab-matnr."Pass Material No here
    IT_MATERIALDESCRIPTION-MATL_DESC = wa_itab-MAKTX."Pass Material Description here
    IT_MATERIALDESCRIPTION-LANGU = WA_ITAB-SPRAS."Language here
    CLEAR: WA_ITAB.

    APPEND IT_MATERIALDESCRIPTION.

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
       HEADDATA                   = WA_HEADDATA
     IMPORTING
       RETURN                     = RETURN
     TABLES
       MATERIALDESCRIPTION        = IT_MATERIALDESCRIPTION.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*     EXPORTING
*       WAIT          =
*     IMPORTING
*       RETURN        =
              .
write:/ return-TYPE.
     endloop.		

but data can not upload is it right or wrong?

21 REPLIES 21
Read only

Former Member
0 Likes
2,387

What was the result of debugging?

pk

Read only

0 Likes
2,387

all the data append in IT_MATERIALDESCRIPTION but data is not uploading.

Read only

0 Likes
2,387

Internal table populated but table not appended. Great....

So what's the obvious conclusion here?

pk

Read only

GauthamV
Active Contributor
0 Likes
2,387

Are you passing basic data view in header ?

wa_headdata-basic_view = 'X'.

Read only

0 Likes
2,387

yes but no change

loop at itab into wa_ITAB.
    WA_HEADDATA-MATERIAL = wa_itab-matnr."Pass Material No here
    IT_MATERIALDESCRIPTION-MATL_DESC = wa_itab-MAKTX."Pass Material Description here
    IT_MATERIALDESCRIPTION-LANGU = WA_ITAB-SPRAS."Language here
    wa_HEADDATA-BASIC_VIEW = 'X'.
    CLEAR: WA_ITAB.

    APPEND IT_MATERIALDESCRIPTION.

Read only

0 Likes
2,387

Try passing material with leading zeros.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,387

Hello,

Did you read my previous post? If yes, are there any entries in the RETURN structure?

BR,

Suhas

Read only

0 Likes
2,387

no entries in RETURN structure.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,387

Did you populate the fields IND_SECTOR & MATL_TYPE of HEADDATA structure?

Read only

0 Likes
2,387

Hi Suhas,

These fields are not required for change operation.

@ OP - Please check whether the values are populated exactly in the fm parameters.

Check the table parameter RETURNMESSAGES.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,387

Where has the OP mentioned he wants to "update" the materials? He wants to "upload" the materials from a TXT file.

Read only

0 Likes
2,387

yes i have mention IND_SECTOR and MATL_TYPE but message type E display.

my code is like this.

loop at itab .
    WA_HEADDATA-MATERIAL = itab-matnr."Pass Material No here
    IT_MATERIALDESCRIPTION-MATL_DESC = itab-MAKTX."Pass Material Description here
    IT_MATERIALDESCRIPTION-LANGU = ITAB-SPRAS."Language here
    wa_HEADDATA-BASIC_VIEW = 'X'.
    wa_HEADDATA-IND_SECTOR = itab-IND_SECTOR.
    wa_HEADDATA-MATL_TYPE = itab-MATL_TYPE.

    CLEAR: ITAB.

    APPEND IT_MATERIALDESCRIPTION.

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
       HEADDATA                   = WA_HEADDATA
     IMPORTING
       RETURN                     = RETURN
     TABLES
       MATERIALDESCRIPTION        = IT_MATERIALDESCRIPTION.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*     EXPORTING
*       WAIT          =
*     IMPORTING
*       RETURN        =
              .
write:/ return-TYPE.
     endloop.

Read only

0 Likes
2,387

Hi Suhas,

mm02 - change material

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,387

>

> Hi Suhas,

> mm02 - change material

Time to call it a day !!!

Read only

Former Member
0 Likes
2,387

>

> no entries in RETURN structure.

You are just looking at the header of the RETURN table. This will always come back from the BAPI empty. Instead, you must LOOP through the RETURN table to see where the problem is.

Rob

Read only

Former Member
0 Likes
2,387

Rob,

I am pretty sure that RETURN is not an internal table in this FM.

Read only

Former Member
0 Likes
2,387

Hmmmm.....

That seems to be correct; however, it shouldn't be empty. It should have the last message processed.

But all of the messages should be in the table RETURNMESSAGES which I don't think is being retrieved here.

Rob

Read only

Former Member
0 Likes
2,387

I think you may have hit on the problem.

However, it really does seem strange to me that the return structure is empty. I use this bapi all the time, and I check the return structure (not the internal table returnmessages) for errors, and it works perfectly.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,387

Hello,

As per the FM documentation:

When you create material master data, the following fields must always contain a value in the structure: MATERIAL, IND_SECTOR & MATL_TYPE.

At least one view must be selected:

BASIC_VIEW (always necessary when creating material master data)

I don't see you populating the fields IND_SECTOR & MATL_TYPE of HEADDATA structure. You need to ask your functional consultant regarding what values need to be updated in these fields.

BR,

Suhas

Read only

Former Member
0 Likes
2,387

If the material number has only numbers as the OP suggests, then you really need to pad that number with those leading zeros as Keshav suggested.

Probably the best way to do it would be to call the conversion routine.


 CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
   EXPORTING
     INPUT        = wa_itab-matnr
   IMPORTING
     OUTPUT       = WA_HEADDATA-MATERIAL
            .

Edited by: Larry Browning on Nov 15, 2010 1:27 PM

Read only

Former Member
0 Likes
2,387

You should also only call the update once for each material instead of trying to update the material 1 language at a time.


loop at itab into wa_ITAB.
    at new matnr.
      WA_HEADDATA-MATERIAL = wa_itab-matnr."Pass Material No here
      WA_HEADDATA-BASIC_VIEW = 'X'.
      clear it_materialdescription[].
    endat.
    IT_MATERIALDESCRIPTION-MATL_DESC = wa_itab-MAKTX."Pass Material Description here
    IT_MATERIALDESCRIPTION-LANGU = WA_ITAB-SPRAS."Language here
 
    APPEND IT_MATERIALDESCRIPTION.
 
    at end of matnr.
      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
         HEADDATA                   = WA_HEADDATA
       IMPORTING
         RETURN                     = RETURN
       TABLES
         MATERIALDESCRIPTION        = IT_MATERIALDESCRIPTION.
 
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*       EXPORTING
*         WAIT          =
*       IMPORTING
*         RETURN        =
    endat.
  endloop.

Edited by: Larry Browning on Nov 15, 2010 1:45 PM

Edited by: Larry Browning on Nov 15, 2010 1:47 PM