*1.根据模板把数据批导进入程序 *
*2.根据导入数据更新物料进价
*&---------------------------------------------------------------------*
* TITLE ZMDT003
* APPLICATION : MD *
* SUBJECT : 售价批量创建(变更)程序 *
* REQUESTED BY : *
* EXECUTION : USER REQUIRED *
* REF NO: : *
* AUTHOR : zcwei *
* REQ DATE : 20141117 *
*********************************************************************
* 设计主要逻辑与原理说明 *
*********************************************************************
*1.根据模板把数据批导进入程序 *
*2.根据导入数据更新物料进价 *
*********************************************************************
REPORT ZMDT007 MESSAGE-ID ZBH1.
TABLES: SSCRFIELDS, MARA.
TYPES: BEGIN OF TY_UPLOAD,
KSCHL TYPE KONH-KSCHL, "条件类型
MATNR TYPE A506-MATNR, "商品号
KBETR TYPE KONP-KBETR, "价格
VTWEG TYPE A506-VTWEG, "分销渠道 / 价格清单
INDAT(10), "有效从
VKORG TYPE A506-VKORG, "销售组织
WERKS TYPE A506-WERKS, "门店
DATAB TYPE KONH-DATAB, "开始生效日期
ZZMSG(200),
SELDA(1),
STATUS(1),
ICON TYPE ICON-ID,
END OF TY_UPLOAD,
BEGIN OF TY_OUTPUT,
KNUMH TYPE KONH-KNUMH, "条件记录号
KSCHL TYPE KONH-KSCHL, "条件类型
MATNR TYPE A506-MATNR, "商品号
KBETR TYPE KONP-KBETR, "价格
VTWEG TYPE A506-VTWEG, "分销渠道
DATAB TYPE KONH-DATAB, "有效从
DATBI TYPE KONH-DATBI, "有效至
VKORG TYPE A506-VKORG, "销售组织
WERKS TYPE A506-WERKS, "门店
PLTYP TYPE A502-PLTYP, "价格清单
ZZMSG(200),
SELDA(1),
ICON TYPE ICON-ID,
END OF TY_OUTPUT.
DATA: GT_UPLOAD TYPE TABLE OF TY_UPLOAD,
GS_UPLOAD TYPE TY_UPLOAD,
GT_OUTPUT TYPE TABLE OF TY_OUTPUT,
GS_OUTPUT TYPE TY_OUTPUT.
DATA: GT_A502_DEL TYPE TABLE OF A502,
GT_A503_DEL TYPE TABLE OF A503,
GT_A506_DEL TYPE TABLE OF A506.
DATA:GT_CONDCT TYPE TABLE OF BAPICONDCT,
GS_CONDCT TYPE BAPICONDCT,
GT_CONDHD TYPE TABLE OF BAPICONDHD,
GS_CONDHD TYPE BAPICONDHD,
GT_CONDIT TYPE TABLE OF BAPICONDIT,
GS_CONDIT TYPE BAPICONDIT,
GT_CONDQS TYPE TABLE OF BAPICONDQS,
GS_CONDQS TYPE BAPICONDQS,
GT_CONDVS TYPE TABLE OF BAPICONDVS,
GS_CONDVS TYPE BAPICONDVS,
GT_RET_MES TYPE TABLE OF BAPIRET2,
GS_RET_MES TYPE BAPIRET2,
GT_KNUMHS TYPE TABLE OF BAPIKNUMHS,
GS_KNUMHS TYPE BAPIKNUMHS,
GT_MEM_INITIAL TYPE TABLE OF CND_MEM_INITIAL,
GS_MEM_INITIAL TYPE CND_MEM_INITIAL.
DATA: GT_EXCLUDE TYPE TABLE OF SY-UCOMM.
*----------------------------------------------------------------------*
*ALV DEFINE
*----------------------------------------------------------------------*
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
*----------------------------------------------------------------------*
*OO ALV DEFINE
*----------------------------------------------------------------------*
CLASS LCL_ER_1100 DEFINITION DEFERRED.
CLASS LCL_ER_1100 DEFINITION.
PUBLIC SECTION.
METHODS:HANDLE_TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING
E_OBJECT E_INTERACTIVE.
METHODS:HANDLE_USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
ENDCLASS. "lcl_er_1100 DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_er_2000 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_ER_1100 IMPLEMENTATION.
METHOD HANDLE_TOOLBAR.
PERFORM HANDLE_TOOLBAR USING E_OBJECT E_INTERACTIVE.
ENDMETHOD.
METHOD HANDLE_USER_COMMAND.
PERFORM HANDLE_USER_COMMAND USING E_UCOMM.
ENDMETHOD.
ENDCLASS. "lcl_er_2000 IMPLEMENTATION
DATA: GO_ER_1100 TYPE REF TO LCL_ER_1100.
DATA: GO_CC_1100_H TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GO_AG_1100_H TYPE REF TO CL_GUI_ALV_GRID,
* GT_FC_1100_H TYPE LVC_T_FCAT,
GS_LO_1100_H TYPE LVC_S_LAYO,
GT_TE_1100_H TYPE UI_FUNCTIONS,
GT_SORT_1100_H TYPE LVC_T_SORT,
GS_VARIANT TYPE DISVARIANT.
* gt_te_1100_H TYPE ui_functions.
DATA: GT_FIELDCAT_1100 TYPE LVC_T_FCAT, " 功能C: 设定fieldcat
GS_FIELDCAT_1100 TYPE LVC_S_FCAT. " 功能C: 设定fieldcat
DATA: GS_LAYOUT_1100 TYPE LVC_S_LAYO. " 功能B: 设定layout
DATA: GT_EXCLUDE_1100 TYPE UI_FUNCTIONS." 功能G: 设定屏蔽标准ALV 工具栏的按钮
DATA: GV_OC_1100 LIKE SY-UCOMM,
GV_SO_1100 LIKE GV_OC_1100.
DATA: GV_X(1) VALUE 'X'.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-002.
PARAMETERS: RB_SC RADIOBUTTON GROUP G1 USER-COMMAND SELECT DEFAULT 'X' MODIF ID KZ, "上传
RB_WH RADIOBUTTON GROUP G1 MODIF ID KZ. "维护
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-003.
PARAMETERS: RB_BH RADIOBUTTON GROUP G2, "百货
RB_CS RADIOBUTTON GROUP G2 DEFAULT 'X', "超市
RB_DQ RADIOBUTTON GROUP G2. "电器
SELECTION-SCREEN END OF BLOCK BL2.
SELECTION-SCREEN BEGIN OF BLOCK SC1 WITH FRAME TITLE TEXT-001.
PARAMETER: P_FILE TYPE RLGRAP-FILENAME MODIF ID M1."
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR MODIF ID M2.
SELECTION-SCREEN END OF BLOCK SC1.
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = '下载模板'.
AT SELECTION-SCREEN.
PERFORM FRM_DOWNLOAD_TEMPLATE.
AT SELECTION-SCREEN OUTPUT.
* BREAK ZCWEI.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'M1'.
IF RB_SC EQ 'X'.
SCREEN-ACTIVE = '1'.
ELSE.
SCREEN-ACTIVE = '0'.
ENDIF.
ENDIF.
IF SCREEN-GROUP1 = 'M2'.
IF RB_SC EQ 'X'.
SCREEN-ACTIVE = '0'.
ELSE.
SCREEN-ACTIVE = '1'.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
START-OF-SELECTION.
IF RB_SC EQ 'X'.
PERFORM FRM_UPLOAD_DATA.
PERFORM FRM_CHECK_DATA.
PERFORM FRM_SHOW_MSG.
ELSE.
PERFORM FRM_CHECK_INPUT.
ENDIF.
* PERFORM FRM_CALL_BAPI.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM FRM_GETPATH.
*&---------------------------------------------------------------------*
*& Form FRM_DOWNLOAD_TEMPLATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DOWNLOAD_TEMPLATE .
DATA: LS_KEY TYPE WWWDATATAB,
LV_TEMP TYPE C,
LV_FILE TYPE STRING,
LV_FILEPATH TYPE RLGRAP-FILENAME,
LV_RESULT TYPE ABAP_BOOL,
LV_PATH TYPE STRING,
LV_MSG TYPE STRING.
CASE SSCRFIELDS-UCOMM.
WHEN 'FC01'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
EXPORTING
WINDOW_TITLE = '选择文件目录'
* initial_folder = 'C:\TEMP'
CHANGING
SELECTED_FOLDER = LV_PATH
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF RB_DQ EQ 'X'.
LV_FILE = '\ZMDT007_DQ.XLSX'.
LS_KEY-OBJID = 'ZMDT007_DQ'. "SMW0定义的对象名称
ELSEIF RB_BH EQ 'X'.
LV_FILE = '\ZMDT007_BH.XLSX'.
LS_KEY-OBJID = 'ZMDT007_BH'. "SMW0定义的对象名称
ELSE.
LV_FILE = '\ZMDT007_CS.XLSX'.
LS_KEY-OBJID = 'ZMDT007_CS'. "SMW0定义的对象名称
ENDIF.
CONCATENATE LV_PATH LV_FILE INTO LV_FILE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = LV_FILE
RECEIVING
RESULT = LV_RESULT
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF LV_RESULT = 'X'.
CONCATENATE '模板' LV_FILE '已存在!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S'.
STOP.
ELSE.
LS_KEY-RELID = 'MI'.
LV_FILEPATH = LV_FILE.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = LS_KEY
DESTINATION = LV_FILEPATH.
IF SY-SUBRC <> 0.
MESSAGE '下载模板失败!' TYPE 'E'.
ELSE.
MESSAGE S000 WITH '成功下载模板,请重新调整以适应本机!下载目录:' LV_FILEPATH '。'.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " FRM_DOWNLOAD_TEMPLATE
*&---------------------------------------------------------------------*
*& Form FRM_GETPATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FNAME text
*----------------------------------------------------------------------*
FORM FRM_GETPATH.
CALL FUNCTION 'TB_LIMIT_WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = '*.xls'
DEF_PATH = 'C:\'
MASK = ',All Files,*.*,Excel Files,*.xls.'
MODE = 'O'
TITLE = 'Please choose file to use '
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " FRM_GETPATH
*---------------------------------------------------------------------*
* FORM FRM_UPLOAD_DATA *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM FRM_UPLOAD_DATA.
DATA: LT_RAW TYPE TRUXS_T_TEXT_DATA.
CLEAR: LT_RAW[], GT_UPLOAD.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = LT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = GT_UPLOAD
EXCEPTIONS
CONVERSION_FAILED = 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. "FRM_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CALL_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CALL_BAPI .
CLEAR: GT_CONDCT,GS_CONDCT,GT_CONDHD,GS_CONDHD,GT_CONDIT,GS_CONDIT,
GT_CONDQS,GS_CONDQS,GT_CONDVS,GS_CONDVS,GT_RET_MES,GS_RET_MES,
GT_KNUMHS,GS_KNUMHS,GT_MEM_INITIAL,GS_MEM_INITIAL.
IF RB_CS EQ 'X'.
PERFORM FRM_CS_DATA.
ELSEIF RB_DQ EQ 'X'.
PERFORM FRM_DQ_DATA.
ELSEIF RB_BH EQ 'X'.
PERFORM FRM_BH_DATA.
ENDIF.
BREAK ZCWEI.
CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
EXPORTING
PI_PHYSICAL_DELETION = 'X'
TABLES
TI_BAPICONDCT = GT_CONDCT
TI_BAPICONDHD = GT_CONDHD
TI_BAPICONDIT = GT_CONDIT
TI_BAPICONDQS = GT_CONDQS
TI_BAPICONDVS = GT_CONDVS
TO_BAPIRET2 = GT_RET_MES
TO_BAPIKNUMHS = GT_KNUMHS
TO_MEM_INITIAL = GT_MEM_INITIAL
EXCEPTIONS
UPDATE_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
LOOP AT GT_KNUMHS INTO GS_KNUMHS.
* READ TABLE GT_CONDIT INTO GS_CONDIT WITH KEY COND_NO = GS_KNUMHS-COND_NO_OLD.
* IF SY-SUBRC EQ 0.
* CLEAR LS_DATA.
*
* LS_DATA-KNUMH = GS_KNUMHS-COND_NO_NEW.
* LS_DATA-KSCHL = GS_CONDIT-COND_TYPE.
* LS_DATA-KBETR = GS_CONDIT-COND_VALUE.
* LS_DATA-KONWA = GS_CONDIT-CONDCURR.
* LS_DATA-KPEIN = GS_CONDIT-COND_P_UNT.
* LS_DATA-KMEIN = GS_CONDIT-COND_UNIT.
*
* LS_DATA-TCODE = SY-TCODE.
* LS_DATA-ZTRANS = ' '.
*
* APPEND LS_DATA TO LT_DATA.
* ENDIF.
ENDLOOP.
*_插入数据到接口传输表
* MODIFY ZTBHSPPRICE FROM TABLE LT_DATA.
IF RB_CS EQ 'X'.
DELETE A502 FROM TABLE GT_A502_DEL.
ELSEIF RB_DQ EQ 'X'.
DELETE A503 FROM TABLE GT_A503_DEL.
ELSEIF RB_BH EQ 'X'.
DELETE A506 FROM TABLE GT_A506_DEL.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
GS_UPLOAD-ICON = '@08@'. "成功
GS_UPLOAD-ZZMSG = '成功'.
GS_UPLOAD-STATUS = 'S'.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
GS_UPLOAD-ICON = '@0A@'. "失败
GS_UPLOAD-STATUS = 'E'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 INTO GS_UPLOAD-ZZMSG.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDIF.
ENDFORM. " FRM_CALL_BAPI
*&---------------------------------------------------------------------*
*& Form CONVERT_INTO_INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_IT_CONDIT_COND_UNIT text
*----------------------------------------------------------------------*
FORM CONVERT_INTO_INPUT CHANGING P_COND_UNIT.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = P_COND_UNIT
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = P_COND_UNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
ENDFORM. " CONVERT_INTO_INPUT
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_MSG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SHOW_MSG .
PERFORM FRM_FILL_FIELDCAT.
PERFORM FRM_FILL_LAYOUT.
PERFORM FRM_OUTPUT_LIST .
ENDFORM. " FRM_SHOW_MSG
*&---------------------------------------------------------------------*
*& FORM FRM_FILL_FIELDCAT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_FILL_FIELDCAT .
DATA: LV_POS TYPE I.
CLEAR LV_POS.
CLEAR GT_FIELDCAT[].
DEFINE D_GET_FIELD.
LV_POS = LV_POS + 1.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = LV_POS.
GS_FIELDCAT-FIELDNAME = &1.
GS_FIELDCAT-SELTEXT_L = &2.
GS_FIELDCAT-OUTPUTLEN = &3.
IF ( &1 EQ 'KBETR' OR &1 EQ 'MATNR' ).
GS_FIELDCAT-NO_ZERO = 'X'.
ENDIF.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.
D_GET_FIELD:
'SELDA' '选择' '4',
'ICON' '信号灯' '4',
'KSCHL' '条件类型' '8',
'MATNR' '物料' '18'.
IF RB_CS EQ 'X'.
D_GET_FIELD:
'VTWEG' '价格清单' '8'.
ELSE.
D_GET_FIELD:
'VKORG' '销售组织' '8',
'VTWEG' '分销渠道' '8',
'WERKS' '工厂' '4'.
ENDIF.
D_GET_FIELD:
'KBETR' '价格' '10'.
D_GET_FIELD:
'DATAB' '有效从' '20',
'ZZMSG' '信息文本' '50'.
ENDFORM. " FRM_FILL_FIELDCAT
*&---------------------------------------------------------------------*
*& FORM FRM_FILL_LAYOUT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_FILL_LAYOUT .
* W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
* 定义条纹显示
GS_LAYOUT-ZEBRA = 'X'.
ENDFORM. " FRM_FILL_LAYOUT
*&---------------------------------------------------------------------*
*& FORM FRM_OUTPUT_LIST
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_OUTPUT_LIST .
DATA: LV_REPID LIKE SY-REPID.
DATA: LS_VARIANT LIKE DISVARIANT.
DATA: LV_SETTING TYPE LVC_S_GLAY.
LV_REPID = SY-REPID.
LS_VARIANT-REPORT = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_BYPASSING_BUFFER = 'X'
* I_GRID_SETTINGS = LV_SETTING
I_CALLBACK_PROGRAM = LV_REPID
IS_LAYOUT = GS_LAYOUT
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = GT_FIELDCAT[]
* IT_SORT = I_SORT[]
* IT_EVENTS = GT_EVENTS[]
* IS_PRINT = W_PRINT
I_SAVE = 'A'
* IS_VARIANT = LS_VARIANT
TABLES
T_OUTTAB = GT_UPLOAD
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENDIF.
ENDFORM. " FRM_OUTPUT_LIST
*&---------------------------------------------------------------------*
*& FORM STANDARD_ER01
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->EXTAB TEXT
*----------------------------------------------------------------------*
FORM PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
DATA: LS_EXTAB TYPE SLIS_EXTAB.
SET PF-STATUS 'MENU'." EXCLUDING RT_EXTAB.
ENDFORM. "STANDARD_ER01
*&---------------------------------------------------------------------*
*& Form FRM_CS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CS_DATA .
DATA: LT_A502 TYPE TABLE OF A502,
LS_A502 TYPE A502.
DATA: LV_COND_NO TYPE KNUMH,
LV_KBETR TYPE KONP-KBETR,
LV_KEY TYPE BAPICONDCT-VARKEY,
LV_LEN TYPE I,
LT_DATA TYPE TABLE OF ZTBHSPPRICE,
LS_DATA TYPE ZTBHSPPRICE,
LV_INDEX TYPE I,
LV_CINDEX(9),
LV_MSGFN TYPE MSGFN,
LV_TABLE_NO(3) VALUE '502',
LV_MEINS TYPE MEINS.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
CLEAR: LV_KBETR.
CLEAR: LV_COND_NO.
LV_INDEX = LV_INDEX + 1.
LV_CINDEX = LV_INDEX.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LV_CINDEX
IMPORTING
OUTPUT = LV_CINDEX.
CONCATENATE '$' LV_CINDEX INTO LV_COND_NO.
***** 转换日期
LV_LEN = STRLEN( GS_UPLOAD-INDAT ).
IF LV_LEN EQ 10.
CONCATENATE GS_UPLOAD-INDAT(4) GS_UPLOAD-INDAT+5(2) GS_UPLOAD-INDAT+8(2) INTO GS_UPLOAD-DATAB.
ELSEIF LV_LEN EQ 8.
GS_UPLOAD-DATAB = GS_UPLOAD-INDAT.
ELSE.
GS_UPLOAD-DATAB = SY-DATUM.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-MATNR
IMPORTING
OUTPUT = GS_UPLOAD-MATNR.
LV_KBETR = GS_UPLOAD-KBETR.
SELECT SINGLE MEINS INTO LV_MEINS
FROM MARA WHERE MATNR = GS_UPLOAD-MATNR.
SELECT * FROM A502 INTO TABLE LT_A502
WHERE KSCHL = GS_UPLOAD-KSCHL
AND MATNR = GS_UPLOAD-MATNR
AND PLTYP = GS_UPLOAD-VTWEG. "价格清单
*& 条件价格赋值
LOOP AT LT_A502 INTO LS_A502.
LV_MSGFN = '004'.
IF LS_A502-DATAB >= GS_UPLOAD-DATAB AND LS_A502-DATBI >= GS_UPLOAD-DATAB.
LV_MSGFN = '003'.
ENDIF.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = LS_A502-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LS_A502-KNUMH.
GS_CONDCT-VALID_FROM = LS_A502-DATAB.
IF LS_A502-DATBI >= GS_UPLOAD-DATAB AND LS_A502-DATAB <= GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = GS_UPLOAD-DATAB - 1.
IF LS_A502-DATBI NE '99991231'.
APPEND LS_A502 TO GT_A502_DEL.
ENDIF.
ELSE.
GS_CONDCT-VALID_TO = LS_A502-DATBI.
ENDIF.
CLEAR LV_KEY.
LV_KEY(2) = LS_A502-PLTYP.
LV_KEY+2(18) = LS_A502-MATNR.
LV_KEY+20(3) = LS_A502-VRKME.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LS_A502-KNUMH.
GS_CONDHD-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = LS_A502-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = LS_A502-DATAB.
IF LS_A502-DATBI >= GS_UPLOAD-DATAB AND LS_A502-DATAB <= GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = GS_UPLOAD-DATAB - 1.
ELSE.
GS_CONDHD-VALID_TO = LS_A502-DATBI.
ENDIF.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LS_A502-KNUMH.
GS_CONDIT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = LS_A502-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
* GS_CONDIT-CONDITIDX = '01'.
* GS_CONDIT-COND_P_UNT = LS_EINE_I-PEINH.
* GS_CONDIT-COND_UNIT = LS_EINE_I-BPRME.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
SELECT SINGLE KBETR
KPEIN
KMEIN
INTO (GS_CONDIT-COND_VALUE,
GS_CONDIT-COND_P_UNT,
GS_CONDIT-COND_UNIT)
FROM KONP
WHERE KNUMH = LS_A502-KNUMH
AND KOPOS = '01'.
APPEND GS_CONDIT TO GT_CONDIT.
* ENDIF.
ENDLOOP.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A502-KNUMH.
GS_CONDCT-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = '99991231'.
CLEAR LV_KEY.
LV_KEY(2) = GS_UPLOAD-VTWEG.
LV_KEY+2(18) = GS_UPLOAD-MATNR.
LV_KEY+20(3) = LV_MEINS.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LV_COND_NO. "'$000000001'. "LS_A502-KNUMH.
GS_CONDHD-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDHD-CREATED_BY = SY-UNAME.
GS_CONDHD-CREAT_DATE = SY-DATUM.
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = '99991231'.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A502-KNUMH.
GS_CONDIT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
* GS_CONDIT-CONDITIDX = '01'.
GS_CONDIT-COND_P_UNT = 1.
GS_CONDIT-COND_UNIT = LV_MEINS.
PERFORM CONVERT_INTO_INPUT CHANGING GS_CONDIT-COND_UNIT.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
GS_CONDIT-COND_VALUE = LV_KBETR.
APPEND GS_CONDIT TO GT_CONDIT.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDFORM. " FRM_CS_DATA
*&---------------------------------------------------------------------*
*& Form FRM_DQ_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DQ_DATA .
DATA: LT_A503 TYPE TABLE OF A503,
LS_A503 TYPE A503.
DATA: LV_COND_NO TYPE KNUMH,
LV_KBETR TYPE KONP-KBETR,
LV_KEY TYPE BAPICONDCT-VARKEY,
LV_LEN TYPE I,
LT_DATA TYPE TABLE OF ZTBHSPPRICE,
LS_DATA TYPE ZTBHSPPRICE,
LV_INDEX TYPE I,
LV_CINDEX(9),
LV_MSGFN TYPE MSGFN,
LV_TABLE_NO(3) VALUE '503',
LV_MEINS TYPE MEINS.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
CLEAR: LV_KBETR.
CLEAR: LV_COND_NO.
LV_INDEX = LV_INDEX + 1.
LV_CINDEX = LV_INDEX.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LV_CINDEX
IMPORTING
OUTPUT = LV_CINDEX.
CONCATENATE '$' LV_CINDEX INTO LV_COND_NO.
***** 转换日期
LV_LEN = STRLEN( GS_UPLOAD-INDAT ).
IF LV_LEN EQ 10.
CONCATENATE GS_UPLOAD-INDAT(4) GS_UPLOAD-INDAT+5(2) GS_UPLOAD-INDAT+8(2) INTO GS_UPLOAD-DATAB.
ELSEIF LV_LEN EQ 8.
GS_UPLOAD-DATAB = GS_UPLOAD-INDAT.
ELSE.
GS_UPLOAD-DATAB = SY-DATUM.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-MATNR
IMPORTING
OUTPUT = GS_UPLOAD-MATNR.
LV_KBETR = GS_UPLOAD-KBETR.
SELECT SINGLE MEINS INTO LV_MEINS
FROM MARA WHERE MATNR = GS_UPLOAD-MATNR.
SELECT * FROM A503 INTO TABLE LT_A503
WHERE KSCHL = GS_UPLOAD-KSCHL
AND VKORG = GS_UPLOAD-VKORG
AND VTWEG = GS_UPLOAD-VTWEG "分销渠道
AND MATNR = GS_UPLOAD-MATNR.
*& 条件价格赋值
LOOP AT LT_A503 INTO LS_A503.
LV_MSGFN = '004'.
IF LS_A503-DATAB >= GS_UPLOAD-DATAB AND LS_A503-DATBI >= GS_UPLOAD-DATAB.
LV_MSGFN = '003'.
ENDIF.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = LS_A503-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LS_A503-KNUMH.
GS_CONDCT-VALID_FROM = LS_A503-DATAB.
IF LS_A503-DATBI >= GS_UPLOAD-DATAB AND LS_A503-DATAB <= GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = GS_UPLOAD-DATAB - 1.
IF LS_A503-DATBI NE '99991231'.
APPEND LS_A503 TO GT_A503_DEL.
ENDIF.
ELSE.
GS_CONDCT-VALID_TO = LS_A503-DATBI.
ENDIF.
CLEAR LV_KEY.
LV_KEY(4) = LS_A503-VKORG.
LV_KEY+4(2) = LS_A503-VTWEG.
LV_KEY+6(18) = LS_A503-MATNR.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LS_A503-KNUMH.
GS_CONDHD-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = LS_A503-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = LS_A503-DATAB.
IF LS_A503-DATBI >= GS_UPLOAD-DATAB AND LS_A503-DATAB <= GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = GS_UPLOAD-DATAB - 1.
ELSE.
GS_CONDHD-VALID_TO = LS_A503-DATBI.
ENDIF.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LS_A503-KNUMH.
GS_CONDIT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = LS_A503-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
SELECT SINGLE KBETR
KPEIN
KMEIN
INTO (GS_CONDIT-COND_VALUE,
GS_CONDIT-COND_P_UNT,
GS_CONDIT-COND_UNIT)
FROM KONP
WHERE KNUMH = LS_A503-KNUMH
AND KOPOS = '01'.
APPEND GS_CONDIT TO GT_CONDIT.
* ENDIF.
ENDLOOP.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A503-KNUMH.
GS_CONDCT-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = '99991231'.
CLEAR LV_KEY.
LV_KEY(4) = GS_UPLOAD-VKORG.
LV_KEY+4(2) = GS_UPLOAD-VTWEG.
LV_KEY+6(18) = GS_UPLOAD-MATNR.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LV_COND_NO. "'$000000001'. "LS_A503-KNUMH.
GS_CONDHD-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDHD-CREATED_BY = SY-UNAME.
GS_CONDHD-CREAT_DATE = SY-DATUM.
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = '99991231'.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A503-KNUMH.
GS_CONDIT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
* GS_CONDIT-CONDITIDX = '01'.
GS_CONDIT-COND_P_UNT = 1.
GS_CONDIT-COND_UNIT = LV_MEINS.
PERFORM CONVERT_INTO_INPUT CHANGING GS_CONDIT-COND_UNIT.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
GS_CONDIT-COND_VALUE = LV_KBETR.
APPEND GS_CONDIT TO GT_CONDIT.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDFORM. " FRM_DQ_DATA
*&---------------------------------------------------------------------*
*& Form FRM_BH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_BH_DATA .
DATA: LT_A506 TYPE TABLE OF A506,
LS_A506 TYPE A506.
DATA: LV_COND_NO TYPE KNUMH,
LV_KBETR TYPE KONP-KBETR,
LV_KEY TYPE BAPICONDCT-VARKEY,
LV_LEN TYPE I,
LT_DATA TYPE TABLE OF ZTBHSPPRICE,
LS_DATA TYPE ZTBHSPPRICE,
LV_INDEX TYPE I,
LV_CINDEX(9),
LV_MSGFN TYPE MSGFN,
LV_TABLE_NO(3) VALUE '506',
LV_MEINS TYPE MEINS.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
CLEAR: LV_KBETR.
CLEAR: LV_COND_NO.
LV_INDEX = LV_INDEX + 1.
LV_CINDEX = LV_INDEX.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LV_CINDEX
IMPORTING
OUTPUT = LV_CINDEX.
CONCATENATE '$' LV_CINDEX INTO LV_COND_NO.
***** 转换日期
LV_LEN = STRLEN( GS_UPLOAD-INDAT ).
IF LV_LEN EQ 10.
CONCATENATE GS_UPLOAD-INDAT(4) GS_UPLOAD-INDAT+5(2) GS_UPLOAD-INDAT+8(2) INTO GS_UPLOAD-DATAB.
ELSEIF LV_LEN EQ 8.
GS_UPLOAD-DATAB = GS_UPLOAD-INDAT.
ELSE.
GS_UPLOAD-DATAB = SY-DATUM.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-MATNR
IMPORTING
OUTPUT = GS_UPLOAD-MATNR.
LV_KBETR = GS_UPLOAD-KBETR.
SELECT SINGLE MEINS INTO LV_MEINS
FROM MARA WHERE MATNR = GS_UPLOAD-MATNR.
SELECT * FROM A506 INTO TABLE LT_A506
WHERE KSCHL = GS_UPLOAD-KSCHL
AND VKORG = GS_UPLOAD-VKORG
AND VTWEG = GS_UPLOAD-VTWEG "分销渠道
AND MATNR = GS_UPLOAD-MATNR
AND WERKS = GS_UPLOAD-WERKS.
*& 条件价格赋值
LOOP AT LT_A506 INTO LS_A506.
LV_MSGFN = '004'.
IF LS_A506-DATAB >= GS_UPLOAD-DATAB AND LS_A506-DATBI >= GS_UPLOAD-DATAB.
LV_MSGFN = '003'.
ENDIF.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = LS_A506-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LS_A506-KNUMH.
GS_CONDCT-VALID_FROM = LS_A506-DATAB.
IF LS_A506-DATBI >= GS_UPLOAD-DATAB AND LS_A506-DATAB <= GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = GS_UPLOAD-DATAB - 1.
IF LS_A506-DATBI NE '99991231'.
APPEND LS_A506 TO GT_A506_DEL.
ENDIF.
ELSE.
GS_CONDCT-VALID_TO = LS_A506-DATBI.
ENDIF.
CLEAR LV_KEY.
LV_KEY(4) = LS_A506-VKORG.
LV_KEY+4(2) = LS_A506-VTWEG.
LV_KEY+6(18) = LS_A506-MATNR.
LV_KEY+24(4) = LS_A506-WERKS.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LS_A506-KNUMH.
GS_CONDHD-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = LS_A506-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = LS_A506-DATAB.
IF LS_A506-DATBI >= GS_UPLOAD-DATAB AND LS_A506-DATAB <= GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = GS_UPLOAD-DATAB - 1.
ELSE.
GS_CONDHD-VALID_TO = LS_A506-DATBI.
ENDIF.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LS_A506-KNUMH.
GS_CONDIT-OPERATION = LV_MSGFN. "003 -- 删除 004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = LS_A506-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
SELECT SINGLE KBETR
KPEIN
KMEIN
INTO (GS_CONDIT-COND_VALUE,
GS_CONDIT-COND_P_UNT,
GS_CONDIT-COND_UNIT)
FROM KONP
WHERE KNUMH = LS_A506-KNUMH
AND KOPOS = '01'.
APPEND GS_CONDIT TO GT_CONDIT.
* ENDIF.
ENDLOOP.
CLEAR GS_CONDCT.
GS_CONDCT-COND_USAGE = 'A'.
GS_CONDCT-TABLE_NO = LV_TABLE_NO.
GS_CONDCT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDCT-APPLICATIO = 'V'.
GS_CONDCT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDCT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A506-KNUMH.
GS_CONDCT-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDCT-VALID_TO = '99991231'.
CLEAR LV_KEY.
LV_KEY(4) = GS_UPLOAD-VKORG.
LV_KEY+4(2) = GS_UPLOAD-VTWEG.
LV_KEY+6(18) = GS_UPLOAD-MATNR.
LV_KEY+24(4) = GS_UPLOAD-WERKS.
GS_CONDCT-VARKEY = LV_KEY.
APPEND GS_CONDCT TO GT_CONDCT.
CLEAR GS_CONDHD.
GS_CONDHD-COND_NO = LV_COND_NO. "'$000000001'. "LS_A506-KNUMH.
GS_CONDHD-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDHD-CREATED_BY = SY-UNAME.
GS_CONDHD-CREAT_DATE = SY-DATUM.
GS_CONDHD-COND_USAGE = 'A'.
GS_CONDHD-TABLE_NO = LV_TABLE_NO.
GS_CONDHD-APPLICATIO = 'V'.
GS_CONDHD-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDHD-VARKEY = LV_KEY.
GS_CONDHD-VALID_FROM = GS_UPLOAD-DATAB.
GS_CONDHD-VALID_TO = '99991231'.
APPEND GS_CONDHD TO GT_CONDHD.
CLEAR GS_CONDIT.
GS_CONDIT-COND_NO = LV_COND_NO. "'$000000001'. "LS_A506-KNUMH.
GS_CONDIT-OPERATION = '009'. "004 -- 修改 009 -- 新建
GS_CONDIT-COND_COUNT = '01'.
GS_CONDIT-APPLICATIO = 'V'.
GS_CONDIT-COND_TYPE = GS_UPLOAD-KSCHL.
GS_CONDIT-SCALETYPE = 'A'.
GS_CONDIT-SCALEBASIN = 'C'.
* GS_CONDIT-CONDITIDX = '01'.
GS_CONDIT-COND_P_UNT = 1.
GS_CONDIT-COND_UNIT = LV_MEINS.
PERFORM CONVERT_INTO_INPUT CHANGING GS_CONDIT-COND_UNIT.
GS_CONDIT-CALCTYPCON = 'C'.
GS_CONDIT-EXCLUSION = 'X'.
GS_CONDIT-PMNTTRMS = ''.
GS_CONDIT-CONDCURR = 'CNY'.
GS_CONDIT-COND_VALUE = LV_KBETR.
APPEND GS_CONDIT TO GT_CONDIT.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDFORM. " FRM_BH_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_DATA .
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
IF RB_CS EQ 'X'.
IF GS_UPLOAD-KSCHL EQ 'VKP0'
OR GS_UPLOAD-KSCHL EQ 'ZMAX'
OR GS_UPLOAD-KSCHL EQ 'ZMIN'.
ELSE.
GS_UPLOAD-STATUS = 'E'.
GS_UPLOAD-ZZMSG = '导入条件类型与业态不符!'.
ENDIF.
ELSEIF RB_DQ EQ 'X'.
IF GS_UPLOAD-KSCHL EQ 'Z001'
OR GS_UPLOAD-KSCHL EQ 'Z002'
OR GS_UPLOAD-KSCHL EQ 'Z003'.
ELSE.
GS_UPLOAD-STATUS = 'E'.
GS_UPLOAD-ZZMSG = '导入条件类型与业态不符!'.
ENDIF.
ELSEIF RB_BH EQ 'X'.
IF GS_UPLOAD-KSCHL EQ 'Z004'.
ELSE.
GS_UPLOAD-STATUS = 'E'.
GS_UPLOAD-ZZMSG = '导入条件类型与业态不符!'.
ENDIF.
ENDIF.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDFORM. " FRM_CHECK_DATA
*&--------------------------------------------------------------------*
*& Form user_command
*&--------------------------------------------------------------------*
* 响应用户事件,例如双击事件等
*---------------------------------------------------------------------*
* -->U_UCOMM 系统按钮变量
* -->SELFIELD 选择的栏位名
*---------------------------------------------------------------------*
FORM USER_COMMAND USING U_UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
DATA:LV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA:LO_GUID TYPE REF TO CL_GUI_ALV_GRID.
DATA: LV_INDEX TYPE SY-TABIX.
" ALV GridControl full screen.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = LO_GUID.
" Verification of Changes.
CALL METHOD LO_GUID->CHECK_CHANGED_DATA.
SELFIELD-REFRESH = 'X'. "自动刷新
SELFIELD-COL_STABLE = 'X'. "防止列跑位
SELFIELD-ROW_STABLE = 'X'. "防止行跑位
CASE U_UCOMM.
WHEN 'EXEC'.
READ TABLE GT_UPLOAD INTO GS_UPLOAD WITH KEY SELDA = 'X'
STATUS = 'S'.
IF SY-SUBRC EQ 0.
PERFORM FRM_CALL_BAPI.
ELSE.
MESSAGE '请先选择可以导入的数据!' TYPE 'E'.
ENDIF.
WHEN 'ALSEL'.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
GS_UPLOAD-SELDA = 'X'.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
WHEN 'UNSEL'.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
GS_UPLOAD-SELDA = ''.
MODIFY GT_UPLOAD FROM GS_UPLOAD.
ENDLOOP.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_INPUT .
IF S_MATNR[] IS INITIAL.
MESSAGE '请先输入商品再操作!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " FRM_CHECK_INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_1100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_1100 OUTPUT.
SET PF-STATUS 'STATUS_1100'.
* SET TITLEBAR 'xxx'.
PERFORM SUB_FIRST_DISP_1100.
ENDMODULE. " STATUS_1100 OUTPUT
*&---------------------------------------------------------------------*
*& Form SUB_FIRST_DISP_1100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_FIRST_DISP_1100 .
* OO显示数据
IF GO_ER_1100 IS INITIAL.
CREATE OBJECT GO_ER_1100.
ENDIF.
* 列名、列表属性初始化
PERFORM SUB_INIT_ALV_1100. "###ALV##
IF GO_AG_1100_H IS INITIAL.
CREATE OBJECT GO_AG_1100_H
EXPORTING
I_LIFETIME = CL_GUI_CUSTOM_CONTAINER=>LIFETIME_DYNPRO
I_PARENT = CL_GUI_CONTAINER=>SCREEN0
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4.
IF SY-SUBRC <> 0.
ELSE.
CALL METHOD GO_AG_1100_H->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_SAVE = 'A'
I_BUFFER_ACTIVE = GV_X
I_BYPASSING_BUFFER = GV_X
* IS_LAYOUT = GS_LO_1100_H
IT_TOOLBAR_EXCLUDING = GT_TE_1100_H
IS_VARIANT = GS_VARIANT
CHANGING
IT_SORT = GT_SORT_1100_H
IT_FIELDCATALOG = GT_FIELDCAT_1100
IT_OUTTAB = GT_OUTPUT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3.
IF SY-SUBRC <> 0.
ELSE.
* SET HANDLER GO_ER_1100->DOUBLE_CLICK_ITAB FOR GO_AG_1100_H.
* SET HANDLER GO_ER_1100->HOTSPOT_CLICK FOR GO_AG_1100_H.
SET HANDLER GO_ER_1100->HANDLE_USER_COMMAND FOR GO_AG_1100_H.
SET HANDLER GO_ER_1100->HANDLE_TOOLBAR FOR GO_AG_1100_H.
CALL METHOD GO_AG_1100_H->SET_TOOLBAR_INTERACTIVE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SUB_INIT_ALV_1100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_INIT_ALV_1100 .
GS_LO_1100_H-ZEBRA = GV_X.
* GS_LO_1100_H-CWIDTH_OPT = GV_X.
GS_LO_1100_H-SEL_MODE = 'B'.
* GS_LO_1100_I-GRID_TITLE = '质检结果维护'.
* GS_LO_1100_H-STYLEFNAME = 'CELL_STYLE'.
GS_VARIANT-REPORT = SY-REPID.
GS_VARIANT-VARIANT = GS_LO_1100_H.
REFRESH: GT_FIELDCAT_1100.
CLEAR: GS_FIELDCAT_1100.
DEFINE POPULATE_1100.
GS_FIELDCAT_1100-FIELDNAME = &1.
GS_FIELDCAT_1100-OUTPUTLEN = &2.
GS_FIELDCAT_1100-NO_ZERO = &3.
GS_FIELDCAT_1100-ref_table = &4. "REF_TABNAME
GS_FIELDCAT_1100-ref_field = &5. "REF_FIELDNAME
GS_FIELDCAT_1100-COLTEXT = &6. "SELTEXT_L
GS_FIELDCAT_1100-EDIT = &7.
GS_FIELDCAT_1100-NO_OUT = &8.
GS_FIELDCAT_1100-CHECKBOX = &9.
APPEND GS_FIELDCAT_1100 to GT_FIELDCAT_1100.
CLEAR GS_FIELDCAT_1100.
END-OF-DEFINITION.
POPULATE_1100 'SELDA' '4' '' '' '' '选择' 'X' '' 'X'.
POPULATE_1100 'VBELN' '10' 'X' '' '' '销售订单号' '' '' ''.
POPULATE_1100 'ERDAT' '10' '' '' '' '创建时间' '' '' ''.
POPULATE_1100 'VKBUR' '10' 'X' '' '' '销售办公室' '' '' ''.
POPULATE_1100 'BEZEI' '30' 'X' '' '' '销售办公室描述' '' '' ''.
POPULATE_1100 'LIFSK' '8' 'X' '' '' '交货冻结' '' '' ''.
POPULATE_1100 'MATNR' '18' 'X' '' '' '商品编码' '' '' ''.
POPULATE_1100 'ARKTX' '40' 'X' '' '' '商品描述' '' '' ''.
POPULATE_1100 'KWMENG' '10' 'X' '' '' '商品数量' '' '' ''.
POPULATE_1100 'NETPR' '10' 'X' '' '' '销售价格' '' '' ''.
POPULATE_1100 'KWERT' '10' 'X' '' '' '预销售限价' '' '' ''.
POPULATE_1100 'ZZBFB' '10' 'X' '' '' '扣率%' '' '' ''.
POPULATE_1100 'NETWR' '10' 'X' '' '' '销售额' '' '' ''.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_COPY TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_CUT TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE TO GT_TE_1100_H.
APPEND CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW TO GT_TE_1100_H.
* APPEND CL_GUI_ALV_GRID=>MC_FC_PRINT TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_DETAIL TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_FILTER TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_VIEWS TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_MB_SUBTOT TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_MB_FILTER TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_MB_VARIANT TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_MB_VIEW TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_INFO TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_GRAPH TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_SUM TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_GRAPH TO GT_TE_1100_I.
* APPEND CL_GUI_ALV_GRID=>MC_FC_INFO TO GT_TE_1100_I.
ENDFORM. " SUB_INIT_ALV_1100
*&---------------------------------------------------------------------*
*& Form HANDLE_TOOLBAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_OBJECT text
* -->P_E_INTERACTIVE text
*----------------------------------------------------------------------*
FORM HANDLE_TOOLBAR USING E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET
E_INTERACTIVE TYPE CHAR01.
DATA: LT_TOOLBAR TYPE TTB_BUTTON,
LS_TOOLBAR TYPE STB_BUTTON,
LV_SUBRC TYPE SY-SUBRC.
LT_TOOLBAR = E_OBJECT->MT_TOOLBAR.
**************************屏幕更新的时候 按钮 只添加一次。
READ TABLE LT_TOOLBAR WITH KEY FUNCTION = 'ALSEL' INTO LS_TOOLBAR.
IF SY-SUBRC <> 0.
CLEAR LS_TOOLBAR.
MOVE 3 TO LS_TOOLBAR-BUTN_TYPE.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
****************************添加按钮 函数
MOVE 'ALSEL' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SELECT_ALL TO LS_TOOLBAR-ICON.
MOVE '全选' TO LS_TOOLBAR-QUICKINFO.
MOVE '全选' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
****************************添加按钮 函数
MOVE 'UNSEL' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_DESELECT_ALL TO LS_TOOLBAR-ICON.
MOVE '取消全选' TO LS_TOOLBAR-QUICKINFO.
MOVE '取消全选' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
****************************添加按钮 函数
MOVE 'SAVE' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SYSTEM_SAVE TO LS_TOOLBAR-ICON.
MOVE '确认保存' TO LS_TOOLBAR-QUICKINFO.
MOVE '确认保存' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDIF.
ENDFORM. " HANDLE_TOOLBAR
*&---------------------------------------------------------------------*
*& Form HANDLE_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_UCOMM text
*----------------------------------------------------------------------*
FORM HANDLE_USER_COMMAND USING E_UCOMM TYPE SY-UCOMM.
CALL METHOD GO_AG_1100_H->CHECK_CHANGED_DATA.
CASE E_UCOMM.
WHEN 'SAVE'.
WHEN 'ALSEL'.
LOOP AT GT_OUTPUT INTO GS_OUTPUT.
GS_OUTPUT-SELDA = 'X'.
MODIFY GT_OUTPUT FROM GS_OUTPUT.
ENDLOOP.
WHEN 'UNSEL'.
LOOP AT GT_OUTPUT INTO GS_OUTPUT.
GS_OUTPUT-SELDA = ''.
MODIFY GT_OUTPUT FROM GS_OUTPUT.
ENDLOOP.
ENDCASE.
PERFORM SUB_REFRESH_DISP.
ENDFORM. " HANDLE_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form SUB_REFRESH_DISP_0301
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_REFRESH_DISP.
DATA: LS_STBL TYPE LVC_S_STBL.
* CALL METHOD GO_AG_0301_I->CHECK_CHANGED_DATA.
CALL METHOD GO_AG_1100_H->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GS_LO_1100_H.
CALL METHOD GO_AG_1100_H->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LS_STBL.
ENDFORM. " SUB_REFRESH_DISP_0301