Skip to Content
0

SAP SCRIPT resets page number to 0

Apr 09 at 09:21 PM

28

avatar image

All,

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. 
INCLUDE STRUCTURE tline. 
DATA: END OF table_lines.

* Print the text
LOOP AT table_lines.
    PERFORM under_line.
ENDLOOP.

* New Element
  CALL FUNCTION 'WRITE_FORM'
    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[].

  CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
  EXPORTING
    codepage                = '0000'
    formatwidth             = 100
    LANGUAGE                = sy-langu
    tabletype               = 'ASC'
  IMPORTING
    c_datatab               = li_datatab
  TABLES
    itf_lines               = li_tline.

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

* Call the loop at table_lines again to print the text


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Hedvig Rohonyi
Apr 10 at 01:03 PM
0

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,

Hedvig

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks a lot Hedvig. That explains the reason for resetting the page number. I liked your suggestions. Thanks again for all your help.

0