‎2009 Jul 03 6:13 AM
Hii Experts,
I m using FM BAPI_MATERIAL_SAVEDATA . But it is resulting in shortdump. I hv passed 3 tables namely IT_HEADDATA (like BAPIMATHEAD) IT_UOM (like BAPI_MARM) and IT_UX(like BAPI_MARMX) ..
It gives dump ,the moment it enters FM saying that "type of IT_HEADDATA is correct but length does not match"..
i hv put the following data in respective tables:
Material No in HEADDATA
UOM ,Alternate UOM,Numerator,Denominator in IT_UOM
UOM ,Alternate UOM,Numerator,Denominator in IT_UX (X in Numerator and Denominator)
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = IT_HEADDATA
TABLES
UNITSOFMEASURE = IT_UOM
UNITSOFMEASUREX = IT_UX.
‎2009 Jul 03 6:27 AM
Hi Apoorv,
The Header data should be a single record, i mean its a structure type not a internal table type, so you ghave to pass only one record.
Declare it like these
DATA : wa_headdata TYPE BAPIMATHEAD.
fill the structure and pass to the BAPI
Regards
Bala Krishna
‎2009 Jul 03 6:25 AM
Hi
Try by giving
IND_SECTOR, MATL_TYPE in HEADDATA
& BASE_UOM IN CLIENTDATA & resp field of BASE_UOM in CLIENTDATAX AS 'X'.
Regards.
‎2009 Jul 03 6:27 AM
Hi Apoorv,
The Header data should be a single record, i mean its a structure type not a internal table type, so you ghave to pass only one record.
Declare it like these
DATA : wa_headdata TYPE BAPIMATHEAD.
fill the structure and pass to the BAPI
Regards
Bala Krishna
‎2009 Jul 03 6:31 AM
Hi Apoorv,
The Header data should be a single record, i mean its a structure type not a internal table type, so you ghave to pass only one record.
Declare it like these
DATA : wa_headdata TYPE BAPIMATHEAD.
fill the structure and pass to the BAPI
Regards
Bala Krishnahi bala.. but i have to pass multiple material number how can passing of just one material no. to FM work? what about other materials?
‎2009 Jul 03 6:38 AM
@ bala..
yes i got you. Will try the same and get back to you.
Thanks.
‎2009 Jul 03 6:40 AM
Hi,
Try with this BAPI
BAPI_MATERIAL_SAVEREPLICA BAPI for Mass Maintenance of Material Data
or call the BAPI_MATERIAL_SAVEDATA in Loop of the internal table holding all the material data
Regards
Bala Krishna
Edited by: Bala Krishna on Jul 3, 2009 11:10 AM
‎2009 Jul 03 6:41 AM
Hi,
As pointed out by Apoorva just loop at internal table containing all the materials that you wish to create. After reading each record call the BAPI each time after populating
the input structures as required by the BAPI.
Regards
Raju Chitale
‎2009 Jul 03 12:55 PM
Thanks To Everyone. I m alloting points to all of you..
Regards,
Apoorv
‎2009 Jul 03 6:40 AM
wa_headdata-material = '000000000000001234'.
wa_headdata-ind_sector = 'M'.
wa_headdata-matl_type = 'FERT' .
wa_headdata-basic_view = 'X'.
Move data to client data.
wa_clientdata-base_uom = 'EA'.
wa_clientdata-base_uom_iso = 'EA'.
wa_clientdatax-base_uom = 'X'.
wa_clientdatax-base_uom_iso = 'X'.
the description of material should be passed to internal table.
MOVE : wa_material-desc TO wa_matdesc-desc,
'EN' TO wa_matdesc-langu.
APPEND wa_matdesc TO it_matdesc.
Call BAPI to create/change materials
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = wa_headdata
clientdata = wa_clientdata
clientdatax = wa_clientdatax
IMPORTING
return = return
TABLES
materialdescription = it_matdesc.
DATA : wa_bapiret2 TYPE bapiret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = wa_bapiret2.
This should work for you.
Regards,
Sreekanth.
‎2009 Jul 03 6:45 AM
Hi APOORV,
Please Look in to the below example program about the usage of BAPI_MATERIAL_SAVEDATA
Note:
Input File for the below program should contain material number, industrial sector, material type , material group, Language and Material description.
&----
*& Report ZBAPI_MATERIAL
*&
&----
*&
*&
&----
REPORT zbapi_material.
TABLES:bapimathead,
bapi_makt,
bapi_mara,
bapi_marax.
*--declaration for internal table
DATA:BEGIN OF itab OCCURS 0,
material TYPE bapimathead-material,
ind_sector(20),
matl_type TYPE bapimathead-matl_type,
matl_group TYPE bapi_mara-matl_group,
langu TYPE bapi_makt-langu,
matl_desc TYPE bapi_makt-matl_desc,
END OF itab,
it_return LIKE bapiret2,
it_bapi LIKE bapi_makt OCCURS 0 WITH HEADER LINE.
*---selection screen
PARAMETERS:p_file TYPE ibipparms-path OBLIGATORY.
*---f4 help for the file from PC
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_f4help.
*--start-of-selection .
START-OF-SELECTION.
PERFORM upload_file_itab.
PERFORM call_bapi.
&----
*& Form get_f4help
&----
FORM get_f4help .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
ENDFORM. "get_f4help
&----
*& Form upload_file_itab
&----
FORM upload_file_itab .
DATA:v_file TYPE string.
MOVE p_file TO v_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab.
ENDFORM. " upload_file_itab
&----
*& Form call_bapi
&----
FORM call_bapi .
LOOP AT itab.
bapimathead-material = itab-material.
bapimathead-ind_sector = itab-ind_sector.
bapimathead-matl_type = itab-matl_type.
bapimathead-basic_view = 'X'.
bapi_mara-matl_group = itab-matl_group.
bapi_mara-base_uom = 'KGS'.
bapi_marax-matl_group = 'X'.
bapi_marax-base_uom = 'X'.
it_bapi-langu = itab-langu.
it_bapi-langu_iso = 'EN'.
it_bapi-matl_desc = itab-matl_desc.
APPEND it_bapi.
CLEAR it_bapi.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
IMPORTING
return = it_return
TABLES
materialdescription = it_bapi.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
*---this is the message type which indicates whether it is failed or
*succeded
WRITE:/ it_return-type.
ENDLOOP.
ENDFORM. " call_bapi
Thanks,
Naveen Kumar.