Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

READ_TEXT but for command processing

mantas_andriekus
Participant
0 Kudos

Hi there,

Interesting problem -

READ_TEXT can return the contents of a standard text, however if the standard text has an include command - for example "INCLUDE STDTXTKEYxxxx OBJECT TEXT ID ST" then the command text will be returned and not the actual contents of STDTXTKEYxxxx.

Is there a function module that would return the full long text and process the commands and look their text up?

Your help would be invaluable. A solution would provide the most points.

Thanks

Mantas

1 ACCEPTED SOLUTION

messier31
Active Contributor
0 Kudos

Hi,

What you should do is after calling READ_TEXT you check if you returned lines contains INCLUDE standard text. If yes then you call again READ_TEXT for this standard text and add lines retrieved from this call to original returned lines. Please also make note of line number where this is called because you will have to adust same.

You may also consider going for loop logic so that you keep on call READ_TEXT untill the retuned lines doesn't contain any further include. But then then only if this can be a possible scenario in your case.

Let me know if you have any doubt on this.

Enjoy SAP.

Pankaj Singh.

5 REPLIES 5

Former Member
0 Kudos

Hi,

I've not tried it but the method GET_TEXT of class CL_SAPSCRIPT_LONGTEXT looks like it will do the trick.

method get_text .
*-- returns the the text with placeholders like &V1& or &DATE&
*-- replaced by the corresponding texts as set by method
*-- ADD_PLACEHOLDER_VALUES

  data: c_line_width  type i value 80.

  result = me->raw_text.
  me->header-tdform = 'S_DOCU_PRINT'.
  call function 'PRINT_TEXT'
       exporting
            header = me->header
            device = 'OTF_MEM'
       tables
            lines  = result
       exceptions
            others.

  call function 'CONVERT_OTF_MEMORY'
       exporting
            max_linewidth = 80
       tables
            lines         = result
       exceptions
            others.


endmethod.

Cheers,

Darren

0 Kudos

Good suggestions there. Unfortunately I'm working with 4.6C and cannot find CL_SAPSCRIPT_LONGTEXT.

messier31
Active Contributor
0 Kudos

Hi,

What you should do is after calling READ_TEXT you check if you returned lines contains INCLUDE standard text. If yes then you call again READ_TEXT for this standard text and add lines retrieved from this call to original returned lines. Please also make note of line number where this is called because you will have to adust same.

You may also consider going for loop logic so that you keep on call READ_TEXT untill the retuned lines doesn't contain any further include. But then then only if this can be a possible scenario in your case.

Let me know if you have any doubt on this.

Enjoy SAP.

Pankaj Singh.

Former Member
0 Kudos

This sounds kind of dangerous. What if you have a self-referencing include or include loops?

0 Kudos

Only if you thing it can be possible scenario.. and if yes you not loop and just go for one level check..

Enjoy SAP.

Pankaj Singh