Application Development 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: 

Help on ALV GRID display outputting format for 2 internal tables

Former Member
0 Kudos

Hi,

I have requirement in ALV GRID where I need to display the data from 2 internal tables. The first internal table has the content of Delivery due list data and second the internal table has the corresponding stock transfer data of the Delivery Due list. I have a checbox on my selection screen, when unchecked it should output the 1st internal table data, i.e for Delivery due list. When it is checked then it should output 1st Internal table data + 2nd internal table data of stock transfer. For example, 1 document delivery due list data and 2nd line for that document should show the stock transfer data. You can also check the transaction code VL10E for that will show a delivery due list...and for stock tranfer,you need to check with Purchase order in in the USer Role tabstrip. Pls suggest.

Regards,

Mira

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I would not suggest mixing two different sets of data into 1 ALV grid. I would suggest having two ALV grids in one screen. One with the delivery info, the second with the stock transfer info. You will need to use the class CL_GUI_ALV_GRID instead of the function module and also you will have to define a dynpro.

Regards,

Rich Heilman

Former Member
0 Kudos

I believe you have two issues at hand for which you seek solution:

a) How to decide at runtime what to display on screen ?

b) How to integrate two internal tables and display the result in screen ?

Answers to both these questions are simple:

Assuming that you have two different tables, one for delivery due list and other stock transfer data. I assume they have one to one correspondence. If they do, you have to somehow merge them into one table. This should not be issue as one record of delivery due list would match exactly one or no record of stock transfer data and vice-versa. Basically using LOOP and Read table you can figure this out how to integrate these values in a single table.

In case, one record of delivery due list would match multiple records of stock transfer, you need to have a tree kind of scenario. ( you might excuse my functional knowledge or lack of it ).

The above answers the (b) part of your (supposed) question.

To answer the (a) part, based on the checklist condition:

You can create the fieldcatalog and decide whether you want to merge the tables.

Regards,

Subramanian V.

0 Kudos

Hello Subramanian V.

Your elaborate replies are greatly appreciated.

In case, the checkbox is checked for dual display(Header+Detail), how is the fieldcatalog going

to reflect the correct values for this tree structure.

In other words, the fieldcatalog will have the Delivery

List fields or the Stock Transfer List fields.

It is difficult to visualize how for a multi-line display

the header_line columns and the detail_line columns

are populated in the same fieldcatalog.

Any code snippet will be greatly appreciated....

Dave S.

0 Kudos

Hi Dave,

If it is header+detail, the function module to use is REUSE_ALV_HIERSEQ* , otherwise you can use a simple REUSE_ALV_GRID_DISPLAY to show your information.

For sample programs, you may refer to BCHIERSEQ in SE38. It would also show you how to merge fieldcatalog using FM REUSEFIELDCATMERGE

The issue with the above FM would be you cannot have the selection-screen and the output on the same screen.

Regards,

Subramanian V.

Former Member
0 Kudos

Hi,

I would suggest you to use <u><b>Tabstrip with two tabs</b></u>.

If that checkbox is checked then u can display the output in the second tab. If unchecked then display in the first tab.

If u r in need of sample code i will provide u.

Thanks & Regards,

Judith.

Former Member
0 Kudos

Hi Judith,

Thanks for your response about the tabstrips.....

I have a report that should display SO headers

and Details. This could be shown as a tree or with two tabstrips( as you suggested). With the tree structure I have difficulty showing both the Header Columns texts and the Detail columns texts. I would be interested to know more about your tabstrip approach.

Any sample code would be greatly appreciated....

Regards

0 Kudos

Hi,

U can try out this code

REPORT zzz_test NO STANDARD PAGE HEADING

MESSAGE-ID zz.

  • The Data Declarations

INCLUDE zzm_test_alv_data.

  • The Selection Screen Definition

INCLUDE zzm_test_alv_selscrn.

  • The definition and implementation of the event reciever class

INCLUDE zzm_test_alv_class.

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

  • START-OF-SELECTION

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

START-OF-SELECTION.

PERFORM f1000_load_itabs.

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

    • END-OF-SELECTION

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

END-OF-SELECTION.

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

IF NOT cb_disp IS INITIAL.

CALL SCREEN 9001.

ENDIF.

  • Include for getting data

INCLUDE zzm_test_alv_forms.

  • Include for PAI and PBO of screen

INCLUDE zzm_test_alv_screen.

----


  • INCLUDE ZZM_TEST_ALV_DATA *

----


  • This include has all the data declaration defined

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

  • Author............: Judith Jessie Selvi

  • Creation Date.....: 28/03/2005

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

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

  • Table Declarations:

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

TABLES: mara,

makt.

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

  • Internal Tables:

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

  • The following structure type must be defined in the data dictionary

