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

OOP ALV?

former_member2382
Active Participant
0 Likes
703

Hi,

Can you lemme know, how do we implement ALV using OOABAP? Will be good be can provide me sample code for the same.

Regards,

Parvez.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
682

Hi Parvez,

Here is the simple code as explained previously.


*&---------------------------------------------------------------------*
*& Report  ZGS_SIMPLE_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zgs_simple_alv.

DATA : it_mara TYPE TABLE OF mara.

DATA : container TYPE REF TO cl_gui_custom_container,
       grid TYPE REF TO cl_gui_alv_grid.

SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.

 CREATE OBJECT container
   EXPORTING
*     PARENT                      =
     container_name              =  'CONTAINER'
*     STYLE                       =
*     LIFETIME                    = lifetime_default
*     REPID                       =
*     DYNNR                       =
*     NO_AUTODEF_PROGID_DYNNR     =
*   EXCEPTIONS
*     CNTL_ERROR                  = 1
*     CNTL_SYSTEM_ERROR           = 2
*     CREATE_ERROR                = 3
*     LIFETIME_ERROR              = 4
*     LIFETIME_DYNPRO_DYNPRO_LINK = 5
*     others                      = 6
     .
 IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 ENDIF.


CREATE OBJECT grid
  EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
    i_parent          = container
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
*    I_FCAT_COMPLETE   = SPACE
*  EXCEPTIONS
*    ERROR_CNTL_CREATE = 1
*    ERROR_CNTL_INIT   = 2
*    ERROR_CNTL_LINK   = 3
*    ERROR_DP_CREATE   = 4
*    others            = 5
    .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD grid->set_table_for_first_display
  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
    i_structure_name              = 'MARA'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
*    IR_SALV_ADAPTER               =
  CHANGING
    it_outtab                     = it_mara
*    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.

CALL SCREEN 100.

Reward points if useful,

Aleem.

5 REPLIES 5
Read only

uwe_schieferstein
Active Contributor
0 Likes
682

Hello Parvez

Have a look at my sample reports

You will find plenty of additional sample reports. Just search for <b>ZUS_SDN_..</b>.

Regards

Uwe

Read only

Former Member
0 Likes
682

Hi

We can implement OOPS concepts in SAP using ABAP objets concept.

ABAP Objects is a new concept in R/3 Release 4.0. The term has two meanings. On the one hand, it stands for the entire ABAP runtime environment. On the other hand, it represents the object-oriented extension of the ABAP language.

The Runtime Environment

The new name ABAP Objects for the entire ABAP runtime environment is an indication of the way in which SAP has, for some time, been moving towards object orientation, and of its commitment to pursuing this line further. The ABAP Workbench allows you to create R/3 Repository objects such as programs, authorization objects, lock objects, Customizing objects, and so on. Using function modules, you can encapsulate functions in separate programs with a defined interface. The Business Object Repository (BOR) allows you to create SAP Business Objects for internal and external use (DCOM/CORBA). Until now, object-oriented techniques have been used exclusively in system design, and have not been supported by the ABAP language.

The Object-Oriented Language Extension

ABAP Objects is a complete set of object-oriented statements that has been introduced into the ABAP language. This object-oriented extension of ABAP builds on the existing language, and is fully compatible with it. You can use ABAP Objects in existing programs, and can also use "conventional" ABAP in new ABAP Objects programs.

ABAP Objects supports object-oriented programming. Object orientation (OO), also know as the object-oriented paradigm, is a programming model that unites data and functions in objects. The rest of the ABAP language is primarily intended for structured programming, where data is stored in a structured form in database tables and function-oriented programs access and work with it.

The object-oriented enhancement of ABAP is based on the models of Java and C++. It is compatible with external object interfaces such as DCOM and CORBA. The implementation of object-oriented elements in the kernel of the ABAP language has considerably increased response times when you work with ABAP Objects. SAP Business Objects and GUI objects - already object-oriented themselves - will also profit from being incorporated in ABAP Objects.

Please check these links ...

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

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

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

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

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

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

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

Reward if usefull

Read only

Former Member
0 Likes
682

Hi Parvez,

Go to the following link which gives you sample codes with brief description of the programs.

<a href="http://www.sapdev.co.uk/reporting/alv/alvscr.htm">OOALV</a>

Then coming to steps for creation of ALV in OOABAP.

1. Create a program in se38 and just activate it without any code for now.

2. Go to module pool and create a screen, put a custom container control on to the screen. (You will find this control on right side tool box).

3. Give a name to the control created in step 2.

4. Activate the screen.

5. Come to the program declare two variables to hold instances of 2 classes CL_GUI_CUSTOM_CONTAINER, CL_GUI_ALV_GRID.

6. create an instance of the class CL_GUI_CUSTOM_CONTAINER passing container name created in step 3.

7. create an instance of the class CL_GUI_ALV_GRID passing INSTANCE VARIBALE name created in step 6.

8. using the ref. variable of previous step call method SET_TABLE FORFIRST_DISPLAY method and pass structure name and internal table containing data.

9. then call screen created in step 2.

Hey... execute the program . You are there with your OOALV.

Reward points if useful,

Aleem.

Read only

Former Member
0 Likes
682
Read only

Former Member
0 Likes
683

Hi Parvez,

Here is the simple code as explained previously.


*&---------------------------------------------------------------------*
*& Report  ZGS_SIMPLE_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zgs_simple_alv.

DATA : it_mara TYPE TABLE OF mara.

DATA : container TYPE REF TO cl_gui_custom_container,
       grid TYPE REF TO cl_gui_alv_grid.

SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.

 CREATE OBJECT container
   EXPORTING
*     PARENT                      =
     container_name              =  'CONTAINER'
*     STYLE                       =
*     LIFETIME                    = lifetime_default
*     REPID                       =
*     DYNNR                       =
*     NO_AUTODEF_PROGID_DYNNR     =
*   EXCEPTIONS
*     CNTL_ERROR                  = 1
*     CNTL_SYSTEM_ERROR           = 2
*     CREATE_ERROR                = 3
*     LIFETIME_ERROR              = 4
*     LIFETIME_DYNPRO_DYNPRO_LINK = 5
*     others                      = 6
     .
 IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 ENDIF.


CREATE OBJECT grid
  EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
    i_parent          = container
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
*    I_FCAT_COMPLETE   = SPACE
*  EXCEPTIONS
*    ERROR_CNTL_CREATE = 1
*    ERROR_CNTL_INIT   = 2
*    ERROR_CNTL_LINK   = 3
*    ERROR_DP_CREATE   = 4
*    others            = 5
    .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD grid->set_table_for_first_display
  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
    i_structure_name              = 'MARA'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
*    IR_SALV_ADAPTER               =
  CHANGING
    it_outtab                     = it_mara
*    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.

CALL SCREEN 100.

Reward points if useful,

Aleem.