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: 

How to put text editor and alv control on a tab strip control

Former Member
0 Kudos

Hi All,

I searched the forum but i think i did not get what i was looking for or may be i could not understand.

I need to use tab strip control and embed cl_gui_textedit and cl_gui_alv_grid. I put tabstrip and subscreen on each tabs. Then when i try to put custom control on these subscreens, i dont see it getting displayed on subscreens in SE51.

How do we go about embedding these controls on tabstrip. Any ideas/alternatives?

Thanks for your time,

SKJ

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello

I assume you link the controls to the subscreen dynpros. However, you need to link them to the main dynpro.

Sample report ZUS_SDN_N2DEMO_TABSTRIP demonstrates how it works. The report has four screens:

  • 2000 = main screen

  • 2001 = subscreen

  • 2002 = subscreen, contains custom control element 'CONTAINER_2002'

  • 2003 = subscreen, contains custom control element 'CONTAINER_2003'


*&---------------------------------------------------------------------*
*& Report  N2DEMO_TABSTRIP
*  demonstriert eine einfache Steuerung von Kartei-Karten              *
*&  rz 19.04.2000                                                      *
*&---------------------------------------------------------------------*
*& Thread: How to put text editor and alv control on a tab strip control                                                                      *
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1174327"></a>                                                                     *
*&---------------------------------------------------------------------*
REPORT  zus_sdn_n2demo_tabstrip               .


TYPE-POOLS: abap.


data:
  gd_repid        type syst-repid,
*
  gt_outtab       type STANDARD TABLE OF knb1,

  go_textedit     type ref to cl_gui_textedit,
  go_grid         type ref to cl_gui_alv_grid,
  go_container2   type ref to cl_gui_custom_container,
  go_container3   type ref to cl_gui_custom_container.


*********************************************************************
*        Daten...
*********************************************************************
CONTROLS: register TYPE TABSTRIP.      " Deklaration des Controls

* --- die Nummern der Subscreen-Dynpros (die Karten) als Konstanten...
*     ...ermöglicht eine pfiffige Blätter-Mimik...
* Der Trick: die Konstanten heissen genau so, wie die OK-Codes der
*            Push-Buttons im Register
*
CONSTANTS: karte_1      TYPE sy-dynnr VALUE '2001',
           karte_2      TYPE sy-dynnr VALUE '2002',
           karte_3      TYPE sy-dynnr VALUE '2003',
           haupt_dynpro TYPE sy-dynnr VALUE '2000'. " nicht nötig,
                                       " aber elegant.
   " (!! bitte die Dynpro-Nummer als 4-stellige Zeichenkette !!)

* ----- ich brauche eine Variable, über die ich die richtige Karte
*       einblenden kann (s. Ablauflogik des Haupt-Dynpros)
DATA: aktuelle_karte TYPE sy-dynnr.


* ----- die üblichen OK-Code-Variablen (keine Bindestriche mehr)
DATA: ok_code       TYPE sy-ucomm,
      save_ok_code  TYPE sy-ucomm.



**********************************************************************
*                'Haupt'-Programm
**********************************************************************
START-OF-SELECTION.

  perform INIT_CONTROLS.

  aktuelle_karte = karte_1.            " wir fangen mit Karte 1 an...
  CALL SCREEN haupt_dynpro.



**********************************************************************
*            'Unter'-Programme...
**********************************************************************
* ***************************************  Module  set_STATUS  OUTPUT
MODULE set_status OUTPUT.
  SET PF-STATUS 'DEMO'.
ENDMODULE.                             " set_STATUS  OUTPUT



* **************************************** Module  USER_COMMAND  INPUT
MODULE user_command INPUT.

  save_ok_code = ok_code.
  CLEAR ok_code.

  CASE save_ok_code.
*   ----------------------------- zurück...beenden...abbrechen
    WHEN 'BACK'  OR  'END'  OR  'CANCEL'.
      SET SCREEN 0.
      LEAVE SCREEN.


    WHEN OTHERS.
*     ------------------------- Blättern der Register-Karten...
      IF save_ok_code   CP   'KARTE_*'.

*              --- blende den richtigen Subscreen ein...
        WRITE (save_ok_code) TO aktuelle_karte.
*              --- ...und hole den Button in den Vordergrund
        MOVE   save_ok_code  TO register-activetab.

      ELSE.    " alles was ich nicht kenne, führt zum Abbruch
        SET SCREEN 0.
        LEAVE SCREEN.
      ENDIF.

  ENDCASE.


ENDMODULE.                             " USER_COMMAND  INPUT



*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form INIT_CONTROLS .

  gd_repid = syst-repid.

  CREATE OBJECT go_container2
    EXPORTING
*      parent                      =
      container_name              = 'TEXT'
*      style                       =
*      lifetime                    = lifetime_default
*      repid                       =
*      dynnr                       =
*      no_autodef_progid_dynnr     =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CREATE OBJECT go_textedit
    EXPORTING
