REPORT ZJACK_014 MESSAGE-ID YS.
DATA : BEGIN OF TAB OCCURS 0,
ID TYPE CHAR01,
NAME TYPE CHAR10,
GRADE LIKE YSFC1_FSCT054-CREATEDATE,
STATUS TYPE CHAR2,
KWMENG(5) TYPE C,
END OF TAB.
DATA:TAB1 LIKE TAB OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF T_DATE OCCURS 20,
ETADAT LIKE YSFC1_FSCT04-ETADAT,
END OF T_DATE.
FIELD-SYMBOLS: <WA> LIKE TAB.
FIELD-SYMBOLS: <WA1> LIKE TAB1.
*****ALV*******************************************************
TYPE-POOLS:SLIS.
DATA:WA_REPID TYPE SY-REPID,
WA_FIELD TYPE SLIS_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: WA_LAYO TYPE LVC_S_LAYO.
DATA: WA_FCAT TYPE LVC_S_FCAT,
IT_FCAT TYPE LVC_T_FCAT.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
DATA:YMD(8).
DATA:ITAB_EXCLUDING TYPE SLIS_T_EXTAB.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA> TYPE ANY.
FIELD-SYMBOLS <FS1> TYPE ANY.
FIELD-SYMBOLS <FS2> TYPE ANY.
FIELD-SYMBOLS <FS3> TYPE ANY.
FIELD-SYMBOLS <FS4> TYPE ANY.
DATA: GT_SORT TYPE LVC_S_SORT OCCURS 0,
LS_SORT LIKE LINE OF GT_SORT.
">>>>Define alv components
*****ALV*******************************************************
TAB-ID = '1'. TAB-NAME = 'A001'. TAB-STATUS = '10'. TAB-GRADE = '20180603'. TAB-KWMENG = '0006'. APPEND TAB.CLEAR TAB.
TAB-ID = '2'. TAB-NAME = 'A001'. TAB-STATUS = '20'. TAB-GRADE = '20180604'. TAB-KWMENG = '0007'. APPEND TAB.CLEAR TAB.
TAB-ID = '2'. TAB-NAME = 'A002'. TAB-STATUS = '20'. TAB-GRADE = '20180604'. TAB-KWMENG = '0008'. APPEND TAB.CLEAR TAB.
TAB-ID = '3'. TAB-NAME = 'A002'. TAB-STATUS = '40'. TAB-GRADE = '20180606'. TAB-KWMENG = '0009'. APPEND TAB.CLEAR TAB.
TAB-ID = '3'. TAB-NAME = 'A002'. TAB-STATUS = '40'. TAB-GRADE = '20180607'. TAB-KWMENG = '0009'. APPEND TAB.CLEAR TAB.
SORT TAB1 BY ID NAME STATUS.
DELETE ADJACENT DUPLICATES FROM TAB1 COMPARING ALL FIELDS.
REFRESH:T_DATE[].
LOOP AT TAB ASSIGNING <WA>.
T_DATE-ETADAT = <WA>-GRADE.
APPEND T_DATE.
CLEAR T_DATE.
ENDLOOP.
SORT T_DATE.
DELETE ADJACENT DUPLICATES FROM T_DATE COMPARING ALL FIELDS.
*****ALV HEADER
CLEAR: IT_FCAT.
PERFORM FRM_ADD_FCAT USING: 'ID' '序號' '15'.
PERFORM FRM_ADD_FCAT USING: 'NAME' '名稱' '15'.
PERFORM FRM_ADD_FCAT USING: 'STATUS' '總數' '15'.
LOOP AT T_DATE.
CLEAR:YMD.
YMD = T_DATE-ETADAT.
PERFORM FRM_ADD_FCAT USING:YMD YMD '20'.
ENDLOOP.
* 根据it_fact生成动态表
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FCAT
IMPORTING
EP_TABLE = DY_TABLE.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
LOOP AT TAB.
MOVE-CORRESPONDING TAB TO TAB1.
APPEND TAB1.
CLEAR TAB1.
ENDLOOP.
SORT TAB1 BY ID NAME STATUS.
DELETE ADJACENT DUPLICATES FROM TAB1 COMPARING ID NAME STATUS.
LOOP AT TAB1 ASSIGNING <WA1>.
IF <WA1>-ID = '1'.
DELETE TAB1.
CONTINUE.
ENDIF.
ASSIGN COMPONENT 'ID' OF STRUCTURE <DYN_WA> TO <FS1>.
<FS1> = <WA1>-ID.
ASSIGN COMPONENT 'NAME' OF STRUCTURE <DYN_WA> TO <FS2>.
<FS2> = <WA1>-NAME.
ASSIGN COMPONENT 'STATUS' OF STRUCTURE <DYN_WA> TO <FS3>.
<FS3> = <WA1>-STATUS.
LOOP AT TAB ASSIGNING <WA> WHERE
ID = <WA1>-ID
AND NAME = <WA1>-NAME
AND STATUS = <WA1>-STATUS.
YMD = <WA>-GRADE.
ASSIGN COMPONENT YMD OF STRUCTURE <DYN_WA> TO <FS4>.
SHIFT <WA>-KWMENG LEFT DELETING LEADING '0'.
<FS4> = <WA>-KWMENG.
UNASSIGN <FS4>.
ENDLOOP.
APPEND <DYN_WA> TO <DYN_TABLE>.
CLEAR <DYN_WA>.
ENDLOOP.
PERFORM LAYOUT_FORMAT.
PERFORM ALV_REPORT .
FORM LAYOUT_FORMAT.
LS_SORT-SPOS = 1.
LS_SORT-FIELDNAME = 'ID'.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
CLEAR LS_SORT.
ENDFORM.
FORM ALV_REPORT .
WA_REPID = SY-REPID.
WA_LAYO-ZEBRA = 'X'.
WA_LAYO-CWIDTH_OPT = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = WA_LAYO
IT_FIELDCAT_LVC = IT_FCAT
IT_EXCLUDING = ITAB_EXCLUDING
I_SAVE = 'A'
IT_SORT_LVC = GT_SORT
TABLES
T_OUTTAB = <DYN_TABLE>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
FORM FRM_ADD_FCAT USING VALUE1 VALUE2 VALUE3.
WA_FCAT-FIELDNAME = VALUE1.
WA_FCAT-REPTEXT = VALUE2.
WA_FCAT-INTLEN = VALUE3.
APPEND WA_FCAT TO IT_FCAT.
CLEAR: WA_FCAT.
ENDFORM. " FRM_ADD_FCAT
相关文章
- 03-29ABAP動態內表
- 03-29Winform後台如何動態修改App.config文件里的內容
- 03-29JS動態綁定下拉單內容