You are on page 1of 7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

eGalleryALVProgramsCollection

ABAP7StepstocreateOOPSALVforbeginners
7 AddedbyJayanthiJayaraman,lasteditedbySmrutiRanjanMohantyonOct02,2013(view
change)
Author:JayanthiJayaraman
Subm itted:15.06.07
RelatedLinks:

http://help.sap.com/saphelp_47x200/helpdata/en/0a/b5533cd30911d2b467006094192fe3/frameset.htm
https://w w w .sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d69002010010b7add9719a415907
https://w w w .sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae89002010010ef8bf970a9c41d47
Description
Thisdocumentdescribeshow tocreateanALVusingOOPSmethodinfew steps.Itw illhelpthebeginnerstostartw ith.

Procedure
Step1:Createacontainer.Thereare2containers.Theyaredockingandcustom.
Foreg..Createdockingcontainer.
GotoSE38.Createaprogram.UsePatternbuttontocreateobjectfordockingcontainer.ClickABAPObjectPatternradiobutton.

1
2
3
4
5
6
7
8
9
10
11
12

CREATEOBJECTO_DOCKING
EXPORTING
*PARENT=
*REPID=
*DYNNR=
*SIDE=DOCK_AT_LEFT
*EXTENSION=50
*STYLE=
*LIFETIME=lifetime_default
*CAPTION=
*METRIC=0
RATIO='95'

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

1/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

13
14
15
16
17
18
19
20
21
22
23
24
25
26

*NO_AUTODEF_PROGID_DYNNR=
*NAME=
*EXCEPTIONS
*CNTL_ERROR=1
*CNTL_SYSTEM_ERROR=2
*CREATE_ERROR=3
*LIFETIME_ERROR=4
*LIFETIME_DYNPRO_DYNPRO_LINK=5
*others=6
.
IFSYSUBRC<>0.
*MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
*WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.

Step2:Createagridinsidethecontainer.
UsePatternbuttontocreatethesame.Maketheparentofgridascontainer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

CREATEOBJECTO_GRID
EXPORTING
*I_SHELLSTYLE=0
*I_LIFETIME=
I_PARENT=O_DOCKING
*I_APPL_EVENTS=space
*I_PARENTDBG=
*I_APPLOGPARENT=
*I_GRAPHICSPARENT=
*I_NAME=
*EXCEPTIONS
*ERROR_CNTL_CREATE=1
*ERROR_CNTL_INIT=2
*ERROR_CNTL_LINK=3
*ERROR_DP_CREATE=4
*others=5
.
IFSYSUBRC<>0.
*MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

2/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

20
21

*WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.

Step3:CallthefunctionLVC_FIELDCATALOG_MERGEtogetthefieldcatalog.
Passthestructurename.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

CALLFUNCTION'LVC_FIELDCATALOG_MERGE'
EXPORTING
*I_BUFFER_ACTIVE=
I_STRUCTURE_NAME='MARA'
*I_CLIENT_NEVER_DISPLAY='X'
*I_BYPASSING_BUFFER=
*I_INTERNAL_TABNAME=
CHANGING
CT_FIELDCAT=I_FIELDCAT
*EXCEPTIONS
*INCONSISTENT_INTERFACE=1
*PROGRAM_ERROR=2
*OTHERS=3
.
IFSYSUBRC<>0.
*MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
*WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.

Step4:Callthemethodofgridset_table_for_first_displaytodisplaytheoutput.

1
2
3
4
5
6
7
8
9
10
11

W_VARIANTREPORT=SYREPID.
CALLMETHODO_GRID>SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
*I_BUFFER_ACTIVE=
*I_BYPASSING_BUFFER=
*I_CONSISTENCY_CHECK=
*I_STRUCTURE_NAME=
IS_VARIANT=W_VARIANT
I_SAVE='A'
*I_DEFAULT='X'
*IS_LAYOUT=

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

3/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

*IS_PRINT=
*IT_SPECIAL_GROUPS=
*IT_TOOLBAR_EXCLUDING=
*IT_HYPERLINK=
*IT_ALV_GRAPHICS=
*IT_EXCEPT_QINFO=
CHANGING
IT_OUTTAB=ITAB
IT_FIELDCATALOG=I_FIELDCAT
*IT_SORT=
*IT_FILTER=
*EXCEPTIONS
*INVALID_PARAMETER_COMBINATION=1
*PROGRAM_ERROR=2
*TOO_MANY_LINES=3
*others=4
.
IFSYSUBRC<>0.
*MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
*WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.

