‎2010 Nov 15 10:20 AM
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?
‎2010 Nov 15 10:25 AM
‎2010 Nov 15 10:26 AM
all the data append in IT_MATERIALDESCRIPTION but data is not uploading.
‎2010 Nov 15 10:34 AM
Internal table populated but table not appended. Great....
So what's the obvious conclusion here?
pk
‎2010 Nov 15 10:30 AM
Are you passing basic data view in header ?
wa_headdata-basic_view = 'X'.
‎2010 Nov 15 10:37 AM
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.
‎2010 Nov 15 10:45 AM
‎2010 Nov 15 10:57 AM
Hello,
Did you read my previous post? If yes, are there any entries in the RETURN structure?
BR,
Suhas
‎2010 Nov 15 11:04 AM
‎2010 Nov 15 11:37 AM
Did you populate the fields IND_SECTOR & MATL_TYPE of HEADDATA structure?
‎2010 Nov 15 11:41 AM
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.
‎2010 Nov 15 11:48 AM
Where has the OP mentioned he wants to "update" the materials? He wants to "upload" the materials from a TXT file.
‎2010 Nov 15 12:18 PM
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.
‎2010 Nov 15 12:20 PM
‎2010 Nov 15 12:47 PM
>
> Hi Suhas,
> mm02 - change material
Time to call it a day !!!
‎2010 Nov 15 7:35 PM
>
> 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
‎2010 Nov 15 7:40 PM
Rob,
I am pretty sure that RETURN is not an internal table in this FM.
‎2010 Nov 15 7:49 PM
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
‎2010 Nov 15 7:57 PM
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.
‎2010 Nov 15 10:32 AM
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
‎2010 Nov 15 7:26 PM
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
‎2010 Nov 15 7:36 PM
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