Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CALL METHOD GRID4->SET_TABLE_FOR_FIRST_DISPLAY

Hi All,

I would like to know how to display 5 internal table same time in a single output screen. I have attached the program for your reference.

Presently I am able to get i_final1 and i_final2 output on the screen. I need to display on the same screen grid 3 and grid 4. Is it possible to display.

&----


*& REPORT Z_READ_PROFILE

*&

&----


*&

*&

&----


REPORT Z_READ_PROFILE.

TABLES: TCATS, TCATST, TCATX_GRID.

DATA: ST_CT1_FIELDCAT1 TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: IT_CT1_FIELDCAT1 TYPE LVC_T_FCAT.

DATA: ST_CT1_FIELDCAT2 TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: IT_CT1_FIELDCAT2 TYPE LVC_T_FCAT.

DATA: ST_CT1_FIELDCAT3 TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: IT_CT1_FIELDCAT3 TYPE LVC_T_FCAT.

DATA: ST_CT1_FIELDCAT4 TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: IT_CT1_FIELDCAT4 TYPE LVC_T_FCAT.

DATA: DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER,

SPLIT TYPE REF TO CL_GUI_SPLITTER_CONTAINER,

GRID1 TYPE REF TO CL_GUI_ALV_GRID,

GRID2 TYPE REF TO CL_GUI_ALV_GRID,

GRID3 TYPE REF TO CL_GUI_ALV_GRID,

GRID4 TYPE REF TO CL_GUI_ALV_GRID,

DOC1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,

DOC3 TYPE REF TO CL_GUI_DOCKING_CONTAINER,

DOC4 TYPE REF TO CL_GUI_DOCKING_CONTAINER,

CON22 TYPE REF TO CL_GUI_DOCKING_CONTAINER,

LI_FIELDCAT1 TYPE LVC_T_FCAT.

SELECTION-SCREEN: BEGIN OF BLOCK B1.

PARAMETERS: P_PROF1 LIKE TCATS-VARIANT,

P_PROF2 LIKE TCATS-VARIANT.

SELECTION-SCREEN: END OF BLOCK B1.

DATA: BEGIN OF I_DD03P OCCURS 0.

INCLUDE STRUCTURE DD03P.

DATA: END OF I_DD03P.

DATA: BEGIN OF I_FIELDS1 OCCURS 0,

PROFILE LIKE TCATS-VARIANT,

MFIELD TYPE FAWFLDNAM,

INPUT LIKE RSFAC-INPUT,

OBLIGAT LIKE RSFAC-OBLIGAT,

DISPLAY LIKE RSFAC-DISPLAY,

NOTACT LIKE RSFAC-NOTACT,

END OF I_FIELDS1.

DATA: BEGIN OF I_FIELDS2 OCCURS 0,

PROFILE LIKE TCATS-VARIANT,

MFIELD TYPE FAWFLDNAM,

INPUT LIKE RSFAC-INPUT,

OBLIGAT LIKE RSFAC-OBLIGAT,

DISPLAY LIKE RSFAC-DISPLAY,

NOTACT LIKE RSFAC-NOTACT,

END OF I_FIELDS2.

DATA: BEGIN OF I_FINAL1 OCCURS 0,

PROFILE LIKE TCATS-VARIANT,

TEXT LIKE TCATST-TEXT,

MFIELD TYPE FAWFLDNAM,

INPUT LIKE RSFAC-INPUT,

OBLIGAT LIKE RSFAC-OBLIGAT,

DISPLAY LIKE RSFAC-DISPLAY,

NOTACT LIKE RSFAC-NOTACT,

END OF I_FINAL1.

DATA: BEGIN OF I_FINAL2 OCCURS 0,

PROFILE LIKE TCATS-VARIANT,

TEXT LIKE TCATST-TEXT,

MFIELD TYPE FAWFLDNAM,

INPUT LIKE RSFAC-INPUT,

OBLIGAT LIKE RSFAC-OBLIGAT,

