Skip to end of metadata
Go to start of metadata

Author:  Rene Turnheim
Submitted: 01/18/2009
Related Links:

Over the last year or so I have developed for my company an enhanced method to maintain text for custom applications and some of the SAP transactions. The text editing solution allows text editing with notes logic, the maintenance of HTML as standard text for email through SO10 and opens several other possibilities. This tutorial will explain in several parts the solution I have developed and implemented at Instrumentation Laboratory. This tutorial at the end has a small sample program to illustrate the use of the class. First to get an idea how this solution works, please read the article I wrote ( look above ).

Based on this article I would like now to explain all the required code to get this solution fully working. During the Part I I want to explain the basic objects needed to allow the text maintenance with different editors and the implementation of the notes logic.
The first thing we need is to create the interface, which will be used for the different editors the object is supporting. To create the interface we need the following data elements/domains and structures:

ZZNOTES_POSITION

Fix val.

Short description

T

top

B

bottom

L

lext

R

right

 

 

ZZSORT_ORDER

Fix val.

Short description

1

Oldest to Newest

2

Newest to Oldest

3

Newest to Oldest not first

 

 

ZZTEXTCONV

Fix val.

Short description

  

Plain text

S

Snippet (mainly HTML: text without header/body )


 

And the following Structures:

ZSYT_S_TEXT_DISP_OPT_BOX

 

 

 

Text Object Display Options Box

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

NO_TOOLBAR_DISP


FLAG

CHAR

1

0

General Flag

NO_STATUSBAR_DISP


FLAG

CHAR

1

0

General Flag

STATUS_BAR_TEXT


ZSTATUS_BAR_TEXT

CHAR

256

0

Status Bar Text

DISPLAY_ONLY


FLAG

CHAR

1

0

General Flag

DISPLAY_NOTES_TOOLBAR

FLAG

CHAR

1

0

General Flag

NOTES_POSITION


ZZNOTES_POSITION

CHAR

1

0

Notes position for text object

SASH_POSITION


INT4

INT4

10

0

Natural Number

TABMODE


INT4

INT4

10

0

Natural Number

 

 

 

 

 

 

 

ZSYT_S_TEXT_DISP_OPT

 

 

 

Text Object Display Options

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

.INCLUDE


ZSYT_S_TEXT_DISP_OPT_BOX


0

0

Text Object Display Options Box

USERTITLE


TDUSERTITL

CHAR

1

0

Text editor: User-defined title for title bar


The Interface Z_I_SYT_EDITOR:

Method

Level

Methode type

Description

INITIALIZE

Instance Method

 

Create editor and set everything up

FREE

Instance Method

 

Free

FILL_DESCRIPTION

Instance Method

 

Get two lines of description

GET_IS_MODIFIED

Instance Method

 

Check if text has been changed

GET_LINE_COUNT

Instance Method

 

Get line count of text

REFRESH_TEXT

Instance Method

 

Update text with newer lines

SET_DISPLAY_OPTIONS

Instance Method

 

Set toolbar and status bar mode

GET_TEXT_FROM_EDITOR

Instance Method

 

Get the updated text

ADD_HISTORYLINE

Instance Method

 

Add the history line for notes logic

SET_DISPLAY_OPTIONS_NOTES

Instance Method

 

Set toolbar and status bar mode

CONVERT_TEXT

Instance Method

 

Convert text to required format and table type

Attributes Z_I_SYT_EDITOR: 

Attribute

Level

Typing

Associated type

Description

Initial value

W_LINES_START

Instance Attribute

Type

I

                                

                                                                                                         

C_NORMAL

Constant

Type

ZZTEXTCONV

Conversion types for text object

' '

C_SNIPPET

Constant

Type

ZZTEXTCONV

Conversion types for text object

'S'

Parameters for methods of Z_I_SYT_EDITOR:  

INITIALIZE

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_THEADER

Importing



Type

THEAD

                                           

SAPscript: Text Header

IC_PARENT

Importing



Type Ref To

CL_GUI_CONTAINER

                                           

Container for Custom Controls in the Screen Area

IT_LINES

Importing



Type

TSFTEXT

                                            

SAPscript: Text Lines

 

 

 

 

 

 

 

 

FILL_DESCRIPTION

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IT_TEXT

Importing



Type

TSFTEXT

                                           

Smart Forms: Text

IS_HEADER

Importing



Type

THEAD

                                           

SAPscript: Text Header

E_PART1

Exporting



Type

STRING

                                           

First line of Text

E_PART2

Exporting



Type

STRING

                                           

Second line of Text

 

 

 

 

 

 

 

 

GET_IS_MODIFIED

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_FLUSH

Importing


X

Type

FLAG

'X'

General Flag

R_IS_MODIFIED

Returning

X


Type

I

                                           

Text has been modified

 

 

 

 

 

 

 

 

GET_LINE_COUNT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_FLUSH

Importing

X

X

Type

FLAG

'X'

General Flag

E_LINES_NOW

Exporting



Type

I

                                           

Number of text lines now

E_LINES_START

Exporting



Type

I

                                           

Number of text lines when read from database

 

 

 

 

 

 

 

 

REFRESH_TEXT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_THEADER

Importing



Type

THEAD

                                           

SAPscript: Text Header

IT_LINES

Importing



Type

TSFTEXT

                                           

Smart Forms: Text

 

 

 

 

 

 

 

 

SET_DISPLAY_OPTIONS

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTDO

Importing



Type

ZSYT_S_TEXT_DISP_OPT

                                           

Text Object Display Options

 

 

 

 

 

 

 

 

GET_TEXT_FROM_EDITOR

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_THEADER

Importing



Type

THEAD

                                           

SAPscript: Text Header

RT_LINES

Returning

X


Type

TSFTEXT

                                            

Smart Forms: Text

 

 

 

 

 

 

 

 

ADD_HISTORYLINE

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_SORT_ORDER

Importing



Type

ZZSORT_ORDER

                                            

Notes Sort Order

I_NO_REFRESH

Importing


X

Type

FLAG

                                           

Notes text get not refreshed with 'X'

IS_THEADER

Importing



Type

THEAD

                                           

SAPscript: Text Header

IT_LINES

Importing



Type

TSFTEXT

                                           

Smart Forms: Text

RT_LINES

Returning

X


Type

TSFTEXT

                                           

Smart Forms: Text

 

 

 

 

 

 

 

 

SET_DISPLAY_OPTIONS_NOTES

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTDO

Importing



Type

ZSYT_S_TEXT_DISP_OPT

                                           

Text Object Display Options

 

 

 

 

 

 

 

 

CONVERT_TEXT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_TEXTCONV

Importing


X

Type

ZZTEXTCONV

' '

Conversion types for text object

IT_LINES

Importing



Type

TSFTEXT

                                           

Text

ET_LINES

Exporting



Type

TSFTEXT

                                           

Text

E_STRING

Exporting



Type

STRING

                                           

Return in one string

 Now we need several more  classes, but first we need two tables:
 ZYST_TTXOB is used for additional configuration data for the text ids. It has the same key as TTXOB. The table contains sort order for notes line size if need bigger then sap max 132 and the name of the key fields for text object key. The second table ZSYT_TOBJECTV is an addition to STXH and stores transactional data for each text id. The main propose is to store the first two lines of text ( easier on reports) and the language. I was not interested to keep each text in all languages and therefore this table keeps the created language not in key. If you don't like this then the language has to go in key and bit of code has to change.


 

ZSYT_TTXOB

 

 

 

 

 

 

 

Field

Key

InitialValue

Data Element

Data Type

Length

Decimal Pl

Short Description

MANDT


X

MANDT

CLNT

3

0

Client

TDOBJECT

X

X

TDOBJECT

CHAR

10

0

Texts: Application Object

TDID

X

X

TDID

CHAR

4

0

Text ID

FIELDNAME1

 

 

ZZFIELDNAME1

CHAR

30

0

Field Name 1

FIELDNAME2

 

 

ZZFIELDNAME2

CHAR

30

0

Field Name 2

FIELDNAME3

 

 

ZZFIELDNAME3

CHAR

30

0

Field Name 3

FIELDNAME4

 

 

ZZFIELDNAME4

CHAR

30

0

Field Name 4

FIELDNAME5

 

 

ZZFIELDNAME5

CHAR

30

0

Field Name 5

FIELDNAME6

 

 

ZZFIELDNAME6

CHAR

30

0

Field Name 6

SORT_ORDER

 

 

ZZSORT_ORDER

NUMC

1

0

Notes Sort Order

TDLINESIZE

 

 

ZZTDLINESIZE

NUMC

3

0

Line Width

 

 

 

 

 

 

 

 

ZSYT_TOBJECTV

 

 

 

 

 

 

 

Field

Key

InitialValue

Data Element

Data Type

Length

Decimal Pl

Short Description

MANDT

X

X

MANDT

CLNT

3

0

Client

TEXTOBJECT

X

X

TDOBJECT

CHAR

10

0

Texts: Application Object

TEXTNAME

X

X

TDOBNAME

CHAR

70

0

Name

TEXTID

X

X

TDID

CHAR

4

0

Text ID

SPRAS



SPRAS

LANG

1

0

Language Key

DESCR1



ZZDESCR132

CHAR

132

0

Description 132

DESCR2

 

 

ZZDESCR132

CHAR

132

0

Description 132

TEXT_L



ZZTEXT_L

CHAR

1

0

Long text exists

ERSDA



ERSDA

DATS

8

0

Created On

ERNAM



ZZERNAM

CHAR

12

0

Created by

LAEDA



LAEDA

DATS

8

0

Date of Last Change

AENAM



ZZAENAM

CHAR

12

0

Changed by

 To create the objects we need the following data elements/domains and structures:
 

ZZNOTES_POSITION

 

Fix val.

Short description

T

Top

B

Bottom

L

Lext

R

Right

 

 

