Application Development and Automation 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: 
Read only

Implementing Text Editor

Former Member
0 Likes
2,758

Greetings~

As apart of interactive module pool application we are developing we need to implement a text editor into the screen to capture many/several lines of free form text. Ideally I would like to implement the type of text editor used by SAP in VA03-Header Text with several text types in a left hand navigation tree and a text input area on the right. If someone could point me to a sample program or the right FM or Objects to use I would appreciate it.

Thanks!

7 REPLIES 7
Read only

Former Member
1,413

The text editor is build with class CL_GUI_TEXTEDIT

the left options can be made with CL_GUI_COLUMN_TREE

VA03 makes the magic work with an split container.

I would advise you to look at the dynpro 2100 in program SAPLV70T and check the initializations of all the classes.

Very interesting, might build something like that in my free time

Read only

Former Member
0 Likes
1,413

Hi,

 DATA DEFINITION:
TYPES: BEGIN OF TY_EDIT,
         LINE TYPE SO_URL,
       END OF TY_EDIT.

*For Textedit
DATA: GV_TEXTEDIT_4202 TYPE SCRFNAME VALUE 'TEXT_EDIT_4202',
      GO_TEXTEDIT_4202 TYPE REF TO CL_GUI_TEXTEDIT,
      GO_TEXTEDIT_CONTAINER_4202 TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GT_EDIT_1002  TYPE STANDARD TABLE OF TY_EDIT,
      GWA_EDIT_1002 LIKE LINE OF GT_EDIT_1002.





PBO MODULE

*&---------------------------------------------------------------------*
*&      Module  MOD_STATUS_4202  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE MOD_STATUS_4202 OUTPUT.
  PERFORM FRM_SET_EDIT_4202 TABLES GS_YDJHBZ-PT1002[]
                                   GT_EDIT_1002.

  IF GO_TEXTEDIT_CONTAINER_4202 IS INITIAL.
    CREATE OBJECT GO_TEXTEDIT_CONTAINER_4202
      EXPORTING
        CONTAINER_NAME              = GV_TEXTEDIT_4202
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    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_4202
      EXPORTING
        PARENT                     = GO_TEXTEDIT_CONTAINER_4202
        WORDWRAP_MODE              =
          CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
        WORDWRAP_POSITION          = 40
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.

    CALL METHOD GO_TEXTEDIT_4202->SET_TEXT_AS_R3TABLE
      EXPORTING
*        TABLE  = GS_YDJHBZ-PT1002[]
        TABLE  = GT_EDIT_1002[]
      EXCEPTIONS
        OTHERS = 1.

  ELSE.
    CALL METHOD CL_GUI_CFW=>DISPATCH.

    CALL METHOD GO_TEXTEDIT_4202->SET_TEXT_AS_R3TABLE
      EXPORTING
*        TABLE  = GS_YDJHBZ-PT1002[]
        TABLE  = GT_EDIT_1002[]
      EXCEPTIONS
        OTHERS = 1.
  ENDIF.

  IF OK_CODE_1200 = 'DISPLAY'.
    CALL METHOD GO_TEXTEDIT_4202->SET_READONLY_MODE
*      EXPORTING
*        READONLY_MODE          = TRUE
       EXCEPTIONS
         ERROR_CNTL_CALL_METHOD = 1
         INVALID_PARAMETER      = 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.
  ENDIF.

  IF NOT GS_YDJHBZ-P1036 IS INITIAL.
    WRITE ICON_DISPLAY_MORE AS ICON TO BTN_CBXM.
  ELSE.
    WRITE ICON_ENTER_MORE AS ICON TO BTN_CBXM.
  ENDIF.

  SELECT SINGLE KTEXT FROM T77KC
  INTO GS_T77KC-KTEXT
  WHERE LANGU = SY-LANGU
    AND KOBES = GS_YDJHBZ-P1036-KOBES.
ENDMODULE.                 " MOD_STATUS_4202  OUTPUT





PAI MODULE

*&---------------------------------------------------------------------*
*&      Module  MOD_USER_COMMAND_4202  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE MOD_USER_COMMAND_4202 INPUT.
  CALL METHOD CL_GUI_CFW=>DISPATCH.

  REFRESH GT_EDIT_1002.
  CALL METHOD GO_TEXTEDIT_4202->GET_TEXT_AS_R3TABLE
    IMPORTING
      TABLE  = GT_EDIT_1002
    EXCEPTIONS
      OTHERS = 1.

  PERFORM FRM_GET_EDIT_4202 TABLES GS_YDJHBZ-PT1002[]
                                   GT_EDIT_1002.
ENDMODULE.                 " MOD_USER_COMMAND_4202  INPUT 

Read only

Former Member
0 Likes
1,413

Hi Joseph Adamski ,

As per your requirement, you need to use cl_gui_textedit.

Before you implement this, you need to add Custom Controller onto your screen. It is of type cl_gui_custom_container.

Then, in the PBO of your screen's flow logic, add a module (like name it as create_object) and inside that module you need to create an object of Custom controller initially, then create an object of textedit and pass the controller object into parent field of the exporting parameter in create stmt. Thats it!

Write back to me if you find a problem.

Regards,

Pranaam.

Read only

0 Likes
1,413

NI - Your example was great but I'm looking to extend this with implementing the split container approach i.e. like the sales order text implementation in function in FG V70T.

Ramiro / Pranaam - Would you have demo or sample program for this approach, the SAP delivered SAPLV70T is very comprehensive and robust and so a bit difficult to road map from.

Read only

0 Likes
1,413

But... SAP gives you all the demos you need! Go to SE38, menu environment | examples | control examples

Read only

0 Likes
1,413

Hi Joseph,

I think you may need to check the DEMO programs in TCODE: DWDM.

Cheers,

Read only

0 Likes
1,413

Hi Joseph Adamski,

I did a lot of search and found that the solution for splitting the sceen as in VA03 would be to use SAP Easy Splitter Container.

If this is not sufficient in your case, you can go with SAP Splitter Container (or Docking Container). I'm not sure about the usage of these, but I found the following links useful:

[SAP Easy Splitter Container|http://help.sap.com/saphelp_sm32/helpdata/EN/f5/4f6e109f2511d295cc00a0c930660b/frameset.htm]

[Custom Control|http://help.sap.com/saphelp_nw04/helpdata/en/2a/755b94ca5911d299af5c9604c10e27/content.htm].

And, I can surely help you with the text edit with an example:

1. First add a custom contoller on the screen painter(I named it as CUST_CONTROLLER).

2. Add a module named create_object in the PBO of the screen.

3. Here are my declarations in the declaration part:

DATA:container TYPE REF TO cl_gui_custom_container, "Variable containing the reference of Container class

editor TYPE REF TO cl_gui_textedit.

4. I used the code below in the module create_object:

MODULE create_object OUTPUT. "Creates the container and editor objects

IF container IS INITIAL.

CREATE OBJECT container "CREATES A CONTAINER OBJECT

EXPORTING

container_name = 'CUST_CONTROLLER'

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 OBJECT editor " CREATES AN EDITOR OBJECT

EXPORTING

parent = container

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = 255

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

ENDIF.

ENDIF.

ENDMODULE.

Regards,

Pranaam.