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

Re: OOPS

Former Member
0 Likes
528

Hi all,

when we developing a report ,

what is the advantage if u develop a report using oops over normal report,

explain me with exmpale, i wil give u full points.

regards,

Sashi

3 REPLIES 3
Read only

0 Likes
498

Perhaps the most important cause is because sap is updating all his reports and standard transactions to use oops, so many people prefres use oops.

Read only

Former Member
0 Likes
498

Hi,

There is a lot of difference...is there..first of all alv is very flexible and convinent for the endcustomer..and can do what ever changes he want..on final output...for this there is less coding part required....more user oriented...

stylish..colorfull,,attractive..

so now days cutomers are taking only alv report..

Sample code:

&----


*& Report ZMAT_ALV_GRID *

*& *

&----


*& *

*& *

&----


REPORT ZCL_CLASS1.

TYPES: BEGIN OF T_MARA,

MATNR TYPE MARA-MATNR,

MAKTX TYPE MAKT-MAKTX,

WERKS TYPE MARD-WERKS,

LGORT TYPE MARD-LGORT,

LABST TYPE MARD-LABST,

END OF T_MARA.

*DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.

DATA: IT_MARA TYPE T_MARA OCCURS 0.

DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_GRID TYPE REF TO CL_GUI_ALV_GRID.

DATA: X_FLDCAT TYPE LVC_S_FCAT.

DATA: IT_FLDCAT TYPE LVC_T_FCAT.

DATA: I_LAYOUT TYPE LVC_S_LAYO.

DATA: X_SORT TYPE LVC_S_SORT.

DATA: I_SORT TYPE LVC_T_SORT.

TABLES: MARA.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

PARAMETERS: P_CHK AS CHECKBOX.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM GENERATE_FLDCAT.

PERFORM GENERATE_LAYOUT.

PERFORM DO_SORT.

SET SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN'.

  • SET TITLEBAR 'xxx'.

PERFORM BUILD_ALV.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form BUILD_ALV

&----


  • text

----


FORM BUILD_ALV .

CREATE OBJECT O_CONT

EXPORTING

CONTAINER_NAME = 'MAT_CONTAINER'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

others = 6.

CREATE OBJECT O_GRID

EXPORTING

I_PARENT = O_CONT

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

others = 5.

CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = ' '

IS_LAYOUT = I_LAYOUT

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = IT_MARA

IT_FIELDCATALOG = IT_FLDCAT[]

IT_SORT = I_SORT

  • IT_FILTER =

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

others = 4.

ENDFORM. " BUILD_ALV

&----


*& Form GET_DATA

&----


  • text

----


FORM GET_DATA .

SELECT A~MATNR

B~MAKTX

C~WERKS

C~LGORT

C~LABST

INTO TABLE IT_MARA

FROM MARA AS A

INNER JOIN MAKT AS B

ON BMATNR = AMATNR

INNER JOIN MARD AS C

ON CMATNR = AMATNR

WHERE A~MATNR IN S_MATNR

AND B~SPRAS = SY-LANGU.

ENDFORM. " GET_DATA

&----


*& Form GENERATE_FLDCAT

&----


  • text

----


FORM GENERATE_FLDCAT .

*CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

  • EXPORTING

    • I_BUFFER_ACTIVE =

  • I_STRUCTURE_NAME = 'ZSMARA'

    • I_CLIENT_NEVER_DISPLAY = 'X'

    • I_BYPASSING_BUFFER =

    • I_INTERNAL_TABNAME = ' '

  • CHANGING

  • CT_FIELDCAT = IT_FLDCAT

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3.

X_FLDCAT-COL_POS = 1.

X_FLDCAT-FIELDNAME = 'MATNR'.

X_FLDCAT-OUTPUTLEN = '18'.

X_FLDCAT-REPTEXT = 'Material No'.

APPEND X_FLDCAT TO IT_FLDCAT.

X_FLDCAT-COL_POS = 2.

X_FLDCAT-FIELDNAME = 'MAKTX'.

X_FLDCAT-OUTPUTLEN = '48'.

X_FLDCAT-REPTEXT = 'Material Desc'.

X_FLDCAT-TOOLTIP = 'Material Desc'.

APPEND X_FLDCAT TO IT_FLDCAT.

X_FLDCAT-COL_POS = 3.

X_FLDCAT-FIELDNAME = 'WERKS'.

X_FLDCAT-OUTPUTLEN = '5'.

