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 Help

Former Member
0 Kudos

HI Friends,

I know to code the ALV Reports using the Function Modules.

Can anyone specify me the help links for me to learn the ALV using Classes ?

1 ACCEPTED SOLUTION

prasanth_kasturi
Active Contributor
0 Kudos

hi,

Hi,

Here is a code for a single grid.

In the screen layout,make a custom container (Icon with C ) and name it in Capital letters as CONTAINER.The code below in bold letters is what exactly you want.I ve given a small example on how to use ALV:

REPORT SAMPLE.

DATA: alv type ref to cl_gui_alv_GRID,

cont type ref to cl_gui_custom_container,

itab_spfli type table of spfli.

START-OF-SELECTION.

select * from spfli into table itab_spfli.

call screen 100.

END-OF-SELECTION.

&----


*& Module STATUS_0100 OUTPUT

&----


text

-


MODULE STATUS_0100 OUTPUT.

seT PF-STATUS 'GUI'.

SET TITLEBAR 'xxx'.

if cont is initial.

CREATE OBJECT cont

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT ALV

EXPORTING

I_PARENT = CONT.

CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SPFLI'

CHANGING

IT_OUTTAB = itab_spfli

Now for your requirement,you can create two custom containers in the screen layout and two different alv grid instances.ie:

DATA: alv1 type ref to cl_gui_alv_GRID,

cont1 type ref to cl_gui_custom_container

alv2 type ref to cl_gui_alv_GRID,

cont2 type ref to cl_gui_custom_container.

To select data from first grid,you can use events on double_click and fetch information and then display it in the second grid.

SOME MATERIAL REGARDING ALV:

www.abap4.it/download/ALV.pdf (very useful)

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

-->download the PDF from following link.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

SAMPLE PROGRAMS IN ALV:http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid

DEMO PROGRAMS IN ALV:BCALV*

https://forums.sdn.sap.com/click.jspa?searchID=11250185&messageID=4159845

https://forums.sdn.sap.com/click.jspa?searchID=11250185&messageID=2971316

http://abapprogramming.blogspot.com/2007/11/alv-list-using-oo-style-sample-code.html

http://sap-abapinfo.blogspot.com/2008/05/alv-list-using-oo-style-sample-code.html

http://www.saptechnical.com/Tutorials/ALV/ALVMainPage.htm

http://www.saptechnical.com/Tutorials/ALV/ColumnExcl.htm

http://www.saptechnical.com/Tutorials/ALV/Total/text.htm

http://www.abapcode.info/2007/06/object-oriented-alv-sample-program-to.html

regards

prasanth

5 REPLIES 5

prasanth_kasturi
Active Contributor
0 Kudos

hi,

Hi,

Here is a code for a single grid.

In the screen layout,make a custom container (Icon with C ) and name it in Capital letters as CONTAINER.The code below in bold letters is what exactly you want.I ve given a small example on how to use ALV:

REPORT SAMPLE.

DATA: alv type ref to cl_gui_alv_GRID,

cont type ref to cl_gui_custom_container,

itab_spfli type table of spfli.

START-OF-SELECTION.

select * from spfli into table itab_spfli.

call screen 100.

END-OF-SELECTION.

&----


*& Module STATUS_0100 OUTPUT

&----


text

-


MODULE STATUS_0100 OUTPUT.

seT PF-STATUS 'GUI'.

SET TITLEBAR 'xxx'.

if cont is initial.

CREATE OBJECT cont

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT ALV

EXPORTING

I_PARENT = CONT.

CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SPFLI'

CHANGING

IT_OUTTAB = itab_spfli

Now for your requirement,you can create two custom containers in the screen layout and two different alv grid instances.ie:

DATA: alv1 type ref to cl_gui_alv_GRID,

cont1 type ref to cl_gui_custom_container

alv2 type ref to cl_gui_alv_GRID,

cont2 type ref to cl_gui_custom_container.

