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 Grid

Former Member
0 Likes
2,407

Hi all,

Developed 'Medical and hospitalization' report'.

for ex selection period - 01.05.2008 - 31.05.2008

totally 4 alv layouts will be display.

Ie 2 layouts for medical and 2 layouts for hospitalization .

1. Medical month - 01.05.2008 - 31.05.2008

2. Medical year - 01.01.2008 - 31.05.2008

3. Hospitalization month - 01.05.2008 - 31.05.2008

4. Hospitalization year - 01.01.2008 - 31.05.2008

My req is display above all layouts in one screen? Is it possible? if yes means any body can help to me. If not possible means what is other way to do?

Thanks in advance.

shruthi

Hi all,

Developed 'Medical and hospitalization' report'.

for ex selection period - 01.05.2008 - 31.05.2008

totally 4 alv layouts will be display.

Ie 2 layouts for medical and 2 layouts for hospitalization .

1. Medical month - 01.05.2008 - 31.05.2008

2. Medical year - 01.01.2008 - 31.05.2008

3. Hospitalization month - 01.05.2008 - 31.05.2008

4. Hospitalization year - 01.01.2008 - 31.05.2008

My req is display above all layouts in one screen? Is it possible? if yes means any body can help to me. If not possible means what is other way to do?

Thanks in advance.

shruthi

16 REPLIES 16
Read only

bpawanchand
Active Contributor
Read only

0 Likes
2,383

u can use block alv for the same requirment.

for example go to DWDM transaction

Read only

Former Member
0 Likes
2,383

for this u can use custom controls in asingle screen.

use oo alv concpts.

see the examples provided by sap .

Read only

Former Member
0 Likes
2,383

Hi Shruthi,

Check this blog for complete code:

Regards,

Chandra Sekhar

Read only

0 Likes
2,383

Hi,

I already used interactive reports for displaying 4 layouts.

but users want at least display 2 in each screen.

Shruthi.

Read only

Former Member
0 Likes
2,383

Hi Shruthi,

u can do it using ALV BLOCK LISTS...

Check the sample code..

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = pfstatus

i_callback_user_command = 'USER_COMMAND'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = i_layout

it_fieldcat = i_fieldcat

i_tabname = 'T_BASIC1'

it_events = gt_xevents

TABLES

t_outtab = t_basic1

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 FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

it_fieldcat = i_fieldcat1

is_layout = i_layout

i_tabname = 'T_BASIC2F'

it_events = gt_yevents

TABLES

t_outtab = t_basic2f.

gt_print-reserve_lines = 2.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXPORTING

is_print = gt_print

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

.

ENDIF.

Read only

Former Member
0 Likes
2,383

Hi,

Try object oriented ALV. Search SDN you will find lots of material on OO ALV.

Regards,

Prashant

Read only

0 Likes
2,383

Hi all,

I tried OO ALV to display output (Single Layout).

but nothing to display.

1. I created report

2. Created a screen 'with screen no '100' (SE 51)

3. Created status in SE41 for the same program.

Just refer the below code.

Can u tell anyone what are missing in code wise?

&----


*& Report ZOO_ALV

*&

&----


*&

*&

&----


REPORT ZOO_ALV.

tables : mara.

*----


  • G L O B A L I N T E R N A L T A B L E S

*----


DATA: it_mara TYPE STANDARD TABLE OF mara.

*----


  • G L O B A L D A T A

*----


DATA: ok_code LIKE sy-ucomm,

g_wa_sflight LIKE sflight.

  • Declare reference variables to the ALV grid and the container

DATA : ob_custom TYPE REF TO cl_gui_custom_container ,

ob_split1 TYPE REF TO cl_gui_easy_splitter_container ,

ob_split2 TYPE REF TO cl_gui_easy_splitter_container ,

ob_grid1 TYPE REF TO cl_gui_alv_grid ,

ob_grid2 TYPE REF TO cl_gui_alv_grid ,

ob_grid3 TYPE REF TO cl_gui_alv_grid .

DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.

data lt_fieldcat TYPE slis_t_fieldcat_alv.

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.

DATA gr_ccontainer1 TYPE REF TO cl_gui_custom_container.

DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.

DATA gc_custom_control_name1 TYPE scrfname VALUE 'CC_ALV1'.

DATA gs_layout TYPE lvc_s_layo.

DATA: lv_structure TYPE dd02l-tabname VALUE 'MARA',

*----


  • S T A R T - O F - S E L E C T I O N.

*----


START-OF-SELECTION.

  • PERFORM load_data_into_grid.

call SCREEN '100'.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ZPF01'.

SET TITLEBAR 'ZPF01'.

PERFORM prepare_field_catalog CHANGING gt_fieldcat[].

