TABLES: pa0001 , pa0002.
TYPE-POOLS: slis.
SELECT-OPTIONS: pernr FOR pa0002-pernr.
DATA: repid TYPE sy-repid,
it_fcat_1 TYPE slis_t_fieldcat_alv,
it_fcat_2 TYPE slis_t_fieldcat_alv,
wa_fcat_1 TYPE slis_fieldcat_alv,
wa_fcat_2 TYPE slis_fieldcat_alv,
R_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT,
t0001 TYPE TABLE OF pa0001,
t0002 TYPE TABLE OF pa0002,
wa0001 TYPE pa0001,
wa0002 TYPE pa0002.
repid = sy-repid.
wa_fcat_1-COL_POS = 1.
wa_fcat_1-FIELDNAME = 'PERNR'.
wa_fcat_1-seltext_m = 'Personnel number'.
wa_fcat_1-REF_TABNAME = 'T0001'.
APPEND wa_fcat_1 TO it_fcat_1.
CLEAR wa_fcat_1.
wa_fcat_1-COL_POS = 2.
wa_fcat_1-FIELDNAME = 'BUKRS'.
wa_fcat_1-seltext_m = 'Company code'.
wa_fcat_1-REF_TABNAME = 'T0001'.
APPEND wa_fcat_1 TO it_fcat_1.
CLEAR wa_fcat_1.
wa_fcat_1-COL_POS = 3.
wa_fcat_1-FIELDNAME = 'WERKS'.
wa_fcat_1-seltext_m = 'Personal area'.
wa_fcat_1-REF_TABNAME = 'T0001'.
APPEND wa_fcat_1 TO it_fcat_1.
CLEAR wa_fcat_1.
wa_fcat_1-COL_POS = 4.
wa_fcat_1-FIELDNAME = 'PERSG'.
wa_fcat_1-seltext_m = 'Emp grp'.
wa_fcat_1-REF_TABNAME = 'T0001'.
APPEND wa_fcat_1 TO it_fcat_1.
CLEAR wa_fcat_1.
wa_fcat_1-COL_POS = 5.
wa_fcat_1-FIELDNAME = 'PERSK'.
wa_fcat_1-seltext_m = 'Emp sub grp'.
wa_fcat_1-REF_TABNAME = 'T0001'.
APPEND wa_fcat_1 TO it_fcat_1.
CLEAR wa_fcat_1.
wa_fcat_2-COL_POS = 1.
wa_fcat_2-FIELDNAME = 'PERNR'.
wa_fcat_2-seltext_m = 'Personnel number'.
wa_fcat_2-REF_TABNAME = 'T0002'.
APPEND wa_fcat_2 TO it_fcat_2.
CLEAR wa_fcat_2.
wa_fcat_2-COL_POS = 2.
wa_fcat_2-FIELDNAME = 'NACHN'.
wa_fcat_2-seltext_m = 'Last name'.
wa_fcat_2-REF_TABNAME = 'T0002'.
APPEND wa_fcat_2 TO it_fcat_2.
CLEAR wa_fcat_2.
wa_fcat_2-COL_POS = 3.
wa_fcat_2-FIELDNAME = 'VORNA'.
wa_fcat_2-seltext_m = 'First name'.
wa_fcat_2-REF_TABNAME = 'T0002'.
APPEND wa_fcat_2 TO it_fcat_2.
CLEAR wa_fcat_2.
wa_fcat_2-COL_POS = 4.
wa_fcat_2-FIELDNAME = 'GBDAT'.
wa_fcat_2-seltext_m = 'DOB'.
wa_fcat_2-REF_TABNAME = 'T0002'.
APPEND wa_fcat_2 TO it_fcat_2.
CLEAR wa_fcat_2.
wa_fcat_2-COL_POS = 5.
wa_fcat_2-FIELDNAME = 'NATIO'.
wa_fcat_2-seltext_m = 'Nationality'.
wa_fcat_2-REF_TABNAME = 'T0002'.
APPEND wa_fcat_2 TO it_fcat_2.
CLEAR wa_fcat_2.
WA_EVENTS-FORM = 'TOP_PAGE'.
WA_EVENTS-NAME = 'TOP_OF_PAGE'.
APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = repid.
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING = .
select * from pa0001 into table t0001 where pernr in pernr.
select * from pa0002 into table t0002 where pernr in pernr.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = r_layout
it_fieldcat = it_fcat_1[]
i_tabname = 'P0001'
it_events = it_events[]
* IT_SORT =
* I_TEXT = ' '
tables
t_outtab = t0001
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = r_layout
it_fieldcat = it_fcat_2
i_tabname = 'P0002'
it_events = it_events[]
* IT_SORT =
* I_TEXT = ' '
tables
t_outtab = t0002
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* IS_PRINT =
* 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 =
* 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.
FORM TOP_PAGE.
WRITE:/ 'THIS IS BLOCKED ALV REPORT PROGRAM BASED ON 2 BLOCKS' COLOR 2.
ENDFORM.
Serkan AKKAVAK
Computer Engineer BSc
SAP Department Manager
Contact : serkurumsal@yandex.com
0 Comments