DISPLAY LIKE RSFAC-DISPLAY,

NOTACT LIKE RSFAC-NOTACT,

END OF I_FINAL2.

DATA: BEGIN OF ENTRYLIST OCCURS 0,

MFELD TYPE FAWFLDNAM,

VISIBLE TYPE FAWCUST,

REQUIRED TYPE FAWCUST,

READONLY TYPE FAWCUST,

HIDE TYPE FAWCUST,

PROF1 LIKE TCATS-VARIANT,

END OF ENTRYLIST.

DATA: BEGIN OF WORKLIST OCCURS 0.

INCLUDE STRUCTURE FIELD_SELECTION.

DATA: END OF WORKLIST.

DATA: BEGIN OF I_TCATX_GRID1 OCCURS 0,

PROFIL LIKE TCATX_GRID-PROFIL,

TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,

COL LIKE TCATX_GRID-COL,

OBLIGAT LIKE TCATX_GRID-OBLIGAT,

END OF I_TCATX_GRID1.

DATA: BEGIN OF I_TCATX_GRID2 OCCURS 0,

PROFIL LIKE TCATX_GRID-PROFIL,

TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,

COL LIKE TCATX_GRID-COL,

OBLIGAT LIKE TCATX_GRID-OBLIGAT,

END OF I_TCATX_GRID2.

  • PERFORM STATEMENT TO GET THE DATA BASED ON PORIFLE

IF NOT P_PROF1 IS INITIAL .

PERFORM GET_FIELDS1.

PERFORM GET_COMPONENTS1.

ENDIF.

IF NOT P_PROF1 IS INITIAL .

PERFORM GET_FIELDS2.

PERFORM GET_COMPONENTS2.

ENDIF.

PERFORM COMPARE_TABLES.

CALL SCREEN 100.

&----


*& FORM GET_FIELDS

&----


  • TEXT

----


  • --> P1 TEXT

  • <-- P2 TEXT

----


FORM GET_FIELDS1.

CLEAR : ENTRYLIST, WORKLIST.

REFRESH: ENTRYLIST, WORKLIST.

CALL FUNCTION 'CATS_GET_INFLUENCES'

EXPORTING

VARIANT = P_PROF1

TABLES

ENTRYLIST_SELECTION = ENTRYLIST

WORKLIST_SELECTION = WORKLIST

.

IF SY-SUBRC EQ 0.

LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE

AND REQUIRED EQ SPACE

AND READONLY EQ SPACE.

MOVE 'X' TO ENTRYLIST-HIDE.

MODIFY ENTRYLIST TRANSPORTING HIDE.

ENDLOOP.

LOOP AT ENTRYLIST.

MOVE P_PROF1 TO I_FIELDS1-PROFILE.

MOVE ENTRYLIST-MFELD TO I_FIELDS1-MFIELD.

IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .

MOVE ENTRYLIST-VISIBLE TO I_FIELDS1-INPUT.

ENDIF.

MOVE ENTRYLIST-REQUIRED TO I_FIELDS1-OBLIGAT.

MOVE ENTRYLIST-READONLY TO I_FIELDS1-DISPLAY.

MOVE ENTRYLIST-HIDE TO I_FIELDS1-NOTACT.

APPEND I_FIELDS1.

ENDLOOP.

ENDIF.

ENDFORM. " GET_FIELDS

&----


*& FORM GET_FIELDS2

&----


  • TEXT

----


  • --> P1 TEXT

  • <-- P2 TEXT

----


FORM GET_FIELDS2 .

CLEAR : ENTRYLIST, WORKLIST.

REFRESH: ENTRYLIST, WORKLIST.

CALL FUNCTION 'CATS_GET_INFLUENCES'

EXPORTING

VARIANT = P_PROF2

TABLES

ENTRYLIST_SELECTION = ENTRYLIST

WORKLIST_SELECTION = WORKLIST

.

IF SY-SUBRC EQ 0.

LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE

AND REQUIRED EQ SPACE

AND READONLY EQ SPACE.

MOVE 'X' TO ENTRYLIST-HIDE.

MODIFY ENTRYLIST TRANSPORTING HIDE.

ENDLOOP.

LOOP AT ENTRYLIST.

MOVE P_PROF2 TO I_FIELDS2-PROFILE.

MOVE ENTRYLIST-MFELD TO I_FIELDS2-MFIELD.

IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .

MOVE ENTRYLIST-VISIBLE TO I_FIELDS2-INPUT.

ENDIF.

MOVE ENTRYLIST-REQUIRED TO I_FIELDS2-OBLIGAT.

MOVE ENTRYLIST-READONLY TO I_FIELDS2-DISPLAY.

MOVE ENTRYLIST-HIDE TO I_FIELDS2-NOTACT.

APPEND I_FIELDS2.

ENDLOOP.

ENDIF.

ENDFORM. " GET_FIELDS2

&----


*& FORM COMPARE_TABLES

&----


  • TEXT

----


  • --> P1 TEXT

  • <-- P2 TEXT

----


FORM COMPARE_TABLES .

CLEAR: I_FIELDS1, I_FIELDS2.

SORT : I_FIELDS1, I_FIELDS2.

DATA: L_TABLE LIKE DD03L-TABNAME,

L_FIELD LIKE DD03L-FIELDNAME.

LOOP AT I_FIELDS1.

READ TABLE I_FIELDS2 WITH KEY MFIELD = I_FIELDS1-MFIELD

INPUT = I_FIELDS1-INPUT

OBLIGAT = I_FIELDS1-OBLIGAT

DISPLAY = I_FIELDS1-DISPLAY

NOTACT = I_FIELDS1-NOTACT.

IF SY-SUBRC NE 0.

MOVE I_FIELDS1-PROFILE TO I_FINAL1-PROFILE.

SPLIT I_FIELDS1-MFIELD AT '-' INTO L_TABLE L_FIELD.

CALL FUNCTION 'BUS_DDFIELD_GET'

EXPORTING

I_TABNM = L_TABLE

I_FLDNM = L_FIELD

I_LANGU = SY-LANGU

IMPORTING

E_DD03P = I_DD03P

EXCEPTIONS

FIELD_NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC EQ 0.

MOVE I_DD03P-DDTEXT TO I_FINAL1-TEXT.

ENDIF.

MOVE I_FIELDS1-MFIELD TO I_FINAL1-MFIELD.

MOVE I_FIELDS1-INPUT TO I_FINAL1-INPUT.

MOVE I_FIELDS1-OBLIGAT TO I_FINAL1-OBLIGAT.

MOVE I_FIELDS1-DISPLAY TO I_FINAL1-DISPLAY.

MOVE I_FIELDS1-NOTACT TO I_FINAL1-NOTACT.

APPEND I_FINAL1.

ENDIF.

ENDLOOP.

SORT : I_FIELDS1, I_FIELDS2.

LOOP AT I_FIELDS2.

READ TABLE I_FIELDS1 WITH KEY MFIELD = I_FIELDS2-MFIELD

INPUT = I_FIELDS2-INPUT

OBLIGAT = I_FIELDS2-OBLIGAT

DISPLAY = I_FIELDS2-DISPLAY

NOTACT = I_FIELDS2-NOTACT.

IF SY-SUBRC NE 0.

MOVE I_FIELDS2-PROFILE TO I_FINAL2-PROFILE.

SPLIT I_FIELDS2-MFIELD AT '-' INTO L_TABLE L_FIELD.

CALL FUNCTION 'BUS_DDFIELD_GET'

EXPORTING

I_TABNM = L_TABLE

I_FLDNM = L_FIELD

I_LANGU = SY-LANGU

IMPORTING

E_DD03P = I_DD03P

EXCEPTIONS

FIELD_NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC EQ 0.

MOVE I_DD03P-DDTEXT TO I_FINAL2-TEXT.

