Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

multiple ALV'S

Vijay
Active Contributor
0 Likes
614

hi all,

i have ar equiremaent where i need to show three different blocks in alv and the same using oops.

how can i achive this.

The layout should look like this:

________________________________________________

TOP OF PAGE HAVING DETAILS

________________________________________________

CURRENT DATA

_________________________________________________

_____

______

____________

____________

__________

_____

______

____________

____________

__________

CALCULATED DATA

_________________________________________________

_____

______

____________

____________

__________

_____

______

____________

____________

__________

REVIEWED DATA

_________________________________________________

_____

______

____________

____________

__________

_____

______

____________

____________

__________

any sample code will be very helpful.

regards

vijay

5 REPLIES 5
Read only

p291102
Active Contributor
0 Likes
585

Hi,

REPORT YMS_BLOCKALV.

TYPE-POOLS : SLIS.

TABLES : MARA,MAKT.

SELECT-OPTIONS : MAT FOR MARA-MATNR.

DATA : BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MAKTX LIKE MAKT-MAKTX,

MATKL LIKE MARA-MATKL,

MTART LIKE MARA-MTART,

END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 0,

MTART LIKE MARA-MTART,

COUNT TYPE I,

END OF ITAB1.

DATA : BEGIN OF ITAB1_COL OCCURS 0,

MTART LIKE MARA-MTART,

COUNT TYPE I,

END OF ITAB1_COL.

DATA : T_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,

T_FCAT2 TYPE SLIS_T_FIELDCAT_ALV,

WA_FCAT TYPE SLIS_FIELDCAT_ALV,

T_EVE TYPE SLIS_T_EVENT,

WA_EVE TYPE SLIS_ALV_EVENT,

T_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : V_REPID LIKE SY-REPID,

T_MAT LIKE MARA-MATNR.

DEFINE CREATE_FCAT.

CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = &1.

WA_FCAT-SELTEXT_L = &2.

WA_FCAT-OUTPUTLEN = &3.

APPEND WA_FCAT TO T_FCAT1.

END-OF-DEFINITION.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM DIS_DATA.

&----


*& Form get_data

&----


  • text

----


FORM GET_DATA.

SELECT AMATNR BMAKTX AMTART AMATKL INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM MARA AS A INNER JOIN MAKT AS B ON

AMATNR = BMATNR

WHERE A~MATNR IN MAT.

LOOP AT ITAB.

ITAB1-MTART = ITAB-MTART.

ITAB1-COUNT = 1.

APPEND ITAB1.

ENDLOOP.

SORT ITAB1 BY MTART.

LOOP AT ITAB1.

MOVE-CORRESPONDING ITAB1 TO ITAB1_COL.

COLLECT ITAB1_COL.

ENDLOOP.

ENDFORM. "get_data

&----


*& Form dis_data

&----


  • text

----


FORM DIS_DATA.

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID.

REFRESH T_FCAT1.

CLEAR T_FCAT1.

REFRESH T_EVE.

WA_EVE-NAME = 'TOP_OF_PAGE'.

WA_EVE-FORM = 'TOP_OF_PAGE1'.

APPEND WA_EVE TO T_EVE.

CREATE_FCAT:

'MATNR' 'Material' '10',

'MAKTX' 'Material Description' '40',

'MTART' 'Type' '10',

'MATKL' 'Group' '10'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = T_LAYOUT

IT_FIELDCAT = T_FCAT1

I_TABNAME = 'ITAB'

IT_EVENTS = T_EVE

TABLES

T_OUTTAB = ITAB.

REFRESH T_FCAT1.

CLEAR T_FCAT1.

REFRESH T_EVE.

WA_EVE-NAME = 'TOP_OF_PAGE'.

WA_EVE-FORM = 'TOP_OF_PAGE2'.

APPEND WA_EVE TO T_EVE.

CREATE_FCAT:

'MTART' 'Type' '10',

'COUNT' 'Total' '5'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = T_LAYOUT

IT_FIELDCAT = T_FCAT1

I_TABNAME = 'ITAB1_COL'

IT_EVENTS = T_EVE

TABLES

T_OUTTAB = ITAB1_COL.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

ENDFORM. "dis_data

&----


*& Form top_of_page1

&----


  • text

----


FORM TOP_OF_PAGE1.

FORMAT COLOR COL_POSITIVE.

WRITE:/ 'First Block'.

FORMAT COLOR OFF.

ENDFORM. "top_of_page

&----


*& Form top_of_page2

&----


  • text

----


FORM TOP_OF_PAGE2.

FORMAT COLOR COL_NEGATIVE.

WRITE /5 'Second Block'.