Step5:Filltheinternaltableitabw ithvaluesbyusinglogic.
select*frommaraintotableitabupto100row s.
callscreen9000.
Createascreenbydoubleclicking9000intheaboveline.Fillthedescriptionforthescreen.Intheflow logic,uncommentthePBOand
PAImoduleandcreatethoseinmainprogram(forsimplicity).

Step6:CreateGUIstatusasbelow .CreateGUITitleifrequired.

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

4/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

Step7:Freethememoryoccupiedoncethe'BACK,EXIT'or'CANCEL'buttonisclicked.UsePatternbuttontocallthemethod'FREE'of
cl_gui_alv_grid.

CompleteCode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

DATA:ITABTYPESTANDARDTABLEOFMARA,"OutputInternaltable
I_FIELDCATTYPESTANDARDTABLEOFLVC_S_FCAT,"Fieldcatalog
WATYPEMARA,
W_VARIANTTYPEDISVARIANT,
O_DOCKINGTYPEREFTOCL_GUI_DOCKING_CONTAINER,"DockingContainer
O_GRIDTYPEREFTOCL_GUI_ALV_GRID."Grid
SELECT*FROMMARAINTOTABLEITABUPTO100ROWS.
CALLSCREEN9000.
*&amp;
*&amp;ModuleSTATUS_9000OUTPUT
*&amp;
*text
**
MODULESTATUS_9000OUTPUT.
IFO_DOCKINGISINITIAL.
SETPFSTATUS'ZSTATUS'."GUIStatus
SETTITLEBAR'ZTITLE'."Title
*CreatingDockingContainer
CREATEOBJECTO_DOCKING
EXPORTING
RATIO='95'.
IFSYSUBRCEQ0.
*CreatingGrid

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

5/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

CREATEOBJECTO_GRID
EXPORTING
I_PARENT=O_DOCKING.
ENDIF.
*Fillingthefieldcatalogtable
CALLFUNCTION'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME='MARA'
CHANGING
CT_FIELDCAT=I_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE=1
PROGRAM_ERROR=2
OTHERS=3.
W_VARIANTREPORT=SYREPID.
*Displayingtheoutput
CALLMETHODO_GRID>SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT=W_VARIANT
I_SAVE='A'
CHANGING
IT_OUTTAB=ITAB
IT_FIELDCATALOG=I_FIELDCAT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION=1
PROGRAM_ERROR=2
TOO_MANY_LINES=3
OTHERS=4.
IFSYSUBRC<>0.
MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.
ENDIF.
ENDMODULE."STATUS_9000OUTPUT
*&*
*&ModuleUSER_COMMAND_9000INPUT
*&*
*PAI
**
MODULEUSER_COMMAND_9000INPUT.
DATALV_UCOMMTYPESYUCOMM.
LV_UCOMM=SYUCOMM.
CASELV_UCOMM.
WHEN'CANCEl'OR'EXIT'.
PERFORMFREE_OBJECTS.
LEAVEPROGRAM.
WHEN'BACK'.
PERFORMFREE_OBJECTS.
SETSCREEN'0'.

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

6/7

1/30/2015

ABAP7StepstocreateOOPSALVforbeginnersCodeGallerySCNWiki

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

LEAVESCREEN.
ENDCASE.
ENDMODULE."USER_COMMAND_9000INPUT
*&amp;
*&amp;Formfree_objects
*&amp;
*FreeObjects
**
FORMFREE_OBJECTS.
CALLMETHODO_GRID>FREE
EXCEPTIONS
CNTL_ERROR=1
CNTL_SYSTEM_ERROR=2
OTHERS=3.
IFSYSUBRC<>0.
MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.
CALLMETHODO_DOCKING>FREE
EXCEPTIONS
CNTL_ERROR=1
CNTL_SYSTEM_ERROR=2
OTHERS=3.
IFSYSUBRC<>0.
MESSAGEIDSYMSGIDTYPESYMSGTYNUMBERSYMSGNO
WITHSYMSGV1SYMSGV2SYMSGV3SYMSGV4.
ENDIF.
ENDFORM."free_objects

data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22mainheader%22%20style%3D%22marginbottom%3A%2020px%3B%20color%3A%20rgb(51%2C%2

7/7

You might also like