*&---------------------------------------------------------------------*
*& Report ZMM_OOALV_THOMAS
*&
*&---------------------------------------------------------------------*
*& 建一个DIALOG程序,只含一个主屏幕.
*&
*& 屏幕上方建一子屏幕含以下屏幕元素:
*& 日期范围MKPF-CPUDT;
*& 时间范围MKPF-CPUTM;
*& 物料凭证编号范围MKPF-MBLNR;
*& 物料字段范围 MSEG-MATNR;
*& 工厂单选 MSEG-WERKS 必填;
*& 库存地点范围MSEG-LGORT.
*&
*& 屏幕下方用OOALV显示报表,含以下字段:
*& 物料凭证编号MKPF-MBLNR;
*& 日期MKPF-CPUDT;
*& 时间MKPF-CPUTM;
*& 工厂 MSEG-WERKS;
*& 库存地点MSEG-LGORT;
*& 物料号MSEG-MATNR;
*& 移动类型MSEG-BWART;
*& 借贷标识MSEG-SHKZG;
*& 数量 MSEG-MENGE;
*& 单位 MSEG-MEINS.
*&
*& 响应双击事件,双击某行CALL另外一个屏幕显示当行各字段信息并含一个按钮PRINT,点击PRINT用SMARTFORMS打印当前行的信息。
*&
*&---------------------------------------------------------------------*
*& DATE: 20131008
*& DEVELOPER: THOMAS
*&---------------------------------------------------------------------*
REPORT ZMM_OOALV_THOMAS.
TABLES: MKPF, MSEG.
DATA: BEGIN OF IT_MSEG OCCURS 0,
MBLNR TYPE MKPF-MBLNR, "物料凭证编号
CPUDT TYPE MKPF-CPUDT, "日期
CPUTM TYPE MKPF-CPUTM, "时间;
WERKS TYPE MSEG-WERKS, "工厂 ;
LGORT TYPE MSEG-LGORT, "库存地点;
MATNR TYPE MSEG-MATNR, "物料号;
BWART TYPE MSEG-BWART, "移动类型;
SHKZG TYPE MSEG-SHKZG, "借贷标识;
MENGE TYPE MSEG-MENGE, "数量 ;
MEINS TYPE MSEG-MEINS, "单位 .
END OF IT_MSEG.
DATA: WA_MSEG LIKE LINE OF IT_MSEG.
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GRID TYPE REF TO CL_GUI_ALV_GRID.
"DATA: IT_FIELDCAT TYPE LVC_T_FCAT.
"DATA: WA_FIELDCAT TYPE LVC_S_FCAT.
DATA: WA_LAYOUT TYPE LVC_S_LAYO.
DATA: OKCODE2000 TYPE SY-UCOMM.
DATA: OKCODE3000 TYPE SY-UCOMM.
DATA: IT_FIELDCATALOG TYPE LVC_T_FCAT,
WA_FIELDCATALOG TYPE LINE OF LVC_T_FCAT.
CALL SCREEN 2000.
CLASS EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:HANDLER_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN ES_ROW_NO.
ENDCLASS.
CLASS EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLER_DOUBLE_CLICK.
* BREAK-POINT.
* MESSAGE I036(Z_DC) WITH ES_ROW_NO-ROW_ID E_COLUMN-FIELDNAME.
* CALL TRANSACTION 'MM03'.
READ TABLE IT_MSEG INTO WA_MSEG INDEX ES_ROW_NO-ROW_ID.
CALL SCREEN 3000.
* MESSAGE ' 你双击了' TYPE 'I'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
SELECTION-SCREEN BEGIN OF SCREEN 1500 AS SUBSCREEN. "建1500子屏幕
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_CPUDT FOR MKPF-CPUDT, "日期范围
S_CPUTM FOR MKPF-CPUTM, "时间范围
S_MBLNR FOR MKPF-MBLNR, "物料凭证编号范围
S_MATNR FOR MSEG-MATNR. "物料字段范围
PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY. "工厂单选, 必填
SELECT-OPTIONS: S_LGORT FOR MSEG-LGORT. "库存地点范围
SELECTION-SCREEN END OF BLOCK 10.
SELECTION-SCREEN END OF SCREEN 1500.
*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'PF2000'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
*& Module EXIT2000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE EXIT2000 INPUT.
IF OKCODE2000 = 'BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " EXIT2000 INPUT
FORM APPEND_WA USING COL_POS
FIELDNAME
" REF_TABLE
" REF_FIELD
SCRTEXT.
WA_FIELDCATALOG-COL_POS = COL_POS.
WA_FIELDCATALOG-FIELDNAME = FIELDNAME.
" WA_FIELDCATALOG-REF_TABLE = REF_TABLE.
" WA_FIELDCATALOG-REF_FIELD = REF_FIELD.
WA_FIELDCATALOG-SCRTEXT_M = SCRTEXT.
BREAK-POINT.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
ENDFORM. " ADD_FIELD
*&---------------------------------------------------------------------*
*& Module STATUS_3000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_3000 OUTPUT.
SET PF-STATUS 'STATUS3000'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_3000 OUTPUT
*&---------------------------------------------------------------------*
*& Module EXIT3000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE EXIT3000 INPUT.
IF OKCODE3000 = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE. " EXIT3000 INPUT
*&---------------------------------------------------------------------*
*& Module GET_DATA INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_DATA INPUT.
SELECT MKPF~MBLNR "物料凭证编号
MKPF~CPUDT "日期
MKPF~CPUTM "时间
MSEG~WERKS "工厂
MSEG~LGORT "库存地点
MSEG~MATNR "物料号
MSEG~BWART "移动类型
MSEG~SHKZG "借贷标识
MSEG~MENGE "数量
MSEG~MEINS "单位
INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
FROM MSEG
INNER JOIN MKPF
ON MSEG~MBLNR = MKPF~MBLNR
AND MKPF~MJAHR = MSEG~MJAHR
WHERE MKPF~CPUDT IN S_CPUDT
AND MKPF~CPUTM IN S_CPUTM
AND MKPF~MBLNR IN S_MBLNR
AND MSEG~MATNR IN S_MATNR
AND MSEG~LGORT IN S_LGORT
AND WERKS = P_WERKS.
ENDMODULE. " GET_DATA INPUT
*&---------------------------------------------------------------------*
*& Module SHOW_ALV INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SHOW_ALV INPUT.
IF G_CUSTOM_CONTAINER IS INITIAL.
PERFORM APPEND_WA USING: '1' 'MBLNR' '物料凭证编号',
'2' 'CPUDT' '日期',
'3' 'CPUTM' '时间',
'4' 'WERKS' '工厂',
'5' 'LGORT' '库存地点',
'6' 'MATNR' '物料号',
'7' 'BWART' '移动类型',
'8' 'SHKZG' '借贷标识',
'9' 'MENGE' '数量',
'10' 'MEINS' '单位'.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = G_CUSTOM_CONTAINER.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
IS_LAYOUT = WA_LAYOUT
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = IT_MSEG[]
IT_FIELDCATALOG = IT_FIELDCATALOG
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 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.
ENDIF.
SET HANDLER EVENT_RECEIVER=>HANDLER_DOUBLE_CLICK FOR ALL INSTANCES.
ENDIF.
ENDMODULE. " SHOW_ALV INPUT
阅读(2578) | 评论(0) | 转发(0) |