Posted: Mon Oct 01, 2007 3:22 pm Post subject: Fill some views in MM01 using BDC
Well here is an example for you to see how the views are dealt with in BDC's...
Code:
*****************************************************
****This is a BDC for Semi finished Materials********
report ZBDC_SEMIFIN
no standard page heading line-size 255.
include bdcrecx1.
Tables: Mara,"General Material Data
mard,"Storage Location Data for Material
mvke,"Sales Data for Material
Makt,"Material Descriptions
marc,"Plant Data for Material
mbew,"Material Valuation
rlgrap."Program Fields/Screen Fields for SAPLGRAP
Data: begin of ITAB occurs 0,"Internal table for Semi-Finished Material
* Initial data
matnr like mara-matnr, "Material Code
mbrsh like mara-mbrsh, "Industry Data
mtart like mara-mtart, "Material Type
* Org Data
Werks like marc-werks, "Plant
lgort like mard-lgort, "Storage Location
vkorg like mvke-vkorg, "Sales Orgnization
vtweg like mvke-vtweg, "Distribution Chanel
* Basic 1
Maktx Like makt-maktx, "Description
meins like mara-meins, "Uom
matkl like mara-matkl, "Material Group
BISMT LIKE MARA-BISMT, " Old Material Number
spart like mara-spart, "Division
brgew(7),"like mara-brgew, "Gross Weight
gewei like MARA-GEWEI, "Weight Unit
ntgew(7)," like mara-ntgew, "Net Weight
* Purchasing
MAKTL LIKE MARA-MATKL, "Material Group
ekwsl like MARA-EKWSL, " Purchasing Value Key
ekgrp like MARC-EKGRP, " Purchasing Group
* Mrp 1
disgr like MARC-DISGR, "Mrp Group
* ekgrp like MARC-EKGRP, "Purchasing group
dismm like MARC-DISMM, "Mrp Type
dispo like MARC-DISPO, "Mrp Controller
disls like MARC-DISLS, "Lot Size
BSTMI like MARC-BSTMI,
BSTMA like MARC-BSTMA,
BSTRF like MARC-BSTRF,
BSTFE like MARC-BSTFE,
* Mrp 2
beskz like MARC-BESKZ, "Procurement type
lgpro like MARC-LGPRO, "Production Storage Location
dzeit(3),"like MARC-DZEIT, "In house Production time
plifz(3),"like MARC-PLIFZ, "Planned delivery time
fhori(3),"like MARC-FHORI, "Sched margin key
eisbe like MARC-EISBE, "Safety stock
* Mrp 3
PERKZ LIKE MARC-PERKZ,
vrmod like MARC-VRMOD, "Consumption mode
vint1(3)," like MARC-VINT1, "Backward Consumption period
vint2(3),"like MARC-VINT2, "Forward Consumption period
mtvfp like MARC-MTVFP, "Availability Check
* Mrp 4
sbdkz like MARC-SBDKZ, "Individual/ Collective
SAUFT like MARC-SAUFT, "Repetitive Manufacturing
SFEPR like MARC-SFEPR, "REM Profile
* Work Scheduling View
ausme like MARC-AUSME, "Unit of issue
FEVOR LIKE MARC-FEVOR, "Production Scheduler
SFCPF like MARC-SFCPF, "Production Scheduler Profile
umren(5)," like RMMZU-UMREN, "Val for base uom
umrez(5) ,"like RMMZU-UMREz, "Value for uo issue
* Accounting 1
bklas like MBEW-BKLAS, "Valuation Class
vprsv like MBEW-VPRSV, "Price Control Indicator
verpr(7)," like MBEW-VERPR, "Value/Price
STPRS like MBEW-STPRS,
*COSTING
EKALR LIKE MBEW-EKALR," With qty str
LOSGR like MARC-LOSGR, " Costing Lot size
end of ITAB.
**********************************************************
Data: W_record type I, "Record Allready exists.
w_trecord type I. "Total record processed
start-of-selection.
perform upload. "Upload Data from Text File
if w_trecord gt 0 or w_record gt 0.
perform batch_job.
endif.
perform close_group. "Close session
FORM SEMI.
loop at ITAB.
* Check for material in master *************************
select single * from mara where matnr eq ITAB-matnr.
if sy-subrc ne 0.
w_trecord = w_trecord + 1.
*Initial Screen
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
ITAB-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
'M'.
perform bdc_field using 'RMMG1-MTART'
'HALB'.
***********************Views**********************************
*Select Views
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(17'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'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 'MSICHTAUSW-KZSEL(17)'
'X'.
***********************Views**********************************
*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(01)'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(17)'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'MSICHTAUSW-KZSEL(17)'
* ITAB-KZSEL_17_011.
*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(01)'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_dynpro using 'SAPLMGMM' '0070'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSICHTAUSW-DYTXT(13)'.
*perform bdc_field using 'BDC_OKCODE'
* '=ENTR'.
*perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
* ITAB-KZSEL_13_012.
*Org Data
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-LGORT'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-WERKS'
ITAB-WERKS.
perform bdc_field using 'RMMG1-LGORT'
ITAB-LGORT.
*Basic 1
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=SP09'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARA-MATKL'
ITAB-MATKL.
perform bdc_field using 'MARA-BISMT'
ITAB-BISMT.
perform bdc_field using 'MARA-SPART'
ITAB-SPART.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
perform bdc_field using 'BDC_CURSOR'
'MARA-NTGEW'.
perform bdc_field using 'MARA-BRGEW'
ITAB-BRGEW.
perform bdc_field using 'MARA-GEWEI'
ITAB-GEWEI.
perform bdc_field using 'MARA-NTGEW'
ITAB-NTGEW.
*Purchasing
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP12'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARC-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MARA-MATKL'
ITAB-MATKL.
perform bdc_field using 'BDC_CURSOR'
'MARA-EKWSL'.
perform bdc_field using 'MARA-EKWSL'
ITAB-EKWSL.
*MRP 1
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP13'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARC-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MARC-DISMM'
ITAB-DISMM.
perform bdc_field using 'MARC-DISPO'
ITAB-DISPO.
perform bdc_field using 'BDC_CURSOR'
'MARC-DISLS'.
perform bdc_field using 'MARC-DISLS'
ITAB-DISLS.
IF ITAB-DISLS EQ 'EX' .
perform bdc_field using 'MARC-BSTMI'
ITAB-BSTMI."MIN LOT SIZE
perform bdc_field using 'MARC-BSTMA'
ITAB-BSTMA."MAX LOT SIZE
perform bdc_field using 'MARC-BSTRF'
ITAB-BSTRF."RNDING
ELSEIF ITAB-DISLS EQ 'FX'.
perform bdc_field using 'MARC-BSTFE'
ITAB-BSTFE.
ENDIF.
*MRP 2
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP14'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARC-BESKZ'
ITAB-BESKZ.
perform bdc_field using 'MARC-LGPRO'
ITAB-LGPRO.
perform bdc_field using 'MARC-DZEIT'
ITAB-DZEIT.
perform bdc_field using 'MARC-PLIFZ'
ITAB-PLIFZ.
perform bdc_field using 'MARC-FHORI'
ITAB-FHORI.
perform bdc_field using 'BDC_CURSOR'
'MARC-EISBE'.
perform bdc_field using 'MARC-EISBE'
ITAB-EISBE.
*MRP 3
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP15'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARC-PERKZ'
ITAB-PERKZ.
perform bdc_field using 'MARC-VRMOD'
ITAB-VRMOD.
perform bdc_field using 'MARC-VINT1'
ITAB-VINT1.
perform bdc_field using 'MARC-VINT2'
ITAB-VINT2.
perform bdc_field using 'BDC_CURSOR'
'MARC-MTVFP'.
perform bdc_field using 'MARC-MTVFP'
ITAB-MTVFP.
*MRP 4
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP17'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARC-SBDKZ'
ITAB-SBDKZ.
perform bdc_field using 'BDC_CURSOR'
'MARC-SFEPR'.
perform bdc_field using 'MARC-SAUFT'
ITAB-SAUFT.
perform bdc_field using 'MARC-SFEPR'
ITAB-SFEPR.
*Work Scheduling
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP24'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARC-SFCPF'.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARC-FEVOR'
ITAB-FEVOR.
perform bdc_field using 'MARC-LGPRO'
ITAB-LGPRO.
perform bdc_field using 'MARC-SFCPF'
ITAB-SFCPF.
perform bdc_field using 'MARC-DZEIT'
ITAB-DZEIT.
*Check for Conversation Factor
if ITAB-MEINS ne iTAB-ausme and iTAB-umren gt 0
and iTAB-umrez gt 0.
perform bdc_dynpro using 'SAPLMGMM' '0510'.
perform bdc_field using:
'BDC_OKCODE' '=ENTR',
'RMMZU-UMREN' ITAB-UMREN,
'RMMZU-UMREZ' ITAB-UMREZ.
endif.
perform bdc_field using 'MARC-LGPRO'
itab-LGPRO.
perform bdc_field using 'MARC-DZEIT'
itab-DZEIT.
*Accounting
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=SP26'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARA-SPART'
ITAB-SPART.
perform bdc_field using 'BDC_CURSOR'
'MBEW-STPRS'.
perform bdc_field using 'MBEW-BKLAS'
ITAB-BKLAS.
perform bdc_field using 'MBEW-VPRSV'
ITAB-VPRSV.
perform bdc_field using 'MBEW-STPRS'
ITAB-STPRS.
IF ITAB-VPRSV = 'S'.
perform bdc_field using 'MBEW-STPRS' "FILLS STD PRICE
ITAB-VERPR.
ELSEIF ITAB-VPRSV ='V'.
perform bdc_field using 'MBEW-VERPR' "FILLS VALUE
ITAB-VERPR.
ENDIF.
*Cost Estimate
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARC-PRCTR'.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MBEW-EKALR'
ITAB-EKALR.
perform bdc_field using 'MARC-LOSGR'
ITAB-LOSGR.
perform bdc_transaction using 'MM01'.
if w_trecord gt 0.
Write:/ 'Background Job has been Created for ',
w_trecord right-justified, 'Semi-Fin', 80 ''.
write:/ 'Please follow the following steps to run this job',
80 ''.
write:/ 'as listed below.', 80 ''.
format color col_normal.
skip.
write:/05 '1.Goto Transaction SM35', 80 ''.
write:/05 '2.Select your Session Name', 80 ''.
write:/05 '3.Click On Execute Button', 80 ''.
endif.
if w_record gt 0.
format color col_negative.
write:/ w_record ,'records already existed', 80 ''.
format color off.
endif.
uline.
endform.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.