ZZEDITOR

 

Fix val.

Short description


Standard Text editor

N

New BTF editor with XHTML storage STXL

W

Word Text editor


 

ZSYT_S_TEXT_KEY_FIELDS

 

 

 

 

 

Key fields for text's

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

MANDT


MANDT

CLNT

3

0

Client

DOCNO10


NUMC10

NUMC

10

0

Numeric Character Field, Length 10

DOCNO06


ZNUMC06

NUMC

6

0

numc06

DOCNO08


ZNUMC08

NUMC

8

0

NUMC08

DOCNO04


NUMC4

NUMC

4

0

Count parameters

DOCCH04


CHAR4

CHAR

4

0

Not More Closely Defined Area, Possibly Used for Patchlevels

DOCCH18


CHAR18

CHAR

18

0

Field length 18

DOCCH70


CHAR70

CHAR

70

0

Character field, length 70

 

 

 

 

 

 

 

ZSYT_S_TOBJECT_MD

 

 

 

 

 

Master for data for text object

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

.INCLUDE


ZSYT_TTXOB


0

0

Text object configuration new interface

EDITOR


ZZEDITOR

CHAR

1

0

Editor choice

TDSAVEMODE


TDSAVEMODE

CHAR

1

0

Save mode

TDAPPL


TDAPPL

CHAR

2

0

Text editor: Interface for different applications

TDSTYLE


TDSTYLE

CHAR

8

0

Style Name

TDFORM


TDFORM

CHAR

16

0

Form Name

TDINCLOBJ


TDDEFOBJ

CHAR

10

0

Default text object for texts to be included

TDINCLID


TDINCLID

CHAR

4

0

Default ID for texts to be included

TDINCLRES


TDINCLRES

CHAR

1

0

Expand INCLUDE

TDOBLIGAT


TDOBLIGAT

CHAR

1

0

Text contents are mandatory

TDDELPROT


TDDELPROT

CHAR

1

0

Deletion protection

TDSHOWNAME


TDSHOWNAME

CHAR

1

0

Display text name in editor header

TDTEXTTYPE


TDTEXTTYPE

CHAR

6

0

SAPscript: Format of Text

TDKEYSTRUC


TDKEYSTRUC

CHAR

30

0

SAPscript: Structure name for key structure

 

 

 

 

 

 

 

ZSYT_S_TEXTS_FIELDS

 

 

 

 

 

Fields needed for Texts object

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

TDID


TDID

CHAR

4

0

Text ID

TDOBJECT


TDOBJECT

CHAR

10

0

Texts: Application Object

DISPLAY_ONLY


FLAG

CHAR

1

0

General Flag

 

 

 

 

 

 

 

ZSYT_S_TEXT_DATA

 

 

 

 

 

Text data for read access

Component

RType

Component type

Data Type

Length

Decimal Pl

Short Description

TDOBJECT


TDOBJECT

CHAR

10

0

Texts: Application Object

TDNAME


TDOBNAME

CHAR

70

0

Name

TDSPRAS


TDSPRAS

LANG

1

0

Language key

TDID


TDID

CHAR

4

0

Text ID

TLINE


TSFTEXT


0

0

Smart Forms: Text

 

Class Z_C_SYT_TEXT: Main text class for all text objects
 

Methodes Z_C_SYT_TEXT

 

 

 

 

Method

Level

Visibility

Methode type

Description

CONSTRUCTOR

Instance Method

Public


Constructor

CLASS_CONSTRUCTOR

Static Method

Public


Class constructor

FREE_ALL

Static Method

Public

          

Refresh class

SAVE

Static Method

Public

          

Save text objects

READ_TEXT_LINE

Static Method

Public

          

Read only first two text lines from table

UPDATE_TOBJECTV

Static Method

Public

          

Update tobjectv table from text for conversion

GET_EDITOR

Static Method

Public

          

Gets editor from texttype

CREATE_EDITOR

Static Method

Public

          

Create editor interface

UPDATE_TOBJECTV2

Static Method

Public

          

Update tobjectv table from text for conversion

GET_TOBJECT_MASTER_DATA

Static Method

Protected

          

Read all data related to text object

GET_TEXT_NAME

Static Method

Protected

          

Get Text Name

READ_TOBJECTV

Static Method

Protected

          

Read table zsy_tobject_v

FLUSH

Static Method

Protected

          

Execute a flush




The type ZSYT_T_TEXT_OBJECT is a table type in reference to Z_C_SYT_TEXT_OBJECT, which is next on the list. All other types are listed above.

Attributes Z_C_SYT_TEXT

 

 

 

 

 

 

Attribute

Level

Visibility

Typing

Associated type

Description

Initial value

C_NO

Constant

Public

Type

FLAG

General flag

'N'

C_YES

Constant

Public

Type

FLAG

General flag

'Y'

C_TRUE

Constant

Public

Type

I

True means 1

1

C_FALSE

Constant

Public

Type

I

False means 0

0

WT_TEXT_POINTERS

Static Attribute

Public

Type

ZSYT_T_TEXT_OBJECT

Text Object Pointers

 

C_TOP

Constant

Public

Type

ZZNOTES_POSITION

Notes position for text object

'T'

C_BOTTOM

Constant

Public

Type

ZZNOTES_POSITION

Notes position for text object

'B'

C_LEFT

Constant

Public

Type

ZZNOTES_POSITION

Notes position for text object

'L'

C_RIGHT

Constant

Public

Type

ZZNOTES_POSITION

Notes position for text object

'R'

C_EDITOR

Constant

Public

Type

ZZEDITOR

Standard Text editor

' '

C_EDITOR_N

Constant

Public

Type

ZZEDITOR

New BTF editor with XHTML storage old

'N'

C_EDITOR_W

Constant

Public

Type

ZZEDITOR

Word Text editor

'W'

C_SORT_NOTES_OLD_NEW

Constant

Protected

Type

ZZSORT_ORDER

Issue Tracking Notes Sort Order - Oldest to Newest

'1'

C_SORT_NOTES_NEW_OLD

Constant

Protected

Type

ZZSORT_ORDER

Issue Tracking Notes Sort Order - Newest to Oldest

'2'

C_SORT_NOTES_NEW_OLD_1

Constant

Protected

Type

ZZSORT_ORDER

Issue Tracking Notes Sort Order - Newest to Oldest NOT 1

'3'

WT_TOBJECT_MD

Static Attribute

Protected

Type

ZSYT_T_TOBJECT_MD

Master data for text object

 

WT_TOBJECTV

Static Attribute

Protected

Type

ZSYT_T_TOBJECTV

Text objects data

 

W_OFFLINE

Instance Attribute

Protected

Type

I

 

 

WT_FIELDS

Static Attribute

Private

Type

ZSY_T_DD03L

Table type for table DD03L

 

 

Now follow the parameters for each method and then the code. 

SAVE

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_COMMIT

Importing



Type

FLAG

                                                        

General Flag

IS_TEXTS

Importing


X

Type

ZSYT_S_TEXT_KEY_FIELDS

                                                       

Fields needed for Texts

 

 

 

 

 

 

 

 

READ_TEXT_LINE

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTF

Importing



Type

ZSYT_S_TEXTS_FIELDS

                                                       

Fields needed for Texts

IS_TEXTS

Importing



Type

ZSYT_S_TEXT_KEY_FIELDS

                                                        

Key fields for text's

ES_TOBJECTV

Exporting



Type

ZSYT_TOBJECTV

                                                       

Text objects for Issue tracking

ES_TOBJECT_MD

Exporting



Type

ZSYT_S_TOBJECT_MD

                                                       

Master for data for text object

 

 

 

 

 

 

 

 

GET_EDITOR

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_TEXTTYPE

Importing



Type

TDTEXTTYPE

Type

THEAD

R_EDITOR

Returning



Type

ZZEDITOR

Type

TSFTEXT

 

 

 

 

 

 

 

 

CREATE_EDITOR

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_EDITOR

Importing



Type

ZZEDITOR

                                                        

Editor choice

CC_TEXTEDITOR

Changing



Type Ref To

Z_I_SYT_EDITOR

                                                       

Interface for different editor

 

 

 

 

 

 

 

 

GET_TOBJECT_MASTER_DATA

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTF

Importing



Type

ZSYT_S_TEXTS_FIELDS

                                                       

Fields needed for Texts

ES_TOBJECT_MD

Exporting



Type

ZSYT_S_TOBJECT_MD

                                                       

Master for data for text object

 

 

 

 

 

 

 

 

GET_TEXT_NAME

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTF

Importing



Type

ZSYT_S_TEXTS_FIELDS

                                                       

Fields needed for Texts

IS_TEXTS

Importing



Type

ZSYT_S_TEXT_KEY_FIELDS

                                                       

Key fields for text's

E_TNAME

Exporting



Type

THEAD-TDNAME

                                                       

Name

ES_TOBJECT_MD

Exporting



Type

ZSYT_S_TOBJECT_MD

                                                       

Master for data for text object

 

 

 

 

 

 

 

 

READ_TOBJECTV

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

ES_TOBJECTV

Exporting



Type

ZSYT_TOBJECTV

                                                       

Text objects value table

CS_THEADER

Changing



Type

THEAD

                                                       

SAPscript: Text Header



And now the code:
 Z_C_SYT_TEXT->CONSTRUCTOR: 
CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
      e_offline = w_offline.

 
Z_C_SYT_TEXT->CLASS_CONSTRUCTOR: 
SELECT        * FROM  dd03l APPENDING TABLE wt_fields
         WHERE  tabname   = 'ZSYT_S_TEXT_KEY_FIELDS'
         AND    as4local  = 'A'
         AND    as4vers   = '0'.
 
