‎2008 Oct 07 11:46 AM
hi,
i am developing bdc for material master upload(mm01)..,can anyone suggest for thsi which one is better - bdc,lsmw,bapi....
if suppose i do material master upload by bdc then how do i handle views which r dependent on the material type...
‎2008 Oct 07 11:57 AM
Hi
For MM01, going with BDC is not a good idea...as you have different types of view..
The better and best way is to go with BAPI.. It is more safe..and recommended also.
Regards,
Vishwa.
‎2008 Oct 07 11:55 AM
Hi Siddhath,
It really up to you to choose BDC,BAPI or LSMW. I can suggest if you are working in lower version than 4.3 then go for BDC i think the later version has BAPI. Experts please correct if i am wrong!!!
For Views i strictly recommend conditional statements which help you to choose which depending upon the Material Type...
Hope this helps you
‎2008 Oct 07 11:57 AM
Hi
For MM01, going with BDC is not a good idea...as you have different types of view..
The better and best way is to go with BAPI.. It is more safe..and recommended also.
Regards,
Vishwa.
‎2008 Oct 07 12:03 PM
Hello Sid,
Can u tell which all views u have 2 capture, as PO text is not able 2 capture through BDC
Aastha
‎2008 Oct 07 12:27 PM
hi,,
i am working on ecc 6 and capturing po text too....so for views ,in the coding i have to put condition on the basis of material type....i think that would create problem b/coz there r many material types and creating views for each one of them would be a tedious task....
well apart from this what all r the limitations with mm01 bdc...
well if i go for BAPI then how r these limitaions sorted out...
can anybody explain...
‎2008 Oct 07 1:01 PM
‎2008 Oct 07 1:05 PM
Hi
Here is the BAPI: BAPI_MATERIAL_SAVEDATA. Use this instead of BDC.
And how it works..is something u have to know from Function Module Documentation in SE37 tcode.
Regards,
Vishwa.
‎2008 Oct 07 1:52 PM
hi,
can anyone tell how BAPI_MATERIAL_SAVEDATA overcomes the view problem of MM01 bdc....
‎2008 Oct 08 6:26 AM
‎2008 Oct 08 6:38 AM
Hi Sidharth,
Don't worry about the view ,you just find the your field in given bapi structure and populate that with your field value.Bapi will automatically will take care of it.
Thanks
Mohit
‎2008 Oct 08 6:45 AM
Hello Sid,
U can refer this code, in this 4 PO text I use BAPI_MATERIAL_SAVEDATA'
report ZMATMASSRAW
no standard page heading line-size 255.
include bdcrecx1.
Added by Aditya
data: headdata type bapimathead.
data: iltxt type table of bapi_mltx with header line.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
data: wamatnr like mara-matnr.
DATA: POTEXT TYPE STRING.
**********
parameters: dataset(132) lower case.
data : x_header TYPE thead.
tables:RMMG1.
DATA : lv_subrc TYPE sy-subrc,
ls_thead TYPE thead,
ls_line TYPE tline,
lt_tline TYPE STANDARD TABLE OF tline with header line,
long_text(100).
DATA : w_header LIKE thead,
key LIKE stxh-tdname,
w_text LIKE stxh-mandt,
key1 LIKE stxh-tdname,
w_text1 LIKE stxh-mandt,
w_header1 LIKE thead.
data: begin of record occurs 0,
*General Data
data element: MATNR
matnr_001(018),
data element: MBRSH
mbrsh_002(001),
data element: MTART
mtart_003(004),
data element: WERKS_D
werks_021(004),
data element: LGORT_D
lgort_022(004),
data element: BWTAR
bwtar_023(010),
data element: VKORG
vkorg_024(004),
data element: VTWEG
vtweg_025(002),
Basic Data1
data element: MAKTX
maktx_026(040),
data element: MEINS
meins_027(003),
data element: MATKL
matkl_028(009),
data element: BISMT
bismt_029(018),
data element: SPART
spart_030(002),
data element: GEWEI
gewei_031(003),
Basic data2
data element: DZEINR
zeinr_032(022),
Sales Organisation 1
data element: SKTOF
SKTOF_037(001),
data element: TAXKM
TAXKM_01_038(001),
data element: TAXKM
TAXKM_02_039(001),
data element: TAXKM
TAXKM_03_040(001),
data element: TAXKM
TAXKM_04_041(001),
Sales Organisation 2
data element: MTPOS_MARA
MTPOS_MARA_059(004),
data element: MTPOS
MTPOS_060(004),
Sales General/Plant
data element: MTVFP
MTVFP_064(002),
data element: TRAGR
TRAGR_065(004),
data element: LADGR
LADGR_066(004),
Purchasing
data element: BSTME
bstme_069(003),
data element: VABME
vabme_070(001),
data element: EKGRP
ekgrp_071(003),
data element: EKWSL
ekwsl_073(004),
data element: WEBAZ
webaz_074(003),
Pop Up Box
data element: UMREN
umren_075(006),
data element: UMREZ
umrez_076(006),
MRP1
data element: DISGR
disgr_087(004),
data element: DISMM
dismm_089(002),
data element: MINBE
minbe_090(017),
data element: DISPO
dispo_091(003),
data element: DISLS
disls_092(002),
data element: BSTRF
bstrf_093(013),
MRP2
data element: LGPRO
lgpro_094(004),
data element: PLIFZ
plifz_095(002),
data element: WEBAZ
webaz_096(003),
data element: FHORI
fhori_097(003),
data element: EISBE
eisbe_098(013),
MRP3
data element: PERKZ
perkz_100(001),
data element: MTVFP
mtvfp_101(002),
MRP4
data element: SA_SAUFT
sauft_103(001),
data element: SFEPR
sfepr_104(004),
Storage1
data element: LGPBE
lgpbe_107(010),
data element: MHDRZ
mhdrz_108(005),
data element: MHDHB
mhdhb_109(005),
data element: DATTP
iprkz_110(001),
Quality Management
data element: QPART
art_01_116(008),
data element: QPART
art_02_117(008),
data element: QPART
art_03_118(008),
data element: QPART
art_04_119(008),
data element: QMATAKTIV
aktiv_01_121(001),
data element: QMATAKTIV
aktiv_02_122(001),
data element: QMATAKTIV
aktiv_03_123(001),
data element: QMATAKTIV
aktiv_04_124(001),
data element: QMATAUTH
qmata_128(006),
data element: QSSPUR
ssqss_130(008),
Accounting1
data element: BWTTY_D
bwtty_133(001),
data element: BKLAS
bklas_135(004),
data element: VPRSV
vprsv_136(001),
data element: PEINH
peinh_137(006),
data element: VERPR
verpr_138(006),
data element: STPRS
stprs_139(006),
Costing1
data element: CK_EKALREL
ekalr_141(001),
data element: CK_LOSGR
losgr_142(017),
txline_2(700),
txline_3(700),
txline_4(700),
txline_5(700),
txline_6(700),
txline_7(700),
end of record.
start-of-selection.
data : vf_index type i.
data : vf_start_col type i value '2', "start column
vf_start_row type i value '5', "start row
vf_end_col type i value '200', "maximum column
vf_end_row type i value '2500', "maximum row
p_text(20). "stores error messages
Internal Table
DATA:IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
************************************************************************
*/ Work Area
data: wa_intern like it_excel.
************************************************************************
*/ Field symbol
field-symbols : <fs>.
parameters: p_file like rlgrap-filename.
*upload data from excel
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
exporting
filename = 'c:\materoh.xls'
i_begin_col = vf_start_col
i_begin_row = vf_start_row
i_end_col = vf_end_col
i_end_row = vf_end_row
tables
intern = it_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'c:\materoh.xls'
i_begin_col = vf_start_col
i_begin_row = vf_start_row
i_end_col = vf_end_col
i_end_row = vf_end_row
tables
intern = it_excel
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
if sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if it_excel[] is initial.
p_text = 'No Data Uploaded'.
else.
sort it_excel by row col.
loop at it_excel.
move : it_excel-col to vf_index.
assign component vf_index of structure record to <fs>.
move : it_excel-value to <fs>.
at end of row.
append record.
clear record.
endat.
endloop.
endif.
loop at record .
General Data
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'RMMG1-MATNR'
record-matnr_001.
.
perform bdc_field using 'RMMG1-MBRSH'
record-mbrsh_002.
perform bdc_field using 'RMMG1-MTART'
record-mtart_003.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
Selection Views
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(15)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(05)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(06)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(09)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(12)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(14)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(15)'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
General Data
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'RMMG1-WERKS'
record-werks_021.
perform bdc_field using 'RMMG1-LGORT'
record-lgort_022.
perform bdc_field using 'RMMG1-BWTAR'
record-bwtar_023.
perform bdc_field using 'RMMG1-VKORG'
record-vkorg_024.
perform bdc_field using 'RMMG1-VTWEG'
record-vtweg_025.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
Basic data 1
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'MAKT-MAKTX'
record-maktx_026.
perform bdc_field using 'MARA-MEINS'
record-meins_027.
perform bdc_field using 'MARA-MATKL'
record-matkl_028.
perform bdc_field using 'MARA-BISMT'
record-bismt_029.
perform bdc_field using 'MARA-SPART'
record-spart_030.
perform bdc_field using 'MARA-GEWEI'
record-gewei_031.
perform bdc_field using 'BDC_OKCODE'
'=SP02'.
Basic Data 2
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'MARA-ZEINR'
record-zeinr_032.
perform bdc_field using 'BDC_OKCODE'
'=SP09'.
Sales Organisation 1
*perform bdc_dynpro using 'SAPLMGMM' '4000'.
**perform bdc_field using 'MVKE-SKTOF'
record-SKTOF_037.
**perform bdc_field using 'MG03STEUER-TAXKM(01)'
record-TAXKM_01_038.
**perform bdc_field using 'MG03STEUER-TAXKM(02)'
record-TAXKM_02_039.
*perform bdc_field using 'BDC_OKCODE'
'/00'.
*
*perform bdc_dynpro using 'SAPLMGMM' '4200'.
*perform bdc_field using 'BDC_OKCODE'
'=MAIN'.
*
**perform bdc_field using 'MG03STEUER-TAXKM(03)'
record-TAXKM_03_040.
**perform bdc_field using 'MG03STEUER-TAXKM(04)'
record-TAXKM_04_041.
*
*perform bdc_field using 'BDC_OKCODE'
'=SP05'.
*
Sales Organisation 2
*
*perform bdc_dynpro using 'SAPLMGMM' '4000'.
**perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_059.
**perform bdc_field using 'MVKE-MTPOS'
record-MTPOS_060.
*perform bdc_field using 'BDC_OKCODE'
'=SP06'.
*
Sales General / Plant
*perform bdc_dynpro using 'SAPLMGMM' '4000'.
**perform bdc_field using 'MARC-MTVFP'
record-MTVFP_064.
**perform bdc_field using 'MARA-TRAGR'
record-TRAGR_065.
**perform bdc_field using 'MARC-LADGR'
record-LADGR_066.
*perform bdc_field using 'BDC_OKCODE'
'=SP09'.
Purchasing
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARA-BSTME'
record-bstme_069.
perform bdc_field using 'MARA-VABME'
record-vabme_070.
perform bdc_field using 'MARC-EKGRP'
record-ekgrp_071.
perform bdc_field using 'MARA-EKWSL'
record-ekwsl_073.
perform bdc_field using 'MARC-WEBAZ'
record-webaz_074.
if record-vabme_070 <> ' '.
perform bdc_field using 'BDC_OKCODE'
'/00'.
Pop Up Box
perform bdc_dynpro using 'SAPLMGMM' '0510'.
perform bdc_field using 'RMMZU-UMREN'
record-umren_075.
perform bdc_field using 'RMMZU-UMREZ'
record-umrez_076.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
else.
perform bdc_field using 'BDC_OKCODE'
'=SP12'.
endif.
MRP 1
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARC-DISGR'
record-disgr_087.
perform bdc_field using 'MARC-DISMM'
record-dismm_089.
perform bdc_field using 'MARC-MINBE'
record-minbe_090.
perform bdc_field using 'MARC-DISPO'
record-dispo_091.
perform bdc_field using 'MARC-DISLS'
record-disls_092.
perform bdc_field using 'MARC-BSTRF'
record-bstrf_093.
perform bdc_field using 'BDC_OKCODE'
'=SP13'.
MRP2
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARC-LGPRO'
record-lgpro_094.
perform bdc_field using 'MARC-PLIFZ'
record-plifz_095.
perform bdc_field using 'MARC-WEBAZ'
record-webaz_096.
perform bdc_field using 'MARC-FHORI'
record-fhori_097.
perform bdc_field using 'MARC-EISBE'
record-eisbe_098.
perform bdc_field using 'BDC_OKCODE'
'=SP14'.
MRP3
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARC-PERKZ'
record-perkz_100.
perform bdc_field using 'MARC-MTVFP'
record-mtvfp_101.
perform bdc_field using 'BDC_OKCODE'
'=SP15'.
MRP4
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARC-SAUFT'
record-sauft_103.
perform bdc_field using 'MARC-SFEPR'
record-sfepr_104.
perform bdc_field using 'BDC_OKCODE'
'=SP19'.
Storage1
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARD-LGPBE'
record-lgpbe_107.
perform bdc_field using 'MARA-MHDRZ'
record-mhdrz_108.
perform bdc_field using 'MARA-MHDHB'
record-mhdhb_109.
perform bdc_field using 'MARA-IPRKZ'
record-iprkz_110.
perform bdc_field using 'BDC_OKCODE'
'=SP23'.
Quality Management
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=PB01'.
perform bdc_dynpro using 'SAPLQPLS' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=NEU'.
perform bdc_dynpro using 'SAPLQPLS' '0100'.
perform bdc_field using 'RMQAM-ART(01)'
record-art_01_116.
perform bdc_field using 'RMQAM-ART(02)'
record-art_02_117.
perform bdc_field using 'RMQAM-ART(03)'
record-art_03_118.
perform bdc_field using 'RMQAM-ART(04)'
record-art_04_119.
if record-aktiv_01_121 = 'X'.
perform bdc_field using 'RMQAM-AKTIV(01)'
'X'."record-AKTIV_01_121.
endif.
if record-aktiv_02_122 = 'X'.
perform bdc_field using 'RMQAM-AKTIV(02)'
'X'."record-AKTIV_02_122.
endif.
if record-aktiv_03_123 = 'X' .
perform bdc_field using 'RMQAM-AKTIV(03)'
'X'."record-AKTIV_03_123.
endif.
if record-aktiv_04_124 = 'X'.
perform bdc_field using 'RMQAM-AKTIV(04)'
'X'."record-AKTIV_04_124.
endif.
perform bdc_field using 'BDC_OKCODE'
'=WEIT'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MARC-QMATA'
record-qmata_128.
perform bdc_field using 'MARC-SSQSS'
record-ssqss_130.
perform bdc_field using 'BDC_OKCODE'
'=SP24'.
Accounting1
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MBEW-BWTTY'
record-bwtty_133.
perform bdc_field using 'MBEW-BKLAS'
record-bklas_135.
perform bdc_field using 'MBEW-VPRSV'
record-vprsv_136.
perform bdc_field using 'MBEW-PEINH'
record-peinh_137.
perform bdc_field using 'MBEW-VERPR'
record-verpr_138.
For Standard Price*************
perform bdc_field using 'MBEW-STPRS'
record-stprs_139.
For Standard Price*************
perform bdc_field using 'BDC_OKCODE'
'=SP26'.
Costing1
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'MBEW-EKALR'
'X'."record-EKALR_141.
perform bdc_field using 'MARC-LOSGR'
record-losgr_142.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_dynpro using 'SAPLSPO1' '0300'.
*perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
call transaction 'MM01' USING it_excel mode 'A' .
*************************************For Purchase Order Text
clear:iltxt,iltxt[].
get parameter id 'MAT' field wamatnr.
select single * from mara into xmara
where matnr = wamatnr.
CONCATENATE record-txline_2 record-txline_3 record-txline_4 into POTEXT
SEPARATED BY SPACE.
headdata-material = xmara-matnr.
headdata-ind_sector = xmara-mbrsh.
headdata-matl_type = xmara-mtart.
headdata-basic_view = 'X'.
headdata-purchase_view = 'X'.
iltxt-applobject = 'MATERIAL'.
iltxt-text_name = wamatnr.
iltxt-text_id = 'BEST'.
iltxt-langu = sy-langu.
iltxt-langu_iso = 'EN'.
iltxt-format_col = space.
iltxt-text_line = POTEXT.
append iltxt.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
importing
return = return
tables
materiallongtext = iltxt
returnmessages = returnm.
check sy-subrc = 0.
*************************************For Purchase Order Text
endloop .
Hope this will resolve ur problem.
Aastha