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: 

OOPS CONCEPTS IN ALV

Former Member
0 Kudos
238

Hi ,

Can anyone pls help me out with oops concepts in alv..If any of u have any kind of material for oops in alv pls do share witrh me.....Are there any oops specific function modules using which we generate alv reporting...Pls help me out ASAP in this regard...

8 REPLIES 8

Former Member
0 Kudos
83

Hi,

When we say OOPS (at least in the ALV context), we don't talk about the Function Module at all. There's just some classes which we use and their <i>methods</i>.

Serdar has written a good technical article on this. Here's the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf">link</a>.

Regards,

Anand Mandalika.

0 Kudos
83

Hi Anand

Thank you for giving the link...

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

0 Kudos
83

Thanks seader thats really a very gud article on oops...that really helped me a lot......

jayanthi_jayaraman
Active Contributor
0 Kudos
83

Hi,

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

In case of sorting,filetering,etc., you need to add extra codings.

In this text-e0* are error messages.

Regards,

J.Jayanthi

Message was edited by: Jayanthi Jayaraman

Former Member
0 Kudos
83

Thanks very much anand & Jayanthi...Thats really helpful for me....But pls the other guys too share if u have any material with u....or just share ur knowledge on OOPS in ALV....Kindly consider this guys as i need to work on this very soon....

jayanthi_jayaraman
Active Contributor
0 Kudos
83

Hi,

Try this link.

http://www.sapgenie.com/abap/controls/alvgrid.htm

Regards,

J.Jayanthi

0 Kudos
83

Thanks a lot jayanti..That will b very much helpful to me...