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: 

Prob with Drill down ALV's Layout

Former Member
0 Kudos

Hi Friends,

I have developed a report with class based ALV grid.

First screen 100 - has an ALV for header details.


  CALL METHOD G_GRID_100->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IS_VARIANT           = GS_DISVARIANT
      IS_LAYOUT            = GS_LAYOUT
      IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
      I_SAVE               = 'A'
    CHANGING
      IT_OUTTAB            = GT_DATA
      IT_FIELDCATALOG      = GT_FIELDCAT100.

on double click of any record in primary ALV, another screen 200 is called with line item details of that header in screen 100.


    CALL METHOD G_GRID_200->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_VARIANT           = GS_DISVARIANT1
        IS_LAYOUT            = GS_LAYOUT1
        IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
        I_SAVE               = 'A'
      CHANGING
        IT_FIELDCATALOG      = GT_FIELDCAT200
        IT_OUTTAB            = GT_LINEITEM.

Problem: what ever layout is set in header alv is being copied in lineitem alv.

I want to have independent layouts for primary and secondary ALVs.

How to do that.

Any help on this is highly appreciated.

Regards,

Simha

12 REPLIES 12

Former Member
0 Kudos

Wat have u given for GS_LAYOUT and GS_LAYOUT1? Is there any difference in the structure or only the name?

0 Kudos

Hi Sharjan,

Its only diff name but the structure of GS_Layout is same as that of LVC_S_LAYO

which is populated as below


GS_LAYOUT-GRID_TITLE = 'title'.
GS_LAYOUT-SMALLTITLE = 'X'.
GS_LAYOUT-SEL_MODE   = 'A'.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-ZEBRA      = 'X'.

how can i control the diff layouts..what ever changes that i do at primary list is effecting the layout of secondary list

Regards,

Simha

0 Kudos

in this case i use SET_FRONTEND_LAYOUT method. this works for me very well

0 Kudos

Hi Vijay,

It is not working for me.

I changed as suggested by you for the secondarly ALV Grid.


    CALL METHOD G_GRID_200->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_VARIANT           = GS_DISVARIANT1
*        IS_LAYOUT            = GS_LAYOUT1
        IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
        I_SAVE               = 'A'
      CHANGING
        IT_FIELDCATALOG      = GT_FIELDCAT200
        IT_OUTTAB            = GT_LINEITEM.

    CALL METHOD G_GRID_200->SET_FRONTEND_LAYOUT
      EXPORTING
        IS_LAYOUT = GS_LAYOUT1.

I commented IS_Layout for the method set_table_for_first_display and have calle dthe method set_frontend_layout, but still the secondary ALV is getting Layout settings from the primary ALV?

Help me out. Can you paste the code that is working with you?

Thanks.

Simha

0 Kudos

it is working for me. here is one working example. some where you are doing a mistake cross check it once.

REPORT  ztest_alv_oo.

DATA: it_carr TYPE TABLE OF scarr,
      it_flight TYPE TABLE OF sflight.

DATA: grid1 TYPE REF TO cl_gui_alv_grid,
      grid2 TYPE REF TO cl_gui_alv_grid,
      con1 TYPE REF TO cl_gui_custom_container,
      con2 TYPE REF TO cl_gui_custom_container.
DATA: layout1 TYPE lvc_s_layo,
      layout2 TYPE  lvc_s_layo.
*----------------------------------------------------------------------*
*       CLASS cl_defintion
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_one DEFINITION.

  PUBLIC SECTION.

    METHODS:
        double_click         FOR EVENT double_click
                             OF cl_gui_alv_grid
                             IMPORTING e_row
                                       e_column
                                       es_row_no.

ENDCLASS.                    "cl_defintion

*----------------------------------------------------------------------*
*       CLASS cl_implemenatation
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_one IMPLEMENTATION.

  METHOD double_click.
    DATA: wa_carr TYPE scarr.
    READ TABLE it_carr INTO wa_carr INDEX e_row-index.
    IF sy-subrc EQ 0.
      SELECT * FROM sflight
      INTO TABLE it_flight
      WHERE carrid EQ wa_carr-carrid.
      CALL SCREEN 200.
    ENDIF.
  ENDMETHOD.                    "double_click

ENDCLASS.                    "cl_implemenatation

