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: 

ALV Layout problem needs your help.

Former Member
0 Kudos

Dear SAP Fun

I have met following problem with ALV.

The customer said

In condition A.

The screen should display one ALV control with size of

50 * 100(The total size of this control).

In condition B.

The screen should display two same ALV controls with size of 25100. That means the total size of the two ALVs is the same as the previous one. So, 50100 is just

for the two ALVs.

I want confirm it is possible to realize it by using ALV?

Thank you!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Minghan Song ,

Its possible using Abap Objects where u can define two Alv Controls with the ur specified size parameters. BUt in normal ALV , u can have restriction that grid supports max of 1024 chars only i.e total lenght of all fields should not exceed 1024 chars.

regards,

Kiran b

7 REPLIES 7

amit_khare
Active Contributor
0 Kudos

Hi,

Following requirement can be easily full-filled by using custom containers on screen.This requires using of OOABAP for which you can refer to standard reports using BCALV_* in SE38 Tcode.

You can call more than one container on the screen and use it like a frame.

So for diaplaying your requirement best option is to design two screen one with one container and another with two container and accordingly call the screen on the request basis.

Regards,

Amit

0 Kudos

Or you can have one screen with 1 container. Then in the PBO, check the condition, if it is satisfied, then you can implement a splitter inside of your custom container, then implement the two alv grids in the split containers, otherwise just use the original container to house an alv grid.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi

Yes you can but use the OO GRID

Max

Former Member
0 Kudos

Thanks a lot.

All of you are very helpful to me.

However, Is there any example for my ALV?

BCALV_* there are two many cases _

Former Member
0 Kudos

Hi Minghan Song ,

Its possible using Abap Objects where u can define two Alv Controls with the ur specified size parameters. BUt in normal ALV , u can have restriction that grid supports max of 1024 chars only i.e total lenght of all fields should not exceed 1024 chars.

regards,

Kiran b

0 Kudos

Here is an example. This program implements this using a docking container, but can easily be changed to implement into one custom container on your dynpro. I did it this way for a cut/paste example. Just copy the code and run. Select the radiobuttons on the right to switch the layout. Notice that the alv grids use the same original container.



report  zrich_0005.

data: imara type table of mara with header line.
data: it001w type table of t001w with header line.

  data:
        dockingleft  type ref to cl_gui_docking_container,
        dock_sub_cont1   type ref to cl_gui_container,
        dock_sub_cont2   type ref to cl_gui_container,
        splitter     type ref to cl_gui_splitter_container,
        alv_bottom   type ref to cl_gui_alv_grid,
        alv_top     type ref to cl_gui_alv_grid,
        repid type syrepid.

parameters: p_check type c,
            p_rad1 radiobutton group grp1 default 'X' user-command chk,
            p_rad2 radiobutton group grp1.

start-of-selection.

at selection-screen output.



  repid = sy-repid.


  if not dockingleft is initial.
    call method dockingleft->free.
    clear dockingleft.  free dockingleft.
    call method cl_gui_cfw=>flush.
  endif.

  if p_rad1 = 'X'.
    create object dockingleft
                exporting repid     = repid
                          dynnr     = sy-dynnr
                          side      = dockingleft->dock_at_left
                          extension = 500.

    create object alv_top
                  exporting i_parent = dockingleft.


* Get data
    select * into corresponding fields of table imara
                from mara
                      where mtart = 'ZNBW'.

* Set first display
    call method alv_top->set_table_for_first_display
        exporting
             i_structure_name       = 'MARA'
        changing
             it_outtab       = imara[].

  elseif p_rad2 = 'X'.

    create object dockingleft
                exporting repid     = repid
                          dynnr     = sy-dynnr
                          side      = dockingleft->dock_at_left
                          extension = 500.


    create object splitter
                      exporting parent = dockingleft
                                rows    = 2
                                columns = 1.

    call method:
                    splitter->get_container
                      exporting row            = 1
                                column         = 1
                                receiving container = dock_sub_cont1,

                    splitter->set_row_height
                      exporting id             = 1
                                height         = '14',

                    splitter->get_container
                      exporting row            = 2
                                column         = 1
                                receiving container = dock_sub_cont2.

    create object alv_top
                exporting i_parent =  dock_sub_cont1.

    create object alv_bottom
                exporting i_parent =  dock_sub_cont2.


* Get data
    select * into corresponding fields of table imara
                from mara
                      where mtart = 'ZNBW'.

    select * into corresponding fields of table it001w
                from t001w.

* Set first display
    call method alv_top->set_table_for_first_display
        exporting
             i_structure_name       = 'MARA'
        changing
             it_outtab       = imara[].


    call method alv_bottom->set_table_for_first_display
       exporting
            i_structure_name       = 'T001W'
       changing
            it_outtab       = it001w[].


  endif.


Regards,

Rich Heilman

Former Member
0 Kudos

Hi ,

Here is simple sample prg...

report alv_gridcontrol message-id zmsg.

data: ok_code like sy-ucomm,

gt_sflight type table of sflight,

g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',

grid1 type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container.

----


  • MAIN *

----


select * from sflight into table gt_sflight.

call screen 100.

----


  • MODULE PBO OUTPUT *

----


module pbo output.

set pf-status space.

if g_custom_container is initial.

create object g_custom_container

exporting container_name = g_container.

create object grid1

exporting i_parent = g_custom_container.

call method grid1->set_table_for_first_display

exporting

i_structure_name = 'SFLIGHT'

changing

it_outtab = gt_sflight.

endif.

endmodule. "PBO OUTPUT

----


  • MODULE PAI INPUT *

----


module pai input.

  • to react on oi_custom_events:

  • CALL METHOD CL_GUI_CFW=>DISPATCH.

  • CASE OK_CODE.

  • WHEN 'EXIT'.

  • PERFORM EXIT_PROGRAM.

  • WHEN OTHERS.

    • do nothing

  • ENDCASE.

  • CLEAR OK_CODE.

call method grid1->select_text_in_curr_cell.

message i000 with 'HELLO WORLD'.

endmodule. "PAI INPUT

----


  • FORM EXIT_PROGRAM *

----


form exit_program.

  • CALL METHOD G_CUSTOM_CONTAINER->FREE.

  • CALL METHOD CL_GUI_CFW=>FLUSH.

leave program.

endform. "EXIT_PROGRAM

Regards,

Kiran