Z_C_SYT_TEXT->FREE_ALL: 
 DATA: lc_textobject TYPE REF TO z_c_syt_text_object,
        lt_textobject TYPE zsyt_t_text_object.

  • We do this because each deletes for itself
      lt_textobject = wt_text_pointers.
      LOOP AT  lt_textobject INTO lc_textobject.
        CALL METHOD lc_textobject->free.
      ENDLOOP.
      REFRESH wt_text_pointers.
     
    Z_C_SYT_TEXT->SAVE 
     
    DATA: lc_textobject TYPE REF TO z_c_syt_text_object.
      LOOP AT wt_text_pointers INTO lc_textobject.
        CALL METHOD lc_textobject->save_text
          EXPORTING
            i_commit = i_commit
            is_texts = is_texts.
      ENDLOOP.
     
    Z_C_SYT_TEXT->READ_TEXT_LINE
     
    Data: ls_theader type thead.
  • This may be moved to another object later (for multiple text lines in a loop)
      CALL METHOD get_text_name
        EXPORTING
          is_textf      = is_textf
          is_texts      = is_texts
        IMPORTING
          e_tname       = ls_theader-tdname
          es_tobject_md = es_tobject_md.
      ls_theader-tdid = is_textf-tdid.
      ls_theader-tdobject = is_textf-tdobject.
      read_tobjectv(
         IMPORTING
           es_tobjectv = es_tobjectv
         CHANGING
           cs_theader  = ls_theader
             ). 

Z_C_SYT_TEXT->GET_EDITOR 
 
 CASE i_texttype+1(3).
    WHEN 'GTE'.
      r_editor = c_editor.
    WHEN 'BTF'.
      r_editor = c_editor_n.
    WHEN 'WRD'.
      r_editor = c_editor_w.
    WHEN OTHERS.
      r_editor = c_editor.
  ENDCASE.

Z_C_SYT_TEXT->CREATE_EDITOR 
 
DATA: lc_btf TYPE REF TO z_c_syt_btf,
        lc_wrd TYPE REF TO z_c_syt_wrd,
        lc_gte TYPE REF TO z_c_syt_gte.
  CASE i_editor.
    WHEN c_editor_n.
      CREATE OBJECT lc_btf.
      cc_texteditor = lc_btf.
    WHEN c_editor_w.
      CREATE OBJECT lc_wrd.
      cc_texteditor = lc_wrd.
    WHEN OTHERS.
      CREATE OBJECT lc_gte.
      cc_texteditor = lc_gte.
  ENDCASE.

Z_C_SYT_TEXT->GET_TOBJECT_MASTER_DATA 
 
 DATA: ls_tobject_md TYPE zsyt_s_tobject_md,
        ls_syt_ttxob  TYPE zsyt_ttxob,
        ls_ttxob      TYPE ttxob,
        ls_ttxid      TYPE ttxid.

  • Lets see if we have the data:
      READ TABLE wt_tobject_md INTO ls_tobject_md
              WITH TABLE KEY tdobject = is_textf-tdobject
                             tdid     = is_textf-tdid.
      IF sy-subrc <> 0 .
        SELECT SINGLE * FROM  ttxob INTO ls_ttxob
               WHERE  tdobject  = is_textf-tdobject.
        IF sy-subrc EQ 0.
          SELECT        * FROM  zsyt_ttxob INTO ls_syt_ttxob
               WHERE  tdobject  = is_textf-tdobject.
            IF ls_ttxid-tdid <> ls_syt_ttxob-tdid.
              SELECT SINGLE * FROM  ttxid INTO ls_ttxid
                     WHERE  tdobject  = ls_syt_ttxob-tdobject
                     AND    tdid      = ls_syt_ttxob-tdid.
            ENDIF.
            MOVE-CORRESPONDING ls_ttxob      TO ls_tobject_md.
            MOVE-CORRESPONDING ls_ttxid      TO ls_tobject_md.
            MOVE-CORRESPONDING ls_syt_ttxob  TO ls_tobject_md.
  • If we get the editor from configuration; we overwrite our table.
            IF ls_tobject_md-tdtexttype IS NOT INITIAL.
              ls_tobject_md-editor = get_editor( ls_tobject_md-tdtexttype ).
            ENDIF.
            INSERT ls_tobject_md INTO TABLE wt_tobject_md.
            IF sy-subrc <> 0.
              MODIFY TABLE wt_tobject_md FROM ls_tobject_md.
            ENDIF.
          ENDSELECT.
          READ TABLE wt_tobject_md INTO ls_tobject_md
            WITH TABLE KEY tdobject = is_textf-tdobject
                           tdid     = is_textf-tdid.
          IF sy-subrc <> 0.
            RAISE error.
          ENDIF.
        ELSE.
          RAISE error.
        ENDIF.
      ENDIF.
      MOVE-CORRESPONDING ls_tobject_md TO es_tobject_md.
     
    Z_C_SYT_TEXT->GET_TEXT_NAME
     
      DATA: ls_tobject_md TYPE zsyt_s_tobject_md.
      FIELD-SYMBOLS: <f1> TYPE ANY,
                     <f2> TYPE ANY,
                     <f3> TYPE ANY,
                     <f4> TYPE ANY,
                     <f5> TYPE ANY,
                     <f6> TYPE ANY.
      DATA: l_sfield TYPE thead-tdname,
            l_i      TYPE i,
            l_dd03l  TYPE dd03l.
  • Build the name of the text using the fields from table zsyi_ttobject
      get_tobject_master_data(
        EXPORTING
          is_textf      = is_textf
        IMPORTING
          es_tobject_md = ls_tobject_md
        EXCEPTIONS
          error         = 1
             ).
      IF sy-subrc EQ 0 .
        IF ls_tobject_md-fieldname1 NE space.
          ASSIGN COMPONENT ls_tobject_md-fieldname1
                  OF STRUCTURE is_texts  TO <f1>.
          l_sfield = <f1>.
          e_tname = l_sfield.
          READ TABLE wt_fields INTO l_dd03l WITH TABLE KEY
                   tabname    = 'ZSYT_S_TEXT_KEY_FIELDS'
                   fieldname  = ls_tobject_md-fieldname1.
          l_i = l_dd03l-leng.
          IF ls_tobject_md-fieldname2 NE space.
            ASSIGN COMPONENT ls_tobject_md-fieldname2
                  OF STRUCTURE is_texts  TO <f2>.
            l_sfield = <f2>.
            e_tname+l_i = l_sfield.
            READ TABLE wt_fields INTO l_dd03l WITH TABLE KEY
                     tabname    = 'ZSYT_S_TEXT_KEY_FIELDS'
                     fieldname  = ls_tobject_md-fieldname2.
            l_i = l_i + l_dd03l-leng.
            IF ls_tobject_md-fieldname3 NE space.
              ASSIGN COMPONENT ls_tobject_md-fieldname3
                  OF STRUCTURE is_texts  TO <f3>.
              l_sfield = <f3>.
              e_tname+l_i = l_sfield.
              READ TABLE wt_fields INTO l_dd03l WITH TABLE KEY
                       tabname    = 'ZSYT_S_TEXT_KEY_FIELDS'
                       fieldname  = ls_tobject_md-fieldname3.
              l_i = l_i + l_dd03l-leng.
              IF ls_tobject_md-fieldname4 NE space.
                ASSIGN COMPONENT ls_tobject_md-fieldname4
                  OF STRUCTURE is_texts  TO <f4>.
                l_sfield = <f4>.
                e_tname+l_i = l_sfield.
                READ TABLE wt_fields INTO l_dd03l WITH TABLE KEY
                         tabname    = 'ZSYT_S_TEXT_KEY_FIELDS'
                         fieldname  = ls_tobject_md-fieldname4.
                l_i = l_i + l_dd03l-leng.
                IF ls_tobject_md-fieldname5 NE space.
                  ASSIGN COMPONENT ls_tobject_md-fieldname5
                    OF STRUCTURE is_texts  TO <f5>.
                  l_sfield = <f5>.
                  e_tname+l_i = l_sfield.
                  READ TABLE wt_fields INTO l_dd03l WITH TABLE KEY
                           tabname    = 'ZSYT_S_TEXT_KEY_FIELDS'
                           fieldname  = ls_tobject_md-fieldname5.
                  l_i = l_i + l_dd03l-leng.
                  IF ls_tobject_md-fieldname6 NE space.
                    ASSIGN COMPONENT ls_tobject_md-fieldname6
                      OF STRUCTURE is_texts  TO <f6>.
                    l_sfield = <f6>.
                    e_tname+l_i = l_sfield.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
        es_tobject_md = ls_tobject_md.
      ELSE.
  • Raise error config is missing
        RAISE config_missing.
      ENDIF.

Z_C_SYT_TEXT->READ_TOBJECTV
 
  READ TABLE wt_tobjectv INTO es_tobjectv
       WITH TABLE KEY textname   = cs_theader-tdname
                      textid     = cs_theader-tdid
                      textobject = cs_theader-tdobject.
  IF sy-subrc NE 0 .
    SELECT SINGLE *
           INTO es_tobjectv
           FROM zsyt_tobjectv
           WHERE textname   = cs_theader-tdname
           AND   textid     = cs_theader-tdid
           AND   textobject = cs_theader-tdobject.
    IF sy-subrc NE 0.
      cs_theader-tdspras = sy-langu.
    ELSE.
      cs_theader-tdspras = es_tobjectv-spras.
      INSERT es_tobjectv INTO TABLE wt_tobjectv.
    ENDIF.
  ELSE.
    cs_theader-tdspras = es_tobjectv-spras.
  ENDIF.
 
Z_C_SYT_TEXT->FLUSH
  CALL METHOD cl_gui_cfw=>flush
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error        = 2.
  IF sy-subrc <> 0.
*         MESSAGE .
  ENDIF.


So now to activate the class Z_C_SYT_TEXT you need the implementation of the different editor types. For now here is Z_C_SYT_GTE. The other will follow later. Z_C_SYT_GTE has the class Z_C_SYT_TEXT as super class (inherits from) and also uses the interface Z_I_SYT_EDITOR. None of the methods get redefined. Only the interface methods get implemented. We need the following attributes added: 