START-OF-SELECTION.
  DATA: obj TYPE REF TO cl_one.
  SELECT * FROM scarr
  INTO TABLE it_carr.
  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'CARR'.
  IF con1 IS INITIAL.
    CREATE OBJECT con1
      EXPORTING
        container_name = 'CAR'.
    CREATE OBJECT grid1
      EXPORTING
        i_parent = con1.
    layout1-grid_title = 'Carrid data'.
    layout1-smalltitle = 'X'.
    layout1-sel_mode   = 'A'.
    layout1-cwidth_opt = 'X'.
    layout1-zebra      = 'X'.
    grid1->set_table_for_first_display(
      EXPORTING
        i_structure_name              = 'SCARR'
        is_layout                     = layout1
      CHANGING
        it_outtab                     = it_carr
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
           ).
    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 obj.
    SET HANDLER obj->double_click FOR grid1.
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT.

  SET PF-STATUS 'FLIGHT'.
  IF con2 IS INITIAL.
    CREATE OBJECT con2
      EXPORTING
        container_name = 'FLIGHT'.
    CREATE OBJECT grid2
      EXPORTING
        i_parent = con2.
    layout2-grid_title = 'Flights data'.
    layout2-smalltitle = 'X'.
    layout2-sel_mode   = 'A'.
    layout2-cwidth_opt = 'X'.
    layout2-zebra      = 'X'.

    grid2->set_table_for_first_display(
      EXPORTING
        i_structure_name              = 'SFLIGHT'
        is_layout                     = layout2
      CHANGING
        it_outtab                     = it_flight
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
           ).
    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.
  ELSE.
    CALL METHOD grid2->refresh_table_display.
  ENDIF.
ENDMODULE.                 " STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0200  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0200  INPUT

Container names are CAR, FLIGHT(for 100, 200 respectively)

0 Kudos

Hi Vijay,

Many thanks for the code.

I tried the same thing. In your code no I_SAVE is maintained but here in my code i want, user to set 'User Specific' layout and 'Global Layout' both independent for primary ALV and secondary ALV.

for which i made I_SAVE = 'A'.

inspite of having different Layouts, the cube icon for Select Layout/Manage Layout/change Layout is showing same saved layouts both for header ALV(Screen 100) and lineitem ALV(screen 200).

In Screen 100 - i created a layout /test-1 ( global ) and hidden 4 columns which are also there in structure of layout2 in screen 200.

so when i double click to see lineitems of Layout2 in 200, those 4 fields are hidden here too( which should not be) as Layout considered is the global layout from Screen 100.

How to make them independent?

Any help and clue is highly appreciated.

Regards,

Simha

Edited by: Simha on Oct 21, 2008 5:09 AM

0 Kudos

i just included the variants also, i didn't face any problem like you described. and here some confusion in selection of layouts, may be you saved a variant for the second layout, and checking in first screen. check it once. since both the screens are from same program all the variants appear both places, you have to identify which one is belongs to screen 100/screen 200.

0 Kudos

Hi Vijay,

Thanks for your inputs.

I checked as you suggested.

I have header details in screen 100

Lineitem details in sreen 200.

1. i deleted all the layouts created.

2. changed layout in 100 and saved it.

3. double click and go to 200, the layout is changed and all the columns which are not part of header layout are all not displayed. Displaying only those columns which are common to100 and 200.

4. when i make a layout default for 100, its becoming default for 200 as well.

How can i stop 200 taking the layout from 100?

Many thanks,

Simha

0 Kudos

Hi All,

Thanks for your time and inputs.

I am closing this thread as the problem is obsolete but i could not make the secondary layout independent of the first one.

i am clueless about this. i will try to do more R&D on this when i get time. Thanks

Simha

Former Member
0 Kudos

are you used same condition for IS_VARIANT? I think u should comment this line for screen 0200.

IS_VARIANT = GS_DISVARIANT1

0 Kudos

Hi anuar jusoh ,

thanks for your inputs.

I commented

IS_VARIANT = GS_DISVARIANT1 for screen 200 as you suggested.

It worked fine and did not take the screen 100's default layout

but the Layout settings cube changed to 'Change Layout' type instead of 'Layout settings' which has to allow User specific layout saving or global layout saving specific to screen 200.

User want to control screen 100 ALV and screen 200 ALV's layout seperately.

with the above change, i lost the saving and managing option on screen 200 ALV.

How to achieve this?

Thanks,

Simha

0 Kudos

Hi Ajay,

            Did you manage to solve the problem ? If so could you pleaes share me some knowledge as i am facing the same problem now..

Regards,

Shyam.