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

Text editer in PopUp window



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu Jul 24, 2008 12:29 pm    Post subject: Text editer in PopUp window Reply with quote

Author: Uwe Schieferstein

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... u can use read_text and save_text FMs instead.


Code:
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


Example 2
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.

Code:

  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
*& https://forums.sdn.sap.com/thread.jspa?threadID=899495&tstart=0
*&---------------------------------------------------------------------*
*&
*& 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



Example 2
Code:

* use cli_gui_textedit class
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,
  o_docking TYPE REF TO cl_gui_docking_container,
  repid LIKE sy-repid,
  line_length TYPE i VALUE '72'.



* 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.

CREATE 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 NE 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 NE 0.
  MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
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 -> Dialog Programming 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.