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

OO ALV?

Former Member
0 Likes
1,446

Hi Experts,

If some one asked me to list out the <u><b>step by step</b></u> procedure to develop a (very) simple ALV grid based on OO ABAP! So, wht culd b the answer for it?

ThanQ.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,299

For OOALV,we define a container.Generally we use a custom container.The class used is <b>cl_gui_custom_container</b>.In the <b>layout of your screen</b>,make a custom container (icon with C written) and name it <b>CONTAINER</b> (in caps).Now create the container by going to the PATTERN button->ABAP objects.

We can now attach a control to the container.ALV,text editor,picture control are different types of controls.For ALV,we use the class <b>cl_gui_alv_grid</b>.Again you can create an instance by using the pattern button.The container name is given as the parent of the ALV in the constructor method.

We can use several methods of the ALV class to display data and for various functionalities.To display the data first time,we use <b>SET_TABLE_FOR_FIRST_DISPLAY</b> method.You can go to se24,type CL_GUI_ALV_GRID and click DISPLAY button.There you can see all the methods and attributes of the ALV class which you can use.

REPORT SAMPLE.

<b>**alv and cont are references to the respective classes.However,the objects are not created yet.</b>

DATA: alv type ref to cl_gui_alv_GRID,

cont type ref to cl_gui_custom_container,

itab_spfli type table of spfli,

ok_code type sy-ucomm.

START-OF-SELECTION.

<b>**I fill my internal table itab_spfli with the data that i want in my ALV display</b>

select * from spfli into table itab_spfli.

<b>**I call the screen.In the screen layout,i have made a container named CONTAINER</b>

call screen 100.

END-OF-SELECTION.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

seT PF-STATUS 'GUI'.

  • SET TITLEBAR 'xxx'.

<b>**If the container is being made for the first time,i create a container object.I m passing the name CONTAINER that i used in the screen layout here</b>

if cont is initial.

CREATE OBJECT cont

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

<b>**The ALV object is created here and the parent name is the container object ie cont</b>

CREATE OBJECT ALV

EXPORTING

I_PARENT = CONT.

<b>**SET_TABLE_FOR_FIRST_DISPLAY method is called to display the data.I give the structure name SPFLI and the internal table which conatins the actual data ie itab_spfli</b>

CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'SPFLI'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT =

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

IT_OUTTAB = itab_spfli

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

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

case ok_code.

when 'BACK'.

leave to screen 0.

when 'EXIT'.

leave to screen 0.

when 'SAVE'.

MODIFY spfli from table itab_spfli.

ENDCASE.

-


<b>Also try the transaction ABAPDOCU for simple ALV programs.</b>

<b>For ALV:</b>

http://help.sap.com/saphelp_erp2005/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm

<b>For OO concepts:</b>

http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

<b>-->download the PDF from following link.</b>

www.abap4.it/download/ALV.pdf

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

Regards,

Beejal

**Reward if this helps

Hi Experts,

If some one asked me to list out the <u><b>step by step</b></u> procedure to develop a (very) simple ALV grid based on OO ABAP! So, wht culd b the answer for it?

ThanQ.

10 REPLIES 10
Read only

amit_khare
Active Contributor
0 Likes
1,299

Check this link choose the easy document yourself -

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
1,299

Hi,

Please check this link on how to build OO ALV.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=...ObjectModelCodeSample.zip

Also please check SAP sample programs:

BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.

BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.

BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.

The report checks the input value(s) semantically and provides protocol messages in case of error

BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to

implement the saving of the new data.

BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:

(1) how to define a column for editable checkboxes for an attribute of your list

(2) how to evaluate the checked checkboxes

(3) how to switch between editable and non-editable checkboxes

BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV

Grid Control.

BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.

BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects

are dealt with:

(1) how to replace the standard f4 help

(2) how to pass the selected value to the ALV Grid Control

(3) how to build an f4 help, whose value range depend on a value of another cell.

Regards,

Ferry Lianto

Read only

0 Likes
1,299

thanq all.

Read only

Former Member
0 Likes
1,300