PERFORM prepare_layout CHANGING gs_layout.

PERFORM data_retrival.

IF gr_alvgrid IS INITIAL.

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

IF sy-subrc <> 0.

ENDIF.

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

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 METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = it_mara[]

it_fieldcatalog = gt_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endif.

ENDMODULE. " status_0100 OUTPUT

&----


*& Module user_command_0100 INPUT.

&----


  • text

----


MODULE user_command_0100 INPUT.

IF sy-ucomm = 'BACK' OR sy-ucomm = 'EXIT' .

FREE : ob_grid1 ,

ob_grid2 ,

ob_grid3 ,

ob_split1 ,

ob_split2 ,

ob_custom .

LEAVE TO SCREEN 0 .

ENDIF.

ENDMODULE. " user_command_0100 INPUT

  • ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Form load_data_into_grid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM load_data_into_grid .

  • Read data from table SFLIGHT

SELECT *

FROM mara

INTO TABLE it_mara up to 10 rows.

ENDFORM. " load_data_into_grid

&----


*& Form prepare_field_catalog

&----


  • text

----


  • <--P_GT_FIELDCAT[] text

----


FORM prepare_field_catalog CHANGING FIELDCAT TYPE lvc_t_fcat.

DATA ls_fieldcat TYPE lvc_s_fcat.

ls_fieldcat-tabname = 'IT_MARA'.

ls_fieldcat-fieldname = 'MATNR'.

ls_fieldcat-scrtext_m = 'MATERIAL NO'.

ls_fieldcat-col_pos = 0.

ls_fieldcat-outputlen = 10.

APPEND ls_fieldcat TO fieldcat.

ls_fieldcat-tabname = 'IT_MARA'.

ls_fieldcat-col_pos = 1.

ls_fieldcat-fieldname = 'ERSDA'.

ls_fieldcat-scrtext_m = 'ERSDA'.

APPEND ls_fieldcat TO fieldcat.

ls_fieldcat-tabname = 'IT_MARA'.

ls_fieldcat-fieldname = 'ERNAM'.

ls_fieldcat-scrtext_m = 'ERNAM'.

APPEND ls_fieldcat TO fieldcat.

ENDFORM. " prepare_field_catalog

&----


*& Form data_retrival

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_retrival .

SELECT * from mara

INTO CORRESPONDING FIELDS OF TABLE it_mara

UP TO 50 ROWS.

ENDFORM. " data_retrival

&----


*& Form prepare_layout

&----


  • text

----


  • <--P_GS_LAYOUT text

----


FORM prepare_layout CHANGING GS_LAYOUT TYPE lvc_s_layo.

gs_layout-stylefname = 'FIELD_STYLE'.

gs_layout-zebra = 'X'.

gs_layout-grid_title = 'FLIGHT'.

gs_layout-sel_mode = 'A'.

gs_layout-ctab_fname = 'COLORS'.

ENDFORM. " prepare_layout

Read only

0 Likes
2,383

Hi

In Dialog progamming the START-OF-SELECTION event won't trigger. The main events in Module pool are

PBO, PAI, POV & POH.

Call the subroutine "load_data_into_grid" in MODULE STATUS_100 OUTPUT event instead of

START-OF-SELECTION event

Hope it helps.

Murthy

Read only

0 Likes
2,383

Hi Murthy,

I called the perform data_retrival in MODULE STATUS_0100 OUTPUT.

But still didn't pick up.

at the point of executing ' CALL METHOD gr_alvgrid->set_table_for_first_display'

IT table and field catalog have some values. But didn't display.

Hi allem,

Users want ALV Grid not ALV List.

Thanks.

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ZPF01'.

SET TITLEBAR 'ZPF01'.

PERFORM prepare_field_catalog CHANGING gt_fieldcat[].

PERFORM prepare_layout CHANGING gs_layout.

PERFORM data_retrival.

IF gr_alvgrid IS INITIAL.

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

IF sy-subrc <> 0.

ENDIF.

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

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 METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = it_mara[]

it_fieldcatalog = gt_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endif.

ENDMODULE. " status_0100 OUTPUT

Read only

former_member787646
Contributor
0 Likes
2,383

Hi

You can achieve this by displaying the data in ALV Grids using Object Oriented approach.

I mean OO ABAP.

Hope it helps.

Murthy

Read only

Former Member
0 Likes
2,383

hi,

See for displaying all the 4 list in one screen u can use block report of ALV instead of simple ALV.

the FM to be used are-

reuse_alv_block_list_int.

reuse_alv_block_list_append.

reuse_alv_block_list_display.

Hope this will help u.

regards,

Aleem.

Read only

former_member787646
Contributor
0 Likes
2,383

Hi,

In the METHOD gr_alvgrid->set_table_for_first_display you have to pass the Structure Name in Exporting parameters.

