Split the top of page section of the alv header.
Report program.
REPORT ZAB_FOR_JOIN_TOP.
TABLES:zstu,zstu1.
TYPES: BEGIN OF ty_zstu,
zstu_id TYPE zstu-zstu_id,
zstu_name TYPE zstu-zstu_name,
zstu_dep TYPE zstu-zstu_dep,
zstu_fee TYPE zstu-zstu_fee,
END OF ty_zstu.
TYPES: BEGIN OF ty_zstu1,
zstu_id TYPE zstu1-zstu_id,
zstu_marks TYPE zstu1-zstu_marks,
END OF ty_zstu1.
TYPES:BEGIN OF ty_final,
zstu_id TYPE zstu-zstu_id,
zstu_name TYPE zstu-zstu_name,
zstu_dep TYPE zstu-zstu_dep,
zstu_fee TYPE zstu-zstu_fee,
zstu_marks TYPE zstu1-zstu_marks,
END OF ty_final.
TYPES: ty_t_f TYPE STANDARD TABLE OF ty_final WITH DEFAULT KEY.
DATA:it_zstu TYPE TABLE OF ty_zstu,
it_zstu1 TYPE TABLE OF ty_zstu1,
it_final TYPE TABLE OF ty_final.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
wa_header TYPE slis_listheader,
it_header TYPE slis_t_listheader..
SELECT-OPTIONS: s_id FOR zstu-zstu_id.
START-OF-SELECTION.
IF s_id IS NOT INITIAL.
SELECT zstu_id
zstu_name
zstu_dep
zstu_fee
FROM zstu
INTO TABLE it_zstu
WHERE zstu_id IN s_id.
SORT it_zstu BY zstu_id.
IF it_zstu IS NOT INITIAL.
SELECT zstu_id
zstu_marks
FROM zstu1
INTO TABLE it_zstu1
WHERE zstu_id IN s_id.
SORT it_zstu1 BY zstu_id.
ENDIF.
ENDIF.
it_final = VALUE ty_t_f(
FOR wa_zstu IN it_zstu
FOR wa_zstu1 IN it_zstu1
WHERE ( zstu_id = wa_zstu-zstu_id )
( zstu_id = wa_zstu1-zstu_id zstu_marks = wa_zstu1-zstu_marks
zstu_name = wa_zstu-zstu_name zstu_dep = wa_zstu-zstu_dep
zstu_fee = wa_zstu-zstu_fee ) ).
wa_fieldcat-col_pos = '1'.
wa_fieldcat-fieldname = 'ZSTU_ID'.
wa_fieldcat-seltext_m = 'STUDENT ID'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-ctabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
clear: wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-fieldname = 'ZSTU_NAME'.
wa_fieldcat-seltext_m = 'STUDENT NAME'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ctabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
clear: wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-fieldname = 'ZSTU_DEP'.
wa_fieldcat-seltext_m = 'STUDENT DEP'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ctabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
clear: wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-fieldname = 'ZSTU_FEE'.
wa_fieldcat-seltext_m = 'STUDENT FEE'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ctabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
clear: wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-fieldname = 'ZSTU_MARKS'.
wa_fieldcat-seltext_m = 'STUDENT MARKS'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ctabname = 'IT_FINAL'.
APPEND wa_fieldcat TO it_fieldcat.
clear: wa_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IT_FIELDCAT = it_fieldcat
TABLES
t_outtab = it_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
form TOP_OF_PAGE.
CLEAR: wa_header.
REFRESH : it_header.
wa_header-typ = 'H'.
wa_header-info = 'Join two tables using updated for loop'.
APPEND wa_header to it_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM.
Input
Output
Comments
Post a Comment