Skip to Content
author's profile photo Former Member
Former Member

regarding 'READ_TEXT' FM

hi can anybody explain me the use of lines in fm read_text and how to loop at lines ,because in my sapscript only single text is getting printed for other lines items also .where as it is different for others line items .and how to pass this diff values to lines.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

id = 'A01'

language = 'E'

name = itab1-TDNAME

object = 'EKPO'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

tables

lines = LINESX

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8

thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 06:10 AM

    loop at linesx.

    call function 'WRITE_FROM.

    endloop.

    in script put like this.

    &t_linesx-tdline&

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 06:11 AM

    refer this code.

    ----


    ***INCLUDE ZSAP_DYNPR_TEXTEDITOR1_EXITI01 .

    ----


    &----


    *& Module EXIT INPUT

    &----


    • text

    ----


    &----


    *& Module USER_COMMAND_0300 INPUT

    &----


    • text

    ----


    MODULE USER_COMMAND_0300 INPUT.

    DATA: VAL1 TYPE I.

    DATA VAR(500) TYPE C.

    *// TEXT HEADER

    DATA: GT_HEAD LIKE THEAD,

    *// Text lines

    GT_TEXT LIKE STANDARD TABLE OF TLINE,

    GW_TEXT LIKE TLINE.

    • GT_HEAD-TDOBJECT = 'MVKE' .

    • GT_HEAD-TDID = '0001' .

    • GT_HEAD-TDSPRAS = SY-LANGU.

    • GT_HEAD-TDNAME = 'ivtl'.

    **

    CASE SY-UCOMM.

    WHEN 'INSERT'.

    clear sy-ucomm.

    *APPEND VAR TO I_TEXTTABLE.

    CALL METHOD TEXT_EDITOR2->GET_TEXT_AS_STREAM

    IMPORTING

    TEXT = I_TEXTTABLE

    IS_MODIFIED = VAL1

    EXCEPTIONS

    ERROR_DP = 1

    ERROR_CNTL_CALL_METHOD = 2

    OTHERS = 3.

    DATA HELP_TLINETAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

    CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'

    EXPORTING

    LANGUAGE = SY-LANGU

    TABLES

    TEXT_STREAM = I_TEXTTABLE

    ITF_TEXT = HELP_TLINETAB

    .

    GT_HEAD-TDOBJECT = 'MVKE' .

    GT_HEAD-TDID = '0001' .

    GT_HEAD-TDSPRAS = SY-LANGU.

    GT_HEAD-TDNAME = 'ivtl1'.

    *

    • GW_TEXT-TDFORMAT = '00'.

    • GW_TEXT-TDLINE = I_TEXTTABLE-LINE.

    • APPEND GW_TEXT TO GT_TEXT.

    CALL FUNCTION 'SAVE_TEXT'

    EXPORTING

    CLIENT = SY-MANDT

    HEADER = GT_HEAD

    INSERT = 'X'

    SAVEMODE_DIRECT = 'X'

    OWNER_SPECIFIED = ' '

    TABLES

    LINES = HELP_TLINETAB

    EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

    OBJECT = 4

    OTHERS = 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.

    commit work.

    CLEAR HELP_TLINETAB.

    REFRESH HELP_TLINETAB.

    CLEAR: I_TEXTTABLE.

    REFRESH I_TEXTTABLE.

    WHEN 'CHANGE'.

    clear sy-ucomm.

    CLEAR HELP_TLINETAB.

    REFRESH HELP_TLINETAB.

    CLEAR: I_TEXTTABLE.

    REFRESH I_TEXTTABLE.

    CALL FUNCTION 'READ_TEXT'

    EXPORTING

    CLIENT = SY-MANDT

    ID = '0001'

    LANGUAGE = SY-LANGU

    NAME = 'ivtl1'

    OBJECT = 'MVKE'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

    TABLES

    LINES = HELP_TLINETAB

    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.

    CLEAR I_TEXTTABLE.

    REFRESH I_TEXTTABLE.

    CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'

    EXPORTING

    LANGUAGE = SY-LANGU

    TABLES

    ITF_TEXT = HELP_TLINETAB

    TEXT_STREAM = I_TEXTTABLE

    .

    CALL METHOD TEXT_EDITOR2->SET_TEXT_AS_STREAM

    EXPORTING

    TEXT = I_TEXTTABLE

    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.

    CLEAR HELP_TLINETAB.

    REFRESH HELP_TLINETAB.

    CLEAR: I_TEXTTABLE.

    REFRESH I_TEXTTABLE.

    commit work.

    when 'EDIT'.

    clear sy-ucomm.

    **change

    *GT_HEAD-TDOBJECT = 'MVKE' .

    • GT_HEAD-TDID = '0001' .

    • GT_HEAD-TDSPRAS = SY-LANGU.

    • GT_HEAD-TDNAME = 'ivtl'.

    • GT_HEAD-tdlinesize = '72'.

    CALL FUNCTION 'DELETE_TEXT'

    EXPORTING

    • CLIENT = SY-MANDT

    ID = '0001'

    LANGUAGE = sy-langu

    NAME = 'ivtl1'

    OBJECT = 'MVKE'

    SAVEMODE_DIRECT = ' '

    • TEXTMEMORY_ONLY = ' '

    • LOCAL_CAT = ' '

    EXCEPTIONS

    NOT_FOUND = 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.

    ENDIF.

    commit work.

    break-point.

    CALL METHOD TEXT_EDITOR2->GET_TEXT_AS_STREAM

    IMPORTING

    TEXT = I_TEXTTABLE

    IS_MODIFIED = VAL1

    EXCEPTIONS

    ERROR_DP = 1

    ERROR_CNTL_CALL_METHOD = 2

    OTHERS = 3.

    break-point.

    • DATA HELP_TLINETAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

    CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'

    EXPORTING

    LANGUAGE = SY-LANGU

    TABLES

    TEXT_STREAM = I_TEXTTABLE

    ITF_TEXT = HELP_TLINETAB

    .

    GT_HEAD-TDOBJECT = 'MVKE' .

    GT_HEAD-TDID = '0001' .

    GT_HEAD-TDSPRAS = SY-LANGU.

    GT_HEAD-TDNAME = 'ivtl1'.

    CALL FUNCTION 'SAVE_TEXT'

    EXPORTING

    CLIENT = SY-MANDT

    HEADER = GT_HEAD

    INSERT = 'X'

    SAVEMODE_DIRECT = 'X'

    OWNER_SPECIFIED = ' '

    TABLES

    LINES = HELP_TLINETAB

    EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

    OBJECT = 4

    OTHERS = 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.

    commit work.

    CLEAR HELP_TLINETAB.

    REFRESH HELP_TLINETAB.

    CLEAR: I_TEXTTABLE.

    REFRESH I_TEXTTABLE.

    break-point.

    **GT_HEAD-TDOBJECT = 'MVKE' .

    • GT_HEAD-TDID = '0001' .

    • GT_HEAD-TDSPRAS = SY-LANGU.

    • GT_HEAD-TDNAME = 'ivtl'.

    • GT_HEAD-tdlinesize = '72'.

    *

    *CALL FUNCTION 'EDIT_TEXT'

    • EXPORTING

    • DISPLAY = ' '

    • EDITOR_TITLE = ' '

  • header = GT_HEAD

    • PAGE = ' '

    • WINDOW = ' '

    • save = 'X'

    • LINE_EDITOR = ' '

    • CONTROL = ' '

    • PROGRAM = ' '

    • LOCAL_CAT = ' '

    • IMPORTING

    • FUNCTION =

    • NEWHEADER =

    • RESULT =

  • TABLES

  • lines = HELP_TLINETAB

  • EXCEPTIONS

  • id = 1

  • language = 2

  • linesize = 3

  • name = 4

  • object = 5

  • textformat = 6

  • communication = 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.

  • *

    *

    *

    • CALL METHOD TEXT_EDITOR2->SET_TEXT_AS_STREAM

    • EXPORTING

    • TEXT = I_TEXTTABLE

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

  • *

    *break-point.

    *change

    • CLEAR HELP_TLINETAB.

    • REFRESH HELP_TLINETAB.

    • CLEAR: I_TEXTTABLE.

    • REFRESH I_TEXTTABLE.

    *

    • CALL FUNCTION 'READ_TEXT'

    • EXPORTING

    • CLIENT = SY-MANDT

    • ID = '0001'

    • LANGUAGE = SY-LANGU

    • NAME = 'ivtl'

    • OBJECT = 'MVKE'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • TABLES

  • LINES = HELP_TLINETAB

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

  • *

    • CLEAR I_TEXTTABLE.

    • REFRESH I_TEXTTABLE.

    *

    • CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'

    • EXPORTING

    • LANGUAGE = SY-LANGU

    • TABLES

    • ITF_TEXT = HELP_TLINETAB

    • TEXT_STREAM = I_TEXTTABLE

    • .

    *

    *

    • CALL METHOD TEXT_EDITOR2->SET_TEXT_AS_STREAM

    • EXPORTING

    • TEXT = I_TEXTTABLE

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

  • *

    *break-point.

    *CALL FUNCTION 'INIT_TEXT'

    • EXPORTING

    • id = '0001'

    • language = sy-langu

    • name = 'ivtl'

    • object = 'MVKE'

    • IMPORTING

    • header = GT_HEAD

    • TABLES

    • lines = HELP_TLINETAB

    • EXCEPTIONS

    • id = 1

    • language = 2

    • name = 3

    • object = 4

    • OTHERS = 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.

  • *

    *commit work.

    endcase.

    *

    *

    *data: n type i,

    • l type i,

    • k type i,

    • temp(132).

    • describe table HELP_TLINETAB lines n.

    • k = n * 132.

    **constants l type i value k.

    **l = n * 132.

    *data whole(528).

    • do n times.

    • read table HELP_TLINETAB index sy-index .

    • temp = HELP_TLINETAB-tdline.

    • concatenate whole temp into whole.

    • enddo.

    • REFRESH TDLINETAB.

    • LOOP AT HELP_TLINETAB.

    • APPEND HELP_TLINETAB-TDLINE TO TDLINETAB.

    • ENDLOOP.

    ***<<<<<<<<BEGIN OF INSERTION NOTE 335328<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    • CALL FUNCTION 'APPEND_LANGTEXT_REFS'

    • EXPORTING

    • IV_MODUS = 'T'.

    ***<<<<<<<<END OF INSERTION NOTE 335328<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    • CALL METHOD cl_gui_cfw=>flush "TF 4.6C for safety

    • EXCEPTIONS "TF 4.6C for safety

    • OTHERS = 1. "TF 4.6C for safety

    • ENDIF.

    *

    *

    *

    *

    **

    **CALL METHOD TEXT_EDITOR2->GET_TEXT_AS_STREAM

    • EXPORTING

    • TABLE = I_TEXTTABLE

    • 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 TEXT_EDITOR2->set_text_as_r3table

    • EXPORTING table = I_TEXTTABLE.

    *

    **break-point.

    **ENDCASE.

    • WHEN 'UNCOMMPRO'.

    • NEW ** 99a:

  • CALL METHOD TEXT_EDITOR2->uncomment_selection

  • EXPORTING

  • enable_editing_protected_text = cl_gui_textedit=>true.

  • *

    • WHEN 'UNCOMMENT'.

    • NEW ** 99a:

  • CALL METHOD TEXT_EDITOR2->uncomment_selection.

  • *

    • CASE text_type.

    • WHEN standard_text.

  • CALL METHOD TEXT_EDITOR2->set_wordbreak_procedure

  • EXPORTING

  • text_type = cl_gui_textedit=>text_standard

  • EXCEPTIONS

  • OTHERS = 1.

    • WHEN abap_code.

  • CALL METHOD TEXT_EDITOR2->set_wordbreak_procedure

  • EXPORTING

  • text_type = cl_gui_textedit=>text_abap

  • EXCEPTIONS

  • OTHERS = 1.

    • CALL METHOD TEXT_EDITOR2->set_autoindent_mode

    • EXPORTING

    • auto_indent = cl_gui_textedit=>false

    • EXCEPTIONS

    • OTHERS = 1.

  • CALL METHOD TEXT_EDITOR2->set_autoindent_mode

  • EXPORTING

  • auto_indent = cl_gui_textedit=>true

  • EXCEPTIONS

  • OTHERS = 1.

  • *

    • CALL METHOD TEXT_EDITOR2->set_comments_string.

    • CALL METHOD TEXT_EDITOR2->set_highlight_comments_mode.

    *

    *

    ENDMODULE. " USER_COMMAND_0300 INPUT

    MODULE EXIT INPUT.

    LEAVE TO SCREEN 0.

    ENDMODULE. " EXIT INPUT

Add a comment
10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.