Application Development 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: 

OOALV

Former Member
0 Kudos
2,876

1) Why do we go For OOALV as we can have ALV ?? ( Interview question )

2) Can any one give me some examples of OOPS and FAQ but not on OOALV

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
285

Apart from the advantages in displaying the grid, the found the following advantages with Grid Control.

1. The instance of the grid can be cleared during the session, this is not possible with Function module ALV. When ALV function module is called, the function group gets initialized. All the variables in the funciton group are instantiatd and occupy memory. this memory cannot be cleared in the session. Thus ALV function modules occupy more memory. Thus make them work slower than ALV grid control.

2. Handling of Events at runtime becomes more simpler in ALV grid control.

3. A page can have n number of ALV grid controls.

4. The runtime environment can be controlled efficiently in ALV grid control.

this is another reply

Hi. The use of the grid control vs the function module based ALV is really based on personal preference, I think. Although I think that many should learn the control based ALV as it will help to learn ABAP OO. The control is used when you have a dynpro or container in which the ALV is to reside in. You use the FM, when you want a full screen alv with the buttons on the application toolbar. If you look under the hood, of the FM, you will see that the control based ALV is implemented underneath.

Also, really you should look in the ALV object model which was introduced in Netweaver 2004. It provides one unified tool for the 2d table display, so you can use the one tool to provide the "Full screen" display which is provided by the FM ALV and the control based ALV.

http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm

You will see arguements that you shouldn't use the FM and always use the control based ALV. I'm not sure that it is 100% true either way. But I do think that you should learn and start using the ALV Object Model, if you are on a Netweaver release.

another one

For a better look and feel ALV grid is best and you have all the options for downloading , summing etc on the toolbar itself.

But care should be taken not to use ALV report when the report is executed in background. ALV will give an error.

In this case, check the field SY-BATCH and use simple classical reporting if execute background and ALV if execute foreground.

*************************************************************

1. For all practical purposes, they are the same.

2. Some differences:

a) from abap coding point of view,

alv list is done with Function modules,

alv gris can also be done with FM,

but can also be done using OO concepts.

b) Alv grid (using oo concept) requires

designing the screen layout .

Hence, in one screen, we can show more

then one alv grid

(we cannot show more than

one alv list on one screen)

c) ALV grid uses ActiveX controls

present on the Presentation Server.

Hence, it consumes More Memory

on the presentation server.

d) ALV LIST is Display Only.

Whereas

ALV Grid Can Be made EDITABLE for entry purpose.

e) In alv grid, these options are possible,

but not in alv list.

without horizontal lines

without vertical lines

without cell merging during sorts

display total lines above the entries .

ALV LIST Can be coded using only FMs

ALV GRID Can be coded using FMs and object oriented concepts

ALV LIST Can be displayed hieraicharlly

ALV GRID cannot be displayed hierarichally

“The ALV Grid control is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options.”

The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As a control, it is a component that is installed on the local PC.

The ALV Grid control provides typical list functions as sorting, filtering, summing, etc.,while also gives the opportunity to develop user functions where needed. It presents numerous interfaces like Excel Inplace and Crystal Reports.

The wrapper class implemented to encapsulate ALV Grid functionality is “CL_GUI_ALV_GRID”. There is another way to display lists with ALV utilizing “REUSE_ALV...” functions. However, that way is not comprised in this tutorial.

B. Building Blocks

While preparing a list to be displayed via an ALV grid control, we have some basic components to prepare. These are;

i. List data: Obviously, this is the data in an internal table to be listed. Standard ALV functions except sorting makes just read access to the list data. However, sorting changes state of the internal table. The internal table holding list data may be of any flat type. Deep types are only allowed when set for some functionalities of ALV Grid.

ii. Field Catalog: We use another internal table to define specifications on how the fields of our list will be displayed. This internal table is called the

“field catalog”. The field catalog must comprise some technical and additional information about display options for each column to be displayed. There are three procedures to generate the field catalog as “Automatic generation”, “Semi-automatic generation”, and “Manual generation”. The internal table for the field catalog must be referenced to the dictionary type “LVC_T_FCAT”.

iii. Layout Structure: We fill a structure to specify general layout options for the grid. With this structure we can set general display options, grid customizing, totals options, color adjustments etc... The layout structure must be of type “LVC_S_LAYO”.

iv. Event Handler: We should define and implement an event handler class if we want to handle events triggered by the ALV Grid instance. After creating ALV Grid instance, we must register an instance of this event handler class to handle ALV Grid events.

v. Additional Data: To trigger some additional features of ALV Grid we can have some additional data to pass as parameters. For example, initial sorting criteria, buttons to be deactivated, etc..

***********************************************************************

If you want to implement "right click" options (contextual menu) on your ALV, you will have to do it with object oriented programming.

****************************************************************************

A DISADVANTAGE of the OO ALV as against the classical one is we cannot schedule a program with an OO output in background, since the program tries to intialize the container for the ALV and it dumps.

***********************************************************************

Check the sample code..

REPORT ZTEST_OO_ALV MESSAGE-ID ZZ .

DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.

DATA: L_VALID TYPE C,

V_FLAG,

V_DATA_CHANGE,

V_ROW TYPE LVC_S_ROW,

V_COLUMN TYPE LVC_S_COL,

V_ROW_NUM TYPE LVC_S_ROID.

DATA: IT_ROW_NO TYPE LVC_T_ROID,

X_ROW_NO TYPE LVC_S_ROID.

DATA:BEGIN OF ITAB OCCURS 0,

VBELN LIKE LIKP-VBELN,

POSNR LIKE LIPS-POSNR,

CELLCOLOR TYPE LVC_T_SCOL, "required for color

DROP(10),

check,

END OF ITAB.

"The Below Definitions Must.....

DATA:

  • Reference to document

DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,

  • Reference to split container

DG_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,

  • Reference to grid container

DG_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,

  • Reference to html container

DG_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER,

  • Reference to html container

DG_PARENT_HTML TYPE REF TO CL_GUI_CONTAINER.

"up to here

----


  • CLASS lcl_event_handler DEFINITION

----


CLASS LCL_EVENT_HANDLER DEFINITION .

PUBLIC SECTION .

METHODS:

**Hot spot Handler

HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,

**Double Click Handler

HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW E_COLUMN ES_ROW_NO,

TOP_OF_PAGE FOR EVENT TOP_OF_PAGE "event handler

OF CL_GUI_ALV_GRID

IMPORTING E_DYNDOC_ID.

*

  • END_OF_LIST FOR EVENT end_of_list "event handler

  • OF CL_GUI_ALV_GRID

  • IMPORTING E_DYNDOC_ID.

ENDCLASS. "lcl_event_handler DEFINITION

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


CLASS LCL_EVENT_HANDLER IMPLEMENTATION.

*Handle Hotspot Click

METHOD HANDLE_HOTSPOT_CLICK .

CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.

V_ROW = E_ROW_ID.

V_COLUMN = E_COLUMN_ID.

V_ROW_NUM = ES_ROW_NO.

  • MESSAGE I000 WITH V_ROW 'clicked'.

CLEAR IT_ROW_NO[].

X_ROW_NO-ROW_ID = V_ROW.

APPEND X_ROW_NO TO IT_ROW_NO .

CALL METHOD G_GRID->SET_SELECTED_ROWS

EXPORTING

IT_ROW_NO = IT_ROW_NO.

ENDMETHOD. "lcl_event_handler

*Handle Double Click

METHOD HANDLE_DOUBLE_CLICK.

CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.

V_ROW = E_ROW.

V_COLUMN = E_COLUMN.

V_ROW_NUM = ES_ROW_NO.

IF E_COLUMN = 'VBELN'.

SET PARAMETER ID 'VL' FIELD ITAB-VBELN.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

ENDIF.

IF E_COLUMN = 'POSNR'.

SET PARAMETER ID 'VL' FIELD ITAB-VBELN.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."

ENDIF.

ENDMETHOD. "handle_double_click

  • METHOD END_OF_LIST. "implementation

    • Top-of-page event

  • PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.

  • ENDMETHOD. "top_of_page

METHOD TOP_OF_PAGE. "implementation

  • Top-of-page event

PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.

ENDMETHOD. "top_of_page

ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION

&----


*& Global Definitions

&----


DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1

G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler

DATA: OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE SY-UCOMM,

G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',

GS_LAYOUT TYPE LVC_S_LAYO.

data: v_lines type i.

data: v_line(3) type c.

*- Fieldcatalog for First and second Report

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

X_FIELDCAT TYPE LVC_S_FCAT,

LS_VARI TYPE DISVARIANT.

*----


  • START-OF_SELECTION

*----


START-OF-SELECTION.

SELECT VBELN

POSNR

FROM LIPS

UP TO 20 ROWS

INTO CORRESPONDING FIELDS OF TABLE ITAB.

describe table itab lines v_lines.

END-OF-SELECTION.

IF NOT ITAB[] IS INITIAL.

CALL SCREEN 100.

ELSE.

MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).

ENDIF.

&----


*& Form CREATE_AND_INIT_ALV

&----


  • text

----


FORM CREATE_AND_INIT_ALV .

DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.

"attention.....from here

"split your container here...into two parts

"create the container

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER1.

"this is for top of page

  • Create TOP-Document

CREATE OBJECT DG_DYNDOC_ID

EXPORTING STYLE = 'ALV_GRID'.

  • Create Splitter for custom_container

CREATE OBJECT DG_SPLITTER

EXPORTING PARENT = G_CUSTOM_CONTAINER

ROWS = 2

COLUMNS = 1.

  • Split the custom_container to two containers and move the reference

  • to receiving containers g_parent_html and g_parent_grid

"i am allocating the space for grid and top of page

CALL METHOD DG_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 1

COLUMN = 1

RECEIVING

CONTAINER = DG_PARENT_HTML.

CALL METHOD DG_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 2

COLUMN = 1

RECEIVING

CONTAINER = DG_PARENT_GRID.

  • CALL METHOD DG_SPLITTER->GET_CONTAINER

  • EXPORTING

  • ROW = 2

  • COLUMN = 1

  • RECEIVING

  • CONTAINER = DG_PARENT_HTML.

  • CALL METHOD DG_SPLITTER->GET_CONTAINER

  • EXPORTING

  • ROW = 1

  • COLUMN = 1

  • RECEIVING

  • CONTAINER = DG_PARENT_GRID.

"you can set the height of it

  • Set height for g_parent_html

CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT

EXPORTING

ID = 1

HEIGHT = 5.

"from here as usual..you need to specify parent as splitter part

"which we alloted for grid

CREATE OBJECT G_GRID

EXPORTING I_PARENT = DG_PARENT_GRID.

  • Set a titlebar for the grid control

CLEAR GS_LAYOUT.

GS_LAYOUT-GRID_TITLE = TEXT-003.

GS_LAYOUT-ZEBRA = SPACE.

GS_LAYOUT-CWIDTH_OPT = 'X'.

GS_LAYOUT-NO_ROWMARK = 'X'.

GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.

CALL METHOD G_GRID->REGISTER_EDIT_EVENT

EXPORTING

I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.

CREATE OBJECT G_HANDLER.

SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.

SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.

  • SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.

SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.

DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color

DATA: L_INDEX TYPE SY-TABIX.

"Here i am changing the color of line 1,5,10...

"so you can change the color of font conditionally

LOOP AT ITAB.

L_INDEX = SY-TABIX.

IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.

LS_CELLCOLOR-FNAME = 'VBELN'.

LS_CELLCOLOR-COLOR-COL = '6'.

LS_CELLCOLOR-COLOR-INT = '0'.

LS_CELLCOLOR-COLOR-INV = '1'.

APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

LS_CELLCOLOR-FNAME = 'POSNR'.

LS_CELLCOLOR-COLOR-COL = '6'.

LS_CELLCOLOR-COLOR-INT = '0'.

LS_CELLCOLOR-COLOR-INV = '1'.

APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

ENDIF.

ENDLOOP.

  • setting focus for created grid control

CALL METHOD CL_GUI_CONTROL=>SET_FOCUS

EXPORTING

CONTROL = G_GRID.

  • Build fieldcat and set editable for date and reason code

  • edit enabled. Assign a handle for the dropdown listbox.

PERFORM BUILD_FIELDCAT.

PERFORM SET_DRDN_TABLE.

  • Optionally restrict generic functions to 'change only'.

  • (The user shall not be able to add new lines).

PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.

**Vaiant to save the layout

LS_VARI-REPORT = SY-REPID.

LS_VARI-HANDLE = SPACE.

LS_VARI-LOG_GROUP = SPACE.

LS_VARI-USERNAME = SPACE.

LS_VARI-VARIANT = SPACE.

LS_VARI-TEXT = SPACE.

LS_VARI-DEPENDVARS = SPACE.

**Calling the Method for ALV output

CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IT_TOOLBAR_EXCLUDING = LT_EXCLUDE

IS_VARIANT = LS_VARI

IS_LAYOUT = GS_LAYOUT

I_SAVE = 'A'

CHANGING

IT_FIELDCATALOG = IT_FIELDCAT

IT_OUTTAB = ITAB[].

"do these..{

  • Initializing document

CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.

  • Processing events

CALL METHOD G_GRID->LIST_PROCESSING_EVENTS

EXPORTING

I_EVENT_NAME = 'TOP_OF_PAGE'

I_DYNDOC_ID = DG_DYNDOC_ID.

"end }

  • Set editable cells to ready for input initially

CALL METHOD G_GRID->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 1.

ENDFORM. "CREATE_AND_INIT_ALV

&----


*& Form EXCLUDE_TB_FUNCTIONS

&----


  • text

----


  • -->PT_EXCLUDE text

----


FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.

  • Only allow to change data not to create new entries (exclude

  • generic 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.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM. " EXCLUDE_TB_FUNCTIONS

&----


*& Form build_fieldcat

&----


  • Fieldcatalog

----


FORM BUILD_FIELDCAT .

DATA: L_POS TYPE I.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Check'.

X_FIELDCAT-FIELDNAME = 'CHECK'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-CHECKbox = 'X'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-OUTPUTLEN = '1'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).

X_FIELDCAT-FIELDNAME = 'VBELN'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-NO_ZERO = 'X'.

X_FIELDCAT-OUTPUTLEN = '10'.

X_FIELDCAT-HOTSPOT = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Item'(025).

X_FIELDCAT-FIELDNAME = 'POSNR'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-OUTPUTLEN = '5'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Drop'(025).

X_FIELDCAT-FIELDNAME = 'DROP'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-OUTPUTLEN = '5'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-DRDN_HNDL = '1'.

X_FIELDCAT-DRDN_ALIAS = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

ENDFORM. " build_fieldcat

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'MAIN100'.

IF G_CUSTOM_CONTAINER IS INITIAL.

**Initializing the grid and calling the fm to Display the O/P

PERFORM CREATE_AND_INIT_ALV.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form SET_DRDN_TABLE

&----


  • text

----


FORM SET_DRDN_TABLE.

DATA:LT_DRAL TYPE LVC_T_DRAL,

LS_DRAL TYPE LVC_S_DRAL.

LOOP AT ITAB .

  • First listbox (handle '1').

IF SY-INDEX = 1.

LS_DRAL-HANDLE = '1'.

LS_DRAL-VALUE = ' '.

LS_DRAL-INT_VALUE = ' '.

ELSE.

LS_DRAL-HANDLE = '1'.

LS_DRAL-VALUE = ITAB-POSNR.

LS_DRAL-INT_VALUE = ITAB-POSNR.

ENDIF.

APPEND LS_DRAL TO LT_DRAL.

ENDLOOP.

**Setting the Drop down table for Reason Code

CALL METHOD G_GRID->SET_DROP_DOWN_TABLE

EXPORTING

IT_DROP_DOWN_ALIAS = LT_DRAL.

ENDFORM. " set_drdn_table

&----


*& Form EVENT_TOP_OF_PAGE

&----


  • text

----


  • -->DG_DYNDOC_ID text

----


FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.

"this is more clear.....check it

"first add text, then pass it to comentry write fm

DATA : DL_TEXT(255) TYPE C. "Text

  • Populating header to top-of-page

CALL METHOD DG_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = 'Test Report'

SAP_STYLE = CL_DD_AREA=>HEADING.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move program ID

CONCATENATE 'Program Name :' SY-REPID

INTO DL_TEXT SEPARATED BY SPACE.

  • Add Program Name to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move User ID

CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE

.

  • Add User ID to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move count (no of records).

move v_lines to v_line.

CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.

  • Add Client to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move date

WRITE SY-DATUM TO DL_TEXT.

CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.

  • Add Date to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move time

WRITE SY-UZEIT TO DL_TEXT.

CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.

  • Add Time to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

  • Populating data to html control

PERFORM HTML.

ENDFORM. " EVENT_TOP_OF_PAGE

&----


*& Form ADD_TEXT

&----


  • To add Text

----


FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.

  • Adding text

CALL METHOD DG_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = P_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING.

ENDFORM. " ADD_TEXT

&----


*& Form HTML

&----


  • text

----


FORM HTML.

DATA : DL_LENGTH TYPE I, " Length

DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id

  • Creating html control

IF DG_HTML_CNTRL IS INITIAL.

CREATE OBJECT DG_HTML_CNTRL

EXPORTING

PARENT = DG_PARENT_HTML.

ENDIF.

  • Reuse_alv_grid_commentary_set

CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'

EXPORTING

DOCUMENT = DG_DYNDOC_ID

BOTTOM = SPACE

IMPORTING

LENGTH = DL_LENGTH.

  • Get TOP->HTML_TABLE ready

CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.

  • Set wallpaper

CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND

EXPORTING

PICTURE_ID = DL_BACKGROUND_ID.

  • Connect TOP document to HTML-Control

DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.

  • Display TOP document

CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT

EXPORTING

REUSE_CONTROL = 'X'

PARENT = DG_PARENT_HTML

EXCEPTIONS

HTML_DISPLAY_ERROR = 1.

IF SY-SUBRC NE 0.

MESSAGE I999 WITH 'Error in displaying top-of-page'(036).

ENDIF.

ENDFORM. " HTML

Regards

Vasu

5 REPLIES 5

former_member223537
Active Contributor
0 Kudos
285

1. OO ALV is having additional features like colouring cell, Editing Cells and many other additional feature which ALV FM doesnt provide.

2. http://members.fortunecity.com/viper98/oop.htm

hymavathi_oruganti
Active Contributor
0 Kudos
285

hi,

flexibility will be more with oo alv than with alv. after some extent it will be very difficult for us to achive some output in alv which would be easier with ooalv using methods.

example scenario:

if u want to select multiple rows and get the data and do some manipulation and update the rows.

with noraml alv, for the row to be selected and get the data of the row will be difficlut when compared with oo alv which can be achived with a methos get_selected_rows. like wise there are many methods in many classes which makes ooalv more user friendly screen.

http://www.abap4.it/download/ALV.pdf

the above is a nice pdf on oo alv. pls go thru that link.

Former Member
0 Kudos
285

hi

good

The new object model of the SAP List Viewer (ALV) is an object-oriented encapsulation of the ALV tool that already exists.

· Simple, two-dimensional table

· Hierarchical-sequential list

· Tree structure

The following objectives were fulfilled with the new ALV interface:

· Unified, object-oriented API for all ALV tools wherever possible

· Coherent API

· Earliest possible error detection during programming (for example, exceptions let you know when methods are not possible in specific situations)

· Functions for accessibility are integrated into ALV, which means that you do not have to provide these functions yourself using your application

http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm

thanks

mrutyun^

Former Member
0 Kudos
286

Apart from the advantages in displaying the grid, the found the following advantages with Grid Control.

1. The instance of the grid can be cleared during the session, this is not possible with Function module ALV. When ALV function module is called, the function group gets initialized. All the variables in the funciton group are instantiatd and occupy memory. this memory cannot be cleared in the session. Thus ALV function modules occupy more memory. Thus make them work slower than ALV grid control.

2. Handling of Events at runtime becomes more simpler in ALV grid control.

3. A page can have n number of ALV grid controls.

4. The runtime environment can be controlled efficiently in ALV grid control.

this is another reply

Hi. The use of the grid control vs the function module based ALV is really based on personal preference, I think. Although I think that many should learn the control based ALV as it will help to learn ABAP OO. The control is used when you have a dynpro or container in which the ALV is to reside in. You use the FM, when you want a full screen alv with the buttons on the application toolbar. If you look under the hood, of the FM, you will see that the control based ALV is implemented underneath.

Also, really you should look in the ALV object model which was introduced in Netweaver 2004. It provides one unified tool for the 2d table display, so you can use the one tool to provide the "Full screen" display which is provided by the FM ALV and the control based ALV.

http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm

You will see arguements that you shouldn't use the FM and always use the control based ALV. I'm not sure that it is 100% true either way. But I do think that you should learn and start using the ALV Object Model, if you are on a Netweaver release.

another one

For a better look and feel ALV grid is best and you have all the options for downloading , summing etc on the toolbar itself.

But care should be taken not to use ALV report when the report is executed in background. ALV will give an error.

In this case, check the field SY-BATCH and use simple classical reporting if execute background and ALV if execute foreground.

*************************************************************

1. For all practical purposes, they are the same.

2. Some differences:

a) from abap coding point of view,

alv list is done with Function modules,

alv gris can also be done with FM,

but can also be done using OO concepts.

b) Alv grid (using oo concept) requires

designing the screen layout .

Hence, in one screen, we can show more

then one alv grid

(we cannot show more than

one alv list on one screen)

c) ALV grid uses ActiveX controls

present on the Presentation Server.

Hence, it consumes More Memory

on the presentation server.

d) ALV LIST is Display Only.

Whereas

ALV Grid Can Be made EDITABLE for entry purpose.

e) In alv grid, these options are possible,

but not in alv list.

without horizontal lines

without vertical lines

without cell merging during sorts

display total lines above the entries .

ALV LIST Can be coded using only FMs

ALV GRID Can be coded using FMs and object oriented concepts

ALV LIST Can be displayed hieraicharlly

ALV GRID cannot be displayed hierarichally

“The ALV Grid control is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options.”

The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As a control, it is a component that is installed on the local PC.

The ALV Grid control provides typical list functions as sorting, filtering, summing, etc.,while also gives the opportunity to develop user functions where needed. It presents numerous interfaces like Excel Inplace and Crystal Reports.

The wrapper class implemented to encapsulate ALV Grid functionality is “CL_GUI_ALV_GRID”. There is another way to display lists with ALV utilizing “REUSE_ALV...” functions. However, that way is not comprised in this tutorial.

B. Building Blocks

While preparing a list to be displayed via an ALV grid control, we have some basic components to prepare. These are;

i. List data: Obviously, this is the data in an internal table to be listed. Standard ALV functions except sorting makes just read access to the list data. However, sorting changes state of the internal table. The internal table holding list data may be of any flat type. Deep types are only allowed when set for some functionalities of ALV Grid.

ii. Field Catalog: We use another internal table to define specifications on how the fields of our list will be displayed. This internal table is called the

“field catalog”. The field catalog must comprise some technical and additional information about display options for each column to be displayed. There are three procedures to generate the field catalog as “Automatic generation”, “Semi-automatic generation”, and “Manual generation”. The internal table for the field catalog must be referenced to the dictionary type “LVC_T_FCAT”.

iii. Layout Structure: We fill a structure to specify general layout options for the grid. With this structure we can set general display options, grid customizing, totals options, color adjustments etc... The layout structure must be of type “LVC_S_LAYO”.

iv. Event Handler: We should define and implement an event handler class if we want to handle events triggered by the ALV Grid instance. After creating ALV Grid instance, we must register an instance of this event handler class to handle ALV Grid events.

v. Additional Data: To trigger some additional features of ALV Grid we can have some additional data to pass as parameters. For example, initial sorting criteria, buttons to be deactivated, etc..

***********************************************************************

If you want to implement "right click" options (contextual menu) on your ALV, you will have to do it with object oriented programming.

****************************************************************************

A DISADVANTAGE of the OO ALV as against the classical one is we cannot schedule a program with an OO output in background, since the program tries to intialize the container for the ALV and it dumps.

***********************************************************************

Check the sample code..

REPORT ZTEST_OO_ALV MESSAGE-ID ZZ .

DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.

DATA: L_VALID TYPE C,

V_FLAG,

V_DATA_CHANGE,

V_ROW TYPE LVC_S_ROW,

V_COLUMN TYPE LVC_S_COL,

V_ROW_NUM TYPE LVC_S_ROID.

DATA: IT_ROW_NO TYPE LVC_T_ROID,

X_ROW_NO TYPE LVC_S_ROID.

DATA:BEGIN OF ITAB OCCURS 0,

VBELN LIKE LIKP-VBELN,

POSNR LIKE LIPS-POSNR,

CELLCOLOR TYPE LVC_T_SCOL, "required for color

DROP(10),

check,

END OF ITAB.

"The Below Definitions Must.....

DATA:

  • Reference to document

DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,

  • Reference to split container

DG_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,

  • Reference to grid container

DG_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,

  • Reference to html container

DG_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER,

  • Reference to html container

DG_PARENT_HTML TYPE REF TO CL_GUI_CONTAINER.

"up to here

----


  • CLASS lcl_event_handler DEFINITION

----


CLASS LCL_EVENT_HANDLER DEFINITION .

PUBLIC SECTION .

METHODS:

**Hot spot Handler

HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,

**Double Click Handler

HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW E_COLUMN ES_ROW_NO,

TOP_OF_PAGE FOR EVENT TOP_OF_PAGE "event handler

OF CL_GUI_ALV_GRID

IMPORTING E_DYNDOC_ID.

*

  • END_OF_LIST FOR EVENT end_of_list "event handler

  • OF CL_GUI_ALV_GRID

  • IMPORTING E_DYNDOC_ID.

ENDCLASS. "lcl_event_handler DEFINITION

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


CLASS LCL_EVENT_HANDLER IMPLEMENTATION.

*Handle Hotspot Click

METHOD HANDLE_HOTSPOT_CLICK .

CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.

V_ROW = E_ROW_ID.

V_COLUMN = E_COLUMN_ID.

V_ROW_NUM = ES_ROW_NO.

  • MESSAGE I000 WITH V_ROW 'clicked'.

CLEAR IT_ROW_NO[].

X_ROW_NO-ROW_ID = V_ROW.

APPEND X_ROW_NO TO IT_ROW_NO .

CALL METHOD G_GRID->SET_SELECTED_ROWS

EXPORTING

IT_ROW_NO = IT_ROW_NO.

ENDMETHOD. "lcl_event_handler

*Handle Double Click

METHOD HANDLE_DOUBLE_CLICK.

CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.

V_ROW = E_ROW.

V_COLUMN = E_COLUMN.

V_ROW_NUM = ES_ROW_NO.

IF E_COLUMN = 'VBELN'.

SET PARAMETER ID 'VL' FIELD ITAB-VBELN.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

ENDIF.

IF E_COLUMN = 'POSNR'.

SET PARAMETER ID 'VL' FIELD ITAB-VBELN.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."

ENDIF.

ENDMETHOD. "handle_double_click

  • METHOD END_OF_LIST. "implementation

    • Top-of-page event

  • PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.

  • ENDMETHOD. "top_of_page

METHOD TOP_OF_PAGE. "implementation

  • Top-of-page event

PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.

ENDMETHOD. "top_of_page

ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION

&----


*& Global Definitions

&----


DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1

G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler

DATA: OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE SY-UCOMM,

G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',

GS_LAYOUT TYPE LVC_S_LAYO.

data: v_lines type i.

data: v_line(3) type c.

*- Fieldcatalog for First and second Report

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

X_FIELDCAT TYPE LVC_S_FCAT,

LS_VARI TYPE DISVARIANT.

*----


  • START-OF_SELECTION

*----


START-OF-SELECTION.

SELECT VBELN

POSNR

FROM LIPS

UP TO 20 ROWS

INTO CORRESPONDING FIELDS OF TABLE ITAB.

describe table itab lines v_lines.

END-OF-SELECTION.

IF NOT ITAB[] IS INITIAL.

CALL SCREEN 100.

ELSE.

MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).

ENDIF.

&----


*& Form CREATE_AND_INIT_ALV

&----


  • text

----


FORM CREATE_AND_INIT_ALV .

DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.

"attention.....from here

"split your container here...into two parts

"create the container

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER1.

"this is for top of page

  • Create TOP-Document

CREATE OBJECT DG_DYNDOC_ID

EXPORTING STYLE = 'ALV_GRID'.

  • Create Splitter for custom_container

CREATE OBJECT DG_SPLITTER

EXPORTING PARENT = G_CUSTOM_CONTAINER

ROWS = 2

COLUMNS = 1.

  • Split the custom_container to two containers and move the reference

  • to receiving containers g_parent_html and g_parent_grid

"i am allocating the space for grid and top of page

CALL METHOD DG_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 1

COLUMN = 1

RECEIVING

CONTAINER = DG_PARENT_HTML.

CALL METHOD DG_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 2

COLUMN = 1

RECEIVING

CONTAINER = DG_PARENT_GRID.

  • CALL METHOD DG_SPLITTER->GET_CONTAINER

  • EXPORTING

  • ROW = 2

  • COLUMN = 1

  • RECEIVING

  • CONTAINER = DG_PARENT_HTML.

  • CALL METHOD DG_SPLITTER->GET_CONTAINER

  • EXPORTING

  • ROW = 1

  • COLUMN = 1

  • RECEIVING

  • CONTAINER = DG_PARENT_GRID.

"you can set the height of it

  • Set height for g_parent_html

CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT

EXPORTING

ID = 1

HEIGHT = 5.

"from here as usual..you need to specify parent as splitter part

"which we alloted for grid

CREATE OBJECT G_GRID

EXPORTING I_PARENT = DG_PARENT_GRID.

  • Set a titlebar for the grid control

CLEAR GS_LAYOUT.

GS_LAYOUT-GRID_TITLE = TEXT-003.

GS_LAYOUT-ZEBRA = SPACE.

GS_LAYOUT-CWIDTH_OPT = 'X'.

GS_LAYOUT-NO_ROWMARK = 'X'.

GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.

CALL METHOD G_GRID->REGISTER_EDIT_EVENT

EXPORTING

I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.

CREATE OBJECT G_HANDLER.

SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.

SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.

  • SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.

SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.

DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color

DATA: L_INDEX TYPE SY-TABIX.

"Here i am changing the color of line 1,5,10...

"so you can change the color of font conditionally

LOOP AT ITAB.

L_INDEX = SY-TABIX.

IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.

LS_CELLCOLOR-FNAME = 'VBELN'.

LS_CELLCOLOR-COLOR-COL = '6'.

LS_CELLCOLOR-COLOR-INT = '0'.

LS_CELLCOLOR-COLOR-INV = '1'.

APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

LS_CELLCOLOR-FNAME = 'POSNR'.

LS_CELLCOLOR-COLOR-COL = '6'.

LS_CELLCOLOR-COLOR-INT = '0'.

LS_CELLCOLOR-COLOR-INV = '1'.

APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

ENDIF.

ENDLOOP.

  • setting focus for created grid control

CALL METHOD CL_GUI_CONTROL=>SET_FOCUS

EXPORTING

CONTROL = G_GRID.

  • Build fieldcat and set editable for date and reason code

  • edit enabled. Assign a handle for the dropdown listbox.

PERFORM BUILD_FIELDCAT.

PERFORM SET_DRDN_TABLE.

  • Optionally restrict generic functions to 'change only'.

  • (The user shall not be able to add new lines).

PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.

**Vaiant to save the layout

LS_VARI-REPORT = SY-REPID.

LS_VARI-HANDLE = SPACE.

LS_VARI-LOG_GROUP = SPACE.

LS_VARI-USERNAME = SPACE.

LS_VARI-VARIANT = SPACE.

LS_VARI-TEXT = SPACE.

LS_VARI-DEPENDVARS = SPACE.

**Calling the Method for ALV output

CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IT_TOOLBAR_EXCLUDING = LT_EXCLUDE

IS_VARIANT = LS_VARI

IS_LAYOUT = GS_LAYOUT

I_SAVE = 'A'

CHANGING

IT_FIELDCATALOG = IT_FIELDCAT

IT_OUTTAB = ITAB[].

"do these..{

  • Initializing document

CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.

  • Processing events

CALL METHOD G_GRID->LIST_PROCESSING_EVENTS

EXPORTING

I_EVENT_NAME = 'TOP_OF_PAGE'

I_DYNDOC_ID = DG_DYNDOC_ID.

"end }

  • Set editable cells to ready for input initially

CALL METHOD G_GRID->SET_READY_FOR_INPUT

EXPORTING

I_READY_FOR_INPUT = 1.

ENDFORM. "CREATE_AND_INIT_ALV

&----


*& Form EXCLUDE_TB_FUNCTIONS

&----


  • text

----


  • -->PT_EXCLUDE text

----


FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.

  • Only allow to change data not to create new entries (exclude

  • generic 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.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.

APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM. " EXCLUDE_TB_FUNCTIONS

&----


*& Form build_fieldcat

&----


  • Fieldcatalog

----


FORM BUILD_FIELDCAT .

DATA: L_POS TYPE I.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Check'.

X_FIELDCAT-FIELDNAME = 'CHECK'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-CHECKbox = 'X'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-OUTPUTLEN = '1'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).

X_FIELDCAT-FIELDNAME = 'VBELN'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-NO_ZERO = 'X'.

X_FIELDCAT-OUTPUTLEN = '10'.

X_FIELDCAT-HOTSPOT = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Item'(025).

X_FIELDCAT-FIELDNAME = 'POSNR'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-OUTPUTLEN = '5'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_POS = L_POS + 1.

X_FIELDCAT-SCRTEXT_M = 'Drop'(025).

X_FIELDCAT-FIELDNAME = 'DROP'.

X_FIELDCAT-TABNAME = 'IT_FINAL'.

X_FIELDCAT-COL_POS = L_POS.

X_FIELDCAT-OUTPUTLEN = '5'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-DRDN_HNDL = '1'.

X_FIELDCAT-DRDN_ALIAS = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

ENDFORM. " build_fieldcat

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'MAIN100'.

IF G_CUSTOM_CONTAINER IS INITIAL.

**Initializing the grid and calling the fm to Display the O/P

PERFORM CREATE_AND_INIT_ALV.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form SET_DRDN_TABLE

&----


  • text

----


FORM SET_DRDN_TABLE.

DATA:LT_DRAL TYPE LVC_T_DRAL,

LS_DRAL TYPE LVC_S_DRAL.

LOOP AT ITAB .

  • First listbox (handle '1').

IF SY-INDEX = 1.

LS_DRAL-HANDLE = '1'.

LS_DRAL-VALUE = ' '.

LS_DRAL-INT_VALUE = ' '.

ELSE.

LS_DRAL-HANDLE = '1'.

LS_DRAL-VALUE = ITAB-POSNR.

LS_DRAL-INT_VALUE = ITAB-POSNR.

ENDIF.

APPEND LS_DRAL TO LT_DRAL.

ENDLOOP.

**Setting the Drop down table for Reason Code

CALL METHOD G_GRID->SET_DROP_DOWN_TABLE

EXPORTING

IT_DROP_DOWN_ALIAS = LT_DRAL.

ENDFORM. " set_drdn_table

&----


*& Form EVENT_TOP_OF_PAGE

&----


  • text

----


  • -->DG_DYNDOC_ID text

----


FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.

"this is more clear.....check it

"first add text, then pass it to comentry write fm

DATA : DL_TEXT(255) TYPE C. "Text

  • Populating header to top-of-page

CALL METHOD DG_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = 'Test Report'

SAP_STYLE = CL_DD_AREA=>HEADING.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move program ID

CONCATENATE 'Program Name :' SY-REPID

INTO DL_TEXT SEPARATED BY SPACE.

  • Add Program Name to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move User ID

CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE

.

  • Add User ID to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move count (no of records).

move v_lines to v_line.

CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.

  • Add Client to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move date

WRITE SY-DATUM TO DL_TEXT.

CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.

  • Add Date to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

  • Move time

WRITE SY-UZEIT TO DL_TEXT.

CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.

  • Add Time to Document

PERFORM ADD_TEXT USING DL_TEXT.

  • Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

  • Populating data to html control

PERFORM HTML.

ENDFORM. " EVENT_TOP_OF_PAGE

&----


*& Form ADD_TEXT

&----


  • To add Text

----


FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.

  • Adding text

CALL METHOD DG_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = P_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING.

ENDFORM. " ADD_TEXT

&----


*& Form HTML

&----


  • text

----


FORM HTML.

DATA : DL_LENGTH TYPE I, " Length

DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id

  • Creating html control

IF DG_HTML_CNTRL IS INITIAL.

CREATE OBJECT DG_HTML_CNTRL

EXPORTING

PARENT = DG_PARENT_HTML.

ENDIF.

  • Reuse_alv_grid_commentary_set

CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'

EXPORTING

DOCUMENT = DG_DYNDOC_ID

BOTTOM = SPACE

IMPORTING

LENGTH = DL_LENGTH.

  • Get TOP->HTML_TABLE ready

CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.

  • Set wallpaper

CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND

EXPORTING

PICTURE_ID = DL_BACKGROUND_ID.

  • Connect TOP document to HTML-Control

DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.

  • Display TOP document

CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT

EXPORTING

REUSE_CONTROL = 'X'

PARENT = DG_PARENT_HTML

EXCEPTIONS

HTML_DISPLAY_ERROR = 1.

IF SY-SUBRC NE 0.

MESSAGE I999 WITH 'Error in displaying top-of-page'(036).

ENDIF.

ENDFORM. " HTML

Regards

Vasu

Former Member
0 Kudos
285

Very useful in the ALV OO

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/tabstrip%20in%20alv(OOPS)&focusedComment...

check the below links lot of info and examples r there for OOPS

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

😎 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

regards,

Prabhu

reward if it is helpful