*&---------------------------------------------------------------------*
*& Report ZSUMIT9 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZSUMIT9 .
TYPE-POOLS : SLIS.
TABLES : ZSTUD123 , ZSTUD_DET.
DATA : GD_REPID LIKE SY-REPID .
TYPES : BEGIN OF ST_STUD,
STUDID TYPE ZSTUD123-STUDID,
STUDNAME TYPE ZSTUD123-STUDNAME,
STUDADD TYPE ZSTUD123-STUDADD,
STUDAGE TYPE ZSTUD123-STUDAGE,
END OF ST_STUD.
TYPES : BEGIN OF ST_DETAIL,
STUDID TYPE ZSTUD_DET-STUDID,
COURSE TYPE ZSTUD_DET-COURSE ,
COURSFEE TYPE ZSTUD_DET-COURSFEE,
END OF ST_DETAIL.
TYPES : BEGIN OF ST_JOIN,
STUDID TYPE ZSTUD123-STUDID,
STUDNAME TYPE ZSTUD123-STUDNAME,
STUDADD TYPE ZSTUD123-STUDADD,
STUDAGE TYPE ZSTUD123-STUDAGE,
COURSE TYPE ZSTUD_DET-COURSE ,
COURSFEE TYPE ZSTUD_DET-COURSFEE,
END OF ST_JOIN.
DATA : WA_STUD TYPE ST_STUD,
WA_DETAIL TYPE ST_DETAIL,
WA_JOIN TYPE ST_JOIN.
DATA : IT_STUD LIKE STANDARD TABLE OF WA_STUD,
IT_DETAIL LIKE STANDARD TABLE OF WA_DETAIL,
IT_JOIN LIKE STANDARD TABLE OF WA_JOIN.
DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV ,
IT_FCAT LIKE STANDARD TABLE OF WA_FCAT,
W_EVENT TYPE SLIS_ALV_EVENT,
I_EVENT TYPE SLIS_T_EVENT,
WA_I_FCAT TYPE SLIS_FIELDCAT_ALV ,
IT_I_FCAT LIKE STANDARD TABLE OF WA_FCAT.
SELECTION-SCREEN : BEGIN OF BLOCK B3 WITH FRAME TITLE T3.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE T1 .
SELECT-OPTIONS: S_STUD FOR ZSTUD123-STUDID.
SELECTION-SCREEN : END OF BLOCK B1 .
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE T2 .
PARAMETERS : C_ALV_LT RADIOBUTTON GROUP GRP1,
C_ALV_GD RADIOBUTTON GROUP GRP1,
I_ALV_LT RADIOBUTTON GROUP GRP1,
I_ALV_GD RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN : END OF BLOCK B2 .
SELECTION-SCREEN : END OF BLOCK B3 .
PERFORM GETDATA.
PERFORM IT_FCAT.
IF C_ALV_LT = 'X'.
PERFORM C_ALV_LIST .
ENDIF.
IF C_ALV_GD = 'X'.
PERFORM C_ALV_GRID .
ENDIF.
IF I_ALV_LT = 'X'.
PERFORM I_ALV_LIST .
ENDIF.
IF I_ALV_GD = 'X'.
PERFORM I_ALV_GRID .
ENDIF.
*&---------------------------------------------------------------------*
*& Form GETDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GETDATA .
SELECT * FROM ZSTUD123 INTO TABLE IT_STUD
WHERE STUDID IN S_STUD .
SELECT STUDID
COURSE
COURSFEE
FROM ZSTUD_DET INTO TABLE IT_DETAIL
FOR ALL ENTRIES IN IT_STUD
WHERE STUDID EQ IT_STUD-STUDID.
LOOP AT IT_DETAIL INTO WA_DETAIL.
MOVE : WA_DETAIL-STUDID TO WA_JOIN-STUDID,
WA_DETAIL-COURSE TO WA_JOIN-COURSE,
WA_DETAIL-COURSFEE TO WA_JOIN-COURSFEE.
APPEND WA_JOIN TO IT_JOIN.
ENDLOOP.
LOOP AT IT_JOIN INTO WA_JOIN.
READ TABLE IT_STUD INTO WA_STUD
WITH KEY STUDID = WA_JOIN-STUDID.
MOVE : WA_STUD-STUDNAME TO WA_JOIN-STUDNAME,
WA_STUD-STUDADD TO WA_JOIN-STUDADD,
WA_STUD-STUDAGE TO WA_JOIN-STUDAGE.
MODIFY IT_JOIN FROM WA_JOIN.
ENDLOOP.
ENDFORM. " GETDATA
*&---------------------------------------------------------------------*
*& Form IT_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM IT_FCAT .
WA_FCAT-FIELDNAME = 'STUDID'.
WA_FCAT-COL_POS = '1 ' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'STUDentID'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDNAME'.
WA_FCAT-COL_POS = '5' .
WA_FCAT-OUTPUTLEN = '8'.
WA_FCAT-SELTEXT_L = 'STUDNAME'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDADD'.
WA_FCAT-COL_POS = '3' .
WA_FCAT-OUTPUTLEN = '12'.
WA_FCAT-SELTEXT_L = 'STUDADD'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDAGE'.
WA_FCAT-COL_POS = '4' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'STUDAGE'.
APPEND WA_FCAT TO IT_FCAT.
ENDFORM. " IT_FCAT
*&---------------------------------------------------------------------*
*& Form C_ALV_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM C_ALV_LIST .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_STUD
* 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. " C_ALV_LIST
*&---------------------------------------------------------------------*
*& Form C_ALV_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM C_ALV_GRID .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_STUD
* 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. " C_ALV_GRID
*&---------------------------------------------------------------------*
*& Form I_ALV_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM I_ALV_LIST .
FREE : IT_FCAT,
IT_STUD.
SORT IT_JOIN BY STUDID.
DELETE ADJACENT DUPLICATES FROM IT_JOIN COMPARING STUDID.
PERFORM FIELD_CATLOG_INTERACTIVE .
PERFORM ALV_INTERACTIVE .
ENDFORM. " I_ALV_LIST
*&---------------------------------------------------------------------*
*& Form FIELD_CATLOG_INTERACTIVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FIELD_CATLOG_INTERACTIVE .
WA_FCAT-FIELDNAME = 'STUDID'.
WA_FCAT-COL_POS = '1 ' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'STUDentID'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDNAME'.
WA_FCAT-COL_POS = '2' .
WA_FCAT-OUTPUTLEN = '8'.
WA_FCAT-SELTEXT_L = 'STUDNAME'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDADD'.
WA_FCAT-COL_POS = '3' .
WA_FCAT-OUTPUTLEN = '12'.
WA_FCAT-SELTEXT_L = 'STUDADD'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'STUDAGE'.
WA_FCAT-COL_POS = '4' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'STUDAGE'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'COURSE'.
WA_FCAT-COL_POS = '5' .
WA_FCAT-OUTPUTLEN = '12'.
WA_FCAT-SELTEXT_L = 'COURSE'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = 'COURSFEE'.
WA_FCAT-COL_POS = '6' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'COURSFEE'.
APPEND WA_FCAT TO IT_FCAT.
W_EVENT-NAME = 'USER_COMMAND'.
W_EVENT-FORM = 'INTERACTIVE_FORM'.
APPEND W_EVENT TO I_EVENT.
ENDFORM. " FIELD_CATLOG_INTERACTIVE
*&---------------------------------------------------------------------*
*& Form ALV_INTERACTIVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_INTERACTIVE .
GD_REPID = SY-REPID.
IF I_ALV_LT = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GD_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = I_EVENT
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_JOIN
* 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.
ENDIF.
GD_REPID = SY-REPID.
IF I_ALV_GD = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GD_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = I_EVENT
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_JOIN
* 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.
ENDIF.
ENDFORM. " ALV_INTERACTIVE
*&--------------------------------------------------------------------*
*& Form INTERACTIVE_FORM
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->USER_COMMANtext
* -->SEL text
*---------------------------------------------------------------------*
FORM INTERACTIVE_FORM USING USER_COMMAND LIKE SY-UCOMM
SEL TYPE SLIS_SELFIELD.
DATA: CUS(5) TYPE C,
SAL(10).
IF SEL-FIELDNAME = 'STUDID'.
CUS = SEL-VALUE.
SELECT STUDADD
STUDAGE
FROM ZSTUD INTO CORRESPONDING FIELDS OF TABLE IT_STUD
WHERE STUDID EQ CUS.
PERFORM IT_I_FCAT.
ENDIF.
*&---------------------------------------------------------------------*
*& Form I_ALV_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
GD_REPID = SY-REPID.
IF I_ALV_LT = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GD_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = IT_I_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS = I_EVENT
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_JOIN
* 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.
ENDIF.
GD_REPID = SY-REPID.
IF I_ALV_GD = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GD_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = IT_I_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS = I_EVENT
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_JOIN
* 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.
ENDIF.
ENDFORM. "INTERACTIVE_FORM
*&---------------------------------------------------------------------*
*& Form IT_I_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM IT_I_FCAT .
WA_FCAT-FIELDNAME = 'STUDADD'.
WA_FCAT-COL_POS = '1' .
WA_FCAT-OUTPUTLEN = '12'.
WA_FCAT-SELTEXT_L = 'STUDADD'.
APPEND WA_FCAT TO IT_I_FCAT.
WA_FCAT-FIELDNAME = 'STUDAGE'.
WA_FCAT-COL_POS = '2' .
WA_FCAT-OUTPUTLEN = '10'.
WA_FCAT-SELTEXT_L = 'STUDAGE'.
APPEND WA_FCAT TO IT_I_FCAT.
ENDFORM. " IT_I_FCAT
*&--------------------------------------------------------------------*
*& Form I_ALV_GRID
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM I_ALV_GRID .
FREE : IT_FCAT,
IT_STUD.
SORT IT_JOIN BY STUDID.
DELETE ADJACENT DUPLICATES FROM IT_JOIN COMPARING STUDID.
PERFORM FIELD_CATLOG_INTERACTIVE .
PERFORM ALV_INTERACTIVE .
ENDFORM. " I_ALV_GRID
No comments:
Post a Comment