For OOALV,we define a container.Generally we use a custom container.The class used is <b>cl_gui_custom_container</b>.In the <b>layout of your screen</b>,make a custom container (icon with C written) and name it <b>CONTAINER</b> (in caps).Now create the container by going to the PATTERN button->ABAP objects.

We can now attach a control to the container.ALV,text editor,picture control are different types of controls.For ALV,we use the class <b>cl_gui_alv_grid</b>.Again you can create an instance by using the pattern button.The container name is given as the parent of the ALV in the constructor method.

We can use several methods of the ALV class to display data and for various functionalities.To display the data first time,we use <b>SET_TABLE_FOR_FIRST_DISPLAY</b> method.You can go to se24,type CL_GUI_ALV_GRID and click DISPLAY button.There you can see all the methods and attributes of the ALV class which you can use.

REPORT SAMPLE.

<b>**alv and cont are references to the respective classes.However,the objects are not created yet.</b>

DATA: alv type ref to cl_gui_alv_GRID,

cont type ref to cl_gui_custom_container,

itab_spfli type table of spfli,

ok_code type sy-ucomm.

START-OF-SELECTION.

<b>**I fill my internal table itab_spfli with the data that i want in my ALV display</b>

select * from spfli into table itab_spfli.

<b>**I call the screen.In the screen layout,i have made a container named CONTAINER</b>

call screen 100.

END-OF-SELECTION.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

seT PF-STATUS 'GUI'.

  • SET TITLEBAR 'xxx'.

<b>**If the container is being made for the first time,i create a container object.I m passing the name CONTAINER that i used in the screen layout here</b>

if cont is initial.

CREATE OBJECT cont

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

<b>**The ALV object is created here and the parent name is the container object ie cont</b>

CREATE OBJECT ALV

EXPORTING

I_PARENT = CONT.

<b>**SET_TABLE_FOR_FIRST_DISPLAY method is called to display the data.I give the structure name SPFLI and the internal table which conatins the actual data ie itab_spfli</b>

CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'SPFLI'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT =

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

IT_OUTTAB = itab_spfli

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

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

case ok_code.

when 'BACK'.

leave to screen 0.

when 'EXIT'.

leave to screen 0.

when 'SAVE'.

MODIFY spfli from table itab_spfli.

ENDCASE.

-


<b>Also try the transaction ABAPDOCU for simple ALV programs.</b>

<b>For ALV:</b>

http://help.sap.com/saphelp_erp2005/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm

<b>For OO concepts:</b>

http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

<b>-->download the PDF from following link.</b>

www.abap4.it/download/ALV.pdf

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

Regards,

Beejal

**Reward if this helps

Read only

0 Likes
1,299

ThnaQ.

Read only

0 Likes
1,299

ThnaQ Beejal,

Is it right that in OO ALVs, to build the Filed Catalogue, one must use the only LVC_T_Fieldcat and for Layout, its LVC_T_LAYO?

THnaQ.

Read only

0 Likes
1,299

Hello Srinivas,

Field catalog can be built <b>manually</b> or <b>semi-automatically</b>:

Check Pages <b>10-14</b> in the document below:

<b>http://www.abap4.it/download/ALV.pdf</b>

You can build a field catalog without using LVC_T_FCAT if you are building the field catalog semi-automatically by using a function module.The name of the function module is “<b>LVC_FIELDCATALOG_MERGE</b>”.

For layout adjustments,check pages <b>15-16</b> in the above document.

Regards,

Beejal

Read only

0 Likes
1,299

ThanQ.

So,

1- When we go for SLIS_T_FILEDCAT and When we go for LVC_T_FILEDCAT? What r the differences?

2-In the same way, What r the situations demand for to use SLIS_LAYOUT_ALV and What r for LVC_T_LAYO?

ThanQ.

Read only

Former Member
0 Likes
1,299

Hi,

we use LVC_T_FCAT/LVC_S_FCAT in OO alv and

SLIS_T_FIELDCAT_ALV/ SLIS_FIELDCAT_ALV in normal alv for fieldcatalog,

similarly LVC_S_LAYO use in OO alv and

slis_layout_alv in normal alv for layout setting

Regards,

Read only

0 Likes
1,299

ThanQ all.