REPORT ZSH217ERP_MMRP001.
* MESSAGE-ID xxxxxxxx
* LINE-SIZE xxx
* LINE-COUNT xxx
* NO STANDARD PAGE HEADING.
*INCLUDE xxxxxxxx.
*-----------------------------------------------------------------------------------*
* GLOBLE-DEFINATION *
*-----------------------------------------------------------------------------------*
TABLES:ZTMM_QCKL.
DATA: GT_ZTMM_QCKL TYPE TABLE OF ZTMM_QCKL,
GS_ZTMM_QCKL TYPE ZTMM_QCKL.
DATA:GT_DATA TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
FIELD-SYMBOLS: <WA_ITAB> TYPE ALSMEX_TABLINE.
DATA: WA_CONTAINER TYPE SCRFNAME VALUE 'ALVDATA',
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
WA_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA WA_LAYOUT TYPE LVC_S_LAYO.
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK TYPE SY-UCOMM.
* GS_ZTMM_QCKL TYPE TABLE OF ZTMM_QCKL.
*-----------------------------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK PARAM.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME OBLIGATORY. .
SELECTION-SCREEN END OF BLOCK PARAM.
*---------------------------------------------------------------------------------- *
* INITIALIZATION *
*-----------------------------------------------------------------------------------*
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE." SEACH HELP
* CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* FIELD_NAME = 'FNAME1'
* IMPORTING
* FILE_NAME = FNAME1.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',EXCEL FILE,*.XLS;*.XLSX;'
MODE = 'O' "S为保存,O为打开
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
*-----------------------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*-----------------------------------------------------------------------------------*
AT SELECTION-SCREEN.
* PERFORM SUB_xxxxxxxx.
*-----------------------------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM SUB_01.
CALL SCREEN 9000.
*-----------------------------------------------------------------------------------*
* END-OF-SELECTION *
*-----------------------------------------------------------------------------------*
END-OF-SELECTION.
* PERFORM SUB_xxxxxxxx.
*-----------------------------------------------------------------------------------*
* SUBROUTINES *
*-----------------------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form xxxxxxxx
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* <- p1 text
* -> p2 text
*----------------------------------------------------------------------*
FORM SUB_01.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 100
I_END_ROW = 100
TABLES
INTERN = GT_DATA
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
WRITE: / '读入文件错误!',P_FILE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
LOOP AT GT_DATA ASSIGNING <WA_ITAB>.
IF <WA_ITAB>-ROW <> 0.
CASE <WA_ITAB>-COL.
WHEN '0001'.
GS_ZTMM_QCKL-BWKEY = <WA_ITAB>-VALUE.
WHEN '0002'.
GS_ZTMM_QCKL-MATNR = <WA_ITAB>-VALUE.
WHEN '0003'.
GS_ZTMM_QCKL-MEINH = <WA_ITAB>-VALUE.
WHEN '0004'.
GS_ZTMM_QCKL-UMREZ = <WA_ITAB>-VALUE.
WHEN '0005'.
GS_ZTMM_QCKL-UMREN = <WA_ITAB>-VALUE.
WHEN '0006'.
GS_ZTMM_QCKL-EANNR = <WA_ITAB>-VALUE.
WHEN '0007'.
GS_ZTMM_QCKL-EAN11 = <WA_ITAB>-VALUE.
WHEN '0008'.
GS_ZTMM_QCKL-NUMTP = <WA_ITAB>-VALUE.
WHEN '0009'.
GS_ZTMM_QCKL-LAENG = <WA_ITAB>-VALUE.
WHEN '0010'.
GS_ZTMM_QCKL-BREIT = <WA_ITAB>-VALUE.
WHEN '0011'.
GS_ZTMM_QCKL-HOEHE = <WA_ITAB>-VALUE.
WHEN '0012'.
GS_ZTMM_QCKL-MEABM = <WA_ITAB>-VALUE.
WHEN '0013'.
GS_ZTMM_QCKL-VOLUM = <WA_ITAB>-VALUE.
WHEN '0014'.
GS_ZTMM_QCKL-VOLEH = <WA_ITAB>-VALUE.
WHEN '0015'.
GS_ZTMM_QCKL-BRGEW = <WA_ITAB>-VALUE.
WHEN '0016'.
GS_ZTMM_QCKL-GEWEI = <WA_ITAB>-VALUE.
WHEN '0017'.
GS_ZTMM_QCKL-ATINN = <WA_ITAB>-VALUE.
WHEN '0018'.
GS_ZTMM_QCKL-KZWSO = <WA_ITAB>-VALUE.
WHEN '0019'.
GS_ZTMM_QCKL-MSEHI = <WA_ITAB>-VALUE.
WHEN '0020'.
GS_ZTMM_QCKL-BUDAT = <WA_ITAB>-VALUE.
ENDCASE.
AT END OF ROW.
APPEND GS_ZTMM_QCKL TO GT_ZTMM_QCKL.
CLEAR GS_ZTMM_QCKL.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "SUB_01
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'STATUS1'.
IF WA_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT WA_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = WA_CONTAINER.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = WA_CUSTOM_CONTAINER.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZTMM_QCKL'
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = GT_ZTMM_QCKL.
ENDIF.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SAVE'.
MODIFY ZTMM_QCKL FROM TABLE GT_ZTMM_QCKL.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
* MESSAGE-ID xxxxxxxx
* LINE-SIZE xxx
* LINE-COUNT xxx
* NO STANDARD PAGE HEADING.
*INCLUDE xxxxxxxx.
*-----------------------------------------------------------------------------------*
* GLOBLE-DEFINATION *
*-----------------------------------------------------------------------------------*
TABLES:ZTMM_QCKL.
DATA: GT_ZTMM_QCKL TYPE TABLE OF ZTMM_QCKL,
GS_ZTMM_QCKL TYPE ZTMM_QCKL.
DATA:GT_DATA TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
FIELD-SYMBOLS: <WA_ITAB> TYPE ALSMEX_TABLINE.
DATA: WA_CONTAINER TYPE SCRFNAME VALUE 'ALVDATA',
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
WA_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA WA_LAYOUT TYPE LVC_S_LAYO.
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK TYPE SY-UCOMM.
* GS_ZTMM_QCKL TYPE TABLE OF ZTMM_QCKL.
*-----------------------------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK PARAM.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME OBLIGATORY. .
SELECTION-SCREEN END OF BLOCK PARAM.
*---------------------------------------------------------------------------------- *
* INITIALIZATION *
*-----------------------------------------------------------------------------------*
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE." SEACH HELP
* CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* FIELD_NAME = 'FNAME1'
* IMPORTING
* FILE_NAME = FNAME1.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',EXCEL FILE,*.XLS;*.XLSX;'
MODE = 'O' "S为保存,O为打开
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
*-----------------------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*-----------------------------------------------------------------------------------*
AT SELECTION-SCREEN.
* PERFORM SUB_xxxxxxxx.
*-----------------------------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM SUB_01.
CALL SCREEN 9000.
*-----------------------------------------------------------------------------------*
* END-OF-SELECTION *
*-----------------------------------------------------------------------------------*
END-OF-SELECTION.
* PERFORM SUB_xxxxxxxx.
*-----------------------------------------------------------------------------------*
* SUBROUTINES *
*-----------------------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form xxxxxxxx
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* <- p1 text
* -> p2 text
*----------------------------------------------------------------------*
FORM SUB_01.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 100
I_END_ROW = 100
TABLES
INTERN = GT_DATA
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
WRITE: / '读入文件错误!',P_FILE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
LOOP AT GT_DATA ASSIGNING <WA_ITAB>.
IF <WA_ITAB>-ROW <> 0.
CASE <WA_ITAB>-COL.
WHEN '0001'.
GS_ZTMM_QCKL-BWKEY = <WA_ITAB>-VALUE.
WHEN '0002'.
GS_ZTMM_QCKL-MATNR = <WA_ITAB>-VALUE.
WHEN '0003'.
GS_ZTMM_QCKL-MEINH = <WA_ITAB>-VALUE.
WHEN '0004'.
GS_ZTMM_QCKL-UMREZ = <WA_ITAB>-VALUE.
WHEN '0005'.
GS_ZTMM_QCKL-UMREN = <WA_ITAB>-VALUE.
WHEN '0006'.
GS_ZTMM_QCKL-EANNR = <WA_ITAB>-VALUE.
WHEN '0007'.
GS_ZTMM_QCKL-EAN11 = <WA_ITAB>-VALUE.
WHEN '0008'.
GS_ZTMM_QCKL-NUMTP = <WA_ITAB>-VALUE.
WHEN '0009'.
GS_ZTMM_QCKL-LAENG = <WA_ITAB>-VALUE.
WHEN '0010'.
GS_ZTMM_QCKL-BREIT = <WA_ITAB>-VALUE.
WHEN '0011'.
GS_ZTMM_QCKL-HOEHE = <WA_ITAB>-VALUE.
WHEN '0012'.
GS_ZTMM_QCKL-MEABM = <WA_ITAB>-VALUE.
WHEN '0013'.
GS_ZTMM_QCKL-VOLUM = <WA_ITAB>-VALUE.
WHEN '0014'.
GS_ZTMM_QCKL-VOLEH = <WA_ITAB>-VALUE.
WHEN '0015'.
GS_ZTMM_QCKL-BRGEW = <WA_ITAB>-VALUE.
WHEN '0016'.
GS_ZTMM_QCKL-GEWEI = <WA_ITAB>-VALUE.
WHEN '0017'.
GS_ZTMM_QCKL-ATINN = <WA_ITAB>-VALUE.
WHEN '0018'.
GS_ZTMM_QCKL-KZWSO = <WA_ITAB>-VALUE.
WHEN '0019'.
GS_ZTMM_QCKL-MSEHI = <WA_ITAB>-VALUE.
WHEN '0020'.
GS_ZTMM_QCKL-BUDAT = <WA_ITAB>-VALUE.
ENDCASE.
AT END OF ROW.
APPEND GS_ZTMM_QCKL TO GT_ZTMM_QCKL.
CLEAR GS_ZTMM_QCKL.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "SUB_01
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'STATUS1'.
IF WA_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT WA_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = WA_CONTAINER.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = WA_CUSTOM_CONTAINER.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZTMM_QCKL'
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = GT_ZTMM_QCKL.
ENDIF.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SAVE'.
MODIFY ZTMM_QCKL FROM TABLE GT_ZTMM_QCKL.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT