‎2007 Jul 18 8:07 PM
Hi All,
i have created program to upload Material Master(MM01) using 'BAPI_MATERIAL_SAVEDAT'.
Program is giving below dump :
****************************************
An exception occurred. This exception will be dealt with in more detail
below. The exception, assigned to the class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
not caught, which
led to a runtime error. The reason for this exception is:
The call to the function module "BAPI_MATERIAL_SAVEDATA" is incorrect:
In the function module interface, you can specify only
fields of a specific type and length under "CLIENTDATA".
Although the currently specified field
"I_CLIENTDATA" is the correct type, its length is incorrect.
********************************************************
here is my program:
REPORT ZBDC_MM01_BAPI.
include bdcrecx1.
data: v_mtart like RMMG1-MTART.
************
DATA : lt_intern TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
data: ld_index type i.
field-symbols: <f1>.
data: begin of i_headdata,
material like bapimathead-MATERIAL,
IND_SECTOR like bapimathead-IND_SECTOR,
MATL_TYPE like bapimathead-MATL_TYPE,
BASIC_VIEW like bapimathead-BASIC_VIEW,
PURCHASE_VIEW like bapimathead-PURCHASE_VIEW,
MRP_VIEW like bapimathead-MRP_VIEW,
end of i_headdata.
data: begin of i_clientdata,
MATL_GROUP like BAPI_MARA-MATL_GROUP,
BASE_UOM like BAPI_MARA-BASE_UOM,
end of i_clientdata.
data: begin of i_clientdata_1,
MATL_GROUP like BAPI_MARAX-MATL_GROUP,
BASE_UOM like BAPI_MARAX-BASE_UOM,
end of i_clientdata_1.
data: begin of i_plantdata,
plant like bapi_marc-plant,
abc_id like bapi_marc-abc_id,
pur_group like bapi_marc-pur_group,
mrp_type like bapi_marc-mrp_type,
mrp_ctrler like bapi_marc-mrp_ctrler,
assy_scrap like bapi_marc-assy_scrap,
lotsizekey like bapi_marc-lotsizekey,
reorder_pt like bapi_marc-reorder_pt,
fixed_lot like bapi_marc-fixed_lot,
availcheck like bapi_marc-availcheck,
end of i_plantdata.
data: begin of i_plantdata_1,
plant like bapi_marcx-plant,
abc_id like bapi_marcx-abc_id,
pur_group like bapi_marcx-pur_group,
mrp_type like bapi_marcx-mrp_type,
mrp_ctrler like bapi_marcx-mrp_ctrler,
assy_scrap like bapi_marcx-assy_scrap,
lotsizekey like bapi_marcx-lotsizekey,
reorder_pt like bapi_marcx-reorder_pt,
fixed_lot like bapi_marcx-fixed_lot,
availcheck like bapi_marcx-availcheck,
end of i_plantdata_1.
data: begin of i_bapi_makt occurs 0,
LANGU like bapi_makt-LANGU,
MATL_DESC like bapi_makt-MATL_DESC,
end of i_bapi_makt.
data: begin of i_bapiret occurs 0.
include structure BAPIRET2.
data: end of i_bapiret.
data: begin of itab occurs 0,
matnr(18) type c, "Material
mtart(04) type c, "Material Type
werks(04) type c, "Plant
maktx(40) type c, "Description
meins(03) type c, "UOM
ekgrp(03) type c, "Purchasing grp
ekwsl(04) type c, "Purchasing value key
maabc(01) type c, "ABC Indicator
dismm(02) type c, "MRP Type
minbe(16) type c, "Reorder Pt,
dispo(03) type c, "MRP controler
disls like marc-disls, "Lot size
bstfe(02) type c, "Fix lot size
ausss(07) type c, "Assemly scrap
end of itab.
***********************************************************************
SELECTION SCREEN *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS : P_FLPC LIKE RLGRAP-FILENAME DEFAULT 'C:\'
OBLIGATORY. "File Na
SELECTION-SCREEN END OF BLOCK B2 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FLPC.
data : d1 like sy-repid.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = d1
DYNPRO_NUMBER = SY-DYNNR
FIELD_NAME = ' '
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = P_FLPC .
if sy-subrc <> 0.
Raising the Error Message
message i001.
stop.
endif.
***************************************
start-of-selection.
*********************
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_flpc
I_BEGIN_COL = 1
I_BEGIN_ROW = 3
I_END_COL = 16
I_END_ROW = 65536
TABLES
INTERN = lt_intern
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
message i003.
Stop.
else.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO ld_index.
ASSIGN COMPONENT ld_index OF STRUCTURE ITAB TO <F1> .
MOVE lt_intern-value TO <F1> .
AT END OF row.
APPEND ITAB.
CLEAR ITAB.
ENDAT.
ENDLOOP.
endif.
loop at itab.
i_headdata-material = itab-matnr.
i_headdata-IND_SECTOR = 'M'.
i_headdata-MATL_TYPE = 'FERT'.
i_headdata-BASIC_VIEW = 'X'.
i_headdata-PURCHASE_VIEW = 'X'.
i_headdata-MRP_VIEW = 'X'.
i_clientdata-MATL_GROUP = '01407'.
i_clientdata-BASE_UOM = 'EA'.
i_clientdata_1-MATL_GROUP = 'X'.
i_clientdata_1-BASE_UOM = 'X'.
i_plantdata-plant = itab-werks.
i_plantdata-abc_id = itab-maabc.
i_plantdata-pur_group = itab-ekgrp.
i_plantdata-mrp_type = itab-dismm.
i_plantdata-mrp_ctrler = itab-dispo.
i_plantdata-assy_scrap = itab-ausss.
i_plantdata-lotsizekey = itab-disls.
i_plantdata-reorder_pt = itab-minbe.
i_plantdata-fixed_lot = itab-bstfe.
i_plantdata-availcheck = '01'.
i_plantdata_1-plant = 'X'.
i_plantdata_1-abc_id = 'X'.
i_plantdata_1-pur_group = 'X'.
i_plantdata_1-mrp_type = 'X'.
i_plantdata_1-mrp_ctrler = 'X'.
i_plantdata_1-assy_scrap = 'X'.
i_plantdata_1-lotsizekey = 'X'.
i_plantdata_1-reorder_pt = 'X'.
i_plantdata_1-fixed_lot = 'X'.
i_plantdata_1-availcheck = 'X'.
i_bapi_makt-langu = 'EN'.
i_bapi_makt-matl_desc = itab-maktx.
append i_bapi_makt. clear i_bapi_makt.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = i_headdata
CLIENTDATA = i_clientdata
CLIENTDATAX = i_clientdata_1
PLANTDATA = i_plantdata
PLANTDATAX = i_plantdata_1
IMPORTING
RETURN = i_bapiret
TABLES
MATERIALDESCRIPTION = i_bapi_makt
.
endloop.
if not i_bapiret[] is initial.
loop at i_bapiret.
write:/5 i_bapiret-type,
i_bapiret-id,
i_bapiret-number,
i_bapiret-message.
endloop.
endif.
end-of-selection.
Please let me know how to resolve this.
‎2007 Jul 18 8:18 PM
add exceptions explicitly. wrong type of UOM might have been passed.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = i_headdata
CLIENTDATA = i_clientdata
CLIENTDATAX = i_clientdata_1
PLANTDATA = i_plantdata
PLANTDATAX = i_plantdata_1
IMPORTING
RETURN = i_bapiret
TABLES
MATERIALDESCRIPTION = i_bapi_makt
<b>EXCEPTIONS
ERROR_MESSAGE = 1.</b>
‎2010 Jul 05 10:02 AM
HI Sunil Dhakad here,
i want to know how can i find and delete multiple material code of same material.