分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
REPORT ZIMMC001.
************************************************************************
* D A T A D E C L A R A T I O N *
************************************************************************
*------------------------------------
* Type Declaration of the Structure.
*------------------------------------
TYPES: BEGIN OF TY_SAVE_INDEX,
IDNO TYPE I, " SAVE Index
END OF TY_SAVE_INDEX.
TYPES: BEGIN OF TY_TABDATA,
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Create Material (Initial Screen).
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
MATNR(18) TYPE C, " Material Number.
MBRSH(01) TYPE C, " Industry Sector.
MTART(04) TYPE C, " Material Type.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Organizational Levels.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WERKS(04) TYPE C, " Plant.
LGORT(04) TYPE C, " Storage Location.
VKORG(04) TYPE C, " Sales Organization.
VTWEG(02) TYPE C, " Distribution Channel.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 1 : Tax Classification.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TAXKM1(01) TYPE C, " Tax classification material 1.
TAXKM2(01) TYPE C, " Tax classification material 2.
TAXKM3(01) TYPE C, " Tax classification material 3.
TAXKM4(01) TYPE C, " Tax classification material 4.
TAXKM5(01) TYPE C, " Tax classification material 5.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Additional Data - UoM.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
UMREN1(06) TYPE C, " Denominator for Conversion to Base Units of Measure 1.
MEINH1(03) TYPE C, " Alternative Unit of Measure for Stockkeeping Unit 1.
UMREZ1(06) TYPE C, " Numerator for Conversion to Base Units of Measure 1.
* ..........................................................................................
UMREN2(06) TYPE C, " Denominator for Conversion to Base Units of Measure 2.
MEINH2(03) TYPE C, " Alternative Unit of Measure for Stockkeeping Unit 2.
UMREZ2(06) TYPE C, " Numerator for Conversion to Base Units of Measure 2.
* ..........................................................................................
UMREN3(06) TYPE C, " Denominator for Conversion to Base Units of Measure 3.
MEINH3(03) TYPE C, " Alternative Unit of Measure for Stockkeeping Unit 3.
UMREZ3(06) TYPE C, " Numerator for Conversion to Base Units of Measure 3.
* ..........................................................................................
UMREN4(06) TYPE C, " Denominator for Conversion to Base Units of Measure 4.
MEINH4(03) TYPE C, " Alternative Unit of Measure for Stockkeeping Unit 4.
UMREZ4(06) TYPE C, " Numerator for Conversion to Base Units of Measure 4.
* ..........................................................................................
UMREN5(06) TYPE C, " Denominator for Conversion to Base Units of Measure 5.
MEINH5(03) TYPE C, " Alternative Unit of Measure for Stockkeeping Unit 5.
UMREZ5(06) TYPE C, " Numerator for Conversion to Base Units of Measure 5.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 1
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VRKME(03) TYPE C, " Sales unit.
DWERK(04) TYPE C, " Delivering Plant (Own or External).
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 2
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
VERSG(01) TYPE C, " Material statistics group.
KTGRM(02) TYPE C, " Account assignment group for this material.
MTPOS(04) TYPE C, " Item category group from material master.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* General/Plant.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
BRGEW(17) TYPE C, " Gross weight.
NTGEW(17) TYPE C, " Net weight.
MTVFP(02) TYPE C, " Checking Group for Availability Check.
TRAGR(04) TYPE C, " Transportation group
LADGR(04) TYPE C, " Loading group.
PRCTR(10) TYPE C, " Profit Center.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Foreign Trade Export.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
HERKL(03) TYPE C, " Country of origin of the material.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Purchasing.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
BSTME(03) TYPE C, " Order unit.
KAUTB(01) TYPE C, " Indicator: "automatic purchase order allowed".
XCHPF(01) TYPE C, " Batch management requirement indicator.
EKGRP(03) TYPE C, " Purchasing Group.
WEBAZ(03) TYPE C, " Goods receipt processing time in days.
EKWSL(04) TYPE C, " Purchasing Value Key.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Purch.Order Text.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
PTEXT(40) TYPE C, " Purchase Order Text.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 1
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DISGR(04) TYPE C, " MRP Group.
DISMM(02) TYPE C, " MRP Type.
MINBE(17) TYPE C, " Reorder point.
DISPO(03) TYPE C, " MRP Controller.
DISLS(02) TYPE C, " Lot size (materials planning).
BSTFE(17) TYPE C, " Fixed lot size.
BSTMI(17) TYPE C, " Minimum lot size.
BSTMA(17) TYPE C, " Maximum lot size.
AUSSS(06) TYPE C, " Assembly scrap in percent.
BSTRF(17) TYPE C, " Rounding value for purchase order quantity.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 2
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
BESKZ(01) TYPE C, " Procurement Type.
SOBSL(02) TYPE C, " Special procurement type.
LGPRO(04) TYPE C, " Issue Storage Location.
RGEKZ(01) TYPE C, " Indicator: Backflush.
LGFSB(04) TYPE C, " Default storage location for external procurement.
DZEIT(03) TYPE C, " In-house production time.
PLIFZ(03) TYPE C, " Planned delivery time in days.
MRPPP(03) TYPE C, " PPC planning calendar.
FHORI(03) TYPE C, " Scheduling Margin Key for Floats.
EISBE(17) TYPE C, " Safety stock.
WEBAZ1(03) TYPE C, " Goods receipt processing time in days.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 3
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
STRGR(02) TYPE C, " Planning strategy group.
VRMOD(01) TYPE C, " Consumption mode.
VINT1(03) TYPE C, " Consumption period: backward.
VINT2(03) TYPE C, " Consumption period: forward.
MISKZ(01) TYPE C, " Mixed MRP indicator.
MTVFP1(02) TYPE C, " Checking Group for Availability Check.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 4
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ALTSL(01) TYPE C, " Method for Selecting Alternative Bills of Material.
KAUSF(06) TYPE C, " Component scrap in percent.
SBDKZ(01) TYPE C, " Dependent requirements ind. for individual and coll. reqmts.
SAUFT(01) TYPE C, " Ind.: Repetitive mfg allowed.
SFEPR(04) TYPE C, " Repetitive manufacturing profile.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Work Scheduling.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FRTME(03) TYPE C, " Production unit.
FEVOR(03) TYPE C, " Production scheduler.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Plant Data / Stor. 1
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
AUSME(03) TYPE C, " Unit of issue.
MHDRZ(05) TYPE C, " Minimum remaining shelf life.
MHDHB(05) TYPE C, " Total shelf life.
IPRKZ(01) TYPE C, " Period indicator for shelf life expiration date.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Quality Management.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WEBAZ2(03) TYPE C, " Goods receipt processing time in days.
QMPUR(01) TYPE C, " QM in Procurement is Active.
SSQSS(08) TYPE C, " Control Key for Quality Management in Procurement.
QZGTP(04) TYPE C, " Certificate Type.
QMATV(01) TYPE C, " Inspection Setup Exists for Material/Plant.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Inspection Setup Data.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ART1(08) TYPE C, " Inspection Type 1.
AKTIV1(01) TYPE C, " Inspection Type - Material Combination is Active 1.
ART2(08) TYPE C, " Inspection Type 2.
AKTIV2(01) TYPE C, " Inspection Type - Material Combination is Active 2.
ART3(08) TYPE C, " Inspection Type 3.
AKTIV3(01) TYPE C, " Inspection Type - Material Combination is Active 3.
ART4(08) TYPE C, " Inspection Type 4.
AKTIV4(01) TYPE C, " Inspection Type - Material Combination is Active 4.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Accounting 1.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
BKLAS(04) TYPE C, " Valuation Class.
VPRSV(01) TYPE C, " Price Control Indicator.
PEINH(06) TYPE C, " Price Unit.
STPRS(15) TYPE C, " Standard Price.
VERPR(15) TYPE C, " Moving Average Price/Periodic Unit Price.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Cost Estimate 1.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
EKALR(01) TYPE C, " Material Is Costed with Quantity Structure.
HKMAT(01) TYPE C, " Material Origin.
AWSLS(06) TYPE C, " Variance Key.
PRCTR1(10) TYPE C, " Profit Center.
LOSGR(17) TYPE C, " Lot Size for Product Costing.
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ROWCNT TYPE I, " Normal Row Count.
ROW TYPE I, " Row Count --> Line Items
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
END OF TY_TABDATA.
*------------------------------------------------
* Declaration of the Internal Table & Work Area.
*------------------------------------------------
DATA: IT_SAVE_INDEX TYPE STANDARD TABLE OF TY_SAVE_INDEX,
WA_SAVE_INDEX TYPE TY_SAVE_INDEX.
DATA: IT_TABDATA TYPE STANDARD TABLE OF TY_TABDATA,
WA_TABDATA TYPE TY_TABDATA.
*-------------------------------------------------------------------------------------
* Declaration of the Internal Table with Header Line comprising of the uploaded data.
*-------------------------------------------------------------------------------------
DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
DATA: END OF IT_FILE_UPLOAD.
*-------------------------------
* Global Variable Declarations.
*-------------------------------
DATA: GV_ANS TYPE C.
*--------------------------------------------
* Batch Input Data for a single Transaction.
* Message of Call Transaction.
*--------------------------------------------
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
MSGTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
************************************************************************
* S E L E C T I O N - S C R E E N *
************************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B2,
END OF BLOCK B1.
************************************************************************
* E V E N T : AT S E L E C T I O N - S C R E E N *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = '.'
CHANGING
FILE_NAME = P_FNAME
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
************************************************************************
* E V E N T : S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
* --------------------------------------
* Upload Excel file into Internal Table.
* --------------------------------------
PERFORM UPLOAD_EXCEL_FILE.
IF NOT IT_FILE_UPLOAD IS INITIAL.
* ----------------------------------------------------
* Confirm whether you want to proceed with the Upload.
* ----------------------------------------------------
PERFORM CONFIRM_UPLOAD.
IF GV_ANS EQ '1'.
* -------------------------------------------------------
* Organize the uploaded data into another Internal Table.
* -------------------------------------------------------
PERFORM ORGANIZE_UPLOADED_DATA.
* -----------------------------------
* Modify Row No. for Line Item Count.
* -----------------------------------
PERFORM MODIFY_ROW_NUMBER.
* -----------------
* Open BDC Session.
* -----------------
* PERFORM OPEN_BDC_SESSION.
* ------------------------
* Kick-start BDC Operation
* ------------------------
PERFORM BDC_OPERATION.
* ------------------
* Close BDC Session.
* ------------------
* PERFORM CLOSE_BDC_SESSION.
ENDIF.
ENDIF.
************************************************************************
* E V E N T : E N D - O F - S E L E C T I O N *
************************************************************************
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FNAME
I_BEGIN_COL = 1
I_BEGIN_ROW = 4
I_END_COL = 107
I_END_ROW = 32000
TABLES
INTERN = IT_FILE_UPLOAD
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.
ENDFORM. " UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*& Form CONFIRM_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CONFIRM_UPLOAD .
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Pop-Up to Confirm'
* DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = 'Do you like to proceed with the Upload ???'
* TEXT_BUTTON_1 = 'Ja'(001)
* ICON_BUTTON_1 = ' '
* TEXT_BUTTON_2 = 'Nein'(002)
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
ANSWER = GV_ANS
* TABLES
* PARAMETER =
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CONFIRM_UPLOAD
*&---------------------------------------------------------------------*
*& Form ORGANIZE_UPLOADED_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ORGANIZE_UPLOADED_DATA .
DATA: LV_ROW_CNT TYPE I.
CLEAR: LV_ROW_CNT.
SORT IT_FILE_UPLOAD BY ROW
COL.
LOOP AT IT_FILE_UPLOAD.
CASE IT_FILE_UPLOAD-COL.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Create Material (Initial Screen).
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 1.
WA_TABDATA-MATNR = IT_FILE_UPLOAD-VALUE.
WHEN 2.
WA_TABDATA-MBRSH = IT_FILE_UPLOAD-VALUE.
WHEN 3.
WA_TABDATA-MTART = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Organizational Levels.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 4.
WA_TABDATA-WERKS = IT_FILE_UPLOAD-VALUE.
WHEN 5.
WA_TABDATA-LGORT = IT_FILE_UPLOAD-VALUE.
WHEN 6.
WA_TABDATA-VKORG = IT_FILE_UPLOAD-VALUE.
WHEN 7.
WA_TABDATA-VTWEG = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 1 : Tax Classification.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 8.
WA_TABDATA-TAXKM1 = IT_FILE_UPLOAD-VALUE.
WHEN 9.
WA_TABDATA-TAXKM2 = IT_FILE_UPLOAD-VALUE.
WHEN 10.
WA_TABDATA-TAXKM3 = IT_FILE_UPLOAD-VALUE.
WHEN 11.
WA_TABDATA-TAXKM4 = IT_FILE_UPLOAD-VALUE.
WHEN 12.
WA_TABDATA-TAXKM5 = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Additional Data - UoM.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 13.
WA_TABDATA-UMREN1 = IT_FILE_UPLOAD-VALUE.
WHEN 14.
WA_TABDATA-MEINH1 = IT_FILE_UPLOAD-VALUE.
WHEN 15.
WA_TABDATA-UMREZ1 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 16.
WA_TABDATA-UMREN2 = IT_FILE_UPLOAD-VALUE.
WHEN 17.
WA_TABDATA-MEINH2 = IT_FILE_UPLOAD-VALUE.
WHEN 18.
WA_TABDATA-UMREZ2 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 19.
WA_TABDATA-UMREN3 = IT_FILE_UPLOAD-VALUE.
WHEN 20.
WA_TABDATA-MEINH3 = IT_FILE_UPLOAD-VALUE.
WHEN 21.
WA_TABDATA-UMREZ3 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 22.
WA_TABDATA-UMREN4 = IT_FILE_UPLOAD-VALUE.
WHEN 23.
WA_TABDATA-MEINH4 = IT_FILE_UPLOAD-VALUE.
WHEN 24.
WA_TABDATA-UMREZ4 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 25.
WA_TABDATA-UMREN5 = IT_FILE_UPLOAD-VALUE.
WHEN 26.
WA_TABDATA-MEINH5 = IT_FILE_UPLOAD-VALUE.
WHEN 27.
WA_TABDATA-UMREZ5 = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 1
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 28.
WA_TABDATA-VRKME = IT_FILE_UPLOAD-VALUE.
WHEN 29.
WA_TABDATA-DWERK = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Sales Org. 2
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 30.
WA_TABDATA-VERSG = IT_FILE_UPLOAD-VALUE.
WHEN 31.
WA_TABDATA-KTGRM = IT_FILE_UPLOAD-VALUE.
WHEN 32.
WA_TABDATA-MTPOS = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* General/Plant.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 33.
WA_TABDATA-BRGEW = IT_FILE_UPLOAD-VALUE.
WHEN 34.
WA_TABDATA-NTGEW = IT_FILE_UPLOAD-VALUE.
WHEN 35.
WA_TABDATA-MTVFP = IT_FILE_UPLOAD-VALUE.
WHEN 36.
WA_TABDATA-TRAGR = IT_FILE_UPLOAD-VALUE.
WHEN 37.
WA_TABDATA-LADGR = IT_FILE_UPLOAD-VALUE.
WHEN 38.
WA_TABDATA-PRCTR = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Foreign Trade Export.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 39.
WA_TABDATA-HERKL = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Purchasing.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 40.
WA_TABDATA-BSTME = IT_FILE_UPLOAD-VALUE.
WHEN 41.
WA_TABDATA-KAUTB = IT_FILE_UPLOAD-VALUE.
WHEN 42.
WA_TABDATA-XCHPF = IT_FILE_UPLOAD-VALUE.
WHEN 43.
WA_TABDATA-EKGRP = IT_FILE_UPLOAD-VALUE.
WHEN 44.
WA_TABDATA-WEBAZ = IT_FILE_UPLOAD-VALUE.
WHEN 45.
WA_TABDATA-EKWSL = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Purch.Order Text.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 46.
WA_TABDATA-PTEXT = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 1
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 47.
WA_TABDATA-DISGR = IT_FILE_UPLOAD-VALUE.
WHEN 48.
WA_TABDATA-DISMM = IT_FILE_UPLOAD-VALUE.
WHEN 49.
WA_TABDATA-MINBE = IT_FILE_UPLOAD-VALUE.
WHEN 50.
WA_TABDATA-DISPO = IT_FILE_UPLOAD-VALUE.
WHEN 51.
WA_TABDATA-DISLS = IT_FILE_UPLOAD-VALUE.
WHEN 52.
WA_TABDATA-BSTFE = IT_FILE_UPLOAD-VALUE.
WHEN 53.
WA_TABDATA-BSTMI = IT_FILE_UPLOAD-VALUE.
WHEN 54.
WA_TABDATA-BSTMA = IT_FILE_UPLOAD-VALUE.
WHEN 55.
WA_TABDATA-AUSSS = IT_FILE_UPLOAD-VALUE.
WHEN 56.
WA_TABDATA-BSTRF = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 2
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 57.
WA_TABDATA-BESKZ = IT_FILE_UPLOAD-VALUE.
WHEN 58.
WA_TABDATA-SOBSL = IT_FILE_UPLOAD-VALUE.
WHEN 59.
WA_TABDATA-LGPRO = IT_FILE_UPLOAD-VALUE.
WHEN 60.
WA_TABDATA-RGEKZ = IT_FILE_UPLOAD-VALUE.
WHEN 61.
WA_TABDATA-LGFSB = IT_FILE_UPLOAD-VALUE.
WHEN 62.
WA_TABDATA-DZEIT = IT_FILE_UPLOAD-VALUE.
WHEN 63.
WA_TABDATA-PLIFZ = IT_FILE_UPLOAD-VALUE.
WHEN 64.
WA_TABDATA-MRPPP = IT_FILE_UPLOAD-VALUE.
WHEN 65.
WA_TABDATA-FHORI = IT_FILE_UPLOAD-VALUE.
WHEN 66.
WA_TABDATA-EISBE = IT_FILE_UPLOAD-VALUE.
WHEN 67.
WA_TABDATA-WEBAZ1 = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 3
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 68.
WA_TABDATA-STRGR = IT_FILE_UPLOAD-VALUE.
WHEN 69.
WA_TABDATA-VRMOD = IT_FILE_UPLOAD-VALUE.
WHEN 70.
WA_TABDATA-VINT1 = IT_FILE_UPLOAD-VALUE.
WHEN 71.
WA_TABDATA-VINT2 = IT_FILE_UPLOAD-VALUE.
WHEN 72.
WA_TABDATA-MISKZ = IT_FILE_UPLOAD-VALUE.
WHEN 73.
WA_TABDATA-MTVFP1 = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* MRP 4
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 74.
WA_TABDATA-ALTSL = IT_FILE_UPLOAD-VALUE.
WHEN 75.
WA_TABDATA-KAUSF = IT_FILE_UPLOAD-VALUE.
WHEN 76.
WA_TABDATA-SBDKZ = IT_FILE_UPLOAD-VALUE.
WHEN 77.
WA_TABDATA-SAUFT = IT_FILE_UPLOAD-VALUE.
WHEN 78.
WA_TABDATA-SFEPR = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Work Scheduling.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 79.
WA_TABDATA-FRTME = IT_FILE_UPLOAD-VALUE.
WHEN 80.
WA_TABDATA-FEVOR = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Plant Data / Stor. 1
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 81.
WA_TABDATA-AUSME = IT_FILE_UPLOAD-VALUE.
WHEN 82.
WA_TABDATA-MHDRZ = IT_FILE_UPLOAD-VALUE.
WHEN 83.
WA_TABDATA-MHDHB = IT_FILE_UPLOAD-VALUE.
WHEN 84.
WA_TABDATA-IPRKZ = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Quality Management.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 85.
WA_TABDATA-WEBAZ2 = IT_FILE_UPLOAD-VALUE.
WHEN 86.
WA_TABDATA-QMPUR = IT_FILE_UPLOAD-VALUE.
WHEN 87.
WA_TABDATA-SSQSS = IT_FILE_UPLOAD-VALUE.
WHEN 88.
WA_TABDATA-QZGTP = IT_FILE_UPLOAD-VALUE.
WHEN 89.
WA_TABDATA-QMATV = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Inspection Setup Data.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 90.
WA_TABDATA-ART1 = IT_FILE_UPLOAD-VALUE.
WHEN 91.
WA_TABDATA-AKTIV1 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 92.
WA_TABDATA-ART2 = IT_FILE_UPLOAD-VALUE.
WHEN 93.
WA_TABDATA-AKTIV2 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 94.
WA_TABDATA-ART3 = IT_FILE_UPLOAD-VALUE.
WHEN 95.
WA_TABDATA-AKTIV3 = IT_FILE_UPLOAD-VALUE.
* ...........................................................
WHEN 96.
WA_TABDATA-ART4 = IT_FILE_UPLOAD-VALUE.
WHEN 97.
WA_TABDATA-AKTIV4 = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Accounting 1.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 98.
WA_TABDATA-BKLAS = IT_FILE_UPLOAD-VALUE.
WHEN 99.
WA_TABDATA-VPRSV = IT_FILE_UPLOAD-VALUE.
WHEN 100.
WA_TABDATA-PEINH = IT_FILE_UPLOAD-VALUE.
WHEN 101.
WA_TABDATA-STPRS = IT_FILE_UPLOAD-VALUE.
WHEN 102.
WA_TABDATA-VERPR = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
* Cost Estimate 1.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WHEN 103.
WA_TABDATA-EKALR = IT_FILE_UPLOAD-VALUE.
WHEN 104.
WA_TABDATA-HKMAT = IT_FILE_UPLOAD-VALUE.
WHEN 105.
WA_TABDATA-AWSLS = IT_FILE_UPLOAD-VALUE.
WHEN 106.
WA_TABDATA-PRCTR1 = IT_FILE_UPLOAD-VALUE.
WHEN 107.
WA_TABDATA-LOSGR = IT_FILE_UPLOAD-VALUE.
* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ENDCASE.
AT END OF ROW.
LV_ROW_CNT = LV_ROW_CNT + 1.
WA_TABDATA-ROWCNT = LV_ROW_CNT.
APPEND WA_TABDATA TO IT_TABDATA.
CLEAR: WA_TABDATA.
ENDAT.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
*&---------------------------------------------------------------------*
*& Form MODIFY_ROW_NUMBER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MODIFY_ROW_NUMBER .
DATA: LV_ROW TYPE I.
LOOP AT IT_TABDATA INTO WA_TABDATA.
IF WA_TABDATA-MATNR NE SPACE.
CLEAR: LV_ROW.
ENDIF.
LV_ROW = LV_ROW + 1.
WA_TABDATA-ROW = LV_ROW.
MODIFY IT_TABDATA FROM WA_TABDATA
TRANSPORTING ROW.
ENDLOOP.
ENDFORM. " MODIFY_ROW_NUMBER
*&---------------------------------------------------------------------*
*& Form OPEN_BDC_SESSION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_BDC_SESSION .
DATA: LV_SESSION TYPE APQ_GRPN.
LV_SESSION = 'MATMAST_1'.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
* DEST = FILLER8
GROUP = LV_SESSION
* HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
* RECORD = FILLER1
* PROG = SY-CPROG
* IMPORTING
* QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " OPEN_BDC_SESSION
*&---------------------------------------------------------------------*
*& Form BDC_OPERATION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BDC_OPERATION .
LOOP AT IT_TABDATA INTO WA_TABDATA.
IF WA_TABDATA-MATNR NE ''.
* ------------------------------------------------------------
* Transaction Code - MM01 Create Material : Initial Screen.
* ------------------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RMMG1-MTART'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR' WA_TABDATA-MATNR.
PERFORM BDC_FIELD USING 'RMMG1-MBRSH' WA_TABDATA-MBRSH.
PERFORM BDC_FIELD USING 'RMMG1-MTART' WA_TABDATA-MTART.
IF WA_TABDATA-MTART NE 'ROH'.
* ------------------------------------------------------------
* Transaction Code - MM01 Views Selection Screen (not ROH).
* ------------------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(17)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=P+'.
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(07)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(09)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(11)' '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(16)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(17)' 'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(07)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(04)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(05)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(07)' 'X'.
ELSE.
* ------------------------------------------------------------
* Transaction Code - MM01 Views Selection Screen ( = ROH).
* ------------------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(16)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=P+'.
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(07)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(09)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(11)' '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(16)' 'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(07)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(03)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(04)' 'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(06)' 'X'.
ENDIF.
* --------------------------------------------------------
* Transaction Code - MM01 Organizational Levels Screen.
* --------------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0080'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RMMG1-VTWEG'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-WERKS' WA_TABDATA-WERKS.
PERFORM BDC_FIELD USING 'RMMG1-LGORT' WA_TABDATA-LGORT.
PERFORM BDC_FIELD USING 'RMMG1-VKORG' WA_TABDATA-VKORG.
PERFORM BDC_FIELD USING 'RMMG1-VTWEG' WA_TABDATA-VTWEG.
* ---------------------------------------------------------------------
* Transaction Code - MM01 Sales Organization 1 - Tax Classification.
* ---------------------------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MG03STEUER-TAXKM(02)'.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(01)' WA_TABDATA-TAXKM1.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(02)' WA_TABDATA-TAXKM2.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4200'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MG03STEUER-TAXKM(05)'.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(03)' WA_TABDATA-TAXKM3.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(04)' WA_TABDATA-TAXKM4.
PERFORM BDC_FIELD USING 'MG03STEUER-TAXKM(05)' WA_TABDATA-TAXKM5.
* -------------------------------------------------
* Transaction Code - MM01 Additional Data - UoM.
* -------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ZU01'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MAKT-MAKTX'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ZU02'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RMMG1-MATNR'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'SMEINH-UMREZ(06)'.
PERFORM BDC_FIELD USING 'SMEINH-UMREN(02)' WA_TABDATA-UMREN1.
PERFORM BDC_FIELD USING 'SMEINH-MEINH(02)' WA_TABDATA-MEINH1.
PERFORM BDC_FIELD USING 'SMEINH-UMREZ(02)' WA_TABDATA-UMREZ1.
PERFORM BDC_FIELD USING 'SMEINH-UMREN(03)' WA_TABDATA-UMREN2.
PERFORM BDC_FIELD USING 'SMEINH-MEINH(03)' WA_TABDATA-MEINH2.
PERFORM BDC_FIELD USING 'SMEINH-UMREZ(03)' WA_TABDATA-UMREZ2.
PERFORM BDC_FIELD USING 'SMEINH-UMREN(04)' WA_TABDATA-UMREN3.
PERFORM BDC_FIELD USING 'SMEINH-MEINH(04)' WA_TABDATA-MEINH3.
PERFORM BDC_FIELD USING 'SMEINH-UMREZ(04)' WA_TABDATA-UMREZ3.
PERFORM BDC_FIELD USING 'SMEINH-UMREN(05)' WA_TABDATA-UMREN4.
PERFORM BDC_FIELD USING 'SMEINH-MEINH(05)' WA_TABDATA-MEINH4.
PERFORM BDC_FIELD USING 'SMEINH-UMREZ(05)' WA_TABDATA-UMREZ4.
PERFORM BDC_FIELD USING 'SMEINH-UMREN(06)' WA_TABDATA-UMREN5.
PERFORM BDC_FIELD USING 'SMEINH-MEINH(06)' WA_TABDATA-MEINH5.
PERFORM BDC_FIELD USING 'SMEINH-UMREZ(06)' WA_TABDATA-UMREZ5.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=MAIN'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MAKT-MAKTX'.
* ------------------------------------------------
* Transaction Code - MM01 Sales Organization 1.
* ------------------------------------------------
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MVKE-DWERK'.
PERFORM BDC_FIELD USING 'MVKE-VRKME' WA_TABDATA-VRKME.
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)