Attributes

 

 

 

 

 

 

Attribute

Level

Visibility

Typing

Associated type

Description

Initial value

WO_GTE

Instance Attribute

Private

Type Ref To

CL_GUI_TEXTEDIT

SAP TextEdit Control

 

W_IS_MODIFIED

Instance Attribute

Private

Type

I

                                            

 

W_WORD_RAP

Instance Attribute

Private

Type

I

                                           

 


The code:
 

Z_I_SYT_EDITOR~INITIALIZE
* Two options for now. If linesize is maintained. iT will be used and formated according to line size.
* if not we use window border.
  w_word_rap = is_theader-tdlinesize.
  CASE w_word_rap.
    WHEN 0.
      CREATE OBJECT wo_gte
        EXPORTING
          wordwrap_mode              = cl_gui_textedit=>wordwrap_at_windowborder
          wordwrap_to_linebreak_mode = cl_gui_textedit=>false
          parent                     = ic_parent
        EXCEPTIONS
          error_cntl_create          = 1
          error_cntl_init            = 2
          error_cntl_link            = 3
          error_dp_create            = 4
          gui_type_not_supported     = 5
          OTHERS                     = 6.
    WHEN 999.
      CREATE OBJECT wo_gte
        EXPORTING
          wordwrap_mode              = cl_gui_textedit=>wordwrap_off
          wordwrap_to_linebreak_mode = cl_gui_textedit=>false
          parent                     = ic_parent
        EXCEPTIONS
          error_cntl_create          = 1
          error_cntl_init            = 2
          error_cntl_link            = 3
          error_dp_create            = 4
          gui_type_not_supported     = 5
          OTHERS                     = 6.
    WHEN OTHERS.
      CREATE OBJECT wo_gte
        EXPORTING
          wordwrap_mode              = cl_gui_textedit=>wordwrap_at_fixed_position
          wordwrap_position          = w_word_rap
          wordwrap_to_linebreak_mode = cl_gui_textedit=>false
          parent                     = ic_parent
        EXCEPTIONS
          error_cntl_create          = 1
          error_cntl_init            = 2
          error_cntl_link            = 3
          error_dp_create            = 4
          gui_type_not_supported     = 5
          OTHERS                     = 6.
  ENDCASE.
*     Convert the text to screen
  CALL METHOD convert_text_to_screen
    EXPORTING
      ic_texteditor = wo_gte
      it_texts      = it_lines.
  wo_gte->get_line_count( IMPORTING lines = z_i_syt_editor~w_lines_start ).
 

Z_I_SYT_EDITOR~FREE
 free WO_GTE.
 

Z_I_SYT_EDITOR~FILL_DESCRIPTION
  DATA: ls_ascii TYPE TDLINE,
        lt_ascii TYPE TDTAB_C132.
  CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
   EXPORTING
*   CODEPAGE                = '0000'
      formatwidth             = is_header-tdlinesize
      language                = is_header-tdspras
*   TABLETYPE               = 'ASC'
*   TAB_SUBSTITUTE          = ' '
*   LF_SUBSTITUTE           = ' '
*   REPLACE_SYMBOLS         = 'X'
*   REPLACE_SAPCHARS        = 'X'
   IMPORTING
*   FORMATWIDTH_E           =
*    x_datatab               =
      c_datatab               = lt_ascii
*   X_SIZE                  =
   TABLES
      itf_lines               = it_text
   EXCEPTIONS
      INVALID_TABLETYPE       = 1
      OTHERS                  = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    READ TABLE lt_ascii INTO ls_ascii INDEX 1.
    IF sy-subrc EQ 0.
      e_part1 = ls_ascii.
    ENDIF.
    READ TABLE lt_ascii INTO ls_ascii INDEX 2.
    IF sy-subrc EQ 0.
      e_part2 = ls_ascii.
    ENDIF.
  ENDIF.
Z_I_SYT_EDITOR~GET_IS_MODIFIED
  IF wo_gte IS BOUND.
    wo_gte->get_textstream( IMPORTING is_modified = r_is_modified ).
  ENDIF.
  IF i_flush = abap_true.
    flush( ) .
  ENDIF.
Z_I_SYT_EDITOR~GET_LINE_COUNT
  wo_gte->get_line_count( IMPORTING lines = e_lines_now ).
  IF i_flush = abap_true.
    flush( ) .
  ENDIF.
  e_lines_start = z_i_syt_editor~w_lines_start.
Z_I_SYT_EDITOR~REFRESH_TEXT
  IF wo_gte IS NOT INITIAL.
    CALL METHOD convert_text_to_screen
      EXPORTING
        ic_texteditor = wo_gte
        it_texts      = it_lines.
  ENDIF.
Z_I_SYT_EDITOR~SET_DISPLAY_OPTIONS
  IF wo_gte IS BOUND.
* Display of the tool bar
    IF is_textdo-no_toolbar_disp EQ abap_true.
      CALL METHOD wo_gte->set_toolbar_mode
        EXPORTING
          toolbar_mode           = cl_gui_textedit=>false
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ELSE.
      CALL METHOD wo_gte->set_toolbar_mode
        EXPORTING
          toolbar_mode           = cl_gui_textedit=>true
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ENDIF.
* Display Only
    IF is_textdo-display_only EQ abap_true.
      CALL METHOD wo_gte->set_readonly_mode
        EXPORTING
          readonly_mode          = cl_gui_textedit=>true
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ELSE.
      CALL METHOD wo_gte->set_readonly_mode
        EXPORTING
          readonly_mode          = cl_gui_textedit=>false
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ENDIF.
* Status Bar
    IF is_textdo-no_statusbar_disp EQ space.
      CALL METHOD wo_gte->set_statusbar_mode
        EXPORTING
          statusbar_mode         = cl_gui_textedit=>true
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
      IF is_textdo-status_bar_text <> space.
        CALL METHOD wo_gte->set_status_text
          EXPORTING
            status_text            = is_textdo-status_bar_text
          EXCEPTIONS
            error_cntl_call_method = 1
            OTHERS                 = 2.
      ENDIF.
    ELSE.
      CALL METHOD wo_gte->set_statusbar_mode
        EXPORTING
          statusbar_mode         = cl_gui_textedit=>false
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ENDIF.
  ENDIF.
Z_I_SYT_EDITOR~GET_TEXT_FROM_EDITOR
  IF wo_gte IS NOT INITIAL.
    convert_screen_to_text(
      IMPORTING
        et_texts      = rt_lines
           ).
  ENDIF.
Z_I_SYT_EDITOR~ADD_HISTORYLINE
  DATA: ls_hline TYPE tline,
        l_string TYPE string,
        l_index LIKE sy-index,
        l_lines TYPE i .
  DATA: ls_lines TYPE tline,
        lt_notes TYPE tsftext.
  rt_lines = it_lines.
  lt_notes = z_i_syt_editor~get_text_from_editor( is_theader = is_theader ).
  DESCRIBE TABLE lt_notes LINES l_lines.
  IF l_lines > 0 .
    CALL FUNCTION 'ZSY_USER_HISTORY_LINE'
      IMPORTING
        e_history_line = l_string.
    DESCRIBE TABLE it_lines LINES l_lines.
    ls_hline = l_string.
    IF i_sort_order = c_sort_notes_old_new.
*     If the sort order is oldest to newest append the lines to the
*     end of the table
      CLEAR ls_lines.
      ls_lines-tdformat = '*'.
      APPEND ls_lines TO rt_lines.
      APPEND ls_hline TO rt_lines.
      LOOP AT lt_notes INTO ls_lines.
        APPEND ls_lines TO rt_lines.
      ENDLOOP.
    ELSE.
*     If the sort order is newest to oldest insert the lines to the
*     top of the table
      l_index = 0.
      CASE i_sort_order.
        WHEN c_sort_notes_new_old.
          l_index = 1.
          INSERT ls_hline INTO rt_lines INDEX l_index.
        WHEN c_sort_notes_new_old_1.
          IF l_lines > 0 .
            l_index = 1.
            INSERT ls_hline INTO rt_lines INDEX l_index.
          ENDIF.
      ENDCASE.
      LOOP AT lt_notes INTO ls_lines.
        l_index = l_index + 1.
        INSERT ls_lines INTO rt_lines INDEX l_index.
      ENDLOOP.
* Add one empty line add the end if we have more then one notes:
      IF l_lines > 0 .
        l_index = l_index + 1.
        CLEAR ls_lines.
        ls_lines-tdformat = '*'.
        INSERT ls_lines INTO rt_lines INDEX l_index.
      ENDIF.
    ENDIF.
    IF i_no_refresh IS INITIAL.
      REFRESH lt_notes.
      z_i_syt_editor~refresh_text(
          is_theader = is_theader
          it_lines   = lt_notes
             ).
    ENDIF.
  ENDIF.
Z_I_SYT_EDITOR~SET_DISPLAY_OPTIONS_NOTES
  IF wo_gte IS BOUND.
* The notes are always read-only
    CALL METHOD wo_gte->set_readonly_mode
      EXPORTING
        readonly_mode          = cl_gui_textedit=>true
      EXCEPTIONS
        error_cntl_call_method = 1
        invalid_parameter      = 2
        OTHERS                 = 3.
* Never show the status bar of the notes
    CALL METHOD wo_gte->set_statusbar_mode
      EXPORTING
        statusbar_mode         = cl_gui_textedit=>false
      EXCEPTIONS
        error_cntl_call_method = 1
        invalid_parameter      = 2
        OTHERS                 = 3.
