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

List display for ALV using class and methods

Former Member
0 Likes
1,269

Hi friends

I want the list display for the ALV using Class and methods

which class and methods i can use.

Here we can't use the REUSE_ALV_LIST_DISPLAY and also GRID

I was done GRID display using class and methods but i want only list display for using class.

plz Give me sample code of list display not for grid.

Thanks

Nani.

Hi friends

I want the list display for the ALV using Class and methods

which class and methods i can use.

Here we can't use the REUSE_ALV_LIST_DISPLAY and also GRID

I was done GRID display using class and methods but i want only list display for using class.

plz Give me sample code of list display not for grid.

Thanks

Nani.

3 REPLIES 3
Read only

Former Member
0 Likes
621

Hi,

Please check the std program

BCALV_TEST_LIST

Its pretty simple and easy to understand..Pls reward if useful

Read only

0 Likes
621

Hi,

Yes,This is the simple program but in this we r using the Function module of REUSE_ALV_LIST_DISPLAY.

I dont want to use this FM

Read only

Former Member
0 Likes
621

hi

please check with this code...

  • declare grid and container.

DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,

o_dockingcontainer TYPE REF TO cl_gui_docking_container,

i_fieldcat TYPE lvc_t_fcat,"fieldcatalogue

w_layout TYPE lvc_s_layo."layout

If any events like double click,etc., are needed we have to add additional functionality.

call the screen in program.

  • Then , create the container as follows

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

CREATE OBJECT o_dockingcontainer

EXPORTING

ratio = '95'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

ENDIF.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_dockingcontainer.

  • Build the fieldcatalog

  • create a output structure in SEll for the ALV output

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = <alv output>

CHANGING

ct_fieldcat = i_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE i030."Error in building the field catalogue

LEAVE LIST-PROCESSING.

ENDIF.

*If you need to modify the field catalog,modify it using field sysmbols

*setting the layout

w_layout-grid_title = title.

w_layout-zebra = 'X'.

  • then displaying the output

CALL METHOD o_alvgrid->set_table_for_first_display

EXPORTING

i_save = 'A'

is_layout = w_layout

CHANGING

it_outtab = i_output[]

it_fieldcatalog = i_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE i032 ."Error in Displaying

LEAVE LIST-PROCESSING.

ENDIF.

*After that in PAI of the screen, you need to free the *object while going back from the screen(according to *your requirement)

MODULE user_command_9001 INPUT.

CASE sy-ucomm.

WHEN 'EXIT' OR 'CANC'.

PERFORM f9600_free_objects:

USING o_alvgrid 'ALV' text-e02,

USING o_dockingcontainer 'DOCKING'

text-e01.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

*in the program, write the follwoing code

FORM f9600_free_objects USING pobject

value(ptype)

value(ptext).

DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.

CASE ptype.

WHEN 'ALV'.

l_objectalv = pobject.

IF NOT ( l_objectalv IS INITIAL ).

CALL METHOD l_objectalv->free

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

CLEAR: pobject, l_objectalv.

PERFORM f9700_error_handle USING ptext.

ENDIF.

WHEN 'DOCKING'.

DATA: lobjectdock TYPE REF TO cl_gui_docking_container.

lobjectdock = pobject.

IF NOT ( lobjectdock IS INITIAL ).

CALL METHOD lobjectdock->free

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

CLEAR: pobject, lobjectdock.

PERFORM f9700_error_handle USING ptext.

ENDIF.

WHEN 'CONTAINER'.

DATA: lobjectcontainer TYPE REF TO cl_gui_container.

lobjectcontainer = pobject.

IF NOT ( lobjectcontainer IS INITIAL ).

CALL METHOD lobjectcontainer->free

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

CLEAR: pobject, lobjectcontainer.

PERFORM f9700_error_handle USING ptext.

ENDIF.

WHEN OTHERS.

sy-subrc = 1.

PERFORM f9700_error_handle USING

text-e04.

ENDCASE.

ENDFORM. " f9600_free_objects

FORM f9700_error_handle USING value(ptext).

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = text-e03

txt2 = sy-subrc

txt1 = ptext.

ENDIF.

endform.

also check with this

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

Hope this helps

if it helped, you can acknowledge the same by rewarding

regards

dinesh