DATA: i_fieldcat TYPE lvc_t_fcat,

i_fieldcat1 TYPE lvc_t_fcat,

i_output1 TYPE STANDARD TABLE OF mara,

i_output2 TYPE STANDARD TABLE OF makt,

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

  • Work Areas:

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

w_output1 TYPE STANDARD TABLE OF mara,

w_output2 TYPE STANDARD TABLE OF makt.

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

  • Variable:

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

DATA: lv_repid LIKE sy-repid.

lv_repid = sy-repid.

----


  • INCLUDE ZZM_TEST_ALV_SELSCRN *

----


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

  • Author............: Judith Jessie Selvi

  • Creation Date.....: 28/03/2005

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

SELECTION-SCREEN BEGIN OF BLOCK b_main WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETERS: cb_disp AS CHECKBOX.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN END OF BLOCK b_main.

----


  • INCLUDE ZZM_TEST_ALV_CLASS *

----


  • This include has all the data declaration defined for ALV

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

  • Author............: Judith Jessie Selvi

  • Creation Date.....: 28/03/2005

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

INCLUDE <icon>.

  • Predefine a local class for event handling to allow the

  • declaration of a reference variable before the class is defined.

DATA : o_alvgrid1 TYPE REF TO cl_gui_alv_grid ,

o_alvgrid2 TYPE REF TO cl_gui_alv_grid ,

cont_for_cognos1 TYPE scrfname VALUE 'BCALC_GRID_01_9100',

cont_for_cognos2 TYPE scrfname VALUE 'BCALC_GRID_01_9200',

custom_container1 TYPE REF TO cl_gui_custom_container,

custom_container2 TYPE REF TO cl_gui_custom_container,

----


  • Work Area

----


w_layout TYPE lvc_s_layo ,

w_variant TYPE disvariant.

----


  • Constants

----


CONSTANTS : c_lay(1) TYPE c VALUE 'A' . " All Layouts

CONSTANTS: BEGIN OF c_main_tab,

tab1 LIKE sy-ucomm VALUE 'MAIN_TAB_FC1', "

tab2 LIKE sy-ucomm VALUE 'MAIN_TAB_FC2', "

END OF c_main_tab.

----


  • INCLUDE ZZM_TEST_ALV_FORMS *

----


  • This Include has the various forms used in the program

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

  • Author............: Judith Jessie Selvi

  • Creation Date.....: 28/03/2005

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

&----


*& Form f9001_build_field_cat

&----


  • To Build Field Catalog

----


  • -->P_I_FIELDCAT text

  • -->P_0021 text

----


FORM f9001_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat

USING value(p_structure).

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = p_structure

CHANGING

ct_fieldcat = p_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE i005 WITH 'Error in ALV field catalogue creation'.

" text-e05.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " f9001_build_field_cat

&----


*& Form f9000_objects_create

&----


  • For creating Custom Containers

----


  • --> p1 text

  • <-- p2 text

----


FORM f9000_objects_create.

CREATE OBJECT custom_container1

EXPORTING

container_name = cont_for_cognos1

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

CREATE OBJECT custom_container2

EXPORTING

container_name = cont_for_cognos2

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

IF sy-subrc NE 0.

  • add your handling, for example

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = lv_repid

txt2 = sy-subrc

txt1 = 'The control could not be created'(510).

ENDIF.

CREATE OBJECT o_alvgrid1

EXPORTING i_parent = custom_container1.

CREATE OBJECT o_alvgrid2

EXPORTING i_parent = custom_container2.

ENDFORM. " f9000_objects_create

&----


*& Form f9003_layout

&----


  • To define the layout

----


  • -->P_SY_TITLE text

  • -->P_0030 text

  • -->P_0031 text

  • -->P_0032 text

----


FORM f9003_layout USING value(ptitle)

value(pzebra)

value(pmode)

value(pwidth).

w_layout-grid_title = ptitle.

w_layout-zebra = pzebra.

w_layout-sel_mode = pmode.

w_layout-cwidth_opt = pwidth.

w_variant-report = sy-repid.

ENDFORM. " f9003_layout

&----


*& Form f9006_error_handle

&----


  • To handle event

----


  • -->P_PTEXT text

----


FORM f9006_error_handle USING value(ptext).

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = text-e03 " Error Note

txt2 = sy-subrc

txt1 = ptext.

ENDIF.

ENDFORM. " f9006_error_handle

----


  • FORM EXIT_PROGRAM *

----


FORM exit_program.

CALL METHOD custom_container1->free.

CALL METHOD custom_container2->free.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = lv_repid

txt2 = sy-subrc

txt1 = 'Error in FLush'(500).

ENDIF.

ENDFORM.

&----


*& Form f1000_load_itabs

&----


  • Select from Database