* Display of the notes tool bar
    IF is_textdo-display_notes_toolbar EQ abap_true.
      CALL METHOD wo_gte->set_toolbar_mode
        EXPORTING
          toolbar_mode           = cl_gui_textedit=>true
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ELSE.
      CALL METHOD wo_gte->set_toolbar_mode
        EXPORTING
          toolbar_mode           = cl_gui_textedit=>false
        EXCEPTIONS
          error_cntl_call_method = 1
          invalid_parameter      = 2
          OTHERS                 = 3.
    ENDIF.
  ENDIF.
Z_I_SYT_EDITOR~CONVERT_TEXT
  DATA: ls_text      TYPE tline,
        lt_ascii     TYPE tdtab_c132,
        ls_ascii(132) TYPE c,
        l_ascii(132) TYPE c,
        l_linesize   TYPE itctk-tdlinesize.
  l_linesize = 132.
  CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
   EXPORTING
*   CODEPAGE                = '0000'
      formatwidth             = l_linesize
*   language                = sy-langu
*   TABLETYPE               = 'ASC'
*   TAB_SUBSTITUTE          = ' '
*   LF_SUBSTITUTE           = ' '
*   REPLACE_SYMBOLS         = 'X'
*   REPLACE_SAPCHARS        = 'X'
   IMPORTING
*   FORMATWIDTH_E           =
*    x_datatab               =
      c_datatab               = lt_ascii
*   X_SIZE                  =
   TABLES
      itf_lines               = it_lines
   EXCEPTIONS
      invalid_tabletype       = 1
      OTHERS                  = 2   .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    CASE i_textconv.
      WHEN z_i_syt_editor~c_normal.
        LOOP AT lt_ascii INTO ls_ascii.
          CLEAR ls_text.
          ls_text-tdformat = '*'.
          ls_text-tdline   = ls_ascii.
          INSERT ls_text INTO TABLE et_lines.
          IF l_ascii IS NOT INITIAL AND l_ascii+131(1) = space
             AND ls_ascii(1) <> space.
            CONCATENATE e_string ls_ascii INTO e_string SEPARATED BY ' '.
          ELSE.
            CONCATENATE e_string ls_ascii INTO e_string.
          ENDIF.
          l_ascii = ls_ascii.
        ENDLOOP.
      WHEN OTHERS.
        LOOP AT lt_ascii INTO ls_ascii.
          CLEAR ls_text.
          ls_text-tdformat = '*'.
          ls_text-tdline   = ls_ascii.
          INSERT ls_text INTO TABLE et_lines.
          IF l_ascii IS NOT INITIAL AND l_ascii+131(1) = space
             AND ls_ascii(1) <> space.
            CONCATENATE e_string ls_ascii INTO e_string SEPARATED BY ' '.
          ELSE.
            CONCATENATE e_string ls_ascii INTO e_string.
          ENDIF.
          l_ascii = ls_ascii.
        ENDLOOP.
    ENDCASE.
  ENDIF.

So now we have one editor and the basic class. We need now only a bit more and we can create the first small sample program.

Next class we need is Z_C_SYT_TEXT_OBJECT. It inherits from Z_C_SYT_TEXT. No method is redefined.
 

Methodes

 

 

 

 

Method

Level

Visibility

Methode type

Description

GET_TEXT_FORMATED

Instance Method

Public

              

Get text in specified format

SAVE_TEXT

Instance Method

Public

              

Save Text

CONSTRUCTOR

Instance Method

Public


Constructor

FREE

Instance Method

Public

              

Free

GET_LINE_COUNT

Instance Method

Public

              

Returns number oflines now and at creation

GET_IS_MODIFIED

Instance Method

Public

              

Returns true if text has been changed othewrise false

SET_DISPLAY_ATTRIBUTES

Instance Method

Public

              

Set  Display Attributes

GET_DISPLAY_ATTRIBUTES

Instance Method

Public

              

Get Display Attributes

READ_TEXT

Instance Method

Public

              

Read Text

READ_TEXT_ASCII

Instance Method

Public

              

Read Text in ascii form

DELETE_TEXT

Instance Method

Public

              

Delete Text

AFTER_SAVE

Instance Method

Protected

              

After Save

FULL_SCREEN_EDIT_TEXT

Instance Method

Protected

               

Show Full Screen Edit Text for Batch Input

TEXT_VALIDATIONS

Instance Method

Protected

              

Text Validations

CREATE_CONTAINER

Instance Method

Protected

              

Check parameters and create container

FILL_DESCRIPTIONS

Instance Method

Protected

              

Fill fields descr1 and descr2

UPDATE_TEXT

Instance Method

Protected

              

Update text into recording structure


The added attributes for Z_C_SYT_TEXT_OBJECT are:

Attributes

 

 

 

 

 

Attribute

Level

Visibility

Typing

Associated type

Description

WS_TOBJECTV

Instance Attribute

Public

Type

ZSYT_TOBJECTV

Text Objects

W_LINES_START

Instance Attribute

Public

Type

I

                                                      

WS_TEXTDO

Instance Attribute

Protected

Type

ZSYT_S_TEXT_DISP_OPT

Text Object Display Options

WS_TEXTF

Instance Attribute

Protected

Type

ZSYT_S_TEXTS_FIELDS

Fields needed for Texts

WS_TEXTS

Instance Attribute

Protected

Type

ZSYT_S_TEXT_KEY_FIELDS

Key fields for text's

WS_THEADER

Instance Attribute

Protected

Type

THEAD

SAPscript: Text Header

WC_TEXTEDITOR

Instance Attribute

Protected

Type Ref To

Z_I_SYT_EDITOR

SAP TextEdit Control

WC_TEXTEDITORN

Instance Attribute

Protected

Type Ref To

Z_I_SYT_EDITOR

SAP TextEdit Control

WT_TEXTS

Instance Attribute

Protected

Type

TSFTEXT

Text Lines

W_NODISPLAY

Instance Attribute

Protected

Type

FLAG

No screen display of text opbject

WC_PARENT

Instance Attribute

Protected

Type Ref To

CL_GUI_CONTAINER

Container for Custom Controls in the Screen Area

WT_NOTES

Instance Attribute

Protected

Type

TSFTEXT

Note Lines

WC_PARENT2

Instance Attribute

Protected

Type Ref To

CL_GUI_CONTAINER

Reduced Version of Splitter Container Control

W_DESCR1

Instance Attribute

Protected

Type

ZSYT_TOBJECTV-DESCR1

Description 132

W_DESCR2

Instance Attribute

Protected

Type

ZSYT_TOBJECTV-DESCR1

Description 132

WS_TOBJECT_MD

Instance Attribute

Protected

Type

ZSYT_S_TOBJECT_MD

Master for data for text object

WC_SPLITTER

Instance Attribute

Protected

Type Ref To

CL_GUI_SPLITTER_CONTAINER

Splitter Control

WC_PARENT1

Instance Attribute

Protected

Type Ref To

CL_GUI_CONTAINER

Abstract Container for GUI Controls

W_IS_MODIFIED

Instance Attribute

Protected

Type

I

If text has been changed

LT_TEXT_DATA

Static Attribute

Protected

Type

ZSYT_T_TEXT_DATA

Text data for all text in text objects


Here are the parameters of the methods: 
 

CONSTRUCTOR

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTS



X

Type

ZSYT_S_TEXT_KEY_FIELDS

 

Fields needed for Texts

IS_TEXTF




Type

ZSYT_S_TEXTS_FIELDS

 

Key fields for text's

 

 

 

 

 

 

 

 

GET_TEXT_FORMATED

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_TEXTCONV

Importing


X

Type

ZZTEXTCONV

' '

Conversion types for text object

ET_LINES

Exporting



Type

TSFTEXT

 

Text

ET_SOLI

Exporting



Type

SOLI_TAB

 

Objcont and Objhead as Table Type

E_STRING

Exporting



Type

STRING

 

As string

 

 

 

 

 

 

 

 

SAVE_TEXT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

I_COMMIT

Importing


X

Type

FLAG

 

General flag

IS_TEXTS

Importing


X

Type

ZSYT_S_TEXT_KEY_FIELDS

 

Key fields for text's

RT_TEXTS

Returning



Type

TSFTEXT

 

SAPscript: Text Header

 

 

 

 

 

 

 

 

GET_LINE_COUNT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

E_LINES_NOW

Exporting



Type

I

 

                                                     

E_LINES_START

Exporting



Type

I

 

                                                     

 

 

 

 

 

 

 

 

GET_IS_MODIFIED

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

R_IS_MODIFIED

Returning



Type

I

 

If text has been modified

 

 

 

 

 

 

 

 

SET_DISPLAY_ATTRIBUTES

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTDO

Importing



Type

ZSYT_S_TEXT_DISP_OPT

 

Text Object Display Options

 

 

 

 

 

 

 

 

GET_DISPLAY_ATTRIBUTES

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

ES_TEXTDO

Exporting



Type

ZSYT_S_TEXT_DISP_OPT

 

Text Object Display Options

 

 

 

 

 

 

 

 

READ_TEXT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

ES_HEADER

Exporting



Type

THEAD

 

Text Header

ET_TLINE

Exporting



Type

TSFTEXT

 

Smart Forms: Text

ES_TOBJECTV

Exporting



Type

ZSYT_TOBJECTV

 

Text objects value table

 

 

 

 

 

 

 

 

FULL_SCREEN_EDIT_TEXT

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IT_TEXTS

Importing



Type

TSFTEXT

 

Text Lines

 

 

 

 

 

 

 

 

TEXT_VALIDATIONS

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IS_TEXTS

Importing



Type

ZSYT_S_TEXT_KEY_FIELDS

 

Key fields for text's

 

 

 

 

 

 

 

 

CREATE_CONTAINER

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IC_PARENT

Importing


X

Type Ref To

CL_GUI_CONTAINER

     

Container for Custom Controls in the Screen Area

I_CONTAINER

Importing


X

Type

C

 

 

 

 

 

 

 

 

 

 