FORMAT COLOR OFF.

ENDFORM. "top_of_page

Thanks,

Sankar M

Read only

Former Member
0 Likes
585

HI Vijay ,

If you are implementing the ALV using OOPS concept then you can use the concept of splitters . In splitters what you do is split the custom container in a number of containers where grids can then be assigned.

Please check the detailed help on Splitters for more info.

Hope this helps.

Regards

Arun

Read only

RaymondGiuseppi
Active Contributor
0 Likes
585

In your dynpro create three container.

Fill your three internal table and map each container to one alv grid.

DATA: cont01 TYPE REF TO cl_gui_custom_container,
      grid01 TYPE REF TO cl_gui_alv_grid,
      cont02 TYPE REF TO cl_gui_custom_container,
      grid02 TYPE REF TO cl_gui_alv_grid,
      cont03 TYPE REF TO cl_gui_custom_container,
      grid03 TYPE REF TO cl_gui_alv_grid.

* Do three create objects
    CREATE OBJECT: cont01 EXPORTING container_name = 'CONT01',
                   grid01 EXPORTING i_parent = cont01,
                   cont02 EXPORTING container_name = 'CONT02',
                   grid02 EXPORTING i_parent = cont02,   
                   cont03 EXPORTING container_name = 'CONT03',
                   grid03 EXPORTING i_parent = cont03.

* And three first display of alv grid
    CALL METHOD grid01->set_table_for_first_display
      EXPORTING
        i_structure_name = 'XXXX'
        is_layout = is_layout
        is_variant = is_variant
        i_save = 'A'
        i_default = 'X'
      CHANGING
        it_outtab = itab01.

Also don't forget to pass "dummy" program name to is_variant if you want to maitain display variants for each grid.

Regards

Read only

Former Member
0 Likes
585

hi,

You can create ALV using Custom Control in your Screen painter. I am providing u with a sample cdo ask me if u have any doubts...

**********data declaration**************

DATA: grid1 TYPE REF TO cl_gui_alv_grid, " Custom Control1 declaration

g_cust_cont1 TYPE REF TO cl_gui_custom_container, "Container1 declaration

g_cont1 TYPE scrfname VALUE 'GRID1',

ls_exclude1 TYPE ui_func, "For Excluding Buttons

lt_exclude1 TYPE ui_functions,

gs_fcat1 TYPE lvc_s_fcat, "Field catalogue

gt_fcat1 TYPE lvc_t_fcat,

gs_lay1 TYPE lvc_s_layo,

ls_celltab1 TYPE lvc_s_styl,

lt_celltab1 TYPE lvc_t_styl,

gd_maint1 TYPE syinput.

DATA: grid2 TYPE REF TO cl_gui_alv_grid, " Custom Control1 declaration

g_cust_cont2 TYPE REF TO cl_gui_custom_container, "Container1 declaration

g_cont2 TYPE scrfname VALUE 'GRID1',

ls_exclude2 TYPE ui_func, " For Excluding Buttons

lt_exclude2 TYPE ui_functions,

gs_fcat2 TYPE lvc_s_fcat, "Field catalogue

gt_fcat2 TYPE lvc_t_fcat,

gs_lay2 TYPE lvc_s_layo,

ls_celltab2 TYPE lvc_s_styl,

lt_celltab2 TYPE lvc_t_styl,

gd_maint2 TYPE syinput.

DATA:g_left_container TYPE REF TO cl_gui_container,

g_right_container TYPE REF TO cl_gui_container.

DATA: g_splitter_container TYPE REF TO cl_gui_splitter_container.

*****pbo************

IF g_cust_cont1 IS INITIAL.

g_cont1 = 'CUST_2000'.

CLEAR g_cust_cont1.

CREATE OBJECT g_cust_cont1

EXPORTING

container_name = g_cont1

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

CREATE OBJECT g_splitter_container

EXPORTING

parent = g_cust_cont1

rows = 2

columns = 1

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

ENDIF.

CALL METHOD g_splitter_container->get_container

EXPORTING

row = 1

column = 1

RECEIVING

container = g_left_container.

CALL METHOD g_splitter_container->get_container

EXPORTING

row = 2

column = 1

RECEIVING

container = g_right_container.

ENDIF.

IF grid1 IS INITIAL.

CREATE OBJECT grid1

EXPORTING

i_parent = g_left_container.

ENDIF.

**************population of field catalogues***********

gs_fcat1-col_pos = '1'.

gs_fcat1-fieldname = 'ID'.

gs_fcat1-ref_table = 'ICON'.

gs_fcat1-reptext = 'Icon'.

gs_fcat1-edit = ' '.

gs_fcat1-key = 'X'.

