SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Top of Page in ALV(OOPS)



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Sep 08, 2007 12:02 am    Post subject: Top of Page in ALV(OOPS) Reply with quote

Author: J.Jayanthi

Description:

This document describes how to
display picture in top-of-page
display url in top-of-page
display text in top-of-page
in ALV using OOPS method.

This document uses Splitter concept to split the container and then displays top-of-page in top container and output in bottom container by placing the grid inside the container.

Procedure
Step 1: Create a Docking container. Then create a splitter by taking the docking container as parent.

Data : o_docking type ref to cl_gui_docking_container,"Docking Container
o_split type ref to cl_gui_easy_splitter_container."Splitter
CREATE OBJECT o_docking
EXPORTING
RATIO = '95'.
IF sy-subrc eq 0.
* Splitting the Docking container
CREATE OBJECT o_split
EXPORTING
PARENT = o_docking
sash_position = 14 "Position of Splitter Bar (in Percent)
with_border = 0. "With Border = 1 Without Border = 0
ENDIF.
Step 2: Make the two containers so that one will be placed in top of split and the other in bottom. Create the grid so that it should be inside the bottom container. Create a object for class cl_dd_document so that text, url and images can be placed inside top of page.
Data : o_top_container type ref to cl_gui_container, "Top Container
o_bottom_container type ref to cl_gui_container,"Bottom Container
o_document type ref to cl_dd_document. "Document
* Placing the containers in the splitter
o_top_container = o_split->top_left_container .
o_bottom_container = o_split->bottom_right_container .
* Creating Grid
CREATE OBJECT o_grid
EXPORTING
i_parent = o_bottom_container.
* Creating the document
CREATE OBJECT o_document
EXPORTING
style = 'ALV_GRID'.

Step 3: Add the text, url and images by using o_document.

* Calling the methods for dynamic text
CALL METHOD o_document->add_text
EXPORTING
text = 'No. of Materials:'.
* Adding GAP
CALL METHOD o_document->add_gap
EXPORTING
width = 10.
* Adding Text
CALL METHOD o_document->add_text
EXPORTING
text = v_cln."V_cln is the variable holding no. of materials
* Adding Line
CALL METHOD o_document->new_line.
To add picture to the top of page, we need to find the picture id. We can find this by using tcode OAOR. Give Class name as PICTURES and Class TYPE as OT in selection.



Choose some picture inside that and in bottom click Details tab to get the ID.

* Adding Picture
CALL METHOD o_document->add_picture
EXPORTING
picture_id = 'TRVPICTURE01'
width = '100'.
* Adding Line
CALL METHOD o_document->new_line.
* Adding Links
CALL METHOD o_document->add_link
EXPORTING
name = 'OOPS Link'
url =
'https://forums.sdn.sap.com/forum.jspa?forumID=236'
tooltip = 'ABAP Objects Forum'
text = 'ABAP Objects Forum'.
* Display the data
CALL METHOD o_document->display_document
EXPORTING
parent = o_top_container.
* Calling the method of ALV to process top of page
CALL METHOD o_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_document.


Complete Code
Screen 9000, GUI Status ZSTATUS and GUI Title ZTITLE should be created and in Flow logic of the screen, PBO and PAI should be uncommented.
Code:
* Data Declaration
data : itab type standard table of MARA,"Output Internal table
       i_fieldcat type standard table of lvc_s_fcat,"Field catalog
       wa type MARA,
       w_variant type disvariant,
       o_docking type ref to cl_gui_docking_container,"Docking Container
       o_grid type ref to cl_gui_alv_grid,"Grid
       o_split type ref to cl_gui_easy_splitter_container,"Splitter
       o_top_container type ref to cl_gui_container,   "Top Container
       o_bottom_container type ref to cl_gui_container,"Bottom Container
       o_document type ref to cl_dd_document,          "Document
* Variable Declaration
       v_ln TYPE i,             "No. of lines
       v_cln(255) TYPE c.       "No. of lines
select * from mara into corresponding fields of table itab up to 10 rows.
* Finding no. of lines to display in top-of-page
  DESCRIBE TABLE itab LINES v_ln.
  MOVE v_ln TO v_cln.
call screen 9000.
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_9000 output.
if o_docking is initial.
  SET PF-STATUS 'ZSTATUS'. "GUI Status
  SET TITLEBAR 'ZTITLE'.   "Title
* Creating Objects
  perform create_objects.
* Filling top of page
  perform fill_top_of_page.
* Filling the fieldcatalog table
  perform build_fieldcat.
* Displaying the output
  perform display_output.