To select data from first grid,you can use events on double_click and fetch information and then display it in the second grid.

SOME MATERIAL REGARDING ALV:

www.abap4.it/download/ALV.pdf (very useful)

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

-->download the PDF from following link.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

SAMPLE PROGRAMS IN ALV:http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid

DEMO PROGRAMS IN ALV:BCALV*

https://forums.sdn.sap.com/click.jspa?searchID=11250185&messageID=4159845

https://forums.sdn.sap.com/click.jspa?searchID=11250185&messageID=2971316

http://abapprogramming.blogspot.com/2007/11/alv-list-using-oo-style-sample-code.html

http://sap-abapinfo.blogspot.com/2008/05/alv-list-using-oo-style-sample-code.html

http://www.saptechnical.com/Tutorials/ALV/ALVMainPage.htm

http://www.saptechnical.com/Tutorials/ALV/ColumnExcl.htm

http://www.saptechnical.com/Tutorials/ALV/Total/text.htm

http://www.abapcode.info/2007/06/object-oriented-alv-sample-program-to.html

regards

prasanth

Former Member
0 Kudos

Hi,

Object Oriented ALV-Sample program to insert Logo in ALV

REPORT z_ooalv_logo.

****DECLARATION FOR LOGO INSERT

CONSTANTS: cntl_true TYPE i VALUE 1,

cntl_false TYPE i VALUE 0.

DATA:h_picture TYPE REF TO cl_gui_picture,

h_pic_container TYPE REF TO cl_gui_custom_container.

DATA: graphic_url(255),

graphic_refresh(1),

g_result LIKE cntl_true.

DATA: BEGIN OF graphic_table OCCURS 0,

line(255) TYPE x,

END OF graphic_table.

DATA: graphic_size TYPE i.

CALL SCREEN 100.

&----


*& Module PICTURE OUTPUT

&----


  • text

----


MODULE picture OUTPUT.

DATA: l_graphic_xstr TYPE xstring,

l_graphic_conv TYPE i,

l_graphic_offs TYPE i.

CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

EXPORTING

p_object = 'GRAPHICS'

p_name = 'EDS'"IMAGE NAME - Image name from SE78

p_id = 'BMAP'

p_btype = 'BCOL'

RECEIVING

p_bmp = l_graphic_xstr

EXCEPTIONS

not_found = 1

OTHERS = 2.

graphic_size = XSTRLEN( l_graphic_xstr ).

CHECK graphic_size > 0.

l_graphic_conv = graphic_size.

l_graphic_offs = 0.

WHILE l_graphic_conv > 255.

graphic_table-line = l_graphic_xstr+l_graphic_offs(255).

APPEND graphic_table.

l_graphic_offs = l_graphic_offs + 255.

l_graphic_conv = l_graphic_conv - 255.

ENDWHILE.

graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

APPEND graphic_table.

CALL FUNCTION 'DP_CREATE_URL'

EXPORTING

type = 'image'

subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'

size = graphic_size

lifetime = cndp_lifetime_transaction "'T'

TABLES

data = graphic_table

CHANGING

url = graphic_url

EXCEPTIONS

  • dp_invalid_parameter = 1

  • dp_error_put_table = 2

  • dp_error_general = 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.

EXIT.

ENDIF.

CREATE OBJECT h_pic_container

EXPORTING container_name = 'LOGO'.

CREATE OBJECT h_picture EXPORTING parent = h_pic_container.

CALL METHOD h_picture->load_picture_from_url

EXPORTING

url = graphic_url

IMPORTING

RESULT = g_result.

ENDMODULE. " PICTURE OUTPUT

http://www.abapcode.info/2007/06/object-oriented-alv-sample-program-to.html

Regards,

Jagadish

Former Member
0 Kudos

Easy_Reference_ALV_Grid_Control(1)

thanks

Edited by: Richa Khosla on Jun 9, 2008 7:15 AM