gs_fcat1-outputlen = 4.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '2'.

gs_fcat1-fieldname = 'BEGDA'.

gs_fcat1-ref_table = 'HRP1001'.

gs_fcat1-reptext = 'Start'.

gs_fcat1-coltext = 'Start'.

gs_fcat1-key = 'X'.

IF psyst-ioper = display.

gs_fcat1-edit = ' '.

ELSE.

gs_fcat1-edit = 'X'.

ENDIF.

gs_fcat1-f4availabl = 'X'.

gs_fcat1-key = 'X'.

gs_fcat1-outputlen = '8'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '3'.

gs_fcat1-fieldname = 'ENDDA'.

gs_fcat1-ref_table = 'HRP1001'.

gs_fcat1-reptext = 'End'.

gs_fcat1-coltext = 'End'.

IF psyst-ioper = display.

gs_fcat1-edit = ' '.

ELSE.

gs_fcat1-edit = 'X'.

ENDIF.

gs_fcat1-f4availabl = 'X'.

gs_fcat1-outputlen = '8'.

gs_fcat1-key = 'X'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '4'.

gs_fcat1-fieldname = 'RELATIONSHIP'.

gs_fcat1-ref_table = 'ZIT9004'.

gs_fcat1-reptext = 'Relationship'.

gs_fcat1-coltext = 'Relationship'.

gs_fcat1-edit = 'X'.

gs_fcat1-outputlen = '25'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '5'.

gs_fcat1-fieldname = 'OTYPE'.

gs_fcat1-ref_table = 'ZIT9004'.

gs_fcat1-reptext = 'Object'.

gs_fcat1-coltext = 'Object'.

IF psyst-ioper = display.

gs_fcat1-edit = ' '.

ELSE.

gs_fcat1-edit = 'X'.

ENDIF.

gs_fcat1-outputlen = '2'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '6'.

gs_fcat1-fieldname = 'OBJID'.

gs_fcat1-ref_table = 'ZIT9004'.

gs_fcat1-reptext = 'ID'.

gs_fcat1-coltext = 'ID'.

gs_fcat1-f4availabl = ' '.

gs_fcat1-outputlen = '8'.

gs_fcat1-no_out = 'X'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '7'.

gs_fcat1-fieldname = 'SOBID'.

gs_fcat1-ref_table = 'zit9004'.

gs_fcat1-ref_field = 'sobid'.

gs_fcat1-reptext = 'ID'.

gs_fcat1-coltext = 'ID'.

IF psyst-ioper = display.

gs_fcat1-edit = ' '.

ELSE.

gs_fcat1-edit = 'X'.

ENDIF.

gs_fcat1-f4availabl = 'X'.

gs_fcat1-outputlen = '8'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '8'.

gs_fcat1-fieldname = 'VORNA'.

gs_fcat1-ref_table = 'PA0002'.

gs_fcat1-reptext = 'Name'.

gs_fcat1-coltext = 'Name'.

gs_fcat1-edit = ' '.

gs_fcat1-outputlen = '20'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '9'.

gs_fcat1-fieldname = 'DELIMIT'.

gs_fcat1-ref_table = 'ZIT9004'.

gs_fcat1-reptext = 'Delimit'.

gs_fcat1-coltext = 'Delimit'.

gs_fcat1-edit = ' '.

gs_fcat1-outputlen = '8'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '10'.

gs_fcat1-fieldname = 'CELLTAB'.

gs_fcat1-no_out = 'X'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '11'.

gs_fcat1-fieldname = 'ISTAT'.

gs_fcat1-ref_table = 'HRP1001'.

gs_fcat1-no_out = 'X'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

gs_fcat1-col_pos = '12'.

gs_fcat1-fieldname = 'FLAG'.

gs_fcat1-no_out = 'X'.

APPEND gs_fcat1 TO gt_fcat1.

CLEAR gs_fcat1.

***********for displaying the alv grid**************

CALL METHOD grid1->set_table_for_first_display

EXPORTING

it_toolbar_excluding = lt_exclude1

i_save = 'A'

is_layout = gs_lay1

i_default = 'X'

CHANGING

it_fieldcatalog = gt_fcat1

it_outtab = wt_relat1[].

wa_lvc_s_col-fieldname = wa_col-fieldname.

Read only

Former Member
0 Likes
585

U can use BLOCKEd alv s

use FMs

REUSE_ALV_BLOCKLIST_INIT

REUSE_ALV_BLOCKLIST_APPEND for 1st list

REUSE_ALV_BLOCKLIST_APPEND for 2nd list

etc

REUSE_ALV_BLOCKLIST_DISPLAY

Reward if useful