(go through the program "BCALV_GRID_DEMO" in ABAP Editor)

Hope it helps.

Murthy

Read only

0 Likes
2,383

Hi Murthy,

I already tried that ligic. But doesn't work.

U just copy my program and execute in ur system then u may find what is the problem. Can u tell me the procedure for creating PF Status and title .

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

i_structure_name = 'MARA'

is_layout = gs_layout

CHANGING

it_outtab = it_mara[]

  • it_fieldcatalog = gt_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Thanks.

Read only

0 Likes
2,383

Hi all,

I tried one more sample for OO ALV.

But didn't display output.

i think i did mistakes in setting PF Staus.

Can any body tell the steps to create PF Status related to OO ALV.

This is the another sample program ( Getting from net).

&----


*& Report ZRICH_0001

*&

&----


*&

*&

&----


REPORT ZRICH_0001.

TABLES : scarr .

DATA : it_scarr TYPE TABLE OF scarr .

DATA : ob_custom TYPE REF TO cl_gui_custom_container ,

ob_split1 TYPE REF TO cl_gui_easy_splitter_container ,

ob_split2 TYPE REF TO cl_gui_easy_splitter_container ,

ob_grid1 TYPE REF TO cl_gui_alv_grid ,

ob_grid2 TYPE REF TO cl_gui_alv_grid ,

ob_grid3 TYPE REF TO cl_gui_alv_grid .

SELECT-OPTIONS : s_carrid FOR scarr-carrid .

*START-OF-SELECTION .

  • SELECT * INTO TABLE it_scarr FROM scarr WHERE carrid IN s_carrid .

CALL SCREEN 100.

&----


*&

  • Module status_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'ZPF01' .

SET TITLEBAR 'ZTITLE01' .

SELECT * INTO TABLE it_scarr FROM scarr WHERE carrid IN s_carrid .

  • This will create a container

CREATE OBJECT ob_custom

EXPORTING

container_name = 'CONTAINER' .

  • This spit the container OB_CUSTOM into two

CREATE OBJECT ob_split1

EXPORTING

parent = ob_custom

orientation = cl_gui_easy_splitter_container=>orientation_vertical .

  • Now we have two container

  • OB_SPLIT1->TOP_LEFT_CONTAINER

  • OB_SPLIT1->BOTTOM_RIGHT_CONTAINER

  • Since these two are itself a container we can further devide them into two.

  • Let try to divide OB_SPLIT1->BOTTOM_RIGHT_CONTAINER into two

CREATE OBJECT ob_split2

EXPORTING

parent = ob_split1->bottom_right_container

orientation = cl_gui_easy_splitter_container=>orientation_horizontal .

  • Now we have total 3 container available with us

  • OB_SPLIT1->TOP_LEFT_CONTAINER

  • OB_SPLIT2->TOP_LEFT_CONTAINER

  • OB_SPLIT2->BOTTOM_RIGHT_CONTAINER

  • Note that OB_SPLIT1->BOTTOM_RIGHT_CONTAINER is not available because we divided* that into two.

  • Now Put a grid in each container

CREATE OBJECT ob_grid1

EXPORTING

i_parent = ob_split1->top_left_container .

CREATE OBJECT ob_grid2

EXPORTING

i_parent = ob_split2->top_left_container .

CREATE OBJECT ob_grid3

EXPORTING

i_parent = ob_split2->bottom_right_container .

CALL METHOD ob_grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'SCARR'

CHANGING

it_outtab = it_scarr.

CALL METHOD ob_grid2->set_table_for_first_display

EXPORTING

i_structure_name = 'SCARR'

CHANGING

it_outtab = it_scarr.

CALL METHOD ob_grid3->set_table_for_first_display

EXPORTING

i_structure_name = 'SCARR'

CHANGING

it_outtab = it_scarr.

ENDMODULE. " status_0100 OUTPUT

&----


*& Module user_command_0100 INPUT.

&----


  • text

----


MODULE user_command_0100 INPUT.

IF sy-ucomm = 'BACK' OR sy-ucomm = 'EXIT' .

FREE : ob_grid1 ,

ob_grid2 ,

ob_grid3 ,

ob_split1 ,

ob_split2 ,

ob_custom .

LEAVE TO SCREEN 0 .

ENDIF.

ENDMODULE. " user_command_0100 INPUT

Thanks & Regards,

Shruthi.

Read only

0 Likes
2,383

Click on the ZPF01 , it asks for creation, enter title and ypu will go to Menu painter screen , there you enable what ever function keys you want. and Activate. the same is applicable to Title .Dodble click on it and create the title.

MODULE status_0100 OUTPUT.

SET PF-STATUS 'ZPF01' . "Double click on this and create