ALV with structure using OOABAP

+ -
Requirement: Display list of materials in grid format using Object Oriented techniques.

Step 1: Data deceleration for ALV, custom container and internal table for MARA.

Step 2:Create Screen.

Step 3:Insert Custom container UI element into the screen.

Step 4:Create Modules PBO and PAO, add logic.

Step 5:Display ALV.

Step 1: Data deceleration for ALV, Custom Container and MARA.

Add data deceleration for ALV grid, custom container UI element and for MARA internal table.
DATA : LO_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER. "Custom Container 
DATA : LO_ALV TYPE REF TO CL_GUI_ALV_GRID. "ALV Grid
DATA : IT_MARA TYPE TABLE OF MARA. "MARA internal table

Step 2: Create Screen

Create Screen in start of selection by using key work CALL SCREEN .
START-OF-SELECTION.
**Here 100 is the screen number which we are going to create, you can create any like: 200, 300 etc
CALL SCREEN 100. "double click on 100 to create a screen

After calling screen, double click on 100, click create.

Object Oriented ALV

Provide short description, click on layout, layout designer will open(If you use it first it will take some time, wait till it comes, if you face any issue while opening contact BASIS, there might be configuration missing. ).

Object Oriented ABAP

Step 3: Insert Custom Container UI element

Drag and drop custom container UI element, double click and provide a name and save, activate and close layout designer.

Object Oriented ABAP

Object Oriented ABAP

Step 4: Create Modules

Click on flow logic, un comment MODULES, double click on each one(one at one time), click yes and select main program.

Object Oriented ABAP

OOALV Development

MODULE STATUS_0100 OUTPUT.
**Create object for Custom container
  CREATE OBJECT LO_CONT
    EXPORTING
*     PARENT         =
      CONTAINER_NAME = 'CC_ALV' "container name whcih we have created
.
**Create Object for ALV Grid
  CREATE OBJECT LO_ALV
    EXPORTING
      I_PARENT = LO_CONT "Object of custom container
.
**Get data from MARA
  SELECT * FROM MARA INTO TABLE IT_MARA UP TO 100 ROWS.
**Display ALV data using structure
  CALL METHOD LO_ALV->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.
* Implement suitable error handling here
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT

Execute and test the program .

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 29 People out of 30 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →