*&---------------------------------------------------------------------*
*& Report Z_ALV_BLOCK_COMPANIES_CUSTOME
*&
*&---------------------------------------------------------------------*
*&
*&Author tech.sap29@gmail.com
*&---------------------------------------------------------------------*
REPORT Z_ALV_BLOCK_COMPANIES_CUSTOME.
TYPE-POOLS SLIS.
DATA : IT_T001 TYPE TABLE OF T001,
IT_KNB1 TYPE TABLE OF KNB1 .
DATA : LIST_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_EVENT TYPE SLIS_T_EVENT .
************************************************
START-OF-SELECTION.
LIST_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
PERFORM READ_DATA.
END-OF-SELECTION.
PERFORM INITIALIZE_ALV_BLOCK.
PERFORM FILL_FIELDCATLOG USING 'IT_T001' 'T001' .
PERFORM APPEND_DATA_TO_ALV_BLOCK USING 'IT_T001' IT_T001.
REFRESH IT_FIELDCAT.
PERFORM FILL_FIELDCATLOG USING 'IT_KNB1' 'KNB1'.
PERFORM APPEND_DATA_TO_ALV_BLOCK USING 'IT_KNB1' IT_KNB1.
PERFORM DISPLAY_ALV.
*&---------------------------------------------------------------------*
*& Form INITIALIZE_ALV_BLOCK
*&---------------------------------------------------------------------*
FORM INITIALIZE_ALV_BLOCK .
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
ENDFORM. " INITIALIZE_ALV_BLOCK
*&---------------------------------------------------------------------*
*& Form FILL_FIELDCATLOG
*&---------------------------------------------------------------------*
FORM FILL_FIELDCATLOG USING FP_ITAB TYPE C
FP_STRUCTURE TYPE C.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = FP_ITAB
I_STRUCTURE_NAME = FP_STRUCTURE
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 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.
ENDFORM. " FILL_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form READ_DATA
*&---------------------------------------------------------------------*
FORM READ_DATA .
SELECT * INTO TABLE IT_T001 FROM T001 UP TO 20 ROWS .
IF NOT IT_T001 IS INITIAL .
SELECT * INTO TABLE IT_KNB1 FROM KNB1 FOR ALL ENTRIES IN IT_T001 WHERE BUKRS = IT_T001-BUKRS .
ENDIF .
ENDFORM. " READ_DATA
*&---------------------------------------------------------------------*
*& Form APPEND_DATA_TO_ALV_BLOCK
*&---------------------------------------------------------------------*
FORM APPEND_DATA_TO_ALV_BLOCK USING FP_TNAM TYPE C
FP_DATA TYPE STANDARD TABLE.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LIST_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_TABNAME = FP_TNAM
IT_EVENTS = IT_EVENT
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = FP_DATA
* 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.
ENDFORM. " APPEND_DATA_TO_ALV_BLOCK
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
FORM DISPLAY_ALV .
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.
ENDFORM. " DISPLAY_ALV
*& Report Z_ALV_BLOCK_COMPANIES_CUSTOME
*&
*&---------------------------------------------------------------------*
*&
*&Author tech.sap29@gmail.com
*&---------------------------------------------------------------------*
REPORT Z_ALV_BLOCK_COMPANIES_CUSTOME.
TYPE-POOLS SLIS.
DATA : IT_T001 TYPE TABLE OF T001,
IT_KNB1 TYPE TABLE OF KNB1 .
DATA : LIST_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_EVENT TYPE SLIS_T_EVENT .
************************************************
START-OF-SELECTION.
LIST_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
PERFORM READ_DATA.
END-OF-SELECTION.
PERFORM INITIALIZE_ALV_BLOCK.
PERFORM FILL_FIELDCATLOG USING 'IT_T001' 'T001' .
PERFORM APPEND_DATA_TO_ALV_BLOCK USING 'IT_T001' IT_T001.
REFRESH IT_FIELDCAT.
PERFORM FILL_FIELDCATLOG USING 'IT_KNB1' 'KNB1'.
PERFORM APPEND_DATA_TO_ALV_BLOCK USING 'IT_KNB1' IT_KNB1.
PERFORM DISPLAY_ALV.
*&---------------------------------------------------------------------*
*& Form INITIALIZE_ALV_BLOCK
*&---------------------------------------------------------------------*
FORM INITIALIZE_ALV_BLOCK .
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
ENDFORM. " INITIALIZE_ALV_BLOCK
*&---------------------------------------------------------------------*
*& Form FILL_FIELDCATLOG
*&---------------------------------------------------------------------*
FORM FILL_FIELDCATLOG USING FP_ITAB TYPE C
FP_STRUCTURE TYPE C.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = FP_ITAB
I_STRUCTURE_NAME = FP_STRUCTURE
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 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.
ENDFORM. " FILL_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form READ_DATA
*&---------------------------------------------------------------------*
FORM READ_DATA .
SELECT * INTO TABLE IT_T001 FROM T001 UP TO 20 ROWS .
IF NOT IT_T001 IS INITIAL .
SELECT * INTO TABLE IT_KNB1 FROM KNB1 FOR ALL ENTRIES IN IT_T001 WHERE BUKRS = IT_T001-BUKRS .
ENDIF .
ENDFORM. " READ_DATA
*&---------------------------------------------------------------------*
*& Form APPEND_DATA_TO_ALV_BLOCK
*&---------------------------------------------------------------------*
FORM APPEND_DATA_TO_ALV_BLOCK USING FP_TNAM TYPE C
FP_DATA TYPE STANDARD TABLE.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LIST_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_TABNAME = FP_TNAM
IT_EVENTS = IT_EVENT
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = FP_DATA
* 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.
ENDFORM. " APPEND_DATA_TO_ALV_BLOCK
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
FORM DISPLAY_ALV .
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.
ENDFORM. " DISPLAY_ALV
No comments:
Post a Comment