04-04-2006 10:01 PM - last edited on 02-04-2024 6:27 AM by postmig_api_4
Hi ,
Can anyone please help me out with OOPS concepts in alv.If any one of u have any kind of material for OOPS in alv please share it with me.what are the advantanges of using OO in alv when we have the normal FMs to serve the purpose.i am new to this OOPS concept in alv.please help me out
regards
sandeep
04-04-2006 10:05 PM
hi,
check these programs
BCALV_GRID_01
BCALV_GRID_02
BCALV_GRID_03
BCALV_GRID_04
BCALV_GRID_05
BCALV_GRID_06
BCALV_GRID_07
BCALV_GRID_08
BCALV_GRID_09
BCALV_GRID_10
BCALV_GRID_11
Regards,
Vara
04-04-2006 10:05 PM
hi,
check these programs
BCALV_GRID_01
BCALV_GRID_02
BCALV_GRID_03
BCALV_GRID_04
BCALV_GRID_05
BCALV_GRID_06
BCALV_GRID_07
BCALV_GRID_08
BCALV_GRID_09
BCALV_GRID_10
BCALV_GRID_11
Regards,
Vara
04-04-2006 10:07 PM
hey sandeep
refer these links
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
http://www.sapgenie.com/abap/controls/alvgrid.htm
I found few information in print files above. You can try:
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIDOCK/BCCIDOCK.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIGOF/BCCIGOF.pdf
http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm
Check this link.You will get idea about OOPS concept.
http://www.henrikfrank.dk/abapuk.html
<b><REMOVED BY MODERATOR></b>
Regards
naveen
Message was edited by:
Alvaro Tejada Galindo
04-05-2006 7:20 AM
Hi Sandeep,
to know more on OO ALV here is a link
http://help.sap.com/saphelp_webas630/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm
and here is a sample code to implement ALV using OO.
report zooalv.
CLASS Lcl_application DEFINITION DEFERRED.
data : g_alv type ref to cl_gui_alv_grid,
gref_docking_container TYPE REF TO cl_gui_custom_container,
gs_layout TYPE lvc_s_layo.
data :event_receiver TYPE REF TO lcl_application,
gt_fieldcat type lvc_t_fcat,
gs_fieldcat type lvc_s_fcat.
DATA:gt_outtab type table of <table>.
data : gs_outtab like line of gt_outtab.
call screen 100.
************************************************************************
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_application DEFINITION
CLASS lcl_application IMPLEMENTATION.
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
* append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
* append an icon to show booking table
CLEAR ls_toolbar.
MOVE 'ADD' TO ls_toolbar-function.
MOVE icon_insert_row TO ls_toolbar-icon.
MOVE 'test add button'(111) TO ls_toolbar-quickinfo.
MOVE space TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'ADD'.
gs_outtab-subproject = SPACE.
gs_outtab-packid = space.
gs_outtab-phase = space.
append gs_outtab to gt_outtab.
CALL METHOD g_alv->refresh_table_display
.
ENDCASE.
ENDMETHOD. "handle_user_command
endclass.
************************************************************************
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STAT'.
* SET TITLEBAR 'xxx'.
create object gref_docking_container
exporting
container_name = 'CCAREA_ALV'.
create object g_alv
exporting i_parent = GREF_DOCKING_CONTAINER.
select * from <table> into table GT_OUTTAB.
gs_fieldcat-fieldname = 'F1'.
gs_fieldcat-ref_table = 'table'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-key = 'X'.
append gs_fieldcat to gt_fieldcat.
gs_fieldcat-fieldname = 'f2'.
gs_fieldcat-ref_table = 'table'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-key = 'X'.
append gs_fieldcat to gt_fieldcat.
gs_fieldcat-fieldname = 'F3'.
gs_fieldcat-ref_table = 'table'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-key = 'X'.
append gs_fieldcat to gt_fieldcat.
gs_layout-grid_title = 'TEST'.
call method g_ALV->set_table_for_first_display
exporting
is_layout = gs_layout
changing
it_fieldcatalog = gt_fieldcat
* it_sort = gt_sort
it_outtab = gt_outtab[].
*** addition button on alv
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR g_alv.
SET HANDLER event_receiver->handle_toolbar FOR g_alv.
call method g_alv->register_edit_event exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
* Call method 'set_toolbar_interactive' to raise event TOOLBAR.
CALL METHOD g_alv->set_toolbar_interactive.
ENDMODULE. " STATUS_0100 OUTPUT
you can research further on class <i>cl_gui_alv_grid</i>to find more about OO ALV.
hope you find this helpful.
regards,
Kinshuk Saxena
PS reward points if you find the answer helpful
04-05-2006 7:58 AM
Hi Sandeep,
ALV can be programmed using OO techniques, by making use of container concepts. In the screen, there is a icon for custom container.Just give name to that(say CONTAINER).
In Main program , do the following steps
1) Create two reference variables like this
DATA: con type ref to CL_GUI_CUSTOM_CONTAINER,
grid type ref to CL_GUI_ALV_GRID.
2) In PBO, do the following steps
if con is initial.
creating an instance of the container.
create object con exporting CONTAINER_NAME = 'CONTAINER'.
creating an instance of the grid.
create object grid exporting PARENT = con.
call this function to display the contents in ALV.
call method grid->set_table_for_first_display
exporting I_STRUCTURE_NAME = 'sflight'
changing it_outtab = itab[].
else.
call method grid->refresh_table_display.
endif.
Here itab is an internal table with defintion like this.
data: begin of itab occurs 0.
include structure sflight.
data: end of itab.
If you want some programs , just type BCALV* in SE38 and you will get them.
If you want some documents related to OO ALV, I can send it to your mail id.
Regards,
Sylendra.
04-05-2006 8:01 AM
Hi
Check the program series BCALV_GRID_01,02....etc.
There are lots of resources available on SDN regarding ABAP Objects and OO ALV.I too have a document with me for that.Give ur mail id.i shall forward it to you..
Cheers,
Abdul Hakim
04-05-2006 2:55 PM
hi Sylendra and Abdul
thanks for ur response
my mail id is <b><REMOVED BY MODERATOR></b>
regards
sandeep
Message was edited by:
Alvaro Tejada Galindo
04-05-2006 3:06 PM
Hi,
Check this code..
REPORT ZTEST1234_ALV_TOP 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.
"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.
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'.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
ENDMETHOD. "handle_double_click
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.
*- 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.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(10),
END OF ITAB.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
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.
"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->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 = '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 Client
CONCATENATE 'Client :' SY-MANDT 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
vijay
05-15-2006 12:57 PM
ALV with class CL_SALV_TABLE.
It's very short and convenient:
REPORT ytest_table.
Tabelle zum Anzeigen
DATA: gt_outtab TYPE TABLE OF sflight.
Referenzen auf Klassen
DATA: gr_table TYPE REF TO cl_salv_table,
gr_func TYPE REF TO cl_salv_functions_list,
gr_lay type ref to CL_SALV_LAYOUT,
wa_lay_key type salv_S_layout_key,
gr_col type ref to cl_salv_columns,
gr_display type ref to CL_SALV_DISPLAY_SETTINGS.
Select
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_outtab.
perform alv_anzeigen using gt_outtab.
*&----
*
*& Form alv_anzeigen
*&----
*
form alv_anzeigen using p_gt_outtab.
ALV Objekt erzeugen
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_outtab.
Objekt mit den Funktionen holen
gr_func = gr_table->get_functions( ).
Alle Funktionen setzen
gr_func->set_all( ).
gr_func->set_view_lotus( ' ' ).
gr_func->set_export_xml( abap_true ).
Layout holen zum Speichern
gr_lay = Gr_table->get_layout( ).
Layoutkey befüllen
wa_lay_key-report = sy-repid.
und setzen
gr_lay->set_key( wa_lay_key ).
gr_lay->SET_SAVE_RESTRICTION( 1 ). " Layout userspezifisch & alle erlaubt
gr_lay->set_default( 'X' ). " Default Layout erlaubt
Spaltenbreite optimieren
gr_col = gr_Table->get_columns( ).
gr_col->set_optimize( 'X' ).
Zebra über Display Settings setzen
gr_display = gr_table->get_display_settings( ).
gr_display->SET_STRIPED_PATTERN( 'X' ).
ALV anzeigen
gr_table->display( ).
regrads
Markus
05-15-2006 1:07 PM
Hi,
GO to SE80, and choose package and give 'SLIS' as package name. You will get all the example programs provided by SAP.