UPDATE_TEXT

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

R_SUBRC

Returning



Type

SUBRC

 

Subroutines for return code


Now the code for all methods of Z_C_SYT_TEXT_OBJECT is next.
Z_C_SYT_TEXT_OBJECT->GET_TEXT_FORMATED

  DATA: l_string TYPE string,
        ls_soli  TYPE soli.
  DATA: l_length TYPE i .
  DATA: lt_texts TYPE tsftext.

  REFRESH et_lines.
  REFRESH et_soli.
  CLEAR e_string.

* We have to get it from the editor it is the latest and greatest if we can.
  lt_texts = wc_texteditor->get_text_from_editor( is_theader = ws_theader ).
  IF lt_texts IS INITIAL.
    lt_texts = wt_texts.
  ENDIF.
* Still no text found; lets get back to the database.
  IF lt_texts IS INITIAL.
    read_text(
       IMPORTING
         et_tline    = lt_texts  ).
  ENDIF.

  wc_texteditor->convert_text(
    EXPORTING
      i_textconv = i_textconv
      it_lines   = lt_texts
     IMPORTING
       et_lines   = et_lines
       e_string   = e_string
         ).
  l_string = e_string.

  DO.
    CLEAR ls_soli.
    IF STRLEN( l_string ) > 255.
      ls_soli-line = l_string(255).
      APPEND ls_soli TO et_soli .
      l_length = STRLEN( l_string ) - 255 .
      l_string = l_string+255(l_length).
    ELSE.
      ls_soli-line = l_string.
      APPEND ls_soli TO et_soli.
      EXIT.
    ENDIF.
  ENDDO. 

 Z_C_SYT_TEXT_OBJECT->SAVE_TEXT
  DATA: l_subrc TYPE subrc,
        l_lines TYPE i.

  w_is_modified = get_is_modified( ) .

  text_validations( EXPORTING is_texts = is_texts ).

* If the table is filled, update the text and fill in table
* zsyi_tobjectv with the text information including line 1 and line 2
* of the text.
  DESCRIBE TABLE wt_texts LINES l_lines.

  IF  ws_textdo-display_only <> abap_true AND
      w_is_modified = c_true.

    l_subrc = update_text( ).

    IF l_subrc EQ 0.
      ws_tobjectv-textname   = ws_theader-tdname.
      ws_tobjectv-textid     = ws_theader-tdid.
      ws_tobjectv-textobject = ws_theader-tdobject.
      ws_tobjectv-spras = ws_theader-tdspras.
      IF l_lines GT 0 .
        ws_tobjectv-text_l = abap_true.
      ELSE.
        CLEAR ws_tobjectv-text_l.
      ENDIF.
      ws_tobjectv-ersda = sy-datlo.
      ws_tobjectv-ernam = w_uname.
      ws_tobjectv-laeda = sy-datlo.
      ws_tobjectv-aenam = w_uname.

      fill_descriptions( ) .

      IF l_lines GT 0 OR
         w_descr1 NE space OR
         w_descr2 NE space OR
         w_descr1 IS NOT INITIAL OR
         w_descr2 IS NOT INITIAL.

        INSERT zsyt_tobjectv FROM ws_tobjectv.

        IF sy-subrc NE 0.
          UPDATE zsyt_tobjectv SET  spras     = ws_theader-tdspras
                                    descr1    = ws_tobjectv-descr1
                                    descr2    = ws_tobjectv-descr2
                                    text_l    = ws_tobjectv-text_l
                                    laeda     = sy-datlo
                                    aenam     = w_uname
                               WHERE textname = ws_theader-tdname
                                 AND textid   = ws_theader-tdid.
        ENDIF.
      ELSE.
* User deleted the whole text; we also delete the record in zsy_tobjectv
        DELETE FROM zsyt_tobjectv
               WHERE textname = ws_theader-tdname
                 AND textid   = ws_theader-tdid.
      ENDIF.
    ELSE.
* error during update?????
    ENDIF.
  ENDIF.

  CALL METHOD me->after_save.

  IF i_commit EQ abap_true.
    COMMIT WORK.
  ENDIF.

  rt_texts = wt_texts.

 Z_C_SYT_TEXT_OBJECT->CONSTRUCTOR
 

 CALL METHOD super->constructor.

  CALL METHOD get_text_name
    EXPORTING
      is_textf       = is_textf
      is_texts       = is_texts
    IMPORTING
      e_tname        = ws_theader-tdname
      es_tobject_md  = ws_tobject_md
    EXCEPTIONS
      config_missing = 1
      OTHERS         = 2.

  IF sy-subrc EQ 0 .
    MOVE-CORRESPONDING ws_tobject_md to ws_theader.

    read_tobjectv(
      IMPORTING
         es_tobjectv = ws_tobjectv
      CHANGING
        cs_theader  = ws_theader
           ).
    ws_textf  = is_textf.
    ws_texts  = is_texts.
  ELSE.
    RAISE error.
  ENDIF.

  APPEND me TO wt_text_pointers.
FREE
  IF NOT wc_texteditor IS INITIAL.
    CALL METHOD wc_texteditor->free.
  ENDIF.
  IF NOT wc_texteditorn IS INITIAL.
    CALL METHOD wc_texteditorn->free.
  ENDIF.
  IF NOT wc_parent2 IS INITIAL.
    CALL METHOD wc_parent2->free.
  ENDIF.
  IF NOT wc_parent IS INITIAL.
    CALL METHOD wc_parent->free.
  ENDIF.

  REFRESH: wt_notes,
           wt_texts.

  CLEAR: wc_texteditor,
         wc_texteditorn,
         wc_parent,
         wc_parent.

  DELETE TABLE wt_text_pointers FROM me.
GET_LINE_COUNT
  wc_texteditor->get_line_count(
     IMPORTING
       e_lines_now   =  e_lines_now
       e_lines_start =  e_lines_start
         ).
GET_IS_MODIFIED
  w_is_modified = c_false.

  IF wc_texteditor IS BOUND.
    w_is_modified = wc_texteditor->get_is_modified( ).
  ENDIF.

  r_is_modified = w_is_modified.
GET_DISPLAY_ATTRIBUTES
  es_textdo = ws_textdo.
READ_TEXT
  DATA: ls_text_data TYPE zsyt_s_text_data.

  READ TABLE lt_text_data INTO ls_text_data
           WITH TABLE KEY
                tdid     = ws_theader-tdid
                tdspras  = ws_theader-tdspras
                tdname   = ws_theader-tdname
                tdobject = ws_theader-tdobject.

  IF sy-subrc NE 0 .
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        client                  = sy-mandt
        id                      = ws_theader-tdid
        language                = ws_theader-tdspras
        name                    = ws_theader-tdname
        object                  = ws_theader-tdobject
      IMPORTING
        header                  = ws_theader
      TABLES
        lines                   = wt_texts
      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.
* ?????
    ELSE.
      ws_theader-tdlinesize = ws_tobject_md-tdlinesize.
    ENDIF.
  ELSE.
    wt_texts = ls_text_data-tline.
  ENDIF.

  et_tline    = wt_texts.
  es_tobjectv = ws_tobjectv.
  es_header   = ws_theader.
DELETE_TEXT
* Delete the text and the table entry of zsyi_tobjectv
  CALL FUNCTION 'DELETE_TEXT'
    EXPORTING
      id              = ws_theader-tdid
      language        = ws_theader-tdspras
      name            = ws_theader-tdname
      object          = ws_theader-tdobject
      savemode_direct = 'X'
    EXCEPTIONS
      not_found       = 1
      OTHERS          = 2.

  DELETE FROM zsyt_tobjectv WHERE textname = ws_theader-tdname
                              AND textid   = ws_theader-tdid.

  DELETE lt_text_data
           WHERE tdid     = ws_theader-tdid
           AND   tdspras  = ws_theader-tdspras
           AND   tdname   = ws_theader-tdname
           AND   tdobject = ws_theader-tdobject.
 

FULL_SCREEN_EDIT_TEXT
  CALL FUNCTION 'EDIT_TEXT'
       EXPORTING
            header        = ws_theader
            LINE_EDITOR   = abap_true
       TABLES
            lines         = it_texts
       EXCEPTIONS
            id            = 1
            language      = 2
            linesize      = 3
            name          = 4
            object        = 5
            textformat    = 6
            communication = 7
            OTHERS        = 8.
  IF sy-subrc <> 0.
  ENDIF.
 

TEXT_VALIDATIONS
  IF is_texts IS NOT INITIAL AND
     is_texts <> ws_texts.
* We could copy so we force a save
    w_is_modified = c_true.

    CALL METHOD get_text_name
      EXPORTING
        is_textf         = ws_textf
        is_texts         = is_texts
      IMPORTING
        e_tname          = ws_theader-tdname
        es_tobject_md    = ws_tobject_md
      EXCEPTIONS
        config_missing = 1
        OTHERS         = 2.

    ws_texts = is_texts.

  ENDIF.
 

CREATE_CONTAINER
  DATA: lc_parent TYPE REF TO cl_gui_custom_container.

  IF ic_parent IS INITIAL.
    CREATE OBJECT lc_parent
      EXPORTING
        container_name = i_container
      EXCEPTIONS
        OTHERS         = 1.
    IF sy-subrc <> 0.
      RAISE no_container.
    ENDIF.
    wc_parent = lc_parent.
  ELSE.
    wc_parent = ic_parent.
  ENDIF.

  IF wc_parent IS INITIAL.
    RAISE no_container.
  ENDIF.
 

FILL_DESCRIPTIONS
  DATA: l_part1 TYPE string,
        l_part2 TYPE string.

  CLEAR: ws_tobjectv-descr1,
         ws_tobjectv-descr1.

  wc_texteditor->fill_description(
     exporting
       is_header = ws_theader
       it_text   = wt_texts
     IMPORTING
       e_part1   = l_part1
       e_part2   = l_part2
         ).

  IF STRLEN( l_part1 ) > 0 .
    ws_tobjectv-descr1 = l_part1.
  ELSE.
    IF w_descr1 NE space OR w_descr1 IS NOT INITIAL.
      ws_tobjectv-descr1     = w_descr1.
    ENDIF.
  ENDIF.
  IF STRLEN( l_part2 ) > 0 .
    ws_tobjectv-descr2 = l_part2.
  ELSE.
    IF w_descr2 NE space OR w_descr2 IS NOT INITIAL.
      ws_tobjectv-descr2     = w_descr2.
    ENDIF.
  ENDIF.

UPDATE_TEXT
  DATA: ls_text_data TYPE zsyt_s_text_data.
  ls_text_data-tline = wt_texts.
  CASE ws_tobject_md-editor.
    WHEN OTHERS.
      CALL FUNCTION 'ZSYO_ACTUALIZA_TEXTO'
        EXPORTING
          zheader               = ws_theader
        TABLES
          lines                 = ls_text_data-tline
        EXCEPTIONS
          actualizacion_fallida = 1
          OTHERS                = 2.
      IF sy-subrc = 0.
        DELETE lt_text_data WHERE tdid     = ws_theader-tdid
                            AND   tdspras  = ws_theader-tdspras
                            AND   tdname   = ws_theader-tdname
                            AND   tdobject = ws_theader-tdobject.
        MOVE-CORRESPONDING ws_theader TO  ls_text_data.
        ls_text_data-tline = wt_texts.
        INSERT ls_text_data INTO TABLE lt_text_data.
      ENDIF.
  ENDCASE.

So now we need three more little class and then only the sample program. The following three are used to create the individual text objects. The first we crate is Z_C_SYT_TEXT_BOX and it inherits from Z_C_SYT_TEXT_OBJECT. SET_DISPLAY_ATTRIBUTES is redefined.   

Methodes

 

 

 

 

Method

Level

Visibility

Methode type

Description

CONSTRUCTOR

Instance Method

Public


CONSTRUCTOR

TEXT_TEXTBOX

Instance Method

Protected

                  

Create textbox without notes logic

SET_DISPLAY_ATTRIBUTES

Instance Method

Public

                  

Set  Display Attributes


This is a parameter change of the constructor:

CONSTRUCTOR

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IC_PARENT

 

 

X

Type Ref To

CL_GUI_CUSTOM_CONTAINER

                                                          

Container for Custom Controls in the Screen Area

I_CONTAINER

 

 

X

Type

C

                                                          

                                                

IS_TEXTS

 

 

 

Type

ZSYT_S_TEXT_KEY_FIELDS

                                                           

Fields needed for Texts

IS_TEXTF

 

 

 

Type

ZSYT_S_TEXTS_FIELDS

                                                          

Key fields for text's

IS_TEXTDO

 

 

 

Type

ZSYT_S_TEXT_DISP_OPT

                                                           

Text Object Display Options



And one more Attribute 

Attributes

 

 

 

 

 

 

Attribute

Level

Visibility

Typing

Associated type

Description

Initial value

W_SORT_ORDER

Instance Attribute

Protected

Type

ZZSORT_ORDER

Notes Sort Order

 


SET_DISPLAY_ATTRIBUTES
  CALL METHOD super->set_display_attributes
    EXPORTING
      is_textdo = is_textdo.

  IF wc_texteditor IS NOT INITIAL.

    wc_texteditor->set_display_options( is_textdo = is_textdo  ).

  ENDIF.

  ws_textdo = is_textdo.
CONSTRUCTOR

  CALL METHOD super->constructor
    EXPORTING
      is_texts     = is_texts
      is_textf     = is_textf
    EXCEPTIONS
      error        = 1
      others       = 2.

  IF sy-subrc <> 0.
    RAISE error.
  ENDIF.

  create_container(
     EXPORTING
       ic_parent    = ic_parent
       i_container  = i_container
     EXCEPTIONS
       no_container = 1
         ).

  IF sy-subrc <> 0.
    RAISE error.
  ENDIF.

  CALL METHOD read_text
    IMPORTING
      et_tline = wt_texts.

  ws_textdo = is_textdo.
 

TEXT_TEXTBOX
  create_editor( EXPORTING     i_editor = ws_tobject_md-editor
                 CHANGING cc_texteditor = wc_texteditor ).

  wc_texteditor->initialize(
      is_theader    = ws_theader
      ic_parent     = wc_parent
      it_lines      = wt_texts
         ).

*     Show the display based on the attributes passed in
  CALL METHOD set_display_attributes
    EXPORTING
      is_textdo = ws_textdo.

So two more class to go. Z_C_SYT_TEXT_NOTES inherits from Z_C_SYT_TEXT_BOX. The method  TEXT_VALIDATIONS gets redefined.

Methodes Z_C_SYT_TEXT_NOTES

 

 

 

 

Method

Level

Visibility

Methode type

Description

TEXT_VALIDATIONS

Instance Method

Protected

               

Text Validations

CONSTRUCTOR

Instance Method

Public


CONSTRUCTOR

ADD_HISTORYLINE

Instance Method

Public

               

Add the history line for notes logic display during change

SET_DISPLAY_ATTRIBUTES_NOTES

Instance Method

Protected

               

Get Display Attributes of the display of notes


No changes on the constructor.
 

ADD_HISTORYLINE

 

 

 

 

 

 

 

Parameter

Type

P

O

Typing Method

Associated Type

Default Value

Description

IT_LINES

Importing



Type

TSFTEXT

                                                      

Smart Forms: Text

RT_LINES

Returning



Type

TSFTEXT

                                                      

Smart Forms: Text

 

 

 

 

 

 

 

 


No new attributes. Only the following code
  TEXT_VALIDATIONS
  DATA: l_modified TYPE i,
        l_xstring  TYPE xstring.

  CALL METHOD super->text_validations( is_texts = is_texts ) .

* Lets see if we have to do anything?
  l_modified = get_is_modified( ).

  IF l_modified = c_true.
*     If the program is being run online, get the text the user typed
    IF w_offline = c_false.
      wt_texts = wc_texteditor->add_historyline(
          i_sort_order = w_sort_order
          is_theader   = ws_theader
          it_lines     = wt_texts
             ).

      REFRESH wt_notes.
    ENDIF.
  ENDIF.
CONSTRUCTOR
  CALL METHOD super->constructor
    EXPORTING
      ic_parent    = ic_parent
      i_container  = i_container
      is_texts     = is_texts
      is_textf     = is_textf
      is_textdo    = is_textdo
    EXCEPTIONS
      error        = 1
      no_container = 2
      OTHERS       = 3.

  IF sy-subrc NE 0 .
    RAISE error.
  ENDIF.

* Lets set the default notes position if no is requested
  IF ws_textdo-notes_position IS INITIAL.
    ws_textdo-notes_position = c_bottom.
  ENDIF.
* If general display only mode is set
  IF is_textf-display_only = abap_true.
    ws_textdo-display_only = abap_true.
  ENDIF.

* If we have no desired value lets set it.
  IF ws_textdo-sash_position IS INITIAL.
    ws_textdo-sash_position = 50.
  ENDIF.
  IF ws_tobject_md-sort_order IS INITIAL.
    ws_tobject_md-sort_order =   c_sort_notes_new_old.
  ENDIF.
  IF w_sort_order IS INITIAL.
    w_sort_order = ws_tobject_md-sort_order.
  ENDIF.
ADD_HISTORYLINE
  rt_lines = wc_texteditor->add_historyline(
      i_sort_order = w_sort_order
      i_no_refresh = abap_true
      is_theader   = ws_theader
      it_lines     = it_lines
         ).
SET_DISPLAY_ATTRIBUTES_NOTES
  IF wc_texteditorn IS NOT INITIAL.

    wc_texteditorn->set_display_options_notes( is_textdo = ws_textdo  ).

  endif.
We are almost there: Z_C_SYT_TEXT_2BOX_NOTES is the last class we need for the sample program. Z_C_SYT_TEXT_2BOX_NOTES inherits from Z_C_SYT_TEXT_NOTES.

 The methods SET_DISPLAY_ATTRIBUTES and AFTER_SAVE are redefined. 
 

Methodes

 

 

 

 

Method

Level

Visibility

Methode type

Description

SET_DISPLAY_ATTRIBUTES

Instance Method

Public

               

Set  Display Attributes

AFTER_SAVE

Instance Method

Protected

               

After Save

CONSTRUCTOR

Instance Method

Public


Constructor

NOTES_TEXTBOX

Instance Method

Private

               

Create texbox with notes logic

SET_POSITION

Instance Method

Private

               

Set position for splitt



No new attributes, so only the code and then we can look into a sample program.
SET_DISPLAY_ATTRIBUTES

  super->set_display_attributes(
     EXPORTING
       is_textdo = is_textdo
       ).
  IF is_textdo-display_only = abap_true AND
    wc_splitter IS NOT INITIAL.
    CASE ws_textdo-notes_position.
      WHEN c_left.
        wc_splitter->set_column_width(
          EXPORTING
            id             = 1
            width          = 100
            ).
      WHEN c_right.
        wc_splitter->set_column_width(
          EXPORTING
            id             = 1
            width          = 0
            ).
      WHEN c_top.
        wc_splitter->set_row_height(
          EXPORTING
            id             = 1
            height         = 100
            ).
      WHEN c_bottom.
        wc_splitter->set_row_height(
          EXPORTING
            id             = 1
            height         = 0
            ).
    ENDCASE.
  ELSEIF wc_splitter IS NOT INITIAL.
* If we have no desired value lets set it.
    IF ws_textdo-sash_position IS INITIAL.
      ws_textdo-sash_position = 50.
    ENDIF.