*      max_number_chars       =
*      style                  = 0
*      wordwrap_mode          = wordwrap_at_windowborder
*      wordwrap_position      = -1
*      wordwrap_to_linebreak_mode = false
*      filedrop_mode          = dropfile_event_off
      parent                 = go_container2
*      lifetime               =
*      name                   =
    EXCEPTIONS
      error_cntl_create      = 1
      error_cntl_init        = 2
      error_cntl_link        = 3
      error_dp_create        = 4
      gui_type_not_supported = 5
      others                 = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  CREATE OBJECT go_container3
    EXPORTING
*      parent                      =
      container_name              = 'GRID'
*      style                       =
*      lifetime                    = lifetime_default
*      repid                       =
*      dynnr                       =
*      no_autodef_progid_dynnr     =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CREATE OBJECT go_grid
    EXPORTING
      i_parent          = go_container3
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc ne 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.






  CALL METHOD go_container2->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '2000'
      container                   = 'CONTAINER_2002'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      lifetime_dynpro_dynpro_link = 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.


  CALL METHOD go_container3->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '2000'  " main dynpro
      container                   = 'CONTAINER_2003'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      lifetime_dynpro_dynpro_link = 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.


  select * from knb1 into TABLE gt_outtab up to 20 rows.

  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
*      i_buffer_active               =
*      i_bypassing_buffer            =
*      i_consistency_check           =
      i_structure_name              = 'KNB1'
*      is_variant                    =
*      i_save                        =
*      i_default                     = 'X'
*      is_layout                     =
*      is_print                      =
*      it_special_groups             =
*      it_toolbar_excluding          =
*      it_hyperlink                  =
*      it_alv_graphics               =
*      it_except_qinfo               =
*      ir_salv_adapter               =
    CHANGING
      it_outtab                     = gt_outtab
*      it_fieldcatalog               =
*      it_sort                       =
*      it_filter                     =
    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.                    " INIT_CONTROLS

Regards

Uwe

4 REPLIES 4

uwe_schieferstein
Active Contributor
0 Kudos

Hello

I assume you link the controls to the subscreen dynpros. However, you need to link them to the main dynpro.

Sample report ZUS_SDN_N2DEMO_TABSTRIP demonstrates how it works. The report has four screens:

  • 2000 = main screen

  • 2001 = subscreen

  • 2002 = subscreen, contains custom control element 'CONTAINER_2002'

  • 2003 = subscreen, contains custom control element 'CONTAINER_2003'


*&---------------------------------------------------------------------*
*& Report  N2DEMO_TABSTRIP
*  demonstriert eine einfache Steuerung von Kartei-Karten              *
*&  rz 19.04.2000                                                      *
*&---------------------------------------------------------------------*
*& Thread: How to put text editor and alv control on a tab strip control                                                                      *
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1174327"></a>                                                                     *
*&---------------------------------------------------------------------*
REPORT  zus_sdn_n2demo_tabstrip               .


TYPE-POOLS: abap.


data:
  gd_repid        type syst-repid,
*
  gt_outtab       type STANDARD TABLE OF knb1,

  go_textedit     type ref to cl_gui_textedit,
  go_grid         type ref to cl_gui_alv_grid,
  go_container2   type ref to cl_gui_custom_container,
  go_container3   type ref to cl_gui_custom_container.


*********************************************************************
*        Daten...
*********************************************************************
CONTROLS: register TYPE TABSTRIP.      " Deklaration des Controls

* --- die Nummern der Subscreen-Dynpros (die Karten) als Konstanten...
*     ...ermöglicht eine pfiffige Blätter-Mimik...
* Der Trick: die Konstanten heissen genau so, wie die OK-Codes der
*            Push-Buttons im Register
*
CONSTANTS: karte_1      TYPE sy-dynnr VALUE '2001',
           karte_2      TYPE sy-dynnr VALUE '2002',
           karte_3      TYPE sy-dynnr VALUE '2003',
           haupt_dynpro TYPE sy-dynnr VALUE '2000'. " nicht nötig,
                                       " aber elegant.
   " (!! bitte die Dynpro-Nummer als 4-stellige Zeichenkette !!)

* ----- ich brauche eine Variable, über die ich die richtige Karte
*       einblenden kann (s. Ablauflogik des Haupt-Dynpros)
DATA: aktuelle_karte TYPE sy-dynnr.


* ----- die üblichen OK-Code-Variablen (keine Bindestriche mehr)
DATA: ok_code       TYPE sy-ucomm,
      save_ok_code  TYPE sy-ucomm.



**********************************************************************
*                'Haupt'-Programm
**********************************************************************
START-OF-SELECTION.

  perform INIT_CONTROLS.

  aktuelle_karte = karte_1.            " wir fangen mit Karte 1 an...
  CALL SCREEN haupt_dynpro.



