*&---------------------------------------------------------------------* *& REPORT ZMM_PO_CREATE *& *& REPORTNAME :批量创建PO *&---------------------------------------------------------------------* *& CREATED BY : LIUXINYUAN *& CREATED DATE : 2015-03-16 *&---------------------------------------------------------------------*
REPORT ZMM_PO_CREATE.
TYPE-POOLS: SLIS. TYPE-POOLS:ICON.
*订单类型+采购组织+公司代码+采购组+工厂+供应商+合并标记相同
TYPES:BEGINOF TY_PO,
BSART TYPE EKKO-BSART, "订单类型
EKORG TYPE EKKO-EKORG, "采购组织
BUKRS TYPE EKKO-BUKRS, "公司代码
EKGRP TYPE EKKO-EKGRP, "采购组
WERKS TYPE EKPO-WERKS, "工厂
LIFNR TYPE EKKO-LIFNR, "供应商
HBBJ(3), "合并标记
PSTYP TYPE EKPO-PSTYP, "行项目类别
MATNR TYPE EKPO-MATNR, "物料号
MENGE(13)," TYPE EKPO-MENGE, "数量
EINDT TYPE EKET-EINDT, "交货期 ENDOF TY_PO.
DATA:IT_PO TYPETABLEOF TY_PO WITHHEADERLINE,
WA_PO TYPE TY_PO.
TYPES:BEGINOF TY_PO_RESULT,
BSART TYPE EKKO-BSART, "订单类型
EKORG TYPE EKKO-EKORG, "采购组织
BUKRS TYPE EKKO-BUKRS, "公司代码
EKGRP TYPE EKKO-EKGRP, "采购组
WERKS TYPE EKPO-WERKS, "工厂
LIFNR TYPE EKKO-LIFNR, "供应商
PSTYP TYPE EKPO-PSTYP, "行项目类别
MATNR TYPE EKPO-MATNR, "物料号
MENGE(13)," TYPE EKPO-MENGE, "数量
EINDT TYPE EKET-EINDT, "交货期
HBBJ(1), "合并标记
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
FLAG(1), MESSAGE(200), ENDOF TY_PO_RESULT.
DATA IT_FLDTAB TYPE TPIT_T_FNAME WITHHEADERLINE. DATA: L_IRC TYPEI,L_LINE TYPEI.
DATA:L_TEXT(200).
DATA:IT_MESSTAB LIKE BDCMSGCOLL OCCURS0WITHHEADERLINE. DATA:G_INFO TYPE STRING.
*----------------------------------------------------------------------* * CONSTANTS * *----------------------------------------------------------------------* CONSTANTS: """上传数据准备
C_BEGIN_ROW TYPEIVALUE1, "BEGINNING ROW OF EXCEL FILE
C_BEGIN_COL TYPEIVALUE1, "BEGINNING COLUMN OF EXCEL FILE
C_END_ROW TYPEIVALUE50000, "ENDING ROW OF EXCEL FILE
C_END_COL TYPEIVALUE100. "ENDING COLUMN OF EXCEL FILE
*DATA:LV_DTYPE(1). **ALV DATA:GT_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT. DATA:GS_EVENT_EXIT TYPE SLIS_EVENT_EXIT.
DATA:GT_FIELDCAT TYPE LVC_T_FCAT WITHHEADERLINE. DATA:GC_GLAY TYPE LVC_S_GLAY. DATA:GS_LAYOUT TYPE LVC_S_LAYO, "SLIS_LAYOUT_ALV,
WK_REPID LIKE SY-REPID. DATA:GS_GRID TYPE LVC_S_GLAY. DATA:TEM_GRID TYPEREFTO CL_GUI_ALV_GRID. DATA:GT_EVENTS TYPE SLIS_T_EVENT. DATA:GS_EVENTS LIKELINEOF GT_EVENTS.
DATA:LV_DATUM TYPE SY-DATUM.
SELECTION-SCREEN: FUNCTIONKEY1. "激活下载模板按钮 **选择屏幕
SELECTION-SCREENBEGINOFBLOCK MAIN WITHFRAMETITLETEXT-001.
* SELECT-OPTIONS:S_BUKRS FOR BKPF-BUKRS. * SELECT-OPTIONS:S_BUDAT FOR BKPF-BUDAT. * SELECT-OPTIONS:S_BELNR FOR BKPF-BELNR.
PARAMETERS:P_FILE LIKE RLGRAP-FILENAME ."DEFAULT ‘C:\USERS\ADMINISTRATOR\DESKTOP\计划独立需求的批量导入模板.XLS‘. "上载文件路径
SELECTION-SCREENENDOFBLOCK MAIN.
AT SELECTION-SCREENONVALUE-REQUEST FOR P_FILE. PERFORM FRM_GET_FILENAME USING P_FILE.
AT SELECTION-SCREEN.
* LOOP AT S_WERKS. * AUTHORITY-CHECK OBJECT ‘Z_MM_003‘ * ID ‘WERKS‘ FIELD S_WERKS-LOW. * IF SY-SUBRC <> 0. * MESSAGE E019(ZMM001) WITH S_WERKS-LOW. * ENDIF. * ENDLOOP.
IF WA_PO-PSTYP <> ‘‘. SELECTSINGLE
PSTYP INTO POITEM-ITEM_CAT FROM T163Y WHERE SPRAS = ‘1‘ AND EPSTP = WA_PO-PSTYP. ELSE.
POITEM-ITEM_CAT = WA_PO-PSTYP. ENDIF.
IF WA_PO-BSART = ‘ZNPI‘.
POITEM-FREE_ITEM = ‘X‘. ENDIF.
*&---------------------------------------------------------------------* *& FORM FRM_RETRIVE_DATA *&---------------------------------------------------------------------* * TEXT *----------------------------------------------------------------------* * --> P1 TEXT * <-- P2 TEXT *----------------------------------------------------------------------* FORM FRM_RETRIVE_DATA.
CALLFUNCTION‘SAPGUI_PROGRESS_INDICATOR‘ EXPORTING TEXT = ‘数据处理中.................‘.
DATA I_EXCEL TYPE KCDE_INTERN_STRUC OCCURS0WITHHEADERLINE. REFRESH I_EXCEL. CLEAR I_EXCEL.