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

ALV Reports

Former Member
0 Likes
688

How do I call 2 different ALV reports in one

screen?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
666

1st. Create 2 coustome controls on the screen and then use this code.

                • Flow logic***********************

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_2000.

Module PBO_2000.

PROCESS AFTER INPUT.

  • MODULE USER_COMMAND_2000.

Module PAI2000.

module exit_screen.

                • Main program ********************

&----


*& Module PBO_2000 OUTPUT

&----


*

----


MODULE pbo_2000 OUTPUT.

  • set pf-status.

SET PF-STATUS 'STS'.

DATA: l_layout TYPE lvc_s_layo.

DATA: ls_fcat TYPE lvc_s_fcat,

ls_layout TYPE lvc_s_layo,

lt_fcat TYPE lvc_t_fcat.

CLEAR ls_fcat.

CLEAR lt_fcat[].

ls_fcat-fieldname = 'COLUMNTEXT'.

ls_fcat-ref_table = 'LVC_S_DETA'.

ls_fcat-key = c_x.

ls_fcat-seltext = 'Field'(031).

ls_fcat-outputlen = 30.

APPEND ls_fcat TO lt_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'VALUE'(032).

ls_fcat-ref_table = 'LVC_S_DETA'.

ls_fcat-seltext = 'VALUE'(032).

ls_fcat-outputlen = 60.

APPEND ls_fcat TO lt_fcat.

ls_layout-no_toolbar = c_x.

ls_layout-cwidth_opt = c_x.

LOOP AT gt_popup_tab.

gt_detail_popup1-columntext = gt_popup_tab-name.

gt_detail_popup1-value = gt_popup_tab-value.

APPEND gt_detail_popup1 TO gt_detail_popup.

ENDLOOP.

gs_detail-blockindex = 1.

APPEND gs_detail TO gt_detail.

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING container_name = g_container1.

CREATE OBJECT grid1

EXPORTING i_parent = g_custom_container.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'LVC_T_DETM'

CHANGING

it_outtab = gt_detail_popup

it_fieldcatalog = lt_fcat.

l_layout-no_toolbar = 'X'.

CALL METHOD grid1->set_frontend_layout

EXPORTING

is_layout = l_layout.

ENDIF.

IF NOT gt_cost_obj[] IS INITIAL.

IF g_custom_container1 IS INITIAL.

CREATE OBJECT g_custom_container1

EXPORTING container_name = g_container2.

CREATE OBJECT grid2

EXPORTING i_parent = g_custom_container1.

CALL METHOD grid2->set_table_for_first_display

EXPORTING

i_structure_name = 'ZSH_RHCOST_OBJ_ISR'

CHANGING

it_outtab = gt_cost_obj[].

l_layout-no_toolbar = 'X'.

CALL METHOD grid2->set_frontend_layout

EXPORTING

is_layout = l_layout.

ENDIF.

ENDIF.

ENDMODULE. " PBO_2000 OUTPUT

&----


*& Module PAI2000 INPUT

&----


  • text

----


MODULE pai2000 INPUT.

  • to react on oi_custom_events:

CALL METHOD cl_gui_cfw=>dispatch.

ENDMODULE. " PAI2000 INPUT

&----


*& Module exit_screen INPUT

&----


  • Exit the screen for the popup

----


MODULE exit_screen INPUT.

CASE ok_code.

WHEN 'OK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

  • Do nothing

ENDCASE.

ENDMODULE. " exit_screen INPUT

How do I call 2 different ALV reports in one

screen?

4 REPLIES 4
Read only

Former Member
0 Likes
666

Hi Sreedhar,

You can do this if you are using containers and

Classes. Create two containers in the screen and

and you can plcae two ALV reports.

Let me know if you want to more info.

Thanks & Regards,

Siri.

Read only

Former Member
0 Likes
666

Multiple ALV list display

The SAP program <b>BALVBT01</b> provides an example of displying multiple ALV LIST reports on one page.

Reward points if it helps u.

Read only

0 Likes
666

ya u can use block alv for that.....

sample code or block alv is ....this may be help u ..

REPORT zkis MESSAGE-ID zz.

*

----


  • Declarations for BLOCK ALV DISPLAY

----


*--type pools

TYPE-POOLS:slis.

DATA:x_layout TYPE slis_layout_alv,

t_field TYPE slis_t_fieldcat_alv,

*--field catalog

x_fldcat LIKE LINE OF t_field,

*--to hold all the events

t_events TYPE slis_t_event,

x_events TYPE slis_alv_event,

t_sort TYPE slis_t_sortinfo_alv,

x_sort LIKE LINE OF t_sort ,

*--Print Layout

x_print_layout TYPE slis_print_alv.

*----Macro to add field catalog.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

DEFINE add_catalog.

clear x_fldcat.

x_fldcat-fieldname = &1.

x_fldcat-seltext_m = &2.

x_fldcat-outputlen = &3.

x_fldcat-tech = &4.

x_fldcat-col_pos = &5.

x_fldcat-no_zero = 'X'.

x_fldcat-ddictxt = 'M'.

x_fldcat-datatype = &6.

x_fldcat-ddic_outputlen = &7.

if &6 = 'N'.

x_fldcat-lzero = 'X'.

endif.

*--build field catalog

append x_fldcat to t_field.

END-OF-DEFINITION.

*----- data declerations.

data: v_repid like sy-repid.