ENDIF.

MOVE I_FIELDS2-MFIELD TO I_FINAL2-MFIELD.

MOVE I_FIELDS2-INPUT TO I_FINAL2-INPUT.

MOVE I_FIELDS2-OBLIGAT TO I_FINAL2-OBLIGAT.

MOVE I_FIELDS2-DISPLAY TO I_FINAL2-DISPLAY.

MOVE I_FIELDS2-NOTACT TO I_FINAL2-NOTACT.

APPEND I_FINAL2.

ENDIF.

ENDLOOP.

ENDFORM. " COMPARE_TABLES

&----


*& MODULE STATUS_0100 OUTPUT

&----


  • TEXT

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS SPACE.

SET TITLEBAR 'T001'.

PERFORM FIELDCAT_FINAL1.

PERFORM FIELDCAT_FINAL2.

CREATE OBJECT DOCK

EXPORTING

REPID = SY-REPID

DYNNR = '100'

EXTENSION = '600'

SIDE = '1'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6

.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT DOC1

EXPORTING

REPID = SY-REPID

DYNNR = '100'

EXTENSION = '1000'

SIDE = '4'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6

.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID1 EXPORTING I_PARENT = DOCK.

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'I_FINAL1'

CHANGING

IT_OUTTAB = I_FINAL1[]

