8/3/2017
TabStrip in ALV(OOPS) - Code Gallery - SCN Wiki Getting Started
Community WIKI
SAP Community
Welcome, Guest
Login
Register
Store
Search the Community
Code Gallery
TabStrip in ALV(OOPS) Created by Jayanthi Jayaraman, last modified by Yael Dayan on Oct 31, 2011
Author: Jayanthi Author: Jayanthi Jayaraman Submitted: 17.07.2007 Submitted: 17.07.2007 Related Links: Creating a OOPS ALV Report Coloring a Row and Column in ALV (OOPS) (OOPS) ABAP-Changing Cell characteristics in ALV ALV (OOPS) ALV-Editing ALV -Editing and saving the edited values in Database(OOPS) Top of Page in ALV(OOPS) Toolbar and User command in ALV(OOPS) Description Step1: Create a Program in SE38 [say zzz_jaytest]. Then create a screen (say 9000).Design the attributes by giving short description and choosing Normal radio button. Design the Layout of the screen as below. Drag and drop the tabstrip control control in the layout. Then Drag and drop subscreen area inside it.
Properties of subscreen area:
Properties of Tabstrip: Tabstrip: Inside that for each tab, make sure that fun ction code and ref. field are updated. Here in this, function code(MAIN_TAB_TAB1) code(MAIN_TAB_TAB1) and Ref. field (MAIN_TAB_TAB1_REF1) (MAIN_TAB_TAB1_REF1) as subscreen area for first tab MATERIAL. For the other tab DESCRIPTION, function code MAIN_TAB_TAB MAIN_TAB_TAB2 2 and Ref. field MAIN_TAB_TAB1_REF1. MAIN_TAB_TAB1_REF1. Then create two screens 9100 and 9200 by mentioning subscreen as screen type. Step2: In the flowlogic of screen 9000, write as follows PROCESS BEFORE OUTPUT. OUTPUT. MODULE STATUS_9000. CALL SUBSCREEN MAIN_TAB_TAB1_REF1 INCLUDING i_main_tab-prog i_main_tab-subscreen. * PROCESS AFTER INPUT. MODULE USER_COMMAND_9000. MODULE main_tab_active_tab_get. Here we are calling the corresponding subscreen by making use of call subscreen command in PBO when tab is pressed.
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=38772
1/5
8/3/2017
TabStrip in ALV(OOPS) - Code Gallery - SCN Wiki
MODULE main_tab_active_tab_get is used to track the tab pressed in the screen. MODULE USER_COMMAND_9000 is used for GUI status commands BACK,CANCEL and EXIT. MODULE STATUS_9000 is used to make the action accordingly to the tab pre ssed. Step3: Drag and drop a custom container in screens 9100 and 9200 and name it as CC_9100 and CC_9200 respectively.There is nothing to be done in the flow logic of the screens. Step 4: Create GUI_Status 'ZSTATUS' with BACK, CANCEL and EXIT buttons.
Code REPORT ZZZ_JAYTEST NO STANDARD PAGE HEADING MESSAGE-ID zz. * Tables Declaration TABLES : mara, makt. * Internal table declaration DATA : i_mara TYPE STANDARD TABLE OF mara,"For first tab i_makt TYPE STANDARD TABLE OF makt,"For second tab i_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,"Fieldcatalog * Work area declaration w_mara TYPE mara, w_makt TYPE makt, w_variant TYPE disvariant, * Objects o_custom TYPE REF TO cl_gui_custom_container,"Docking Container o_grid TYPE REF TO cl_gui_alv_grid."Grid * Constants for the function code of Tabs CONSTANTS: BEGIN OF c_main_tab, tab1 LIKE sy-ucom m VALUE 'MAIN_TAB_TAB1', " tab2 LIKE sy-ucom m VALUE 'MAIN_TAB_TAB2', " END OF c_main_tab. CONTROLS: main_ tab TYPE TABSTRIP. DATA:
BEGIN OF i_main _tab, subscreen LIKE sy-dynnr, prog
LIKE sy-repid VALUE 'ZZZ_JAYTEST',"Name of Program
pressed_tab LIKE sy-ucomm VALUE c_main_tab-tab1, "To identify the tab pressed END OF i_main_tab. SELECT * FROM mara INTO TABLE i_mara UP TO 10 ROWS. SELECT * FROM makt INTO TABLE i_makt UP TO 10 ROWS. CALL SCREEN 9000. *&---------------------------------------------------------------------* *& Module STATUS_9001 OUTPUT *&---------------------------------------------------------------------* * This is used to create container,buid fieldcatalogue,setting the * layout and displaying the data *----------------------------------------------------------------------* MODULE status_9000 OUTPUT. SET PF-STATUS 'ZSTATUS'. SET TITLEBAR 'ZTITLE'. main_tab-activetab = i_main_tab-pressed_tab. CASE i_main_tab-pressed_tab. WHEN c_main_tab-tab1. * Creating Object PERFORM create_object USING 'CC_9100' . * Building the field catalog PERFORM create_fieldcat USING 'MARA' . i_main_tab-subscreen = '9100'. * Displaying data PERFORM display_output USING i_mara. WHEN c_main_tab-tab2. * Creating Object PERFORM create_object USING 'CC_9200' . * Building the field catalog PERFORM create_fieldcat USING 'MAKT' . i_main_tab-subscreen = '9200'. * Displaying data PERFORM display_output USING i_makt. ENDCASE. ENDMODULE.
" STATUS_9001 OUTPUT
*&---------------------------------------------------------------------* *&
Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------* *
PAI
*----------------------------------------------------------------------* MODULE user_command_9000 INPUT. DATA lv_ucomm TYPE sy-ucomm.
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=38772
2/5
8/3/2017
TabStrip in ALV(OOPS) - Code Gallery - SCN Wiki
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
*&---------------------------------------------------------------------* *& Module MAIN_TAB_ACTIVE_TAB_GET INPUT *&---------------------------------------------------------------------* * This is used to catch the pressed tab *----------------------------------------------------------------------* MODULE main_tab_active_tab_get INPUT. CASE sy-ucomm. WHEN c_main_tab-tab1. i_main_tab-pressed_tab = c_main_tab-tab1. i_main_tab-subscreen = '9100'. WHEN c_main_tab-tab2. i_main_tab-pressed_tab = c_main_tab-tab2. i_main_tab-subscreen = '9200'. WHEN OTHERS. *
DO NOTHING ENDCASE.
ENDMODUL E.
" MAIN_TAB_ACTIVE_ TAB_GET INPUT
*&---------------------------------------------------------------------* *&
Form create_object
*&---------------------------------------------------------------------* *
Creating Docking Container and grid
*----------------------------------------------------------------------* FORM create_object USING custom. * Creating Docking Container CREATE OBJECT o_custom EXPORTING container_name = custom. IF sy-subrc EQ 0. * Creating Grid CREATE OBJECT o _grid EXPORTING i_parent
= o_custom.
ENDIF. ENDFORM.
" create_object
*&---------------------------------------------------------------------* *&
Form create_fieldcat
*&---------------------------------------------------------------------* *
Filling the fieldcatalog table
*----------------------------------------------------------------------* FORM create_fieldcat USING value(p_structure). * Clearing the contents of the fieldcatalog REFRESH i_fieldcat. * Filling the fieldcatalog table CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name
= p_structure
CHANGING ct_fieldcat
= i_fieldcat
EXCEPTIONS inconsistent_interface = 1 program_error OTHERS ENDFORM.
=2 = 3. " create_fieldcat
*&---------------------------------------------------------------------* *&
Form display_output
*&---------------------------------------------------------------------* *
Displaying the output
*----------------------------------------------------------------------* FORM display_output USING itab . w_variant-report = sy-repid. * Displaying the output CALL METHOD o_grid->set_table_for_first_display EXPORTING is_variant i_save
= w_variant = 'A'
CHANGING
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=38772
3/5
8/3/2017
TabStrip in ALV(OOPS) - Code Gallery - SCN Wiki
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_custom->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
Output Screens
tutorial
tabstrip
oops
5 Comments Guest Hi, its unfortunate to say you that no one of your link which you provide is not working. Thanks Shambhunath
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=38772
4/5
8/3/2017
TabStrip in ALV(OOPS) - Code Gallery - SCN Wiki
Jayanthi Jayaraman Hi, I now included that properly using link option available.It is working fine now.
Guest Dear Jayanthi, I´ve just copied the code and followed the instructions but I´m having a problem. When I call the program the ALV content isn't being showed, so I click in the Description tab but the pro blem still occuring. But when I click back in the first tab, the ALV appear. I´ve checked if there's anything wrong between the PBO and PAI modules but everything is OK. I "solved" the problem by copying the code below before the CALL SCREEN 9000. But I don´t think this is the correct solution. Could you please help me ? Here is the code copied before the call screen. * Creating Object PERFORM create_object USING 'CC_9100' . * Building the field catalog PERFORM create_fieldcat USING 'MARA' . i_main_tab-subscreen = '9100'. * Displaying data PERFORM display_output USING i_mara. * Creating Object PERFORM create_object USING 'CC_9200' . * Building the field catalog PERFORM create_fieldcat USING 'MAKT' . i_main_tab-subscreen = '9200'. * Displaying dataPERFORM display_output USING i_makt.
Guest Hi Jayanthi, Your coding works just nice... Probably you should have wrote clearly: 1. Drag and Drop a TABSTRIP 2. Then drop ONE sub-area into the TABSTRIP... and have all the TAB 1 and TAB 2 refer to the sub area. Because I drop two subareas in to the TAB. I didn't know i just had to drop one and have the tabs refer to it. Anyway, I manage to find out on my own! 3. Then create 2 subscreen 9001 and 9002 and mark as sub screen. Anyway, I like this piece of coding you contributed here. A good guide for ABAP developers to start using ALV with TABStrip... Thank you very much. William Wilstroth
david pulido Thanks Jayanthi, your post was very useful to me, I had the same problem as the guest who indicated that in the second tab not show the ALV in the first click, but i solve already the problem.
Thanks
Contact Us Privacy
SAP Help Portal Terms of Use
Legal Disclosure
Copyright
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=38772
Follow SCN
5/5