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

Error in Fnctn Module BAPI_MATERIAL_SAVEDATA

Former Member
0 Likes
1,185

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.

1 ACCEPTED SOLUTION
Read only

former_member585060
Active Contributor
0 Likes
1,113

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

9 REPLIES 9
Read only

Former Member
0 Likes
1,112

Hi

Try by giving

IND_SECTOR, MATL_TYPE in HEADDATA

& BASE_UOM IN CLIENTDATA & resp field of BASE_UOM in CLIENTDATAX AS 'X'.

Regards.

Read only

former_member585060
Active Contributor
0 Likes
1,114

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

Read only

0 Likes
1,112
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

hi bala.. but i have to pass multiple material number how can passing of just one material no. to FM work? what about other materials?

Read only

0 Likes
1,112

@ bala..

yes i got you. Will try the same and get back to you.

Thanks.

Read only

0 Likes
1,112

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

Read only

0 Likes
1,112

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

Read only

0 Likes
1,112

Thanks To Everyone. I m alloting points to all of you..

Regards,

Apoorv

Read only

Former Member
0 Likes
1,112

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.

Read only

Former Member
0 Likes
1,112

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.