Hi guru's  alv wit oops explain to me good example

hi guru's  alv wit oops explain to me good example

Hi
What is Object Orientation?
In the past, information systems used to be defined primarily by their functionality: data and functions were kept separate and linked together by means of input and output relations.
The object-oriented approach, however, focuses on objects that represent abstract or concrete things of the real world. These objects are first defined by their character and their properties which are represented by their internal structure and their attributes (data). The behaviour of these objects is described by methods (functionality).
Objects form a capsule which combines the character to the respective behaviour. Objects should enable programmers to map a real problem and its proposed software solution on a one-to-one basis.
Typical objects in a business environment are, for example, ‘Customer’, ‘Order’, or ‘Invoice’. From Release 3.1 onwards, the Business Object Repository (BOR) of SAP Web Applicaton Server ABAP has contained examples of such objects. The BOR object model will be integrated into ABAP Objects in the next Release by migrating the BOR object types to the ABAP class library.
A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.
Objects
Objects are instances of classes. They contain data and provides services. The data forms the attributes of the object. The services are known as methods (also known as operations or functions). Typically, methods operate on private data (the attributes, or state of the object), which is only visible to the methods of the object. Thus the attributes of an object cannot be changed directly by the user, but only by the methods of the object. This guarantees the internal consistency of the object.
Classes
Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attributes.
Object References
In a program, you identify and address objects using unique object references. Object references allow you to access the attributes and methods of an object.
In object-oriented programming, objects usually have the following properties:
Encapsulation
Objects restrict the visibility of their resources (attributes and methods) to other users. Every object has an interface, which determines how other objects can interact with it. The implementation of the object is encapsulated, that is, invisible outside the object itself.
Inheritance
You can use an existing class to derive a new class. Derived classes inherit the data and methods of the superclass. However, they can overwrite existing methods, and also add new ones.
Polymorphism
Identical (identically-named) methods behave differently in different classes. In ABAP Objects, polymorphism is implemented by redefining methods during inheritance and by using constructs called interfaces.
Uses of Object Orientation
Below are some of the advantages of object-oriented programming:
· Complex software systems become easier to understand, since object-oriented structuring provides a closer representation of reality than other programming techniques.
· In a well-designed object-oriented system, it should be possible to implement changes at class level, without having to make alterations at other points in the system. This reduces the overall amount of maintenance required.
· Through polymorphism and inheritance, object-oriented programming allows you to reuse individual components.
· In an object-oriented system, the amount of work involved in revising and maintaining the system is reduced, since many problems can be detected and corrected in the design phase.
Achieving these goals requires:
· Object-oriented programming languages
Object-oriented programming techniques do not necessarily depend on object-oriented programming languages. However, the efficiency of object-oriented programming depends directly on how object-oriented language techniques are implemented in the system kernel.
· Object-oriented tools
Object-oriented tools allow you to create object-oriented programs in object-oriented languages. They allow you to model and store development objects and the relationships between them.
· Object-oriented modeling
The object-orientation modeling of a software system is the most important, most time-consuming, and most difficult requirement for attaining the above goals. Object-oriented design involves more than just object-oriented programming, and provides logical advantages that are independent of the actual implementation.
This section of the ABAP User’s Guide provides an overview of the object-oriented extension of the ABAP language. We have used simple examples to demonstrate how to use the new features. However, these are not intended to be a model for object-oriented design. More detailed information about each of the ABAP Objects statements is contained in the keyword documentation in the ABAP Editor. For a comprehensive introduction to object-oriented software development, you should read one or more of the titles listed below.
ABAP supports a hybrid programming model. You can use an object-oriented ("OO") programming model based on classes and interfaces, and you can use the more classic procedural and event-driven programming model based on function modules, subroutines, dialog modules, and event blocks. Both models can be used in parallel. You can use classes inside classic processing blocks or you can call classic procedures from methods. In ABAP Objects, SAP has implemented a cleanup of the ABAP language. Within the scope of this language cleanup, stricter syntax checks are performed in classes that restrict the usage of obsolete language elements.
Object orientation in ABAP is an extension of the ABAP language that makes available the advantages of object-oriented programming, such as encapsulation, interfaces, and inheritance. This helps to simplify applications and make them more controllable.
ABAP Objects is fully compatible with the existing language, so you can use existing statements and modularization units in programs that use ABAP Objects, and can also use ABAP Objects in existing ABAP programs.
Check these links</b>/people/thomas.jung3/blog/2005/09/08/oo-abap-dynpro-programming
/people/ravikumar.allampallam/blog/2005/02/11/abap-oo-in-action
This is good for beginners
/people/sap.user72/blog/2005/05/10/a-small-tip-for-the-beginners-in-oo-abap
check the below links lot of info and examples r there
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sap-img.com/
http://www.sapgenie.com/
http://help.sap.com
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
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
8) 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
Sample code
*"Table declarations...................................................
TABLES:
EKKO, " Purchasing Document Header
CDHDR, " Change document header
SSCRFIELDS. " Fields on selection screens
*"Selection screen elements............................................
SELECT-OPTIONS:
S_EBELN FOR EKKO-EBELN, " Purchasing Document Number
S_LIFNR FOR EKKO-LIFNR, " Vendor's account number
S_EKGRP FOR EKKO-EKGRP, " Purchasing group
S_BEDAT FOR EKKO-BEDAT, " Purchasing Document Date
S_UDATE FOR CDHDR-UDATE. " Creation date of the change
" document
*" Data declarations...................................................
Field String to hold Purchase Document Number *
DATA:
BEGIN OF FS_EBELN,
EBELN(90) TYPE C, " Purchase Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created
" the Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
END OF FS_EBELN,
Field String to hold Purchase Document Header *
BEGIN OF FS_EKKO,
EBELN TYPE EKKO-EBELN, " Purchasing Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created the
" Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
END OF FS_EKKO,
Field String to hold Account Number and name of the Vendor *
BEGIN OF FS_LFA1,
LIFNR TYPE LFA1-LIFNR, " Account Number of Vendor
NAME1 TYPE LFA1-NAME1, " Name1
END OF FS_LFA1,
Field String to hold Change date and the name of the user *
BEGIN OF FS_CDHDR,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS, " Object Class
OBJECTID TYPE CDHDR-OBJECTID, " Object value
CHANGENR TYPE CDHDR-CHANGENR, " Document change number
USERNAME TYPE CDHDR-USERNAME, " User name
UDATE TYPE CDHDR-UDATE, " Creation date of the change
" document
END OF FS_CDHDR,
Field String to hold Change document items *
BEGIN OF FS_CDPOS,
OBJECTCLAS TYPE CDPOS-OBJECTCLAS," Object class
OBJECTID(10) TYPE C, " Object Value
CHANGENR TYPE CDPOS-CHANGENR, " Document change number
TABNAME TYPE CDPOS-TABNAME, " Table Name
FNAME TYPE CDPOS-FNAME, " Field Name
VALUE_NEW TYPE CDPOS-VALUE_NEW, " New contents of changed field
VALUE_OLD TYPE CDPOS-VALUE_OLD, " Old contents of changed field
END OF FS_CDPOS,
Field String to hold Date Element Name *
BEGIN OF FS_DATAELE,
TABNAME TYPE DD03L-TABNAME, " Table Name
FIELDNAME TYPE DD03L-FIELDNAME, " Field Name
ROLLNAME TYPE DD03L-ROLLNAME, " Data element (semantic domain)
END OF FS_DATAELE,
Field String to hold Short Text of the Date Element *
BEGIN OF FS_TEXT,
ROLLNAME TYPE DD04T-ROLLNAME, " Data element (semantic domain)
DDTEXT TYPE DD04T-DDTEXT, " Short Text Describing R/3
" Repository Objects
END OF FS_TEXT,
Field String to hold data to be displayed on the ALV grid *
BEGIN OF FS_OUTTAB,
EBELN TYPE EKKO-EBELN, " Purchasing Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created the
" Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
WERKS TYPE LFA1-WERKS, " Plant
NAME1 TYPE LFA1-NAME1, " Name1
USERNAME TYPE CDHDR-USERNAME, " User name
UDATE TYPE CDHDR-UDATE, " Creation date of the change
" document
DDTEXT TYPE DD04T-DDTEXT, " Short Text Describing R/3
" Repository Objects
VALUE_NEW TYPE CDPOS-VALUE_NEW, " New contents of changed field
VALUE_OLD TYPE CDPOS-VALUE_OLD, " Old contents of changed field
END OF FS_OUTTAB,
Internal table to hold Purchase Document Number *
T_EBELN LIKE STANDARD TABLE
OF FS_EBELN,
Internal table to hold Purchase Document Header *
T_EKKO LIKE STANDARD TABLE
OF FS_EKKO,
Temp Internal table to hold Purchase Document Header *
T_EKKO_TEMP LIKE STANDARD TABLE
OF FS_EKKO,
Internal table to hold Account number and Name of the Vendor *
T_LFA1 LIKE STANDARD TABLE
OF FS_LFA1,
Internal Table to hold Change date and the name of the user *
T_CDHDR LIKE STANDARD TABLE
OF FS_CDHDR,
Internal Table to hold Change document items *
T_CDPOS LIKE STANDARD TABLE
OF FS_CDPOS,
Temp. Internal Table to hold Change document items *
T_CDPOS_TEMP LIKE STANDARD TABLE
OF FS_CDPOS,
Internal Table to hold Data Element Name *
T_DATAELE LIKE STANDARD TABLE
OF FS_DATAELE,
Temp. Internal Table to hold Data Element Name *
T_DATAELE_TEMP LIKE STANDARD TABLE
OF FS_DATAELE,
Internal Table to hold Short Text of the Date Element *
T_TEXT LIKE STANDARD TABLE
OF FS_TEXT,
Internal Table to hold data to be displayed on the ALV grid *
T_OUTTAB LIKE STANDARD TABLE
OF FS_OUTTAB.
C L A S S D E F I N I T I O N *
CLASS LCL_EVENT_HANDLER DEFINITION DEFERRED.
*" Data declarations...................................................
Work variables *
DATA:
W_EBELN TYPE EKKO-EBELN, " Purchasing Document Number
W_LIFNR TYPE EKKO-LIFNR, " Vendor's account number
W_EKGRP TYPE EKKO-EKGRP, " Purchasing group
W_VALUE TYPE EKKO-EBELN, " Reflected Value
W_SPACE VALUE ' ', " Space
W_FLAG TYPE I, " Flag Variable
W_VARIANT TYPE DISVARIANT, " Variant
*--- ALV Grid
W_GRID TYPE REF TO CL_GUI_ALV_GRID,
*--- Event Handler
W_EVENT_CLICK TYPE REF TO LCL_EVENT_HANDLER,
*--- Field catalog table
T_FIELDCAT TYPE LVC_T_FCAT.
AT SELECTION-SCREEN EVENT *
AT SELECTION-SCREEN ON S_EBELN.
Subroutine to validate Purchase Document Number.
PERFORM VALIDATE_PD_NUM.
AT SELECTION-SCREEN ON S_LIFNR.
Subroutine to validate Vendor Number.
PERFORM VALIDATE_VEN_NUM.
AT SELECTION-SCREEN ON S_EKGRP.
Subroutine to validate Purchase Group.
PERFORM VALIDATE_PUR_GRP.
START-OF-SELECTION EVENT *
START-OF-SELECTION.
Subroutine to select all Purchase orders.
PERFORM SELECT_PO.
CHECK W_FLAG EQ 0.
Subroutine to select Object values.
PERFORM SELECT_OBJ_ID.
CHECK W_FLAG EQ 0.
Subroutine to select Changed values.
PERFORM SELECT_CHANGED_VALUE.
CHECK W_FLAG EQ 0.
Subroutine to Select Purchase Orders.
PERFORM SELECT_PUR_DOC.
Subroutine to select Vendor Details.
PERFORM SELECT_VENDOR.
Subroutine to select Text for the Changed values.
PERFORM DESCRIPTION.
END-OF-SELECTION EVENT *
END-OF-SELECTION.
IF NOT T_EKKO IS INITIAL.
Subroutine to populate the Output Table.
PERFORM FILL_OUTTAB.
Subroutine to build Field Catalog.
PERFORM PREPARE_FIELD_CATALOG CHANGING T_FIELDCAT.
CALL SCREEN 100.
ENDIF. " IF NOT T_EKKO...
CLASS LCL_EVENT_HANDLER DEFINITION
Defining Class which handles events
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
HANDLE_HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID.
ENDCLASS. " LCL_EVENT_HANDLER DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION
Implementing the Class which can handle events
CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
*---Handle Double Click
METHOD HANDLE_HOTSPOT_CLICK .
Subroutine to get the HotSpot Cell information.
PERFORM GET_CELL_INFO.
SET PARAMETER ID 'BES' FIELD W_VALUE.
CALL TRANSACTION 'ME23N'.
ENDMETHOD. " HANDLE_HOTSPOT_CLICK
ENDCLASS. " LCL_EVENT_HANDLER
*& Module STATUS_0100 OUTPUT
PBO Event
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'OOPS'.
SET TITLEBAR 'TIT'.
Subroutine to fill the Variant Structure
PERFORM FILL_VARIANT.
IF W_GRID IS INITIAL.
CREATE OBJECT W_GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = CL_GUI_CONTAINER=>SCREEN0
I_APPL_EVENTS =
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. " IF SY-SUBRC <> 0
CALL METHOD W_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 =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = T_OUTTAB
IT_FIELDCATALOG = T_FIELDCAT
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. " IF SY-SUBRC <> 0.
ENDIF. " IF W_GRID IS INITIAL
CREATE OBJECT W_EVENT_CLICK.
SET HANDLER W_EVENT_CLICK->HANDLE_HOTSPOT_CLICK FOR W_GRID.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
PAI Event
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form PREPARE_FIELD_CATALOG
Subroutine to build the Field catalog
<--P_T_FIELDCAT Field Catalog Table
FORM PREPARE_FIELD_CATALOG CHANGING PT_FIELDCAT TYPE LVC_T_FCAT .
DATA LS_FCAT TYPE LVC_S_FCAT.
Purchasing group...
LS_FCAT-FIELDNAME = 'EKGRP'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Purchasing Document Number...
LS_FCAT-FIELDNAME = 'EBELN'.
LS_FCAT-REF_TABLE = 'EKKO' .
LS_FCAT-EMPHASIZE = 'C411'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-HOTSPOT = 'X'.
APPEND LS_FCAT TO PT_FIELDCAT .
CLEAR LS_FCAT .
Name of Person who Created the Object...
LS_FCAT-FIELDNAME = 'ERNAM'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-OUTPUTLEN = '15' .
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Purchasing Document Date...
LS_FCAT-FIELDNAME = 'BEDAT'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Vendor's account number...
LS_FCAT-FIELDNAME = 'LIFNR'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Account Number of Vendor or Creditor...
LS_FCAT-FIELDNAME = 'NAME1'.
LS_FCAT-REF_TABLE = 'LFA1'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Vendor Name'(001).
LS_FCAT-SELTEXT = 'Vendor Name'(001).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Creation date of the change document...
LS_FCAT-FIELDNAME = 'UDATE'.
LS_FCAT-REF_TABLE = 'CDHDR'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Change Date'(002).
LS_FCAT-SELTEXT = 'Change Date'(002).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
User name of the person responsible in change document...
LS_FCAT-FIELDNAME = 'USERNAME'.
LS_FCAT-REF_TABLE = 'CDHDR'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Modified by'(003).
LS_FCAT-SELTEXT = 'Modified by'(003).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Short Text Describing R/3 Repository Objects...
LS_FCAT-FIELDNAME = 'DDTEXT'.
LS_FCAT-REF_TABLE = 'DD04T'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '15'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Old contents of changed field...
LS_FCAT-FIELDNAME = 'VALUE_OLD'.
LS_FCAT-REF_TABLE = 'CDPOS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '12'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
New contents of changed field...
LS_FCAT-FIELDNAME = 'VALUE_NEW'.
LS_FCAT-REF_TABLE = 'CDPOS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '12'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
ENDFORM. " PREPARE_FIELD_CATALOG
*& Form SELECT_PO
Subroutine to select all the Purchase Orders
There are no interface parameters to be passed to this subroutine.
FORM SELECT_PO .
SELECT EBELN " Purchasing Document Number
ERNAM " Name of Person who Created
" the Object
LIFNR " Vendor's account number
EKGRP " Purchasing group
BEDAT " Purchasing Document Date
FROM EKKO
PACKAGE SIZE 10000
APPENDING TABLE T_EBELN
WHERE EBELN IN S_EBELN
AND BEDAT IN S_BEDAT.
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S401(M8).
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " SELECT_PO
*& Form SELECT_OBJ_ID
Subroutine to select Object ID
There are no interface parameters to be passed to this subroutine.
FORM SELECT_OBJ_ID .
IF NOT T_EBELN IS INITIAL.
SELECT OBJECTCLAS " Object Class
OBJECTID " Object value
CHANGENR " Document change number
USERNAME " User name
UDATE " Creation date
FROM CDHDR
INTO TABLE T_CDHDR
FOR ALL ENTRIES IN T_EBELN
WHERE OBJECTID EQ T_EBELN-EBELN
AND UDATE IN S_UDATE
AND TCODE IN ('ME21N','ME22N','ME23N').
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S833(M8) WITH 'Header Not Found'(031).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_EBELN IS INITIAL
ENDFORM. " SELECT_OBJ_ID
*& Form SELECT_CHANGED_VALUE
Subroutine to select Changed Values
There are no interface parameters to be passed to this subroutine.
FORM SELECT_CHANGED_VALUE .
IF NOT T_CDHDR IS INITIAL.
SELECT OBJECTCLAS " Object class
OBJECTID " Object value
CHANGENR " Document change number
TABNAME " Table Name
FNAME " Field Name
VALUE_NEW " New contents of changed field
VALUE_OLD " Old contents of changed field
FROM CDPOS
PACKAGE SIZE 10000
APPENDING TABLE T_CDPOS
FOR ALL ENTRIES IN T_CDHDR
WHERE OBJECTCLAS EQ T_CDHDR-OBJECTCLAS
AND OBJECTID EQ T_CDHDR-OBJECTID
AND CHANGENR EQ T_CDHDR-CHANGENR.
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S833(M8) WITH 'Item Not Found'(032).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_CDHDR IS INITIAL
T_CDPOS_TEMP[] = T_CDPOS[].
ENDFORM. " SELECT_CHANGED_VALUE
*& Form SELECT_PUR_DOC
Subroutine to select Purchase Order Details
There are no interface parameters to be passed to this subroutine.
FORM SELECT_PUR_DOC .
IF NOT T_CDPOS IS INITIAL.
SORT T_EBELN BY EBELN.
LOOP AT T_CDPOS INTO FS_CDPOS.
READ TABLE T_EBELN INTO FS_EBELN WITH KEY EBELN =
FS_CDPOS-OBJECTID BINARY SEARCH.
IF SY-SUBRC NE 0.
DELETE TABLE T_EBELN FROM FS_EBELN.
ENDIF. " IF SY-SUBRC NE 0.
ENDLOOP. " LOOP AT T_CDPOS...
LOOP AT T_EBELN INTO FS_EBELN.
MOVE FS_EBELN-EBELN TO FS_EKKO-EBELN.
MOVE FS_EBELN-ERNAM TO FS_EKKO-ERNAM.
MOVE FS_EBELN-LIFNR TO FS_EKKO-LIFNR.
MOVE FS_EBELN-EKGRP TO FS_EKKO-EKGRP.
MOVE FS_EBELN-BEDAT TO FS_EKKO-BEDAT.
APPEND FS_EKKO TO T_EKKO.
ENDLOOP. " LOOP AT T_EBELN...
T_EKKO_TEMP[] = T_EKKO[].
ENDIF. " IF NOT T_CDPOS IS INITIAL
ENDFORM. " SELECT_PUR_DOC
*& Form SELECT_VENDOR
Subroutine to select Vendor details
There are no interface parameters to be passed to this subroutine.
FORM SELECT_VENDOR .
IF NOT T_EKKO IS INITIAL.
SORT T_EKKO_TEMP BY LIFNR.
DELETE ADJACENT DUPLICATES FROM T_EKKO_TEMP COMPARING LIFNR.
SELECT LIFNR " Account Number of Vendor or
" Creditor
NAME1 " Name 1
FROM LFA1
INTO TABLE T_LFA1
FOR ALL ENTRIES IN T_EKKO_TEMP
WHERE LIFNR EQ T_EKKO_TEMP-LIFNR.
IF SY-SUBRC NE 0.
MESSAGE S002(M8) WITH 'Master Details'(033).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_EKKO IS INITIAL
ENDFORM. " SELECT_VENDOR
*& Form DESCRIPTION
Subroutine to get the description
There are no interface parameters to be passed to this subroutine.
FORM DESCRIPTION .
IF NOT T_CDPOS IS INITIAL.
SORT T_CDPOS_TEMP BY TABNAME FNAME.
DELETE ADJACENT DUPLICATES FROM T_CDPOS_TEMP COMPARING TABNAME FNAME
SELECT TABNAME " Table Name
FIELDNAME " Field Name
ROLLNAME " Data element
FROM DD03L
INTO TABLE T_DATAELE
FOR ALL ENTRIES IN T_CDPOS_TEMP
WHERE TABNAME EQ T_CDPOS_TEMP-TABNAME
AND FIELDNAME EQ T_CDPOS_TEMP-FNAME.
IF NOT T_DATAELE IS INITIAL.
T_DATAELE_TEMP[] = T_DATAELE[].
SORT T_DATAELE_TEMP BY ROLLNAME.
DELETE ADJACENT DUPLICATES FROM T_DATAELE_TEMP COMPARING ROLLNAME.
SELECT ROLLNAME " Data element
DDTEXT " Short Text Describing R/3
" Repository Objects
FROM DD04T
INTO TABLE T_TEXT
FOR ALL ENTRIES IN T_DATAELE_TEMP
WHERE ROLLNAME EQ T_DATAELE_TEMP-ROLLNAME
AND DDLANGUAGE EQ SY-LANGU.
IF SY-SUBRC NE 0.
EXIT.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_DATAELE IS INITIAL.
ENDIF. " IF NOT T_CDPOS IS INITIAL.
ENDFORM. " DESCRIPTION
*& Form FILL_OUTTAB
Subroutine to populate the Outtab
There are no interface parameters to be passed to this subroutine.
FORM FILL_OUTTAB .
SORT T_CDHDR BY OBJECTCLAS OBJECTID CHANGENR.
SORT T_EKKO BY EBELN.
SORT T_LFA1 BY LIFNR.
SORT T_DATAELE BY TABNAME FIELDNAME.
SORT T_TEXT BY ROLLNAME.
LOOP AT T_CDPOS INTO FS_CDPOS.
READ TABLE T_CDHDR INTO FS_CDHDR WITH KEY
OBJECTCLAS = FS_CDPOS-OBJECTCLAS
OBJECTID = FS_CDPOS-OBJECTID
CHANGENR = FS_CDPOS-CHANGENR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_CDHDR-USERNAME TO FS_OUTTAB-USERNAME.
MOVE FS_CDHDR-UDATE TO FS_OUTTAB-UDATE.
READ TABLE T_EKKO INTO FS_EKKO WITH KEY
EBELN = FS_CDHDR-OBJECTID
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_EKKO-EBELN TO FS_OUTTAB-EBELN.
MOVE FS_EKKO-ERNAM TO FS_OUTTAB-ERNAM.
MOVE FS_EKKO-LIFNR TO FS_OUTTAB-LIFNR.
MOVE FS_EKKO-EKGRP TO FS_OUTTAB-EKGRP.
MOVE FS_EKKO-BEDAT TO FS_OUTTAB-BEDAT.
READ TABLE T_LFA1 INTO FS_LFA1 WITH KEY
LIFNR = FS_EKKO-LIFNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_LFA1-NAME1 TO FS_OUTTAB-NAME1.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
MOVE FS_CDPOS-VALUE_NEW TO FS_OUTTAB-VALUE_NEW.
MOVE FS_CDPOS-VALUE_OLD TO FS_OUTTAB-VALUE_OLD.
READ TABLE T_DATAELE INTO FS_DATAELE WITH KEY
TABNAME = FS_CDPOS-TABNAME
FIELDNAME = FS_CDPOS-FNAME
BINARY SEARCH.
IF SY-SUBRC EQ 0.
READ TABLE T_TEXT INTO FS_TEXT WITH KEY
ROLLNAME = FS_DATAELE-ROLLNAME
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_TEXT-DDTEXT TO FS_OUTTAB-DDTEXT.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
APPEND FS_OUTTAB TO T_OUTTAB.
CLEAR FS_OUTTAB.
ENDLOOP.
ENDFORM. " FILL_OUTTAB
*& Form GET_CELL_INFO
Subroutine to get the Cell Information
--> W_VALUE Holds the value of Hotspot clicked
FORM GET_CELL_INFO .
CALL METHOD W_GRID->GET_CURRENT_CELL
IMPORTING
E_ROW =
E_VALUE = W_VALUE
E_COL =
ES_ROW_ID =
ES_COL_ID =
ES_ROW_NO =
ENDFORM. " GET_CELL_INFO
*& Form VALIDATE_PD_NUM
Subroutine to validate Purchase Document Number
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_PD_NUM .
IF NOT S_EBELN[] IS INITIAL.
SELECT EBELN " Purchase Document Number
FROM EKKO
INTO W_EBELN
UP TO 1 ROWS
WHERE EBELN IN S_EBELN.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E717(M8).
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_EBELN[]...
ENDFORM. " VALIDATE_PD_NUM
*& Form VALIDATE_VEN_NUM
Subroutine to validate Vendor Number
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_VEN_NUM .
IF NOT S_LIFNR[] IS INITIAL.
SELECT LIFNR " Vendor Number
FROM LFA1
INTO W_LIFNR
UP TO 1 ROWS
WHERE LIFNR IN S_LIFNR.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E002(M8) WITH W_SPACE.
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_LIFNR[]...
ENDFORM. " VALIDATE_VEN_NUM
*& Form VALIDATE_PUR_GRP
Subroutine to validate the Purchase Group
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_PUR_GRP .
IF NOT S_EKGRP[] IS INITIAL.
SELECT EKGRP " Purchase Group
FROM T024
INTO W_EKGRP
UP TO 1 ROWS
WHERE EKGRP IN S_EKGRP.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E622(M8) WITH W_SPACE.
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_EKFRP[]...
ENDFORM. " VALIDATE_PUR_GRP
*& Form FILL_VARIANT
Subroutine to fill the Variant Structure
There are no interface parameters to be passed to this subroutine
FORM FILL_VARIANT .
Filling the Variant structure
W_VARIANT-REPORT = SY-REPID.
W_VARIANT-USERNAME = SY-UNAME.
ENDFORM. " FILL_VARIANT
Check my previous links
Regards
Pavan

Similar Messages

  • How to get Subtotal text in ALV using OOPS

    hi,
    Can any one pls help me out getting  <b>subtotals text</b> in ALV using OOPS concepts....Pls provide me if any of u have  sample code for that......
    my code:
    data:gr_grid_d0100 type ref to cl_gui_alv_grid.
    data : gr_events_d0100   type ref to lcl_events_d0100.
    classes**********
    class lcl_events_d0100 definition.
      public section.
        methods:
    subtotal_text for event subtotal_text
                        of cl_gui_alv_grid
                        importing es_subtottxt_info
                        ep_subtot_line
                        e_event_data.
    endclass.
    class lcl_events_d0100 implementation.
    method subtotal_text.
        perform d0100_event_subtotal_text using       es_subtottxt_info
    ep_subtot_line
    e_event_data.
      endmethod.                    "subtotal_text
    endclass.
    data : gr_event_handler type ref to lcl_events_d0100.
    SET HANDLER gr_event_handler->subtotal_text FOR wcl_alv_grid_request
    FORM d0100_event_subtotal_text USING
          es_subtottxt_info TYPE LVC_S_STXT
          ep_subtot_line TYPE REF TO data
          e_event_data TYPE REF TO cl_alv_event_data.
      DATA: l_text TYPE string.
      l_text = es_subtottxt_info.
      FIELD-SYMBOLS: <fs> TYPE ANY.
      ASSIGN e_event_data->m_data->* TO <fs>.
                            <fs> = text-007.

    hi vijay
    check this code
    if you want to use field symbols.
    data: total type ref to data,
    subtotal1 type ref to data.
    field-symbols <total> like gt_sflight.
    field-symbols <subtotal1> like gt_sflight.
    call method grid1->get_subtotals
    importing
    ep_collect00 = total
    ep_collect01 = subtotal1.
    assign total->* to <total>.
    assign subtotal1->* to <subtotal1>.
    or u can use
    U have to do the subtotal column wise.In the field catalog specify the following in addition to the corresponding field name(i.e. Column)
    DATA ls_fcat TYPE lvc_s_fcat.
    ls_fcat-do_sum = 'X'.
    Hope this helps u out.
    Thanks & Regards,
    naveen

  • END-OF-PAGE in ALV using OOPS

    Hello ,
    Can anyone let me know how to trigger the END-of-page event in ALV using OOPs.
    Thanks in advance.
    Regards
    Jai

    Hello Pratuysh,
    Thanks for the answer
    I know that report,but that doesn't help me.
    Any other way
    Thanks
    Jai

  • Int-ALV with OOPS

    when i am going from 1st detail list to basic list and choosing another sales order number i am geting the previous data instead of data according to new sales order number.
    i have tried in ECC5.0 and also in 4.7EE.Plz Help me.
    The code is as follows
    *& Report  ZAP_OOPS_ALV_2
    *& Interactive alv with oops.
    REPORT  zap_oops_alv_2 MESSAGE-ID zapmsg.
    *& Structure Declaration
    Structure Declaration for sales order header data
    TYPES: BEGIN OF ty_vbak,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           END OF ty_vbak,
    Structure Declaration for sales order item data
           BEGIN OF ty_vbap,
           vbeln TYPE vbeln_va, "Sales Ord Num
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
           END OF ty_vbap,
    Structure Declaration for customer data
           BEGIN OF ty_kna1,
           kunnr TYPE kunnr, "Customer
           name1 TYPE name1, "Name
           ort01 TYPE ort01, "City
           pstlz TYPE pstlz, "Postal code
           regio TYPE regio, "State
           END OF ty_kna1,
    Structure declaration for final output
          BEGIN OF ty_output,
           vbeln TYPE vbeln_va, "Sales Ord Num
           vkorg TYPE vkorg,    "Sales Org
           vkgrp TYPE vkgrp,    "Sales Grp
           kunnr TYPE kunnr,    "Customer
           name1 TYPE name1,    "Name
           ort01 TYPE ort01,    "City
           pstlz TYPE pstlz,    "Postal code
           regio TYPE regio,    "State
           posnr TYPE posnr,    "Sales item
           matnr TYPE matnr,    "Material Num
           matkl TYPE matkl,    "Material Grp
           netwr TYPE netwr,    "Net values
          END OF ty_output.
    *& Internal table Declaration
    DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak INITIAL SIZE 0,
          t_vbap TYPE STANDARD TABLE OF ty_vbap INITIAL SIZE 0,
          t_kna1 TYPE STANDARD TABLE OF ty_kna1 INITIAL SIZE 0,
          t_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
          t_vbep TYPE STANDARD TABLE OF vbep INITIAL SIZE 0,
    *& Work Area Declaration
      w_vbak TYPE ty_vbak,
      w_vbap TYPE ty_vbap,
      w_kna1 TYPE ty_kna1,
      w_output TYPE ty_output,
      w_vbep TYPE vbep,
      g_flag TYPE char1,
    g_vbeln TYPE vbak-vbeln.
    Alv Declarations
    DATA:g_custom_container1 TYPE REF TO cl_gui_custom_container,
         g_custom_container2 TYPE REF TO cl_gui_custom_container,
         g_grid1 TYPE REF TO cl_gui_alv_grid,
         g_grid2 TYPE REF TO cl_gui_alv_grid,
         w_fieldcat TYPE lvc_s_fcat,
         t_fieldcat TYPE lvc_t_fcat.
    *& Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:s_vbeln FOR g_vbeln.
    SELECTION-SCREEN END OF BLOCK b1.
          CLASS handle DEFINITION
    CLASS handle DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:click FOR EVENT double_click OF cl_gui_alv_grid
                                      IMPORTING e_row.
    ENDCLASS.                    "handle DEFINITION
          CLASS handle IMPLEMENTATION
    CLASS handle IMPLEMENTATION.
      METHOD click.
        CLEAR w_output.
        READ TABLE t_output INTO w_output INDEX e_row.
        CLEAR e_row.
        REFRESH t_vbep.
        SELECT *
         FROM vbep
         INTO TABLE t_vbep
         WHERE vbeln = w_output-vbeln.
        CREATE OBJECT g_custom_container2
                       EXPORTING
                        container_name = 'GRID2'.
        CREATE OBJECT g_grid2
                       EXPORTING
                        i_parent = g_custom_container2.
        CALL SCREEN 200.
      ENDMETHOD.                    "click
    ENDCLASS.                    "handle IMPLEMENTATION
    DATA:   g_handle TYPE REF TO handle.
          CLASS main DEFINITION
    CLASS main DEFINITION.
      PUBLIC SECTION.
        METHODS:get_vbak,
                get_vbap,
                get_kna1,
                disp_output,
                validate_vbeln,
                display_alv.
    ENDCLASS.                    "main DEFINITION
          CLASS main IMPLEMENTATION
    CLASS main IMPLEMENTATION.
    Method declaration for getting vbak data
      METHOD get_vbak.
        SELECT vbeln
               vkorg
               vkgrp
               kunnr
               FROM vbak
               INTO TABLE t_vbak
               WHERE vbeln IN s_vbeln.
      ENDMETHOD.                    "get_vbak
    Method Declaration for getting VBAP data
      METHOD get_vbap.
        SELECT vbeln
               posnr
               matnr
               matkl
               netwr
               FROM vbap
               INTO TABLE t_vbap
               FOR ALL ENTRIES IN t_vbak
               WHERE vbeln = t_vbak-vbeln.
      ENDMETHOD.                    "get_vbap
    Method Declaration for getting KNA1 data
      METHOD get_kna1.
        SELECT kunnr
               name1
               ort01
               pstlz
               regio
               FROM kna1
               INTO TABLE t_kna1
               FOR ALL ENTRIES IN t_vbak
               WHERE kunnr = t_vbak-kunnr.
      ENDMETHOD.                                                "get_kna1
    Method Declaration for displaying the output
      METHOD disp_output.
        LOOP AT t_vbap INTO w_vbap.
          w_output-vbeln = w_vbap-vbeln.
          w_output-posnr = w_vbap-posnr.
          w_output-matnr = w_vbap-matnr.
          w_output-matkl = w_vbap-matkl.
          w_output-netwr = w_vbap-netwr.
          CLEAR w_vbak.
          READ TABLE t_vbak INTO w_vbak WITH KEY vbeln = w_vbap-vbeln.
          IF sy-subrc = 0.
            w_output-vkorg = w_vbak-vkorg.
            w_output-vkgrp = w_vbak-vkgrp.
            w_output-kunnr = w_vbak-kunnr.
          ENDIF.
          CLEAR w_kna1.
          READ TABLE t_kna1 INTO w_kna1 WITH KEY kunnr = w_vbak-kunnr.
          IF sy-subrc = 0.
            w_output-name1 = w_kna1-name1.
            w_output-ort01 = w_kna1-ort01.
            w_output-pstlz = w_kna1-pstlz.
            w_output-regio = w_kna1-regio.
          ENDIF.
          APPEND w_output TO t_output.
          CLEAR w_output.
        ENDLOOP.
      ENDMETHOD.                    "disp_output
      METHOD validate_vbeln.
        DATA:l_vbeln TYPE vbeln_va.
        SELECT SINGLE vbeln
                FROM vbak
                INTO l_vbeln
                WHERE vbeln IN s_vbeln.
        IF sy-subrc <> 0.
          MESSAGE e001.
        ENDIF.
      ENDMETHOD.                    "validate_vbeln
      METHOD display_alv.
        CREATE OBJECT g_custom_container1
                       EXPORTING
                        container_name = 'GRID1'.
        CREATE OBJECT g_grid1
                       EXPORTING
                        i_parent = g_custom_container1.
        SET HANDLER g_handle->click  FOR g_grid1.
        w_fieldcat-col_pos = 1.
        w_fieldcat-fieldname = 'VBELN'.
        w_fieldcat-scrtext_m = 'Sales Ord'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 2.
        w_fieldcat-fieldname = 'POSNR'.
        w_fieldcat-scrtext_m = 'Sales Item'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 3.
        w_fieldcat-fieldname = 'MATNR'.
        w_fieldcat-scrtext_m = 'Material'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 4.
        w_fieldcat-fieldname = 'VKORG'.
        w_fieldcat-scrtext_m = 'Sale Org'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        w_fieldcat-col_pos = 5.
        w_fieldcat-fieldname = 'KUNNR'.
        w_fieldcat-scrtext_m = 'Customer'.
        APPEND w_fieldcat TO t_fieldcat.
        CLEAR w_fieldcat.
        CALL SCREEN 100.
      ENDMETHOD.                    "display_alv
    ENDCLASS.                    "main IMPLEMENTATION
    DATA:g_main TYPE REF TO main.
    Selection SELECTION EVENT
    AT SELECTION-SCREEN.
    *Create the object
      CREATE OBJECT g_main.
      CALL METHOD g_main->validate_vbeln.
    Start of selection EVENT
    START-OF-SELECTION.
      CALL METHOD g_main->get_vbak .
      CALL METHOD g_main->get_vbap.
      CALL METHOD g_main->get_kna1.
      CALL METHOD g_main->disp_output.
      CALL METHOD g_main->display_alv.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = t_output
          it_fieldcatalog = t_fieldcat.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  STATUS_0200  OUTPUT
          text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'MENU1'.
    SET TITLEBAR 'xxx'.
      CALL METHOD g_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name              = 'VBEP'
        CHANGING
          it_outtab                     = t_vbep.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    MODULE user_command_0200 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
         g_flag = 'X'.
         REFRESH t_vbep.
         SET HANDLER g_handle->click  FOR g_grid1.
         CALL METHOD g_main->display_alv.
         CALL SCREEN 100.
         LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 100.
          LEAVE TO SCREEN 0 .
         SET SCREEN 100. LEAVE SCREEN.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT

    Hi Srikar,
       In OOPS ALV, we first define screen then we define container on screen. Container means area on screen where you'll be placing your ALV.
      CREATE OBJECT r_cont
        EXPORTING
          container_name              = 'CONTAINER_1'  " Container name
        EXCEPTIONS
          OTHERS                      = 6
    Now you assign reference of container to your grid. grid defines structure of your ALV.
      CREATE OBJECT r_grid
        EXPORTING
          i_parent          = r_cont
        EXCEPTIONS
          OTHERS            = 5
    Now you call the method set_table_for_first_display of class cl_gui_alv_grid to define fieldcatalog, internal table etc. to display ALV. The reason behind using MODULE is that screen logic is always defined in MODULES. If the user is interacting with screen then screen logic will be defined in PAI of screen.
    One more thing is that in normal ALV you don't define screen and container. That means ALV will always be displayed at system defined place, but in OOP ALV, you define container(area) to define the place for your ALV.
    The advantage which I found in OOP ALV is that it is more flexible to use.
    Regards
    Abhijeet

  • Heirarchical ALV with OOPS

    Can anyone help me with the code of Heirarchical ALV with OOPS in module pool programming.

    hi,
    <i>link</i>
    http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm
    <i>Check this example report :</i> BALVHD01
    <i>chk a sample code.</i>
    REPORT  ZTEST_HIER LINE-COUNT 65
                                 LINE-SIZE 200
                                 NO STANDARD PAGE HEADING
                                 MESSAGE-ID ZZ.
    TYPE-POOLS: SLIS.
    TYPES: BEGIN OF TY_HEAD,
          VBELN LIKE VBAK-VBELN,
          KUNNR LIKE VBAK-KUNNR,
          NAME  LIKE KNA1-NAME1,
          END OF TY_HEAD.
    TYPES: BEGIN OF TY_ITEM,
           VBELN LIKE VBAP-VBELN,
           POSNR LIKE VBAP-POSNR,
           MATNR LIKE VBAP-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           CHECK(1),
           END OF TY_ITEM.
    DATA: IT_ITEM TYPE TABLE OF TY_ITEM.
    DATA: IT_HEADER TYPE TABLE OF TY_HEAD,
           IT_EVENTS TYPE SLIS_T_EVENT,          "Events.
           IT_FIELDCAT      TYPE SLIS_T_FIELDCAT_ALV.
    DATA: X_LAYOUT         TYPE SLIS_LAYOUT_ALV,
          X_FIELDCAT       TYPE SLIS_FIELDCAT_ALV,
          X_KEY           TYPE SLIS_KEYINFO_ALV,
          X_EVENTS TYPE SLIS_ALV_EVENT,      "Event
          X_VBELN LIKE VBAK-VBELN,
          X_ITEM TYPE TY_ITEM.
    CONSTANTS: C_S(1) VALUE '/'.
    DATA: V_FLAG.
    *                   SELECTION-SCREEN                                  *
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR X_VBELN.      "Sales order Number
    SELECTION-SCREEN END OF BLOCK BLK.
    AT SELECTION-SCREEN.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT SINGLE VBELN
               INTO X_VBELN
               FROM VBAK
               WHERE VBELN IN S_VBELN.
        IF SY-SUBRC <> 0.
          MESSAGE E002 WITH 'Please enter valid Sales Order'(020).
        ENDIF.
      ENDIF.
    *       CLASS lcl_bill_complete DEFINITION
    CLASS LCL_BILL_COMPLETE DEFINITION.
      PUBLIC SECTION.
        METHODS:GET_HEADER_DATA,
                GET_ITEM_DATA,
                SHOW_DATA,
                FILL_FIELDCAT,
                FILL_EVENTS,
                TOP_OF_PAGE.
    ENDCLASS.                    "lcl_bill_complete DEFINITION
    *       CLASS lcl_bill_complete IMPLEMENTATION
    CLASS LCL_BILL_COMPLETE IMPLEMENTATION.
      METHOD GET_HEADER_DATA.
        DATA:X_HEADER LIKE LINE OF IT_HEADER.
        X_HEADER-VBELN = '12345'.
        X_HEADER-KUNNR = '1234'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12346'.
        X_HEADER-KUNNR = '1236'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
        X_HEADER-VBELN = '12347'.
        X_HEADER-KUNNR = '1235'.
        X_HEADER-NAME = 'Test'.
        APPEND X_HEADER TO IT_HEADER.
      ENDMETHOD.                    "get_header_data
      METHOD GET_ITEM_DATA.
        DATA:X_ITEM LIKE LINE OF IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12345'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12346'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0010'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
        X_ITEM-VBELN = '12347'.
        X_ITEM-POSNR = '0020'.
        X_ITEM-MATNR = 'TESTMATNR'.
        X_ITEM-MAKTX = 'TESTMAT'.
        APPEND X_ITEM TO IT_ITEM.
      ENDMETHOD.                    "get_item_data
      METHOD SHOW_DATA.
        X_KEY-HEADER01 = 'VBELN'.
        X_KEY-ITEM01   = 'VBELN'.
        X_KEY-ITEM02   = 'POSNR'.
        CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = X_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT[]
            I_TABNAME_HEADER   = 'IT_HEADER'
            I_TABNAME_ITEM     = 'IT_ITEM'
            IS_KEYINFO         = X_KEY
            IT_EVENTS          = IT_EVENTS
          TABLES
            T_OUTTAB_HEADER    = IT_HEADER
            T_OUTTAB_ITEM      = IT_ITEM
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.
      ENDMETHOD.                    "show_data
      METHOD FILL_FIELDCAT.
        DATA: L_POS TYPE I.
        X_LAYOUT-HEADER_TEXT      = 'HEADER'.
        X_LAYOUT-ITEM_TEXT        = 'ITEM'.
        X_LAYOUT-DEFAULT_ITEM     = ' '.
        X_LAYOUT-NO_KEYFIX        = 'X'.
        X_LAYOUT-BOX_TABNAME      = 'IT_ITEM'.
        L_POS = L_POS + 1.
    *- Sales Order Number
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'KUNNR'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to Party'(010).
        X_FIELDCAT-OUTPUTLEN  = 13.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'NAME'.
        X_FIELDCAT-TABNAME    = 'IT_HEADER'.
        X_FIELDCAT-OUTPUTLEN  = 15.
        X_FIELDCAT-SELTEXT_M   = 'Sold-to name'(011).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'CHECK'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-CHECKBOX   = 'X'.
        X_FIELDCAT-INPUT  = 'X'.
        X_FIELDCAT-EDIT  = 'X'.
        X_FIELDCAT-SELTEXT_M   = ' '.
        X_FIELDCAT-OUTPUTLEN  = 2.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'VBELN'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'Sales Order'(017).
        X_FIELDCAT-OUTPUTLEN  = 11.
        X_FIELDCAT-TECH = 'X'.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
    *- Sales Order Item
        X_FIELDCAT-FIELDNAME   = 'POSNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-SELTEXT_M   = 'SO Item'(018).
        X_FIELDCAT-OUTPUTLEN  = 7.
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MATNR'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 18.
        X_FIELDCAT-SELTEXT_M   = 'Material number'(012).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-FIELDNAME   = 'MAKTX'.
        X_FIELDCAT-TABNAME    = 'IT_ITEM'.
        X_FIELDCAT-OUTPUTLEN  = 40.
        X_FIELDCAT-SELTEXT_M   = 'Material Description'(013).
        X_FIELDCAT-COL_POS     = L_POS.
        APPEND X_FIELDCAT TO IT_FIELDCAT.
        CLEAR  X_FIELDCAT.
      ENDMETHOD.                    "fill_fieldcat
    *--Fill the events table
      METHOD FILL_EVENTS.
    *-  Top of page
        X_EVENTS-NAME =  'TOP_OF_PAGE'.
        X_EVENTS-FORM =  'TOP_OF_PAGE'.
        APPEND X_EVENTS TO IT_EVENTS.
      ENDMETHOD.                    "fill_events
      "fill_events
      METHOD TOP_OF_PAGE.
    *-  Call Steelcase Standard Header
        WRITE 'top_of_page here'.
      ENDMETHOD.                    "top_of_page
    ENDCLASS.                    "lcl_bill_complete IMPLEMENTATION
    START-OF-SELECTION.
      DATA: OBJ TYPE REF TO LCL_BILL_COMPLETE.
      CREATE OBJECT OBJ.
      CALL METHOD OBJ->GET_HEADER_DATA.
      CALL METHOD OBJ->GET_ITEM_DATA.
      CALL METHOD OBJ->FILL_FIELDCAT.
      CALL METHOD OBJ->FILL_EVENTS.
      CALL METHOD OBJ->SHOW_DATA.
    *&      Form  top_of_page
    *      TOP_OF_PAGE
    FORM TOP_OF_PAGE.
    *-To show the top of page
      CALL METHOD OBJ->TOP_OF_PAGE.
    ENDFORM.                    "top_of_page
    if hlped plsmark points.
    rgds
    Anver

  • Header in ALV using Oops

    I need to display Table header in ALV using Oops.
    I need to data from 8 fields which I get in the run time of the program.
    I am new to Oops ALV, I have done a similar thing in normal ALV but not in oops.
    Detailed info required, Custom container settings as well.
    Thanks in Advance

    see this weblog TOP_OF_PAGE in ALV  Using CL_GUI_ALV_GRID

  • Dynamically change in size of the custom container using ALV GRID (OOPS)

    Hi Gurus!!!!
    I have an issue with the output of the report which is developed using ALV GRID (OOPS). I have used the custom container occupying full screen (Screen painter). When I execute the report using my PC the output displays report as expected in full screen. The problem is when we execute this report in 19 INCH monitor then there is always gap below the report.
    As per my understanding we should have a code to change the size of custom container dynamically.
    Please suggest some help on this.
    Thanks,
    Hemal Shah

    Hi,
    If you set the attributes, Resizing - Vertical and Horizontal for the customer container, than system will resize the size of the custome continer as per the resolution.
    Hope it helps,
    Sumana

  • HI   ALV USING OOPS CONCEPT

    hi
    i would like to have coding for total and subtotal in alv using oops concept and (not using function module).
    also i would like to have coding for cell color and heading and footer.
    thanx in adv
    rocky

    Hi Rocky,
    please check this link
    http://www.****************/Tutorials/ALV/Total/text.htm
    While modifying field catalog , try the following.
    Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
    LOOP AT i_fieldcat ASSIGNING <lfs_fieldcat>.
    CASE <lfs_fieldcat>-fieldname.
    WHEN 'LOSGR'.
    <lfs_fieldcat>-coltext = text-007.
    <lfs_fieldcat>-do_sum = c_x.
    ENDCASE.
    ENDLOOP.
    Or if you want to use field symbols.
    data: total type ref to data,
    subtotal1 type ref to data.
    field-symbols <total> like gt_sflight.
    field-symbols <subtotal1> like gt_sflight.
    call method grid1->get_subtotals
    importing
    ep_collect00 = total
    ep_collect01 = subtotal1.
    assign total->* to <total>.
    assign subtotal1->* to <subtotal1>.
    Best regards,
    raam

  • Detect rows selection in ALV using oops

    Hi ALL,
    I HAVE An ALV OUTPUT OF RECORDS USING OOPS.
    NOW I CAN SELECT ONE OR MULTIPLE ROWS OF THE OUTPUT AND I HAVE ADDED A DELETE ICON TO MY TOOL BAR.
    I HAVE BACK AND EXIT BUTTON AND I HAVE CODE FOR THE SAME IN PAI.
    FOR DELETE ICON SY-UCOMM IS DELE AND CONTROL COMES TO PAI
    MY QUESTION IS HOW DO YOU KNOW WHICH ROW OR ROWS ARE SELETEd , IN NORMAL ABAP , a field BOX type c has a value X , but what about in ALV using OOPS.
    I have no idea whether my approach is correct or wrong or do i need to something else.
    Thanks

    Hi Darren,
    This is what i have . Iam new oops so i want to just make sure
    method handle_user_command.
    § 3.In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
        data: lt_rows type lvc_t_row.
        case e_ucomm.
          when 'DELETE'.
            call method g_grid->get_selected_rows
                     importing et_index_rows = lt_rows.
    DATA : WA_LT_ROWS LIKE LINE OF LT_ROWS.
    LOOP AT LT_ROWS INTO WA_LT_ROWS.
    DELETE I_ZFINAL INDEX WA_LT_ROWS-INDEX.
    ENDLOOP.
    ENDCASE.
    call method g_grid->set_table_for_first_display
    exporting
       I_BYPASSING_BUFFER            =
       I_BUFFER_ACTIVE               =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
         is_layout                     = g_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
        it_toolbar_excluding          = pt_exclude
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
      changing
        it_outtab                     =  i_zFINAL
        it_fieldcatalog               = fieldcat
       IT_SORT                       =
       IT_FILTER                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
    LET ME KNOW THANKS

  • Editable ALV in OOPs : default value for newly created rows

    <b>I have created editable ALV using OOPs. </b>
    But my requirement is while creating new rows in ALV, one column value should be filled with some default value automatically(as soon as I press create row icon on toolbar)
    Thanks.

    HI HaReSh
    <b>refer to this code below.hope it might help u.</b>
    *& Report  ZTESTDEMO_INTERACTIVE_LIST_2
    REPORT  ZTESTDEMO_INTERACTIVE_LIST_2.
    TABLES: MARA,MARC,MARD.
    * internal table itab_mara 3 fields matnr, ernam,mtart
    DATA: BEGIN OF ITAB_MARA OCCURS 0,
    MATNR LIKE MARA-MATNR,  " material number
    ERNAM LIKE MARA-ERNAM,  " name of person who create
    MTART LIKE MARA-MTART,  " Material Type
    END OF ITAB_MARA.
    * internal table itab_marc 3 fields matnr, werks,lvorm
    DATA: BEGIN OF ITAB_MARC OCCURS 0,
    MATNR LIKE MARC-MATNR,
    WERKS LIKE MARC-WERKS,  " Plant
    LVORM LIKE MARC-LVORM,  " Flag Material for Deletion at Plant Level
    END OF ITAB_MARC.
    * internal table itab_mard 2 fields
    DATA: BEGIN OF ITAB_MARD OCCURS 0,
    MATNR LIKE MARD-MATNR,
    LGORT LIKE MARD-LGORT,  " Storage Location
    END OF ITAB_MARD.
    SELECT-OPTIONS: S_MTART FOR MARA-MTART.
    INITIALIZATION.
    S_MTART-LOW = 'HALB'.
    S_MTART-HIGH = 'HAWA'.
    S_MTART-OPTION = 'BT'.
    APPEND S_MTART.
    START-OF-SELECTION.
    SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
    S_MTART.
    PERFORM DISPLAY.
    TOP-OF-PAGE.
    WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.
    FORM DISPLAY.
    LOOP AT ITAB_MARA.
    WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
    UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
    HIDE: ITAB_MARA-MATNR.
    ENDLOOP.
    ENDFORM.
    AT LINE-SELECTION.
    CASE SY-LSIND.
    WHEN 1.
    SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
    ITAB_MARA-MATNR.
    PERFORM DISPLAY1.
    WHEN 2.
    SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
    ITAB_MARC-MATNR.
    PERFORM DISPLAY2.
    when 3.
    sy-lsind = 0.
    ENDCASE.
    FORM DISPLAY1.
    LOOP AT ITAB_MARC.
    WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
    HIDE: ITAB_MARC-MATNR.
    ENDLOOP.
    WRITE:/ SY-LSIND.
    ENDFORM.
    FORM DISPLAY2.
    LOOP AT ITAB_MARD.
    WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
    ENDLOOP.
    WRITE:/ SY-LSIND.
    ENDFORM.
    regards
    ravish
    <b>plz reward for useful ans</b>

  • Hi gurus what is ALV grid contol explain me plz

    hi gurus what is ALV grid contol explain me plz

    Hi
    Check the below link:
    http://wiki.ittoolbox.com/index.php/FAQ:What_is_module_pool_program_in_abap%3F
    http://help.sap.com/saphelp_46c/helpdata/en/35/26b1aaafab52b9e10000009b38f974/content.htm
    http://sap.mis.cmich.edu/sap-abap/abap09/sld011.htm
    http://sap.mis.cmich.edu/sap-abap/abap09/index.htm
    http://www.geocities.com/ZSAPcHAT
    http://www.allsaplinks.com/files/using_table_in_screen.pdf
    http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://www.sap-img.com/
    http://help.sap.com/saphelp_46c/helpdata/en/08/bef2dadb5311d1ad10080009b0fb56/content.htm
    http://www.sapgenie.com/links/abap.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm
    You can also check the transaction ABAPDOCU which gives you lot of sample programs.
    Also you can see the below examples...
    Go to se38 and give demodynpro and press F4.
    YOu will get a list of demo module pool programs.
    One more T-Code is ABAPDOCU.
    YOu can find more examples there.
    See the prgrams:
    DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement
    DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB
    http://www.geocities.com/ZSAPcHAT
    http://www.allsaplinks.com/files/using_table_in_screen.pdf
    ALV
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100
    1->go to Screen Painter, choose the column which you need to make as drop down.
    2->Click F2 to go tothe properties screen.
    3->Select Listbox or Listbox with Key for the DROPDOWN field (3rd field in properties tab)
    4->give value for the FCODE field also, to track the actions in SY_UCOMM when the user selects the value.
    5->in the ABAP code, you need to include the logic to populate values for this drop down. You can use the function module VRM_SET_VALUES to populate the listbox in each line of the table control. The fucntion module has to be called in the PBO module, which is defined inside the loop...endloop statement in the flow logic.
    6->for changing the values based on user selection, you can include the code in the PAI module, checking SY_UCOMM or OK_CODE.
    check this link:
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCDWBTUT/BCDWBTUT.pdf
    http://help.sap.com/saphelp_40b/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/applet.htm
    Have a look at these good links-
    http://www.allsaplinks.com/dialog_programming.html
    http://sap.mis.cmich.edu/sap-abap/abap09/
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm
    http://sap.mis.cmich.edu/abap-00/
    http://www.allsaplinks.com/files/using_table_in_screen.pdf
    http://help.sap.com/saphelp_46c/helpdata/en/08/bef2dadb5311d1ad10080009b0fb56/content.htm
    http://www.sapgenie.com/links/abap.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://help.sap.com
    http://www.sapgenie.com/abap/example_code.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/52/670ba2439b11d1896f0000e8322d00/frameset.htm
    http://www.allsaplinks.com/dialog_programming.html
    http://www.sapbrain.com/TUTORIALS/default.html
    http://www.sappoint.com/abap/spmp.pdf
    http://sappoint.com/abap.html
    http://www.sap-img.com/abap.htm
    http://sap.ittoolbox.com/code/archives.asp?i=10&t=450&a=t
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://www.sap-img.com/abap/
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://www.sap-img.com/
    http://www.sappoint.com/faq/faqdiapr.pdf
    http://www.allsaplinks.com/dialog_programming.html
    http://www1.sapdesignguild.org/resources/MiniSG/3_Managing/3_Overview_Tree_Variants.htm
    http://www1.sapdesignguild.org/resources/MiniSG/3_Managing/3_Design_Layout.htm
    Check this demo program:
    SAPCOLUMN_TREE_CONTROL_DEMO
    Sample code:
    http://www.geocities.com/victorav15/sapr3/utilities/zvvooa3.txt
    How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    chk these 2 useful links
    http://www.sap-img.com/abap-function.htm
    http://www.geocities.com/mpioud/Abap_programs.html
    check this...
    http://sapbrain.com/TUTORIALS/TECHNICAL/ALV_tutorial.html
    ALV WITH TWO CONTAINER ON ONE PAGE
    Look at the below threads ...
    Logo in OO ALV Grid
    Display Two Report IN ONE
    TOP_OF_PAGE in ALV Grid Using OO Approach!!
    ALV in webdynpro
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4
    Reward if useful.
    Regards,
    Chandru

  • Regarding ALV using OOPS Concept

    Hi Experts,
    Can abody explain to me how can i disable some settings in the tool bar of ALV Grid using oops concept??

    Hi Alex,
    You can perform this step, before you call set_table_for_first_display and pass that to this call.
    **Exculude all unnecessary standard function in ALV
      PERFORM exclude_tb_functions CHANGING lt_exclude.
    CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
      is_layout            = gs_layout
          is_variant           = l_variant
          i_save               = 'A'
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = gt_fieldcat
          it_sort              = gt_sort[]
          it_outtab            = it_final[].
    You can exclude all unwanted function in the subroutine.
    FORM exclude_tb_functions  CHANGING pt_exclude TYPE ui_functions.
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                    " exclude_tb_functions
    This will give you complete the solution for your query.
    Thanks
    Lakshmi

  • Interactive ALV using OOPs

    Hi,
    I want create an ALV report in which when i will double click on record will drill down the report.
    I know interactive ALV report using function module. but now i want to create it using OOPs concept. Please guidme
    thanks and regrds
    abhishek

    methods: double_click for event double_click of cl_gui_alv_grid
                                                     importing e_row e_column es_row_no
    method double_click.
       message s400(00) with 'documents' e_row.                "#EC *
        data : wa_display like line of lt_display.
        if e_column = 'BELNR'.
          read table lt_display index e_row into wa_display.
          if sy-subrc = 0.
            set parameter id 'BLN' field wa_display-belnr.
            set parameter id 'BUK' field wa_display-bukrs.
            set parameter id 'GJR' field wa_display-gjahr.
            call transaction 'FB03' and skip first screen.
          endif.
        endif.
    endmethod.
    see this may help u.
    Regards

  • Populate a field on TAB press in ALV Grid (OOPs)

    Hi Experts,
    I have an ALV(oops) with cl_gui_alv_grid. I have a field MATNR as empty and when i input a value and i press TAB key d anit should go to next field (next coulmn) to fill the  old material# which can be got from MARA.
    I am not able to get the sy-ucomm or e_ucomm for TAB press.
    Q) WHERE should i write my query logic to fill the OLD MAtnr field.
    code sample : I have data change event as below.
    class lcl_event_handler definition
    PUBLIC SECTION .
        METHODS:
      changed_data for event data_changed of cl_gui_alv_grid importing er_data_changed
                                                                               e_ucomm sender,
    ENDCLASS.
    in Implemntation class...
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    METHOD changed_data.
        clear:      ls_stable-row, ls_stable-col.
       loop at er_data_changed->mt_mod_cells into ls_modified.
        clear wa_outdisp.
        READ TABLE gt_outdisp INTO wa_outdisp INDEX ls_modified-row_id.
        CHECK sy-subrc EQ 0.
        lv_field =  ls_modified-fieldname.
        if lv_field = 'MATNR'.
          wa_outdisp-MATNR = ls_modified-value.
          wa_outdisp-bismt = '123'.
        endif.
        MODIFY gt_outdisp FROM wa_outdisp INDEX ls_modified-row_id.
        ls_stable-row = 'X'.
        ls_stable-col = 'X'.
        grid->refresh_table_display( exporting is_stable = ls_stable  ).
        endloop.
      ENDMETHOD.                    "changed_data
    ENDCLASS.
    How can i do this?
    Thanks
    Dan

    Max,
    Yes i am using that event. I am using it before grid -> set_first_display method.
    The debugger is not stopping inside the data change method when i placed a break point.
    I am using refresh method also.
    My code for  sy-ucomm is as below.
    when'NEWROW '
        when others.
          CALL METHOD cl_gui_cfw=>dispatch
            IMPORTING
              return_code = w_return_code.
          CALL METHOD grid->register_edit_event
            EXPORTING
              i_event_id = cl_gui_alv_grid=>mc_evt_modified.

  • Hierarchial ALV using OOP

    Hi Friends,
    I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
    The code written is as follows.
    =====================================================
    data: gt_zsd_abcd      type zsd_abcd  occurs 0,      "Output-Table
    data l_hierarchy_header type treev_hhdr.
      perform build_hierarchy_header changing l_hierarchy_header.
      call method g_alv_tree->set_table_for_first_display
        exporting
          i_structure_name    = 'zsd_abcd'
          is_hierarchy_header = l_hierarchy_header
        changing
          it_outtab           = gt_zsd_abcd. "table must be empty !
      perform create_hierarchy.
      call method g_alv_tree->frontend_update.
    =====================================================
    I would like know as to how to display only the required columns in the header part.
    Pls guide me.
    TIA.
    Regards,
    Mark K

    Hi Mark,
    i got it, in your case you will get all the fields present in the structure you mentioned in the method.
    so if you want only Purchase Order then you need to Build the fieldcat only for that field and then pass that fieldcat to the method. and don't pass the structure in this case.
      call method alv_tree_control->set_table_for_first_display
       exporting
                 is_variant           = l_variant
                 i_save               = 'A'
                 i_default            = 'X'
                 is_hierarchy_header  = l_hierarchy_header
                 it_special_groups    = l_special_groups
                 it_toolbar_excluding = l_toolbar_excluding
       changing
              <b>it_fieldcatalog      = l_field_catalog</b>
                 it_outtab            = l_output_tbl.
    Regards
    vijay

Maybe you are looking for