IT_FIELDCATALOG = IT_CT1_FIELDCAT1[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID2 EXPORTING I_PARENT = DOC1.

CALL METHOD GRID2->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'I_FINAL2'

CHANGING

IT_OUTTAB = I_FINAL2[]

IT_FIELDCATALOG = IT_CT1_FIELDCAT2[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

***********************************************************************

CREATE OBJECT DOC3

EXPORTING

REPID = SY-REPID

DYNNR = '100'

EXTENSION = '600'

SIDE = '1'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6

.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT DOC4

EXPORTING

REPID = SY-REPID

DYNNR = '100'

EXTENSION = '1000'

SIDE = '4'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6

.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID3 EXPORTING I_PARENT = DOC3.

CALL METHOD GRID3->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'TCATX_GRID'

CHANGING

IT_OUTTAB = I_TCATX_GRID1[]

  • IT_FIELDCATALOG = IT_CT1_FIELDCAT1[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID4 EXPORTING I_PARENT = DOC4.

CALL METHOD GRID4->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'TCATX_GRID'

CHANGING

IT_OUTTAB = I_TCATX_GRID2[]

  • IT_FIELDCATALOG = IT_CT1_FIELDCAT2[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& MODULE USER_COMMAND_0100 INPUT

&----


  • TEXT

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& FORM FIELDCAT_FINAL1

&----


  • TEXT

----


  • --> P1 TEXT

  • <-- P2 TEXT

----


FORM FIELDCAT_FINAL1 .

IF IT_CT1_FIELDCAT1[] IS INITIAL.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'PROFILE'.

ST_CT1_FIELDCAT1-COL_POS = 0.

ST_CT1_FIELDCAT1-OUTPUTLEN = 8.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'PROFILE'.

ST_CT1_FIELDCAT1-KEY = 'X'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'MFIELD'.

ST_CT1_FIELDCAT1-COL_POS = 1.

ST_CT1_FIELDCAT1-OUTPUTLEN = 15.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'FIELD'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'TEXT'.

ST_CT1_FIELDCAT1-COL_POS = 1.

ST_CT1_FIELDCAT1-OUTPUTLEN = 30.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'TEXT'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'INPUT'.

ST_CT1_FIELDCAT1-COL_POS = 2.

ST_CT1_FIELDCAT1-OUTPUTLEN = 2.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'INPUT'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'OBLIGAT'.

ST_CT1_FIELDCAT1-COL_POS = 2.

ST_CT1_FIELDCAT1-OUTPUTLEN = 2.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'REQUIRED'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'DISPLAY'.

ST_CT1_FIELDCAT1-COL_POS = 2.

ST_CT1_FIELDCAT1-OUTPUTLEN = 2.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'DISPLAY'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT1-FIELDNAME = 'NOTACT'.

ST_CT1_FIELDCAT1-COL_POS = 2.

ST_CT1_FIELDCAT1-OUTPUTLEN = 2.

ST_CT1_FIELDCAT1-SCRTEXT_L = 'HIDE'.

APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.

CLEAR ST_CT1_FIELDCAT1.

ENDIF.

ENDFORM. " FIELDCAT_FINAL1

&----


*& FORM FIELDCAT_FINAL2

&----


  • TEXT

----


  • --> P1 TEXT

  • <-- P2 TEXT

----


FORM FIELDCAT_FINAL2 .

IF IT_CT1_FIELDCAT2[] IS INITIAL.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'PROFILE'.

ST_CT1_FIELDCAT2-COL_POS = 0.

ST_CT1_FIELDCAT2-OUTPUTLEN = 8.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'PROFILE'.

ST_CT1_FIELDCAT2-KEY = 'X'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'MFIELD'.

ST_CT1_FIELDCAT2-COL_POS = 1.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'FIELD'.

ST_CT1_FIELDCAT2-OUTPUTLEN = 15.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'TEXT'.

ST_CT1_FIELDCAT2-COL_POS = 1.

ST_CT1_FIELDCAT2-OUTPUTLEN = 30.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'TEXT'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'INPUT'.

ST_CT1_FIELDCAT2-COL_POS = 2.

ST_CT1_FIELDCAT2-OUTPUTLEN = 2.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'INPUT'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'OBLIGAT'.

ST_CT1_FIELDCAT2-COL_POS = 2.

ST_CT1_FIELDCAT2-OUTPUTLEN = 2.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'REQUIRED'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL1'.

ST_CT1_FIELDCAT2-FIELDNAME = 'DISPLAY'.

ST_CT1_FIELDCAT2-COL_POS = 2.

ST_CT1_FIELDCAT2-OUTPUTLEN = 2.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'DISPLAY'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.

ST_CT1_FIELDCAT2-FIELDNAME = 'NOTACT'.

ST_CT1_FIELDCAT2-COL_POS = 2.

ST_CT1_FIELDCAT2-OUTPUTLEN = 2.

ST_CT1_FIELDCAT2-SCRTEXT_L = 'HIDE'.

APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.

CLEAR ST_CT1_FIELDCAT2.

ENDIF.

ENDFORM. " FIELDCAT_FINAL2

&----


*& Form GET_COMPONENTS1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_COMPONENTS1 .

CLEAR : I_TCATX_GRID1.

REFRESH: I_TCATX_GRID1.

SELECT * FROM TCATX_GRID

INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID1

WHERE PROFIL EQ P_PROF1.

ENDFORM. " GET_COMPONENTS1

&----


*& Form GET_COMPONENTS2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_COMPONENTS2 .

CLEAR : I_TCATX_GRID2.

REFRESH: I_TCATX_GRID2.

SELECT * FROM TCATX_GRID

INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID2

WHERE PROFIL EQ P_PROF2.

ENDFORM. " GET_COMPONENTS2

Thanks & Regards,

Nagaraj Kalbavi

replied

Hello Najaraj

I have extended the sample report to display 4 ALV lists ( ZUS_SDN_FOUR_ALV_GRIDS ). As you can see it is quite simple to extend the number of displayed ALV grids.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_FOUR_ALV_GRIDS
*&
*&---------------------------------------------------------------------*
*& Thread: CALL METHOD GRID4->SET_TABLE_FOR_FIRST_DISPLAY
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1036217"></a>
*&---------------------------------------------------------------------*
*& Display Sales Order data in four ALV lists:
*& 1st ALV: Sales Orders (double-click => items & customer)
*& 2nd ALV: Positions   of selected sales order (double-click)
*&          Double-click on material -> display material (MM02)
*& 3rd ALV: Customer (double-click => sales areas)
*& 4th ALV: Sales areas of customer
*&---------------------------------------------------------------------*

REPORT  ZUS_SDN_FOUR_ALV_GRIDS.

TYPE-POOLS: abap.

TABLES: vbak.


DATA:
  gd_okcode        TYPE ui_func,
*
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_splitter      TYPE REF TO cl_gui_splitter_container,
  go_splitter_2    TYPE REF TO cl_gui_splitter_container,
  go_splitter_3    type ref to cl_gui_splitter_container,
  go_cell_2_top      TYPE REF TO cl_gui_container,
  go_cell_2_bottom   TYPE REF TO cl_gui_container,
  go_cell_3_top      TYPE REF TO cl_gui_container,
  go_cell_3_bottom   TYPE REF TO cl_gui_container,
  go_cell_left     TYPE REF TO cl_gui_container,
  go_cell_right    TYPE REF TO cl_gui_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid,
  go_grid3         TYPE REF TO cl_gui_alv_grid,
  go_grid4         type ref to cl_gui_alv_grid.


DATA:
  gt_kna1          TYPE STANDARD TABLE OF kna1,
  gt_knvv          type STANDARD TABLE OF knvv,
  gt_vbak          TYPE STANDARD TABLE OF vbak,
  gt_vbap          TYPE STANDARD TABLE OF vbap.




SELECT-OPTIONS:
  s_vbeln     FOR vbak-vbeln.



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.

  PUBLIC SECTION.
    CLASS-METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING
          e_row
          e_column
          es_row_no
          sender.  " sending control, i.e. ALV grid that raised event


ENDCLASS.                    "lcl_eventhandler DEFINITION



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_double_click.
*   define local data
    DATA:
      ls_kna1      TYPE kna1,
      ls_vbak      TYPE vbak,
      ls_vbap      TYPE vbap.


*   Distinguish according to sending grid instance
    CASE sender.
**      WHEN go_grid1.
**        READ TABLE gt_kna1 INTO ls_kna1 INDEX e_row-index.
**        CHECK ( ls_kna1-kunnr IS NOT INITIAL ).
**
**        CALL METHOD go_grid1->set_current_cell_via_id
**          EXPORTING
***              IS_ROW_ID    =
***              IS_COLUMN_ID =
**            is_row_no    = es_row_no.


*         Triggers PAI of the dynpro with the specified ok-code
**        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDERS' ).


      WHEN go_grid1.
        READ TABLE gt_vbak INTO ls_vbak INDEX e_row-index.
        CHECK ( ls_vbak-vbeln IS NOT INITIAL ).

*       Triggers PAI of the dynpro with the specified ok-code
        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).



      WHEN go_grid2.
        READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
        CHECK ( ls_vbap-matnr IS NOT INITIAL ).

        SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
        CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

      WHEN go_grid3.
*       Triggers PAI of the dynpro with the specified ok-code
        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'CUSTOMER_DETAILS' ).

      WHEN OTHERS.
        RETURN.
    ENDCASE.







  ENDMETHOD.                    "handle_double_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION






START-OF-SELECTION.

  IF ( s_vbeln[] IS INITIAL ).
    SELECT        * FROM  vbak INTO TABLE gt_vbak UP TO 500 ROWS.
  ELSE.
    SELECT        * FROM  vbak INTO TABLE gt_vbak
           WHERE  vbeln IN s_vbeln.
  ENDIF.

  perform INIT_CONTROLS.








* Set event handler
  SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
  SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
  SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.


* Display data
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'VBAK'
    CHANGING
      it_outtab        = gt_vbak
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  REFRESH: gt_vbap.
  CALL METHOD go_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'VBAP'
    CHANGING
      it_outtab        = gt_vbap    " empty !!!
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  REFRESH: gt_kna1.
  CALL METHOD go_grid3->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNA1'
    CHANGING
      it_outtab        = gt_kna1    " empty !!!
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  REFRESH: gt_knvv.
  CALL METHOD go_grid4->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNVV'
    CHANGING
      it_outtab        = gt_knvv    " empty !!!
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
  CALL SCREEN '0100'.
* Flow logic of dynpro:
*
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.



END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.  " contains push button "ORDERS"
*  SET TITLEBAR 'xxx'.


* Refresh display of detail ALV list
  CALL METHOD go_grid2->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      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.


* Refresh display of detail ALV list
  CALL METHOD go_grid3->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      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.


  CALL METHOD go_grid4->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      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.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

*   User has pushed button "Display Orders"
    WHEN 'ORDERS'.
      PERFORM customer_show_orders.

    WHEN 'ORDER_DETAILS'.
      PERFORM order_show_details.

    WHEN 'CUSTOMER_DETAILS'.
      PERFORM customer_show_details.
    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form INIT_CONTROLS .

* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent = cl_gui_container=>screen0
      ratio  = 90
    EXCEPTIONS
      OTHERS = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Create splitter container
  CREATE OBJECT go_splitter
    EXPORTING
      parent            = go_docking
      rows              = 1
      columns           = 2
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_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.

* Get cell container
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_left.
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 2
    RECEIVING
      container = go_cell_right.

* Create 2nd splitter container
  CREATE OBJECT go_splitter_2
    EXPORTING
      parent            = go_cell_left
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_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.

* Get cell container
  CALL METHOD go_splitter_2->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_2_top.
  CALL METHOD go_splitter_2->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_2_bottom.


* Create 3nd splitter container
  CREATE OBJECT go_splitter_3
    EXPORTING
      parent            = go_cell_right
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_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.

* Get cell container
  CALL METHOD go_splitter_3->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_3_top.
  CALL METHOD go_splitter_3->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_3_bottom.



* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent = go_cell_2_top
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  CREATE OBJECT go_grid2
    EXPORTING
      i_parent = go_cell_2_bottom
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CREATE OBJECT go_grid3
    EXPORTING
      i_parent = go_cell_3_top
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CREATE OBJECT go_grid4
    EXPORTING
      i_parent = go_cell_3_bottom
    EXCEPTIONS
      OTHERS   = 5.
  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.                    " INIT_CONTROLS


*&---------------------------------------------------------------------*
*&      Form  CUSTOMER_SHOW_ORDERS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM customer_show_orders .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_kna1     TYPE kna1.

  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.

  READ TABLE gt_kna1 INTO ls_kna1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).

  SELECT        * FROM  vbak INTO TABLE gt_vbak
         WHERE  kunnr  = ls_kna1-kunnr.


  REFRESH: gt_vbap.




ENDFORM.                    " CUSTOMER_SHOW_ORDERS

*&---------------------------------------------------------------------*
*&      Form  ORDER_SHOW_DETAILS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM order_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_vbak     TYPE vbak.

  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.

  READ TABLE gt_vbak INTO ls_vbak INDEX ld_row.
  CHECK ( syst-subrc = 0 ).

  refresh: gt_vbap.
  SELECT        * FROM  vbap INTO TABLE gt_vbap
         WHERE  vbeln  = ls_vbak-vbeln.

    refresh: gt_kna1.
    select * from kna1 into table gt_kna1
        where kunnr = ls_vbak-kunnr.



ENDFORM.                    " ORDER_SHOW_DETAILS


*&---------------------------------------------------------------------*
*&      Form  customer_show_details
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form customer_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_kna1     TYPE kna1.

  CALL METHOD go_grid3->get_current_cell
    IMPORTING
      e_row = ld_row.

  READ TABLE gt_kna1 INTO ls_kna1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).

  refresh: gt_knvv.
  SELECT        * FROM  knvv INTO TABLE gt_knvv
         WHERE  kunnr = ls_kna1-kunnr.


endform.                    " customer_show_details

Regards

Uwe

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question