Vertical Tab Control in SAP

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

SDN Contribution

Vertical Tab Control in SAP


Applies to: SAP ABAP

Summary
This program uses the vertical tab control class CL_GUI_CONTAINER_BAR. This control can be used to
display data in vertical tabs.

Author(s): Ravi Shankar Rajan

Company: GMI

Created on: 24th August 2006

Author Bio
Ravi Shankar Rajan is a senior development analyst in GMI.

2006 SAP AG

2006 SAP AG

PF STATUS

TITLEBAR

Screen 100
Flow logic
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0100.

2006 SAP AG

2006 SAP AG

Input/Output field attributes

2006 SAP AG

Button Attributes

2006 SAP AG

REPORT zdrawer.
TABLES:
trdir.
INCLUDE <icon>.
DATA: cc_drawer

TYPE REF TO cl_gui_docking_container,

c_drawer

TYPE REF TO cl_gui_container_bar,

c_container

TYPE REF TO cl_gui_container,

l_caption

TYPE sbptcaptn,

lt_captions

TYPE sbptcaptns,

l_icon

TYPE swd_icon,

lt_icons

TYPE swd_icons,

ok_code

TYPE sy-ucomm,

id

TYPE i,

repid

TYPE sy-repid,

dynnr

TYPE sy-dynnr.

* Display data

TYPES: BEGIN OF ty_data ,


name

LIKE trdir-name,

cnam

LIKE trdir-cnam,

cdat

LIKE trdir-cdat,

END OF ty_data.
DATA : g_alv_sd TYPE REF TO cl_gui_alv_grid,
g_alv_mm TYPE REF TO cl_gui_alv_grid,
g_alv_pp TYPE REF TO cl_gui_alv_grid,
g_alv_fi TYPE REF TO cl_gui_alv_grid,
g_alv_all TYPE REF TO cl_gui_alv_grid,
gs_data TYPE ty_data,
gt_data TYPE STANDARD TABLE OF ty_data.

CLASS lcl_application DEFINITION DEFERRED.


CLASS cl_gui_cfw DEFINITION LOAD.
DATA:
c_application TYPE REF TO lcl_application,
c_alv TYPE REF TO lcl_application.

*---------------------------------------------------------------------*

2006 SAP AG

CLASS lcl_application DEFINITION

*---------------------------------------------------------------------*
*

........

*---------------------------------------------------------------------*
CLASS lcl_application DEFINITION.

PUBLIC SECTION.
METHODS:
on_click FOR EVENT clicked OF cl_gui_container_bar
IMPORTING
id
container,
on_hotspot_click FOR EVENT
hotspot_click OF cl_gui_alv_grid IMPORTING
e_row_id e_column_id.

ENDCLASS.

"lcl_application DEFINITION

*---------------------------------------------------------------------*
*

CLASS lcl_application IMPLEMENTATION

*---------------------------------------------------------------------*
*

........

*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.

METHOD on_click.
DATA: l_fcode
l_link

TYPE ui_func,
TYPE swd_htmlco,

l_quickinfo TYPE iconquick.


DATA:
lx_variant

TYPE

disvariant,

lt_alv_cat

TYPE

lvc_t_fcat,

lx_alv_cat

TYPE

lvc_s_fcat,

lx_alv_lay

TYPE

lvc_s_layo.

DEFINE m_fieldcat.
add 1 to lx_alv_cat-col_pos.
lx_alv_cat-fieldname = &1.
2006 SAP AG

case lx_alv_cat-fieldname.
when 'NAME'.
lx_alv_cat-key

= 'X'.

lx_alv_cat-hotspot

= 'X'.

lx_alv_cat-scrtext_m

= 'Program Name'.

lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
when 'CNAM'.
lx_alv_cat-key

= ''.

lx_alv_cat-hotspot

= ''.

lx_alv_cat-scrtext_m

= 'Created By'.

lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
when 'CDAT'.
lx_alv_cat-key

= ''.

lx_alv_cat-hotspot

= ''.

lx_alv_cat-scrtext_m

= 'Created On'.

lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
endcase.
lx_alv_cat-ref_field = &2.
lx_alv_cat-ref_table = &3.
append lx_alv_cat to lt_alv_cat.
END-OF-DEFINITION.

CASE id.
WHEN 1.
FREE : g_alv_sd.
IF g_alv_sd IS INITIAL.
CREATE OBJECT g_alv_sd
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZSD%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
2006 SAP AG

m_fieldcat 'NAME' 'NAME' 'TRDIR'.


m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Sales and Distribution Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.

*Display
CALL METHOD g_alv_sd->set_table_for_first_display
EXPORTING
*

I_BUFFER_ACTIVE

I_BYPASSING_BUFFER

I_CONSISTENCY_CHECK

I_STRUCTURE_NAME

is_variant

= lx_variant

I_SAVE

I_DEFAULT

= 'X'

is_layout

= lx_alv_lay

IS_PRINT

IT_SPECIAL_GROUPS

IT_TOOLBAR_EXCLUDING

IT_HYPERLINK

IT_ALV_GRAPHICS

IT_EXCEPT_QINFO

CHANGING
it_outtab

gt_data

it_fieldcatalog

lt_alv_cat

IT_SORT

IT_FILTER

EXCEPTIONS
invalid_parameter_combination = 1
program_error

= 2

too_many_lines

= 3

OTHERS

= 4
2006 SAP AG

10

.
IF

c_alv IS INITIAL.

CREATE OBJECT c_alv.


ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_sd.

ENDIF.
WHEN 2.
FREE : g_alv_mm.
IF g_alv_mm IS INITIAL.
CREATE OBJECT g_alv_mm
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZMM%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Material Management Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.

*Display
CALL METHOD g_alv_mm->set_table_for_first_display
EXPORTING
*

I_BUFFER_ACTIVE

I_BYPASSING_BUFFER

I_CONSISTENCY_CHECK

I_STRUCTURE_NAME

is_variant

= lx_variant
2006 SAP AG

11

I_SAVE

I_DEFAULT

= 'X'

is_layout

= lx_alv_lay

IS_PRINT

IT_SPECIAL_GROUPS

IT_TOOLBAR_EXCLUDING

IT_HYPERLINK

IT_ALV_GRAPHICS

IT_EXCEPT_QINFO

CHANGING
it_outtab

gt_data

it_fieldcatalog

lt_alv_cat

IT_SORT

IT_FILTER

EXCEPTIONS
invalid_parameter_combination = 1
program_error

= 2

too_many_lines

= 3

OTHERS

= 4

.
IF

c_alv IS INITIAL.

CREATE OBJECT c_alv.


ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_mm.

ENDIF.

WHEN 3.
FREE : g_alv_pp.
IF g_alv_pp IS INITIAL.
CREATE OBJECT g_alv_pp
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZPP%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
2006 SAP AG

12

m_fieldcat 'NAME' 'NAME' 'TRDIR'.


m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Production Planning Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.

*Display
CALL METHOD g_alv_pp->set_table_for_first_display
EXPORTING
*

I_BUFFER_ACTIVE

I_BYPASSING_BUFFER

I_CONSISTENCY_CHECK

I_STRUCTURE_NAME

is_variant

= lx_variant

I_SAVE

I_DEFAULT

= 'X'

is_layout

= lx_alv_lay

IS_PRINT

IT_SPECIAL_GROUPS

IT_TOOLBAR_EXCLUDING

IT_HYPERLINK

IT_ALV_GRAPHICS

IT_EXCEPT_QINFO

CHANGING
it_outtab

gt_data

it_fieldcatalog

lt_alv_cat

IT_SORT

IT_FILTER

EXCEPTIONS
invalid_parameter_combination = 1
program_error

= 2

too_many_lines

= 3

OTHERS

= 4
2006 SAP AG

13

.
IF

c_alv IS INITIAL.

CREATE OBJECT c_alv.


ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_pp.

ENDIF.
WHEN 4.
FREE : g_alv_fi.
IF g_alv_fi IS INITIAL.
CREATE OBJECT g_alv_fi
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZFI%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Finance and Controlling Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.

*Display
CALL METHOD g_alv_fi->set_table_for_first_display
EXPORTING
*

I_BUFFER_ACTIVE

I_BYPASSING_BUFFER

I_CONSISTENCY_CHECK

I_STRUCTURE_NAME

is_variant

= lx_variant
2006 SAP AG

14

I_SAVE

I_DEFAULT

= 'X'

is_layout

= lx_alv_lay

IS_PRINT

IT_SPECIAL_GROUPS

IT_TOOLBAR_EXCLUDING

IT_HYPERLINK

IT_ALV_GRAPHICS

IT_EXCEPT_QINFO

CHANGING
it_outtab

gt_data

it_fieldcatalog

lt_alv_cat

IT_SORT

IT_FILTER

EXCEPTIONS
invalid_parameter_combination = 1
program_error

= 2

too_many_lines

= 3

OTHERS

= 4

.
IF

c_alv IS INITIAL.

CREATE OBJECT c_alv.


ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_fi.
ENDIF.
WHEN 5.
FREE : g_alv_all.
IF g_alv_all IS INITIAL.
CREATE OBJECT g_alv_all
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'Z%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
2006 SAP AG

15

m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.


*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'All custom Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.