X_FLDCAT-REPTEXT = 'Plant'.

X_FLDCAT-TOOLTIP = 'Plant'.

APPEND X_FLDCAT TO IT_FLDCAT.

X_FLDCAT-COL_POS = 4.

X_FLDCAT-FIELDNAME = 'LGORT'.

X_FLDCAT-OUTPUTLEN = '5'.

X_FLDCAT-REPTEXT = 'S.Loc'.

X_FLDCAT-TOOLTIP = 'S.Loc'.

APPEND X_FLDCAT TO IT_FLDCAT.

X_FLDCAT-COL_POS = 5.

X_FLDCAT-FIELDNAME = 'LABST'.

X_FLDCAT-OUTPUTLEN = '20'.

X_FLDCAT-REPTEXT = 'Quantity'.

X_FLDCAT-TOOLTIP = 'Quantity'.

X_FLDCAT-DO_SUM = 'X'.

APPEND X_FLDCAT TO IT_FLDCAT.

ENDFORM. " GENERATE_FLDCAT

&----


*& Form GENERATE_LAYOUT

&----


  • text

----


FORM GENERATE_LAYOUT .

I_LAYOUT-ZEBRA = 'X'.

I_LAYOUT-FRONTEND = 'X'.

I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.

I_LAYOUT-NUMC_TOTAL = 'X'.

ENDFORM. " GENERATE_LAYOUT

&----


*& Form DO_SORT

&----


  • text

----


FORM DO_SORT .

X_SORT-FIELDNAME = 'MATNR'.

X_SORT-UP = 'X'.

X_SORT-SUBTOT = 'X'.

IF P_CHK = 'X'.

X_SORT-EXPA = SPACE.

ELSE.

X_SORT-EXPA = 'X'.

ENDIF.

APPEND X_SORT TO I_SORT.

ENDFORM. " DO_SORT

inorder to execute this code perfectly, do the following things.

1. Create a Graphical Screen 100.

2. Place a Custom Control on that screen and give name as MAT_CONTAINER.

3. activate the screen.

and execute the program.

Also Check these programs and links.

OOPS ALV

standard pgms

ABAP_OBJECTS_ENJOY_0 Template for Solutions of ABAP Object Enjoy Course

ABAP_OBJECTS_ENJOY_1 Model Solution 1: ABAP Objects Enjoy Course

ABAP_OBJECTS_ENJOY_2 Model Solution 2: ABAP Objects Enjoy Course

ABAP_OBJECTS_ENJOY_3 Model Solution 3: ABAP Objects Enjoy Course

ABAP_OBJECTS_ENJOY_4 Model Solution 4: ABAP Objects Enjoy Course

ABAP_OBJECTS_ENJOY_5 Model Solution 5: ABAP Objects Enjoy Course

DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects

DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen

DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects

DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration

DEMO_ABAP_OBJECTS_INTERFACES Demonstration of Interfaces in ABAP Objects

DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects

DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen

some helful links.

Go through the below links,

For Materials:

1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291

2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt

3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf

5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt

6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf

7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt

😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

1) http://www.erpgenie.com/sap/abap/OO/index.htm

2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

please use these sample codes to understand about OOALV

BC_ALV_GRID_CONTROL

BC_ALVHIERGRID1_D100

BC_ALVHIERGRID1_D210

BC_ALVHIERGRID1_HIER

BC_ALV_DEMO_HTML_D0100

BC_ALV_GRID_CONTROL

BC_ALVEXCEL

BC_ALVEXCEL_D100

BC_ALVEXCEL_D210

BC_ALVEXCEL_HIER

BC_ALVEXCEL_SAP_TEMPL

BC_ALVEXCEL_SAP_TEMPL_F01

BC_ALVEXCEL_SAP_TEMPL_TOP

BC_ALVEXCELTOP

BC_ALVHIERGRID1_D100

BC_ALVHIERGRID1_D210

BC_ALVHIERGRID1_HIER

BC_ALVHIERTOP

For learning OOPS-ALV in every SAP their is transaction named ZALV

or try the following links:

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

The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within

a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP

programs as detailed below:

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.

Reward points if found helpful…..

Cheers,

Chandra Sekhar.

Read only

Former Member
0 Likes
498

Hi,

Normal abap is structured programing, where as OOPs asynchrnous type and it have advantages like abstraction, encapsulation, polymorphism, interfaces etc..

Plzz reward points if it is useful.