----


  • --> p1 text

  • <-- p2 text

----


form f1000_load_itabs.

SELECT * FROM mara

INTO TABLE i_output1

UP TO 50 rows.

SELECT * FROM makt

INTO TABLE i_output2

UP TO 50 rows.

endform. " f1000_load_itabs

----


  • INCLUDE ZZM_TEST_ALV_SCREEN *

----


  • 2/ Description / Include functions

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

  • This include contains PBO and PAI events for the screen of report

  • ZZZJJ_TEST_ALV

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

  • 3/ Responsibility

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

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

  • Author............: Judith Jessie Selvi

  • Creation Date.....: 28/03/2005

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

  • DATA FOR TABSTRIP 'MAIN_TAB'

CONTROLS: main_tab TYPE TABSTRIP.

DATA: BEGIN OF i_main_tab,

subscreen LIKE sy-dynnr,

prog LIKE sy-repid VALUE

'ZZZ_TEST',

pressed_tab LIKE sy-ucomm VALUE c_main_tab-tab1,

END OF i_main_tab.

&----


*& Module STATUS_9001 OUTPUT

&----


  • text

----


MODULE status_9001 OUTPUT.

IF custom_container1 IS INITIAL.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE'.

  • Creating Object

PERFORM f9000_objects_create.

  • Building the field catalog

PERFORM f9001_build_field_cat TABLES i_fieldcat

USING 'MARA'.

PERFORM f9001_build_field_cat TABLES i_fieldcat1

USING 'MAKT'.

  • Modifying the field catalog

  • PERFORM f9002_modify_field_cat TABLES i_fieldcat.

  • For Layout

PERFORM f9003_layout USING sy-title 'X' 'B' 'X'.

ENDIF.

ENDMODULE. " STATUS_9001 OUTPUT

&----


*& Module MAIN_TAB_ACTIVE_TAB_SET OUTPUT

&----


  • Call method to display in the output grid

----


MODULE main_tab_active_tab_set OUTPUT.

main_tab-activetab = i_main_tab-pressed_tab.

CASE i_main_tab-pressed_tab.

WHEN c_main_tab-tab1.

  • To display report

i_main_tab-subscreen = '9100'.

CALL METHOD o_alvgrid1->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = c_lay

is_layout = w_layout

CHANGING

it_outtab = i_output1[]

it_fieldcatalog = i_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE i000 WITH text-e06."Error in ALV report display

LEAVE LIST-PROCESSING.

ENDIF.

WHEN c_main_tab-tab2.

  • To display report

i_main_tab-subscreen = '9200'.

CALL METHOD o_alvgrid2->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = c_lay

is_layout = w_layout

CHANGING

it_outtab = i_output2[]

it_fieldcatalog = i_fieldcat1[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE i005 WITH text-e06."Error in ALV report display

LEAVE LIST-PROCESSING.

ENDIF.

WHEN OTHERS.

  • DO NOTHING

ENDCASE.

ENDMODULE. “MAIN_TAB_ACTIVE_TAB_SET OUTPUT

&----


*& Module MAIN_TAB_ACTIVE_TAB_GET INPUT

&----


  • Check & Process the selected Tab

----


MODULE main_tab_active_tab_get INPUT.

CASE sy-ucomm.

WHEN c_main_tab-tab1.

i_main_tab-pressed_tab = c_main_tab-tab1.

WHEN c_main_tab-tab2.

i_main_tab-pressed_tab = c_main_tab-tab2.

WHEN OTHERS.

  • DO NOTHING

ENDCASE.

ENDMODULE. “MAIN_TAB_ACTIVE_TAB_GET INPUT

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • User Command

----


MODULE user_command_9001 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

PERFORM exit_program.

SET SCREEN '0'.

WHEN 'EXIT' OR 'CANC'.

PERFORM exit_program.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. “USER_COMMAND_9000 INPUT

&----


*& Module MAIN_TAB_ACTIVE_TAB_SET INPUT

&----


  • Set sunscreen

----


MODULE main_tab_active_tab_set INPUT.

main_tab-activetab = i_main_tab-pressed_tab.

CASE i_main_tab-pressed_tab.

WHEN c_main_tab-tab1.

i_main_tab-subscreen = '9100'.

WHEN c_main_tab-tab2.

i_main_tab-subscreen = '9200'.

WHEN OTHERS.

  • DO NOTHING

ENDCASE.

ENDMODULE. “MAIN_TAB_ACTIVE_TAB_SET INPUT

Thanks & Regards,

Judith.

Former Member
0 Kudos

hi SAIKRISHNA ,

when the checkbox is selected use REUSE_ALV_BLOCK_LIST_DISPLAY else use

REUSE_ALV_LIST_DISPLAY. hope it helps

Thanks

senthil