*Display
CALL METHOD g_alv_all->set_table_for_first_display
EXPORTING
*

I_BUFFER_ACTIVE

I_BYPASSING_BUFFER

I_CONSISTENCY_CHECK

I_STRUCTURE_NAME

is_variant

= lx_variant

I_SAVE

I_DEFAULT

= 'X'

is_layout

= lx_alv_lay

IS_PRINT

IT_SPECIAL_GROUPS

IT_TOOLBAR_EXCLUDING

IT_HYPERLINK

IT_ALV_GRAPHICS

IT_EXCEPT_QINFO

CHANGING
it_outtab

gt_data

it_fieldcatalog

lt_alv_cat

IT_SORT

IT_FILTER

EXCEPTIONS
invalid_parameter_combination = 1
program_error

= 2

too_many_lines

= 3

OTHERS

= 4

.
IF

c_alv IS INITIAL.
2006 SAP AG

16

CREATE OBJECT c_alv.


ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_all.
ENDIF.
ENDCASE.

ENDMETHOD.

"on_click

METHOD on_hotspot_click.
DATA:
lx_selected_row TYPE lvc_s_row,
ls_data TYPE ty_data.
CLEAR lx_selected_row.
MOVE-CORRESPONDING e_row_id TO lx_selected_row.
READ TABLE gt_data INTO ls_data INDEX lx_selected_row-index.
SET PARAMETER ID 'RID' FIELD ls_data-name.
CALL TRANSACTION 'SE38' AND SKIP FIRST SCREEN.
ENDMETHOD.

"on_hotspot_click

ENDCLASS.

"lcl_application IMPLEMENTATION

*DATA: c_application TYPE REF TO lcl_application.

START-OF-SELECTION.
CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&

Module

STATUS_0100

OUTPUT

*&---------------------------------------------------------------------*
*

text

*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR

'100'.

repid = sy-repid.
dynnr = sy-dynnr.

*Test the function

* create container for drawer


2006 SAP AG

17

IF cc_drawer IS INITIAL.
CREATE OBJECT cc_drawer
EXPORTING
repid

= repid

dynnr

= dynnr

extension = 500.
ENDIF.
* create drawer
IF c_drawer IS INITIAL.
l_caption-caption = 'Sales and Distribution Reports'(004)."text-004.
l_caption-icon

= icon_wizard.

APPEND l_caption TO lt_captions.


l_caption-caption = 'Material Management Reports'(005). "text-005.
l_caption-icon

= space.

APPEND l_caption TO lt_captions.


l_caption-caption = 'Production Planning Reports'(006). "text-006.
l_caption-icon

= icon_display_text.

APPEND l_caption TO lt_captions.


l_caption-caption = 'Finance and Controlling Reports'(007)."text-007.
l_caption-icon

= icon_display_text.

APPEND l_caption TO lt_captions.


l_caption-caption = 'All custom Reports'(008).
l_caption-icon

"text-008.

= icon_display_text.

APPEND l_caption TO lt_captions.

CREATE OBJECT c_drawer


EXPORTING
parent

= cc_drawer

captions

= lt_captions

EXCEPTIONS
max_number_of_cells_exceeded = 1
OTHERS

= 2.

IF sy-subrc <> 0.
SET SCREEN 0. LEAVE SCREEN.
ENDIF.
IF

c_application IS INITIAL.

CREATE OBJECT c_application.


ENDIF.
SET HANDLER c_application->on_click FOR c_drawer.
2006 SAP AG

18

CALL METHOD c_drawer->set_active


EXPORTING
id = 2.

ENDIF.

ENDMODULE.

" STATUS_0100

OUTPUT

*&---------------------------------------------------------------------*
*&

Module

USER_COMMAND_0100

INPUT

*&---------------------------------------------------------------------*
*

text

*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF ok_code = 'EX'.
CALL METHOD c_drawer->free.
CALL METHOD cc_drawer->free.
SET SCREEN 0. LEAVE SCREEN.
ELSEIF ok_code = 'HI'.
CALL METHOD c_drawer->set_active
EXPORTING
id = id.
ELSEIF ok_code = 'ENTE'.
CALL METHOD c_drawer->set_active
EXPORTING
id = id.
ENDIF.
ENDMODULE.

" USER_COMMAND_0100

INPUT

2006 SAP AG

19

Copyright
Copyright 2006 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries,
zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are
trademarks or registered trademarks of IBM Corporation.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by
Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their
respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All
other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves
informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.
These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied
warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may
result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these
materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and
does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.
Any software coding and/or code lines/strings (Code) included in this documentation are only examples and are not intended to be
used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of
certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors
or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.

2006 SAP AG

20

You might also like