endif.
endmodule.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       PAI
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
data lv_ucomm type sy-ucomm.
lv_ucomm = sy-ucomm.
  CASE lv_ucomm.
    WHEN 'CANCEl' OR 'EXIT'.
      perform free_objects.
      LEAVE PROGRAM.
    when 'BACK'.
      perform free_objects.
     set screen '0'.
     leave screen.
  ENDCASE.
endmodule.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Form  create_objects
*&---------------------------------------------------------------------*
*       Creating Container,Splitter and Grid
*----------------------------------------------------------------------*
form create_objects .
* Creating Docking Container
  CREATE OBJECT o_docking
         EXPORTING
           RATIO                       = '95'.
  IF sy-subrc eq 0.
* Splitting the Docking container
    CREATE OBJECT o_split
      EXPORTING
       PARENT            = o_docking
       sash_position     = 20 "Position of Splitter Bar (in Percent)
       with_border       = 0. "With Border = 1 Without Border = 0
*   Placing the containers in the splitter
    o_top_container = o_split->top_left_container .
    o_bottom_container = o_split->bottom_right_container .
*   Creating Grid
    CREATE OBJECT o_grid
      EXPORTING
        i_parent          =  o_bottom_container.
*   Creating the document
    CREATE OBJECT o_document
    EXPORTING
        style  = 'ALV_GRID'.
  ENDIF.
endform.                    " create_objects
*&---------------------------------------------------------------------*
*&      Form  fill_top_of_page
*&---------------------------------------------------------------------*
*       Filling the top of page
*----------------------------------------------------------------------*
form fill_top_of_page .
* Calling the methods for dynamic text
  CALL METHOD o_document->add_text
    EXPORTING
      text          = 'No. of Materials:'.
* Adding GAP
  CALL METHOD o_document->add_gap
    EXPORTING
      width      = 10.
* Adding Text
  CALL METHOD o_document->add_text
    EXPORTING
      text          = v_cln.
* Adding Line
  CALL METHOD o_document->new_line.
* Adding Picture
  CALL METHOD o_document->add_picture
    EXPORTING
      picture_id       = 'TRVPICTURE01'
      width            =  '100'.
* Adding Line
  CALL METHOD o_document->new_line.
* Adding Links
  CALL METHOD o_document->add_link
    EXPORTING
      name                   = 'OOPS Link'
      url                    =
      'https://forums.sdn.sap.com/forum.jspa?forumID=236'
      tooltip                = 'ABAP Objects Forum'
      text                   = 'ABAP Objects Forum'.
* Display the data
  CALL METHOD o_document->display_document
    EXPORTING
       parent             = o_top_container.
* Calling the method of ALV to process top of page
  CALL METHOD o_grid->list_processing_events
    EXPORTING
      i_event_name      = 'TOP_OF_PAGE'
      i_dyndoc_id       = o_document.
endform.                    " fill_top_of_page
*&---------------------------------------------------------------------*
*&      Form  build_fieldcat
*&---------------------------------------------------------------------*
*       Creating Field catalog
*----------------------------------------------------------------------*
form build_fieldcat .
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
       I_STRUCTURE_NAME             = 'MARA'
    CHANGING
       ct_fieldcat                  =  i_fieldcat
    EXCEPTIONS
          INCONSISTENT_INTERFACE       = 1
          PROGRAM_ERROR                = 2
          OTHERS                       = 3.
endform.                    " build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  display_output
*&---------------------------------------------------------------------*
*       Displaying the Output
*----------------------------------------------------------------------*
form display_output .
  w_variant-report = sy-repid.
   CALL METHOD o_grid->set_table_for_first_display
     EXPORTING
        IS_VARIANT                    = w_variant
        I_SAVE                        = 'A'
     CHANGING
        it_outtab                     = itab
        IT_FIELDCATALOG               = i_fieldcat
         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.
endform.                    " display_output
*&---------------------------------------------------------------------*
*&      Form  free_objects
*&---------------------------------------------------------------------*
*       Free Objects
*----------------------------------------------------------------------*
form free_objects .
CALL METHOD o_grid->free
  EXCEPTIONS
    CNTL_ERROR        = 1
    CNTL_SYSTEM_ERROR = 2
    others            = 3.
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD o_top_container->free
  EXCEPTIONS
    CNTL_ERROR        = 1
    CNTL_SYSTEM_ERROR = 2
    others            = 3.
CALL METHOD o_bottom_container->free
  EXCEPTIONS
    CNTL_ERROR        = 1
    CNTL_SYSTEM_ERROR = 2
    others            = 3.
CALL METHOD o_docking->free
  EXCEPTIONS
    CNTL_ERROR        = 1
    CNTL_SYSTEM_ERROR = 2
    others            = 3.
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.                    " free_objects
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.