Skip to Content

SAP SCRIPT resets page number to 0


I am reading long text using READ_TEXT function module.

I am using a new ELEMENT to print this text. following is my current code.

* Declaration
DATA: BEGIN OF table_lines OCCURS 0. 
DATA: END OF table_lines.

* Print the text
LOOP AT table_lines.
    PERFORM under_line.

* New Element
    EXPORTING                       " write an underline
      element = 'UNDERLINE'
      window  = 'MAIN'.

Now, the users are saying that the text needs to be formatted. I am thus formatting the text as below

The problem is, after i put the following logic to format, i start getting the page number as 0 of 3, 1 of 3 and 2 of 3 instead of 1 of 3, 2 of 3 and 3 of 3.

This works fine if i dont use the following code for formatting.

Not sure, what am i missing or what is going on. Can someone help. Thanks.

* Format the long text
DATA : li_datatab TYPE tdtab_c132,
        lw_datatab(132) TYPE C,
        lw_tline   TYPE tline,
        li_tline   TYPE STANDARD TABLE OF TLINE.

  li_tline[] = table_lines[].

  CLEAR table_lines.

  REFRESH table_lines[].

    codepage                = '0000'
    formatwidth             = 100
    LANGUAGE                = sy-langu
    tabletype               = 'ASC'
    c_datatab               = li_datatab
    itf_lines               = li_tline.

  LOOP AT li_datatab INTO lw_datatab.
    IF sy-tabix = 1.
      lw_tline-tdformat = '*'.
    lw_tline-tdline = lw_datatab.
    APPEND lw_tline TO table_lines.
    CLEAR: lw_datatab, lw_tline.

* Call the loop at table_lines again to print the text

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 10, 2018 at 01:03 PM

    Hi Salil,

    I suppose the reason for your problem is this: The function module CONVERT_ITF_TO_ASCII internally calls the function module TEXT_CONTROL_REPLACE, which always resets the page number to 0. (calls function INIT_TEXTSYMBOL).

    So CONVERT_ITF_TO_ASCII cannot be called inside of an OPEN_FORM...CLOSE_FORM block, if the page number (or e.g. the total number of pages) is used in the form.

    So there are two possibilities: You move the CONVERT_ITF_TO_ASCII in front of the OPEN_FORM or you try to do without it, maybe you can use function FORMAT_TEXTLINES.

    Best regards,


    Add comment
    10|10000 characters needed characters exceeded