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: 

Text edioter in Pop up window

Former Member

Hi all,

My requirement is

When hotspot click on the Basic list it should display Text editor in Popup window where you can enter the text.

Regards,

Madhavi

5 REPLIES 5

Former Member
0 Kudos

ues cli_gui_textedit class

code:

DATA: ok_code LIKE sy-ucomm.

DATA:

  • Create reference to the custom container

custom_container TYPE REF TO cl_gui_custom_container,

  • Create reference to the TextEdit control

editor TYPE REF TO cl_gui_textedit,

repid LIKE sy-repid.

data: o_docking type ref to cl_gui_docking_container.

  • Impmenting events

**********************************************************************

DATA:

event_type(20) TYPE c,

  • Internal table for events that should be registred

i_events TYPE cntl_simple_events,

  • Structure for oneline of the table

wa_events TYPE cntl_simple_event.

REATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Create obejct for the TextEditor control

CREATE OBJECT o_docking

EXPORTING

RATIO = '95'.

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = o_docking

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Former Member
0 Kudos

If your system have IS-U addon can try use next:

DATA: TEXTTAB TYPE TABLE OF TDLINE.

CALL FUNCTION 'ISU_POPUP_TEXT_EDIT'
  EXPORTING
    X_START_X_POS = 5
    X_START_Y_POS = 5
    X_HEIGHT      = 10
    X_TITLE       = 'Title'
  CHANGING
    XY_TEXTTAB    = TEXTTAB
  EXCEPTIONS
    GENERAL_FAULT = 1
    OTHERS        = 2.

If your system have PTRA addon try use next:

DATA: TEXTTAB TYPE TABLE OF TDLINE.
DATA: MOREI TYPE MOREI,
      EDITOR_TYPE TYPE EDITOR_TYPE.

CALL FUNCTION 'TRIP_EDIT_TEXT_IN_POPUP'
  EXPORTING
    I_MOREI                = MOREI
    I_EDITOR_TYPE          = EDITOR_TYPE
    I_TITLE                = 'Title'
    I_MODUS                = 'C'
  TABLES
    T_TAB_EDITOR           = TEXTTAB
  EXCEPTIONS
    DEFAULT_TEXT_NOT_FOUND = 1
    OTHERS                 = 2.

Both FM included dialog Dynpro screen with text elements. You also can followed their lead and coded own FM using this algorithm.

Good luck.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Madhavi

If you want to display a control on a screen level different than the main screen (level=0) then you have to use the correct parameter for IMPORTING parameter PARENT.


  IF ( go_textedit IS NOT BOUND ).
    IF ( p_popup = 'X' ).
      CREATE OBJECT go_docking
         EXPORTING
           parent                      = cl_gui_container=>screen1  " popup => level=1
*          REPID                       =
*          DYNNR                       =
*          SIDE                        = DOCK_AT_LEFT
*          EXTENSION                   = 50
*          STYLE                       =
*          LIFETIME                    = lifetime_default
*          CAPTION                     =
*          METRIC                      = 0
          ratio                       = 90
*          NO_AUTODEF_PROGID_DYNNR     =
*          NAME                        =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
    ELSE.
      CREATE OBJECT go_docking
         EXPORTING
           parent                      = cl_gui_container=>screen0  " main dynpro => level=0
*          REPID                       =
*          DYNNR                       =


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_TEXTEDIT_CTXMENU
*&
*&---------------------------------------------------------------------*
*& Thread: Text edioter in Pop up window
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="899495"></a>
*&---------------------------------------------------------------------*
*&
*& Flow logic of screen 100.
*      PROCESS BEFORE OUTPUT.
*       MODULE STATUS_0100.
**
*      PROCESS AFTER INPUT.
*       MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------------*

REPORT  zus_sdn_textedit_ctxmenu.


TYPE-POOLS: cntl.  " Types for Controls

DATA:
  gd_okcode      TYPE ui_func,
  go_docking     TYPE REF TO cl_gui_docking_container,
  go_textedit    TYPE REF TO cl_gui_textedit,
*
  gd_name        TYPE thead-tdname,
  gs_header      TYPE thead,
  gd_langu       TYPE thead-tdspras,
  gt_lines       TYPE STANDARD TABLE OF tline.




*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.

    CLASS-METHODS:
      handle_context_menu
        FOR EVENT context_menu OF cl_gui_textedit
          IMPORTING
            menu
            sender,

      handle_ctxmenu_selected
        FOR EVENT context_menu_selected OF cl_gui_textedit
          IMPORTING
            fcode
            sender.

ENDCLASS.                    "lcl_eventhandler DEFINITION



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_context_menu.

    CALL METHOD menu->add_function
      EXPORTING
        fcode       = 'MY_FUNC'
        text        = 'My Function'
*        ICON        =
*        FTYPE       =
*        DISABLED    =
*        HIDDEN      =
*        CHECKED     =
*        ACCELERATOR =
        .

  ENDMETHOD.                    "handle_context_menu


  METHOD handle_ctxmenu_selected.

    CASE fcode.
      WHEN 'MY_FUNC'.
        MESSAGE 'My function selected from ctxmenu' TYPE 'I'.

      WHEN OTHERS.
    ENDCASE.

  ENDMETHOD.                    "handle_ctxmenu_selected

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION




PARAMETERS:
  p_pspnr    TYPE prps-pspnr.

PARAMETERS:
  p_popup      AS CHECKBOX.



START-OF-SELECTION.

* Get the text object
  gs_header-tdid = 'LTXT'.  " long text
  gs_header-tdspras = syst-langu.
  CONCATENATE syst-langu p_pspnr
      INTO gs_header-tdname.
  gs_header-tdobject = 'PMS'.


  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*     CLIENT                        = SY-MANDT
      id                            = gs_header-tdid
      language                      = gs_header-tdspras
      name                          = gs_header-tdname
      object                        = gs_header-tdobject
*     ARCHIVE_HANDLE                = 0
*     LOCAL_CAT                     = ' '
*   IMPORTING
*     HEADER                        =
    TABLES
      lines                         = gt_lines
    EXCEPTIONS
      id                            = 1
      language                      = 2
      name                          = 3
      not_found                     = 4
      object                        = 5
      reference_check               = 6
      wrong_access_to_archive       = 7
      OTHERS                        = 8.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  IF ( p_popup = 'X' ).
    CALL SCREEN '0100' STARTING AT 10 10
                       ENDING   AT 80 40.
  ELSE.
    CALL SCREEN '0100'.
  ENDIF.

END-OF-SELECTION.



*&---------------------------------------------------------------------*
*&      Form  SET_REGISTERED_EVENTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM
set_registered_events .
* define local data
  DATA:
    lt_events      TYPE cntl_simple_events,
    ls_event       TYPE cntl_simple_event.


  TYPES: BEGIN OF cntl_simple_event,
       eventid TYPE i,
       appl_event TYPE c,
     END OF cntl_simple_event.


  ls_event-eventid = cl_gui_textedit=>event_context_menu.
  APPEND ls_event TO lt_events.
  ls_event-eventid = cl_gui_textedit=>event_context_menu_selected.
  APPEND ls_event TO lt_events.

  CALL METHOD go_textedit->set_registered_events
    EXPORTING
      events                    = lt_events
    EXCEPTIONS
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 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.                    " SET_REGISTERED_EVENTS



*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN_0100'.
*  SET TITLEBAR 'xxx'.


  CLEAR: gd_okcode.

  IF ( go_textedit IS NOT BOUND ).
    IF ( p_popup = 'X' ).
      CREATE OBJECT go_docking
         EXPORTING
           parent                      = cl_gui_container=>screen1
*          REPID                       =
*          DYNNR                       =
*          SIDE                        = DOCK_AT_LEFT
*          EXTENSION                   = 50
*          STYLE                       =
*          LIFETIME                    = lifetime_default
*          CAPTION                     =
*          METRIC                      = 0
          ratio                       = 90
*          NO_AUTODEF_PROGID_DYNNR     =
*          NAME                        =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
    ELSE.
      CREATE OBJECT go_docking
         EXPORTING
           parent                      = cl_gui_container=>screen0
*          REPID                       =
*          DYNNR                       =
*          SIDE                        = DOCK_AT_LEFT
*          EXTENSION                   = 50
*          STYLE                       =
*          LIFETIME                    = lifetime_default
*          CAPTION                     =
*          METRIC                      = 0
          ratio                       = 90
*          NO_AUTODEF_PROGID_DYNNR     =
*          NAME                        =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
    ENDIF.


    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          =
            c_textedit_control=>wordwrap_at_windowborder
*        WORDWRAP_POSITION      =
        wordwrap_to_linebreak_mode =
           c_textedit_control=>true
*        FILEDROP_MODE          = DROPFILE_EVENT_OFF
        parent                 = go_docking
*        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.

    CALL METHOD go_textedit->set_text_as_r3table
      EXPORTING
        table           = gt_lines
      EXCEPTIONS
        error_dp        = 1
        error_dp_create = 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 go_textedit->set_enable
      EXPORTING
        enable            = cl_gui_cfw=>true
      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.


    PERFORM set_registered_events.
    SET HANDLER:
      lcl_eventhandler=>handle_context_menu     FOR go_textedit,
      lcl_eventhandler=>handle_ctxmenu_selected FOR go_textedit.
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT



*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK'  OR
         'EXIT'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

Regards

Uwe

0 Kudos

Hi Uwe,

thanks for reply.

But that is not working in the system 4.6c.

simply i took the exact code to create a Editor from your code.

but it is showing the POP UP but the Text editor is not showing .

Here i need few clarifications:

1. i have created a screen 100 and i creates a custom container into it and

named 'CONT. where i am calling this container.

2. did i have to create custom container on screen 100 for Dialogbox contianer or

not . Will you please clarify and revert to me.

3. i am a bit confused with this and trying for a longtime.

4. go_textedit->set_enable method is missing in 4.6c versio.

-


REPORT zsdn_dialog1 .

CLASS c_textedit_control DEFINITION LOAD.

TYPE-POOLS: cntl. " Types for Controls

DATA:

gd_okcode TYPE ui_func,

