Tuesday, May 27, 2014

Creating ALV Grid Control using Call FM and OO Approach in ABAP

Creating ALV Grid Control Tutorial in SAP ABAP
Hello friends, welcome to www.sapabapiq.com. Here we are presenting a article on How to create ALV grid control using function module and using object oriented approach in SAP ABAP.







Creating ALV Grid Control using FM and OO Approach in ABAP


If you are looking for a article on how to create ALV grid control, this tutorial will help you in creating ALV gird control by using two methods calling functional module and object oriented approach.


Approaches to create ALV Grid Control



1) Call Function Module





Now lets discuss about these two different approaches in detail.



1) Call Function Module Approach



In this approach, we normally call a appropriate function module and we pass some parameters to that particular function module, according to the supplied parameters the function module will do some manipulation and its done.


The mostly used function modules in creating ALV grid control are: 


REUSE_ALV_LIST_DISPLAY,

EUSE_ALV_GRID_DISPLAY,

REUSE_ALV_GRID_DISPLAY_LVC.



Example Program Using Call Function Module Approach to Create ALV Grid


DATA: LAYOUT TYPE SLIS_LAYOUT_ALV,
        FCAT TYPE SLIS_T_FIELDCATA_ALV,
        W_FCAT TYPE SLIT_FIELDCATA_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
      IS_LAYOUT    = LAYOUT
      IT_FIELDCAT   = FCAT
  TABLES
     T_OUTTAB      = YOUR TABLE.



2) Using Object Oriented Approach to Create ALV Grid


Object Oriented method (OO Approach) is the most flexible way to create ALV gird and its entirely different from call function module method. First we need to create objects for classes,

instance of CL_GUI_ALV_GRID

instance of CL_GUI_CUSTOM_CONTAINER

Now  we need to create screen to hold the container, later we should call a method

SET_TABLE_FOR_FIRST_DISPLAY.

There are some differences between these two approaches.

The parameter types are different for function module  

REUSE_ALV_LIST_DISPLAY,

REUSE_ALV_GRID_DISPLAY.

The parameter IS_LAYOUT is of type SLIS_LAYOUT_ALV,
and the parameter IT_FIELDCAT is of type SLIS_T_FIELDCATA_ALV

But when you using the Object Oriented approach, the two parameter are of type

LVC_S_LAYO
and
LVC_T_FCAT 

however, when you call function module  

REUSE_ALV_GRID_DISPLAY_LVC, 

the two parameters are the same as the OO approach




Sample Program using OO Approach to Create ALV Gird 



DATA: GRID TYPE REF TO CL_GUI_ALV_GRID,
      CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      LAYOUT TYPE LVC_S_LAYO,
      FCAT TYPE LVC_T_FCAT,
      W_FCAT TYPE LVC_S_FCAT.
IF  CONTAINER IS INITIAL.
  CREATE OBJECT  CONTAINER
  EXPORTING CONTAINER_NAME = 'mycont'.
  CREATE OBJECT GRID
  EXPORTING I_PARENT = PARENT_GRID.
  CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
  EXPORTING
    IS_LAYOUT = LAYOUT
  CHANGING
    IT_FIELDCATALOG = FCAT
    IT_OUTTAB = YOUR IT.


"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Categories

ABAP (1) ABAP Interview Questions (112) ABAP Open SQL Statements (1) ABAP Syntax Rules (6) ABAP WORKBENCH (2) ABAP-Interview-Questions (52) ALE IDOC (6) ALE IDOC Interview Questions (6) ale-idoc (6) ALE-IDOC-Interview-Questions (19) ALV Interview Questions (5) ALV-Interview-Questions (22) BADI (2) BAPI (1) BAPI Interview Questions (1) BAPI-Interview-Questions (14) BDC (6) BDC Interview Questions (6) BDC-Interview-Questions (9) big data (2) big data interview questions (1) Classical Reports Interview Question (3) Classical-Reports-Interview-Questions (22) Conditional Statements (1) Cross Applications (3) Cross-Applications (14) Data Dictionary (22) Data Type Questins (1) Data types (1) Data-Dictionary (48) Data-Type-Questins (6) Dialog programming (5) Dialog Programming Interview Questions (4) Dialog-Programming (30) DOMAIN Interview Questions (1) Domain-Interview-Questions (8) Function Module (2) hadoop (2) hadoop interview questions (2) hdfs (1) IDoc Tutorials (6) Interactive Report Interview Questions (4) Interactive-Reports-Interview-Questions (22) Internal Tables (1) interview questions (1) Lock Object Interview Questions (1) Lock-Objects-Interview-Questions (10) Logical Database (1) Modularization Interview Questions (4) Modularization-Interview-Questions (25) Module Pool Programming (5) Module-Pool-Programming (39) modules in sap (1) Object Oriented ABAP (19) Object Oriented ABAP Interview Questions (15) object-oriented-abap (2) Object-Oriented-ABAP-Interview-Questions (34) OOABAP (9) Reports (14) Reports Interview Questions (9) Reports-Interview-Questions (19) RFC (1) RFC Interview Questions (1) RFC-Interview-Questions (14) RICEF (1) RICEF Objects (1) SAP (4) SAP ABAP (4) SAP ABAP Interview Questions (42) SAP ABAP Introduction (46) SAP ABAP Message Types (2) SAP BADI Interview Questions (2) SAP Basics (71) SAP Books (2) SAP Certification (1) SAP CONSULTANTS (5) SAP CRM (1) SAP ENHANCEMENTS (3) SAP EXITS (2) SAP EXITS ( SAP ENHANCEMENTS ) Interview Questions (1) SAP Free Books (1) SAP HR (2) SAP Lock Object (1) sap modules (2) SAP Open SQL Statements (1) SAP R/3 Architecture (4) SAP Search help (1) SAP Smartforms (1) SAP Smartforms Interview Questions (2) SAP Tables (5) SAP Tcodes (10) SAP Views (1) SAP Webdynpro ABAP (12) SAP Work Processors (2) SAP Workflow (3) SAP-BADI-Interview-Questions (11) SAP-Enhancements (39) SAP-Exits (39) SAP-Exits-Enhancements-Interview Questions (3) SAP-HANA (1) SAP-HANA-Interview-Questions (1) SAP-Smartforms-Interview-Questions (2) SAP-Workflow (3) Scripts (3) Scripts Interview Questions (2) Scripts-Interview-Questions (32) Search Help Interview Questions (1) Search-Help-Interview-Questions (9) Smartforms (1) Table Maintenance Generator (1) Table-Maintenance-Generator (4) Tables in SAP (2) Tables Interview Questions (3) Tables-Interview-Questions (3) Type Group Interview Questions (1) Type-Group-Interview-Questions (7) Variable Declaration (1) Views Interview Questions (1) Views-Interview-Questions (5) Webdynpro (12) what is big data (1)

Protected Blog

 
This blog is not affiliated to SAP AG |SAP is trademark of SAP AG |The information collected from various sources use information with your own risk.