06-19-2007 4:22 AM
Hi abapers,
plz tell me how to handle diffrent different type views in MM01.
thanks in addvance
06-19-2007 4:25 AM
06-19-2007 4:26 AM
I think you are using a BDC right? Make use of the FM : MATERIAL_BTCI_SELECTION_NEW to get the views.
form GET_MATVIEW using P_MATNR type MATNR
changing P_D0070 like IT_BTCI_D0070.
call function 'MATERIAL_BTCI_SELECTION_NEW'
exporting
MATERIAL = P_MATNR
SELECTION = C_VIEW
TCODE = C_TCODE
tables
BTCI_D0070 = P_D0070
exceptions
MATERIAL_NOT_FOUND = 1
MATERIAL_NUMBER_MISSING = 2
MATERIAL_TYPE_MISSING = 3
MATERIAL_TYPE_NOT_FOUND = 4
NO_ACTIVE_DYNPRO_SELECTED = 5
NO_AUTHORITY = 6
others = 7.
if SY-SUBRC <> 0.
message id SY-MSGID type SY-MSGTY number SY-MSGNO
with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
delete P_D0070 where FVAL <> C_X.
endform. " get_matview
Regards
Gopi
06-19-2007 5:04 AM
hi,
After the recording, you might see, that the selection of the views is
monething like that: SELECTION(3) = 'X'
SELECTION(4) = 'X'
SELECTION(5) = 'X'
you have to address the selected
views by their index in the table.
in Tcode SHDB, record MM01 transaction only for the MRP1 MRP2 MRP3 and use the same code in ur BDC prog.
Look at the below code for MM01
http://www.sap-img.com/abap/example-how-views-are-dealt-in-bdc.htm
You have + button in the MK01 trasaction code, if you press that you
can enter new record in the table control, so every time, enter a New
record and press that + button, then enter the record then press + , like this we need to handle the table control
Check the links -
example:
Example how Views are dealt in BDC
Can any body tell me some views of MM that we can use in BDC?
***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
Perform Open_group. "Create a session
clear : w_record,w_trecord.
perform semi. "Create Semi Finish Materials
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'.
REFRESH BDCDATA.
else.
w_record = w_record + 1.
endif.
ENDLOOP.
ENDFORM.
form Upload.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ' '
FILETYPE = ' '
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
ENDFORM.
form batch_job.
uline.
format color col_heading.
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.