* lets set the correct position
    set_position( ).
  ENDIF.
  set_display_attributes_notes( ).
 

  AFTER_SAVE
  DATA: l_lines TYPE i,
        l_width TYPE i ,
        l_xstring TYPE xstring,
        l_exception_text       TYPE string.

  CALL METHOD super->after_save.

* Show the texts to the screen again (if objects only)
  IF w_offline EQ '0' AND sy-batch NE abap_true.

    DESCRIBE TABLE wt_texts LINES l_lines.

    IF wc_texteditorn IS NOT INITIAL.
      wc_texteditorn->refresh_text( EXPORTING
                                         is_theader = ws_theader
                                         it_lines   = wt_texts  ).
    ENDIF.

    IF l_lines GT 0.
      IF ws_textdo-sash_position IS INITIAL.
        ws_textdo-sash_position = 50 .
      ENDIF.
      set_position( ).
      IF wc_texteditor IS NOT INITIAL.
        wc_texteditor->refresh_text( EXPORTING
                                           is_theader = ws_theader
                                           it_lines   = wt_notes  ).
      ENDIF.
    ENDIF.
  ENDIF.
 

CONSTRUCTOR
  CALL METHOD super->constructor
    EXPORTING
      ic_parent   = ic_parent
      i_container = i_container
      is_texts    = is_texts
      is_textf    = is_textf
      is_textdo   = is_textdo
    EXCEPTIONS
      error    = 1
      OTHERS   = 2.

  IF sy-subrc NE 0 .
    RAISE error.
  ENDIF.

* First lets check if we are offline and need to show line text for batchinput
  IF ws_textdo-display_only IS INITIAL AND
     w_offline EQ '1' .

    CALL METHOD full_screen_edit_text
      EXPORTING
        it_texts = wt_notes.  "Show blank notes

  ELSE.
    notes_textbox( ).
  ENDIF.
 

NOTES_TEXTBOX
  DATA: l_lines TYPE i .

* Lets see if we have already text from the past
  DESCRIBE TABLE wt_texts LINES l_lines.

  IF ws_textdo-display_only EQ space  AND
     l_lines > 0 .
    IF ws_textdo-notes_position = c_left OR
       ws_textdo-notes_position = c_right.
      CREATE OBJECT wc_splitter
        EXPORTING
          parent  = wc_parent
          rows    = 1
          columns = 2.
      wc_splitter->set_border(
        EXPORTING
          border  = cl_gui_cfw=>false
          ).
      wc_splitter->get_container(
        EXPORTING
          row            = 1
          column         = 1
        RECEIVING
          container = wc_parent1
          ).
      wc_splitter->set_column_sash(
        EXPORTING
          id             = 1
          type           = cl_gui_splitter_container=>type_movable
          value          = c_false
          ).
      wc_splitter->get_container(
        EXPORTING
          row            = 2
          column         = 1
        RECEIVING
          container = wc_parent2
          ).
    ELSE.
      CREATE OBJECT wc_splitter
        EXPORTING
          parent  = wc_parent
          rows    = 2
          columns = 1.
      wc_splitter->set_border(
        EXPORTING
          border  = cl_gui_cfw=>false
          ).
      wc_splitter->get_container(
        EXPORTING
          row            = 1
          column         = 1
        RECEIVING
          container = wc_parent1
          ).
      wc_splitter->set_row_sash(
        EXPORTING
          id             = 1
          type           = cl_gui_splitter_container=>type_movable
          value          = c_false
          ).
      wc_splitter->get_container(
        EXPORTING
          row            = 2
          column         = 1
        RECEIVING
          container = wc_parent2
          ).
    ENDIF.
* Create Editor based on editor type:
    create_editor( EXPORTING     i_editor = ws_tobject_md-editor
                   CHANGING cc_texteditor = wc_texteditor ).
    create_editor( EXPORTING     i_editor = ws_tobject_md-editor
                   CHANGING cc_texteditor = wc_texteditorn ).

    IF ws_textdo-notes_position = c_top OR
     ws_textdo-notes_position = c_left.
      wc_texteditor->initialize(
          is_theader    = ws_theader
          ic_parent     = wc_parent2
          it_lines      = wt_notes
             ).
      wc_texteditorn->initialize(
          is_theader    = ws_theader
          ic_parent     = wc_parent1
          it_lines      = wt_texts
             ).
    ELSE.
      wc_texteditor->initialize(
          is_theader    = ws_theader
          ic_parent     = wc_parent1
          it_lines      = wt_notes
             ).
      wc_texteditorn->initialize(
          is_theader    = ws_theader
          ic_parent     = wc_parent2
          it_lines      = wt_texts
             ).
    ENDIF.
*     Show the display based on the attributes passed in
    CALL METHOD set_display_attributes
      EXPORTING
        is_textdo = ws_textdo.

*     Show the display of the notes based on the attributes passed in
    set_display_attributes_notes( ).

  ELSE.
    text_textbox( ).
  ENDIF.
 

SET_POSITION
  DATA: l_pos TYPE i .

  IF wc_splitter IS NOT INITIAL.
    l_pos = 100 - ws_textdo-sash_position .
    CASE ws_textdo-notes_position.
      WHEN c_left.
        wc_splitter->set_column_width(
          EXPORTING
            id             = 1
            width          = l_pos
            ).
      WHEN c_right.
        wc_splitter->set_column_width(
          EXPORTING
            id             = 1
            width          = ws_textdo-sash_position
            ).
      WHEN c_top.
        wc_splitter->set_row_height(
          EXPORTING
            id             = 1
            height         = l_pos
            ).
      WHEN c_bottom.
        wc_splitter->set_row_height(
          EXPORTING
            id             = 1
            height         = ws_textdo-sash_position
            ).
    ENDCASE.
  ENDIF.

To get the sample program ZSAMPLE_TEXT_OBJECT_SIMPLE to work, create in SE75 a new text object and text id. The program uses ZSY_TEXT with TO01 as ID.
In addition you have to create the entry in ZSYT_TTXOB accordingly.
333     ZSY_TEXT    TO01  MANDT          DOCNO04                                                                 132
So now the code:
ZSAMPLE_TEXT_OBJECT_SIMPLE
*&---------------------------------------------------------------------*
*& Report  ZSAMPLE_TEXT_OBJECT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zsample_text_object_simple.

INCLUDE ZSAMPLE_TEXT_OBJECT_SIMPLE_TOP.

START-OF-SELECTION.

END-OF-SELECTION.

  CALL SCREEN 100.

INCLUDE ZSAMPLE_TEXT_OBJECT_SIMPLE_PBO.

INCLUDE ZSAMPLE_TEXT_OBJECT_SIMPLE_PAI.

INCLUDE ZSAMPLE_TEXT_OBJECT_SIMPLE_F01.
ZSAMPLE_TEXT_OBJECT_SIMPLE_TOP
*&---------------------------------------------------------------------*
*&  Include           ZSAMPLE_TEXT_OBJECT_TOP
*&---------------------------------------------------------------------*
PARAMETERS: s_docno4 TYPE zsyt_s_text_key_fields-docno04 DEFAULT 1.

DATA: wo_notes      TYPE REF TO z_c_syt_text_2box_notes.

DATA: ok_code LIKE sy-ucomm.
ZSAMPLE_TEXT_OBJECT_SIMPLE_PBO
*----------------------------------------------------------------------*
***INCLUDE ZSAMPLE_TEXT_OBJECT_PBO .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '0100'.
  SET TITLEBAR '0100'.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  init  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init OUTPUT.

ENDMODULE.                 " init  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  create_object  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE create_object OUTPUT.
  PERFORM create_textbox_notes.
ENDMODULE.                 " create_object  OUTPUT
ZSAMPLE_TEXT_OBJECT_SIMPLE_PAI
*----------------------------------------------------------------------*
***INCLUDE ZSAMPLE_TEXT_OBJECT_PBO .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '0100'.
  SET TITLEBAR '0100'.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  init  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init OUTPUT.

ENDMODULE.                 " init  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  create_object  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE create_object OUTPUT.
  PERFORM create_textbox_notes.
ENDMODULE.                 " create_object  OUTPUT
ZSAMPLE_TEXT_OBJECT_SIMPLE_F01
*----------------------------------------------------------------------*
***INCLUDE ZSAMPLE_TEXT_OBJECT_F01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  create_textbox_notes
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_textbox_notes .
  DATA: ls_texts TYPE zsyt_s_text_key_fields,
        ls_textf TYPE zsyt_s_texts_fields,
        ls_textdo TYPE zsyt_s_text_disp_opt.

  IF wo_notes IS INITIAL.
* First key fields for the text object name
    ls_texts-mandt   = sy-mandt.
    ls_texts-docno04 = s_docno4.
* Key for text object
    ls_textf-tdobject = 'ZSY_TEXT'.
    ls_textf-tdid     = 'TO01'.
* Display options for text
    ls_textdo-no_toolbar_disp = ' '.
    ls_textdo-no_statusbar_disp = ' '.
    ls_textdo-status_bar_text = 'Text Box notes'.
    ls_textdo-display_only = ' '.
    ls_textdo-display_notes_toolbar = ' '.
    ls_textdo-notes_position = z_c_syt_text_1box=>c_bottom .

    CREATE OBJECT wo_notes
      EXPORTING
*    ic_parent    =
        i_container  = 'CONTAINER'
        is_texts     = ls_texts
        is_textf     = ls_textf
        is_textdo    = ls_textdo
*  EXCEPTIONS
*    no_container = 1
*    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.

  ENDIF.
ENDFORM.                    " create_textbox_notes
The screen 100 has just custom container for the editor and the gui status has the function codes defined for back, exit and save.
If you have any questions or I forgot something. Let me know.
In Part II I will add the code to implement this for a customer master text, to show how this can be used in standard SAP transactions.

1 Comment

  1. Unknown User (o2w3v6v)

    Thanks Rene.  Works perfectly.