**********************************************************************
*            'Unter'-Programme...
**********************************************************************
* ***************************************  Module  set_STATUS  OUTPUT
MODULE set_status OUTPUT.
  SET PF-STATUS 'DEMO'.
ENDMODULE.                             " set_STATUS  OUTPUT



* **************************************** Module  USER_COMMAND  INPUT
MODULE user_command INPUT.

  save_ok_code = ok_code.
  CLEAR ok_code.

  CASE save_ok_code.
*   ----------------------------- zurück...beenden...abbrechen
    WHEN 'BACK'  OR  'END'  OR  'CANCEL'.
      SET SCREEN 0.
      LEAVE SCREEN.


    WHEN OTHERS.
*     ------------------------- Blättern der Register-Karten...
      IF save_ok_code   CP   'KARTE_*'.

*              --- blende den richtigen Subscreen ein...
        WRITE (save_ok_code) TO aktuelle_karte.
*              --- ...und hole den Button in den Vordergrund
        MOVE   save_ok_code  TO register-activetab.

      ELSE.    " alles was ich nicht kenne, führt zum Abbruch
        SET SCREEN 0.
        LEAVE SCREEN.
      ENDIF.

  ENDCASE.


ENDMODULE.                             " USER_COMMAND  INPUT



*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form INIT_CONTROLS .

  gd_repid = syst-repid.

  CREATE OBJECT go_container2
    EXPORTING
*      parent                      =
      container_name              = 'TEXT'
*      style                       =
*      lifetime                    = lifetime_default
*      repid                       =
*      dynnr                       =
*      no_autodef_progid_dynnr     =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CREATE OBJECT go_textedit
    EXPORTING
*      max_number_chars       =
*      style                  = 0
*      wordwrap_mode          = wordwrap_at_windowborder
*      wordwrap_position      = -1
*      wordwrap_to_linebreak_mode = false
*      filedrop_mode          = dropfile_event_off
      parent                 = go_container2
*      lifetime               =
*      name                   =
    EXCEPTIONS
      error_cntl_create      = 1
      error_cntl_init        = 2
      error_cntl_link        = 3
      error_dp_create        = 4
      gui_type_not_supported = 5
      others                 = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  CREATE OBJECT go_container3
    EXPORTING
*      parent                      =
      container_name              = 'GRID'
*      style                       =
*      lifetime                    = lifetime_default
*      repid                       =
*      dynnr                       =
*      no_autodef_progid_dynnr     =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CREATE OBJECT go_grid
    EXPORTING
      i_parent          = go_container3
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc ne 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.






  CALL METHOD go_container2->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '2000'
      container                   = 'CONTAINER_2002'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      lifetime_dynpro_dynpro_link = 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.


  CALL METHOD go_container3->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '2000'  " main dynpro
      container                   = 'CONTAINER_2003'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      lifetime_dynpro_dynpro_link = 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.


  select * from knb1 into TABLE gt_outtab up to 20 rows.

  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
*      i_buffer_active               =
*      i_bypassing_buffer            =
*      i_consistency_check           =
      i_structure_name              = 'KNB1'
*      is_variant                    =
*      i_save                        =
*      i_default                     = 'X'
*      is_layout                     =
*      is_print                      =
*      it_special_groups             =
*      it_toolbar_excluding          =
*      it_hyperlink                  =
*      it_alv_graphics               =
*      it_except_qinfo               =
*      ir_salv_adapter               =
    CHANGING
      it_outtab                     = gt_outtab
*      it_fieldcatalog               =
*      it_sort                       =
*      it_filter                     =
    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.                    " INIT_CONTROLS

Regards

Uwe

Former Member
0 Kudos

Hi Uwe,

First of all thank you very much for your reply. I saw your reply on friday itself but i could not access my system over weekend. Looks like i am very close to my solution. Comments in the program are difficult to understand. However, i followed below steps:

I copied the code into a temp prog ZN2DEMO_TABSTRIP1 and created 4 screens as below:

2000 - Screen type - Normal

2001 - Screen type - Subscreen

2002 - Screen type - Subscreen (on layout i created custom container control)

2003 - Screen type - Subscreen (on layout i created custom container control)

Activated the program. When i run the program i dont see any output. I tried to understand the code. In which do i need to create TEXT and GRID custom controls please? Sorry, i lack the concept. Appreciate if you guide me.

Thanks for your time,

SKJ

Former Member
0 Kudos

Hi Uwe,

Ok, this is what i did now:

Screen 2000 - type - Main Screen:

I assigned two subscreens TEXT and GRID to each tab of TABSTRIP naming REGISTER

Screen 2002 - type - Sub Screen:

Took custom container control naming CONTAINER_2002

Screen 2003 - type - Sub Screen:

Took custom container control naming CONTAINER_2003

When i run the program, TAB2 is shown but i dont see neither ALV control with data from KNA1 nor Text editor control.

Pls advice where am i going wrong.

Thanks,

SKJ

Former Member
0 Kudos

Thanks Uwe. Its done finally.

Thanks,

SKJ