data: begin of itab occurs 0,

matnr like mara-matnr,

ernam like mara-ernam,

meins like mara-meins,

end of itab.

data: begin of jtab occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of jtab.

select matnr ernam meins

up to 20 rows

from mara

into table itab.

select matnr maktx

up to 20 rows

from makt

into table jtab.

v_repid = sy-repid.

*DISPLAY alv

  • Initialize Block

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = v_repid.

*Block 1:

*INITIALIZE

refresh t_field. clear t_field.

refresh t_events.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

add_catalog:

'MATNR' 'Material' '18' '' '1' 'C' '18',

'ERNAM' 'Created By' '12' '' '2' 'C' '12',

'MEINS' 'Unit' '5' '' '3' 'C' '3'.

*--build table for events.

x_events-form = 'TOP_OF_LIST1'.

x_events-name = slis_ev_top_of_list.

append x_events to t_events.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = x_layout

it_fieldcat = t_field

i_tabname = 'ITAB'

it_events = t_events

it_sort = t_sort

tables

t_outtab = itab

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.

*--BLOCK 2(SUMMARY REPORT)

*INITIALIZE

refresh t_field. clear t_field.

refresh t_events.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

add_catalog:

'MATNR' 'Material' '20' '' '1' 'C' '18',

'MAKTX' 'Description' '40' '' '2' 'C' '40'.

*--build table for events.

x_events-form = 'TOP_OF_LIST2'.

x_events-name = slis_ev_top_of_list.

append x_events to t_events.

  • Append table block.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = x_layout

it_fieldcat = t_field

i_tabname = 'JTAB'

it_events = t_events

tables

t_outtab = jtab

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 FM TO DISPLAY THE BLOCK REPORT.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • exporting

  • is_print = x_print_layout

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_of_list1.

skip 1.

write: 10 'List 1',

/5 '----


'.

skip 1.

format reset.

endform.

form top_of_list2.

skip 1.

write: 10 'List 2',

/5 '----


'.

skip 1.

format reset.

endform.

Read only

Former Member
0 Likes
667

1st. Create 2 coustome controls on the screen and then use this code.

                • Flow logic***********************

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_2000.

Module PBO_2000.

PROCESS AFTER INPUT.

  • MODULE USER_COMMAND_2000.

Module PAI2000.

module exit_screen.

                • Main program ********************

&----


*& Module PBO_2000 OUTPUT

&----


*

----


MODULE pbo_2000 OUTPUT.

  • set pf-status.

SET PF-STATUS 'STS'.

DATA: l_layout TYPE lvc_s_layo.

DATA: ls_fcat TYPE lvc_s_fcat,

ls_layout TYPE lvc_s_layo,

lt_fcat TYPE lvc_t_fcat.

CLEAR ls_fcat.

CLEAR lt_fcat[].

ls_fcat-fieldname = 'COLUMNTEXT'.

ls_fcat-ref_table = 'LVC_S_DETA'.

ls_fcat-key = c_x.

ls_fcat-seltext = 'Field'(031).

ls_fcat-outputlen = 30.

APPEND ls_fcat TO lt_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'VALUE'(032).

ls_fcat-ref_table = 'LVC_S_DETA'.

ls_fcat-seltext = 'VALUE'(032).

ls_fcat-outputlen = 60.

APPEND ls_fcat TO lt_fcat.

ls_layout-no_toolbar = c_x.

ls_layout-cwidth_opt = c_x.

LOOP AT gt_popup_tab.

gt_detail_popup1-columntext = gt_popup_tab-name.

gt_detail_popup1-value = gt_popup_tab-value.

APPEND gt_detail_popup1 TO gt_detail_popup.

ENDLOOP.

gs_detail-blockindex = 1.

APPEND gs_detail TO gt_detail.

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING container_name = g_container1.

CREATE OBJECT grid1

EXPORTING i_parent = g_custom_container.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'LVC_T_DETM'

CHANGING

it_outtab = gt_detail_popup

it_fieldcatalog = lt_fcat.

l_layout-no_toolbar = 'X'.

CALL METHOD grid1->set_frontend_layout

EXPORTING

is_layout = l_layout.

ENDIF.

IF NOT gt_cost_obj[] IS INITIAL.

IF g_custom_container1 IS INITIAL.

CREATE OBJECT g_custom_container1

EXPORTING container_name = g_container2.

CREATE OBJECT grid2

EXPORTING i_parent = g_custom_container1.

CALL METHOD grid2->set_table_for_first_display

EXPORTING

i_structure_name = 'ZSH_RHCOST_OBJ_ISR'

CHANGING

it_outtab = gt_cost_obj[].

l_layout-no_toolbar = 'X'.

CALL METHOD grid2->set_frontend_layout

EXPORTING

is_layout = l_layout.

ENDIF.

ENDIF.

ENDMODULE. " PBO_2000 OUTPUT

&----


*& Module PAI2000 INPUT

&----


  • text

----


MODULE pai2000 INPUT.

  • to react on oi_custom_events:

CALL METHOD cl_gui_cfw=>dispatch.

ENDMODULE. " PAI2000 INPUT

&----


*& Module exit_screen INPUT

&----


  • Exit the screen for the popup

----


MODULE exit_screen INPUT.

CASE ok_code.

WHEN 'OK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

  • Do nothing

ENDCASE.

ENDMODULE. " exit_screen INPUT