TYPES: BEGIN OF TY_OUT,
CHUSHI TYPE D,
DATE00 TYPE STRING,
DATE01 TYPE STRING,
DATE02 TYPE STRING,
DATE03 TYPE STRING,
END OF TY_OUT.
DATA: GS_OUT TYPE TY_OUT,
GT_OUT TYPE STANDARD TABLE OF TY_OUT.
DATA: LV_DATE TYPE STRING.
DATA: LV_INDEX TYPE N LENGTH 2.
DATA: LV_FIELD TYPE STRING.
FIELD-SYMBOLS <FS> TYPE ANY.
DATA: TA_FIELD TYPE LVC_T_FCAT,
WA_FIELD TYPE LVC_S_FCAT,
WA_LAYO TYPE LVC_S_LAYO,
G_LOW TYPE SY-DATUM,
NUM TYPE I,
NUMS TYPE I.
DATA: LV_D TYPE D.
DATA DATE2(10) TYPE C.
DATA: D_POS TYPE I VALUE 0.
DATA: I_FIELDCAT_ALV TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
I_LAYOUT TYPE SLIS_LAYOUT_ALV, "alv的格式
W_FIELDCAT TYPE SLIS_FIELDCAT_ALV, "alv列属性
W_REPID LIKE SY-REPID. "当前程序
DEFINE MCR_AGV_FIELDCAT.
WA_FIELD-FIELDNAME = &1.
WA_FIELD-SCRTEXT_L = &2.
WA_FIELD-REF_TABLE = &3.
APPEND WA_FIELD TO TA_FIELD.
CLEAR WA_FIELD.
END-OF-DEFINITION.
PARAMETERS PDATE TYPE SY-DATUM.
START-OF-SELECTION.
MCR_AGV_FIELDCAT: 'CHUSHI' '初始日期' ''.
CLEAR GS_OUT.
GS_OUT-CHUSHI = PDATE.
CONCATENATE PDATE+0(6) '01' INTO G_LOW."月的第一天
DO 5 TIMES.
CLEAR:LV_DATE,LV_INDEX,LV_FIELD.
LV_INDEX = SY-INDEX - 1.
CONCATENATE 'GS_OUT-DATE' LV_INDEX INTO LV_DATE.
ASSIGN (LV_DATE) TO <FS>.
IF <FS> IS ASSIGNED.
LV_D = G_LOW + 1 * SY-INDEX - 1 .
LV_FIELD = 'DATE' && LV_INDEX.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
DATE_INTERNAL = LV_D
IMPORTING
DATE_EXTERNAL = DATE2
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
<FS> = DATE2.
ENDIF.
MCR_AGV_FIELDCAT LV_FIELD <FS> ''.
GS_OUT-DATE01 ='11'.
ENDDO.
APPEND GS_OUT TO GT_OUT.
CLEAR WA_LAYO.
WA_LAYO-ZEBRA = 'X'.
WA_LAYO-CWIDTH_OPT = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT_LVC = WA_LAYO
IT_FIELDCAT_LVC = TA_FIELD
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_OUT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*&---------------------------------------------------------------------*
*& Form SUB_SET_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->VALUE text
* -->(NAME) text
* -->P_TEXT text
*----------------------------------------------------------------------*
FORM MCR_AGV_FIELDCAT USING VALUE(NAME) P_TEXT.
D_POS = D_POS + 1.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = D_POS.
W_FIELDCAT-FIELDNAME = NAME.
W_FIELDCAT-SELTEXT_L = P_TEXT.
W_FIELDCAT-NO_ZERO = 'X'.
IF D_POS <= 6 .
W_FIELDCAT-KEY = 'X'.
ENDIF.
APPEND W_FIELDCAT TO I_FIELDCAT_ALV.
ENDFORM. "SUB_SET_FIELD