on 05-23-2005 2:47 PM
Hello,
I'm writing a program where I want a long text box where the user can enter long descriptions. Does anyone know how to do this not using OO programming?
I thought I could do it using a table control but this won't wrap my text onto the next line.
Any ideas?
Thanks,
Gill
I know that you said, no OO, but I believe that this is the only way to do it. Here is a sample program which shows how easy it would be to do.
Create screen 100, and create a custom container in that screen. Name it CONTAINER. Create gui status 100 with Fcodes CHANGE, DISPLAY, and SAVE.
REPORT ZRICH_0001
NO STANDARD PAGE HEADING.
* Miscellanous Variables
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM.
* Variable for "Text Container" Abap Object
DATA: EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
X_EDITOR TYPE REF TO C_TEXTEDIT_CONTROL,
CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: WA_TEXT LIKE TLINE-TDLINE.
DATA: BEGIN OF LINES OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF LINES.
DATA: TEXTLINES LIKE TLINE-TDLINE OCCURS 0.
* Constants
CONSTANTS: TRUE(1) TYPE C VALUE 'X',
FALSE(1) TYPE C VALUE ' ',
YES(1) TYPE C VALUE 'J',
NO(1) TYPE C VALUE 'N'.
START-OF-SELECTION.
CALL SCREEN 100.
************************************************************************
* Module STATUS_0100 OUTPUT
************************************************************************
MODULE STATUS_0100 OUTPUT.
CLEAR: TEXTLINES. REFRESH: TEXTLINES.
CLEAR: LINES. REFRESH LINES.
* Initialize container
IF NOT CONTAINER IS INITIAL.
CALL METHOD CONTAINER->FREE.
ENDIF.
* Create Text Container
CREATE OBJECT CONTAINER
EXPORTING CONTAINER_NAME = 'CONTAINER'.
CREATE OBJECT EDITOR
EXPORTING PARENT = CONTAINER.
PERFORM SET_TEXT.
CASE SAVE_OK.
WHEN 'CHANGE'.
SET PF-STATUS '0100' EXCLUDING 'CHANGE'.
CALL METHOD EDITOR->SET_READONLY_MODE
EXPORTING READONLY_MODE = EDITOR->FALSE.
WHEN OTHERS.
SET PF-STATUS '0100' EXCLUDING 'DISPLAY'.
CALL METHOD EDITOR->SET_READONLY_MODE
EXPORTING READONLY_MODE = EDITOR->TRUE.
ENDCASE.
SET TITLEBAR '0100'.
ENDMODULE.
************************************************************************
* Module USER_COMMAND_0100 INPUT
************************************************************************
MODULE USER_COMMAND_0100 INPUT.
DATA: MODIFIED TYPE I.
SAVE_OK = OK_CODE.
CASE OK_CODE.
WHEN 'CHANGE' OR 'DISPLAY'.
CLEAR OK_CODE.
WHEN 'SAVE'.
CLEAR OK_CODE.
* Retrieve text from container
CALL METHOD EDITOR->GET_TEXT_AS_R3TABLE
EXPORTING
ONLY_WHEN_MODIFIED = C_TEXTEDIT_CONTROL=>FALSE
IMPORTING
TABLE = TEXTLINES
IS_MODIFIED = MODIFIED
EXCEPTIONS
OTHERS = 1.
* Write out contents of text editor
LEAVE TO LIST-PROCESSING.
LOOP AT TEXTLINES INTO WA_TEXT.
WRITE:/ WA_TEXT.
ENDLOOP.
WHEN 'BACK'.
CLEAR OK_CODE.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
************************************************************************
* FORM SET_TEXT
************************************************************************
FORM SET_TEXT.
LINES-TDLINE = 'Here we are filling the text editor - Line 1'.
APPEND LINES.
LINES-TDLINE = 'Here we are filling the text editor - Line 2'.
APPEND LINES.
LOOP AT LINES .
SHIFT LINES LEFT DELETING LEADING SPACE.
APPEND LINES TO TEXTLINES .
ENDLOOP.
* Fill container with text lines
CALL METHOD EDITOR->SET_TEXT_AS_R3TABLE
EXPORTING
TABLE = TEXTLINES
EXCEPTIONS
OTHERS = 1.
ENDFORM.
Regards,
Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd recommend Rich's way to implement it.
However there is also a lazy version: use statement 'EDITOR-CALL FOR itab.' Please keep in mind, that it's obsolete in release 6.40.
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.