REPORT ZWZ_03_2.
TABLES : ZRFQ_PRINT, VBAK .
DATA : BEGIN OF IT OCCURS 0 .
INCLUDE STRUCTURE ZRFQ_PRINT .
DATA BOX TYPE C .
DATA END OF IT .
DATA : ITAB LIKE STANDARD TABLE OF ZRFQ_PRINT,
WA TYPE ZRFQ_PRINT .
DATA S_CODE LIKE SY-UCOMM.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text -001 .
SELECT -OPTIONS: P_VBELN for VBAK-VBELN .
SELECTION-SCREEN END OF BLOCK b1 .
*DATA wa_03 TYPE wa_03.
*-----------------------------------------------------------------------
*ALV层级关系定义
*-----------------------------------------------------------------------
INCLUDE <LINE> .
TYPE -POOLS: SLIS.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WT_FIELDCAT LIKE LINE OF IT_FIELDCAT ,
WT_LAYOUT TYPE SLIS_LAYOUT_ALV .
START-OF -SELECTION .
*追加ALV字段
PERFORM ALV_FIELD_HEAD.
*选择数据
PERFORM GET_DATA.
*显示ALV
PERFORM CALL_ALV_SHOW.
*--------------------------------------------------------------------*
* 取数据
*--------------------------------------------------------------------*
FORM GET_DATA .
SELECT ZRFQ_PRINT~VBELN ZRFQ_PRINT~STATUS INTO CORRESPONDING FIELDS OF TABLE IT
FROM ZRFQ_PRINT WHERE ZRFQ_PRINT~VBELN IN P_VBELN .
ENDFORM .
*----------------------------------------------------------------------
*预定义用于ALV加入字段
*----------------------------------------------------------------------
DEFINE ADD_FIELD.
CLEAR WT_FIELDCAT.
WT_FIELDCAT-fieldname = &1 .
WT_FIELDCAT-SELTEXT_L = &2 .
WT_FIELDCAT-edit = &3 .
WT_FIELDCAT-checkbox = &4 .
* WT_FIELDCAT-hotspot = &5 .
APPEND WT_FIELDCAT TO IT_FIELDCAT.
END -OF -DEFINITION .
*---------------------------------------------------------------------*
* Form ALV_OUTPUT
*---------------------------------------------------------------------*
FORM ALV_FIELD_HEAD.
ADD_FIELD 'VBELN' '单号' '' '' .
ADD_FIELD 'STATUS' '状态' 'X' 'X' .
ENDFORM . " ALV_OUTPUT
*---------------------------------------------------------------------*
* FORM CALL_ALV_SHOW.
*---------------------------------------------------------------------*
FORM CALL_ALV_SHOW.
WT_LAYOUT-BOX_FIELDNAME = 'BOX' .
WT_LAYOUT-ZEBRA = 'X' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' " ALV function Module
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = WT_LAYOUT
* I_CALLBACK_PF_STATUS_SET = 'SET_STA'
* I_DEFAULT = 'X'
* I_SAVE = 'X'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = IT[]
* EXCEPTIONS
* PROGRAM_ERROR = 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 .
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
CASE UCOMM.
WHEN '&DATA_SAVE' .
LOOP AT IT WHERE BOX = 'X' .
MOVE -CORRESPONDING IT TO WA .
APPEND WA TO ITAB .
CLEAR WA .
ENDLOOP .
MODIFY ZRFQ_PRINT FROM TABLE ITAB .
ENDCASE .
ENDFORM .
" another ALV function Module SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } 'REUSE_ALV_GRID_DISPLAY_LVC'