go_docking TYPE REF TO cl_gui_docking_container,

go_textedit TYPE REF TO cl_gui_textedit.

START-OF-SELECTION.

CALL SCREEN '0100' STARTING AT 10 10

ENDING AT 80 40.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module STATUS_0100 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

cREATE OBJECT go_docking

EXPORTING

parent = cl_gui_container=>screen1

  • REPID =

  • DYNNR =

  • SIDE = DOCK_AT_LEFT

  • EXTENSION = 50

  • STYLE =

  • LIFETIME = lifetime_default

  • CAPTION =

  • METRIC = 0

ratio = 90

  • NO_AUTODEF_PROGID_DYNNR =

  • NAME =

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

CREATE OBJECT go_textedit

EXPORTING

  • MAX_NUMBER_CHARS =

  • STYLE = 0

wordwrap_mode =

c_textedit_control=>wordwrap_at_windowborder

  • WORDWRAP_POSITION =

wordwrap_to_linebreak_mode =

c_textedit_control=>true

  • FILEDROP_MODE = DROPFILE_EVENT_OFF

parent = go_docking

  • 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 eq 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • CALL METHOD go_textedit->set_enable

  • EXPORTING

  • enable = cl_gui_cfw=>true

  • EXCEPTIONS

  • cntl_error = 1

  • cntl_system_error = 2

  • OTHERS = 3.

  • IF sy-subrc eq 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

endmodule. " STATUS_0100 OUTPUT

with this code it is showing the popup but not showing the text Editor in it.

Regards,

Madhavi

Edited by: varisetty madhavi on Jun 4, 2008 11:17 AM

Former Member
0 Kudos

Hi,

Check the below code...

Here selection screen is used as initial screen where a ALV grid is displayed.......

Material field is hotspot....

the text type in popup is stored and retrived from ABAP memory...v can use read_text and save_text FMs instead....

REPORT  ztest2_8181 NO STANDARD PAGE HEADING LINE-SIZE 263.

*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.

  PUBLIC SECTION.

    METHODS : hotspot_click FOR EVENT hotspot_click
                            OF        cl_gui_alv_grid
                            IMPORTING e_row_id
                                      e_column_id
                                      es_row_no,

              close         FOR EVENT close
                            OF        cl_gui_dialogbox_container.


ENDCLASS.                    "lcl_event_handler DEFINITION

PARAMETER p.                           " Dummy

DATA : container   TYPE REF TO cl_gui_docking_container,
       popup       TYPE REF TO cl_gui_dialogbox_container,
       alv_grid    TYPE REF TO cl_gui_alv_grid,
       text_editor TYPE REF TO cl_gui_textedit,
       handler     TYPE REF TO lcl_event_handler,
       lt_mara     TYPE TABLE OF mara       WITH HEADER LINE,
       lt_fcat     TYPE          lvc_t_fcat WITH HEADER LINE,
       lt_texttab  TYPE soli_tab.

AT SELECTION-SCREEN OUTPUT.

  CHECK container IS NOT BOUND.

  CREATE OBJECT container EXPORTING repid      = sy-repid
                                    dynnr      = sy-dynnr
                                    side       = cl_gui_docking_container=>dock_at_left
                                    extension  = '99999' .

  CREATE OBJECT alv_grid EXPORTING i_parent = container.

  SELECT * FROM mara INTO TABLE lt_mara UP TO 20 ROWS.

  PERFORM build_fcat.

  alv_grid->set_table_for_first_display( CHANGING it_outtab       = lt_mara[]
                                                  it_fieldcatalog = lt_fcat[] ).

  CREATE OBJECT handler.

  SET HANDLER : handler->hotspot_click FOR ALL INSTANCES,
                handler->close         FOR ALL INSTANCES.

*&--------------------------------------------------------------------*
*&      Form  build_fcat
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM build_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = 'MARA'
    CHANGING
      ct_fieldcat            = lt_fcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc = 0.
    LOOP AT lt_fcat WHERE fieldname = 'MATNR'.
      lt_fcat-hotspot = 'X'.
      MODIFY lt_fcat.
    ENDLOOP.
  ENDIF.

ENDFORM.                    "build_fcat

*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.

  METHOD hotspot_click.
    CHECK popup IS NOT BOUND.
    CREATE OBJECT popup EXPORTING width   = '500'
                                  height  = '80'
                                  top     = '100'
                                  left    = '100'
                                  caption = 'Enter the text here'.

    CREATE OBJECT text_editor EXPORTING parent            = popup
                                        wordwrap_mode     = '2'
                                        wordwrap_position = '250'.

    IMPORT tab TO lt_texttab FROM MEMORY ID 'ABCD'.
    text_editor->set_text_as_r3table( EXPORTING table = lt_texttab[] ).

  ENDMETHOD.                    "hotspot_click

  METHOD close.
    text_editor->get_text_as_r3table( IMPORTING table = lt_texttab[] ).
    EXPORT tab FROM lt_texttab  TO MEMORY ID 'ABCD' COMPRESSION ON.
    popup->free( ).
    CLEAR popup.
  ENDMETHOD.                    "close

ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

.

Cheers,

Jose.