Application Development and Automation 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 only

Standard text with a variable

Former Member
0 Likes
16,874

Hello, a question.

SO10 I created in a standard text: "Facts: &v_df&"

With the READ_TEXT put that text in a table

But now I am interested to give a value to this variable: v_df

In Table I only have this sentence and is the first line.

The question is this, how to give a value to a variable that is inside a table?

I suppose that could also put a value in the variable since the READ_TEXT, or before putting on the table, but that's only guess.

If someone could tell me something please.

(I'm Spanish, sorry for language)

Thank you.

10 REPLIES 10
Read only

Former Member
0 Likes
6,313

After you have read the text then pass the contents into FM REPLACE_TEXTSYMBOL - assuming that your variable to replace is known to the local program. This FM will then replace all occurances from start to finish (via STARTLINE and ENDLINE parameters).

Thanks,

Pete

Read only

0 Likes
6,313

Thanks for your answer.

The code would look like:

CALL FUNCTION 'REPLACE_TEXTSYMBOL'

EXPORTING

endline = 2

  • FORMATWIDTH = 72

language = sy-langu

linewidth = 132

option_dialog = ' '

replace_program = 'X'

replace_standard = 'X'

replace_system = 'X'

replace_text = 'X'

v_df = v_ci_name

startline = 1

  • IMPORTING

  • CHANGED =

TABLES

lines = i_datos.

She says that the variable v_df is unknown.

Thanks again.

Read only

Former Member
0 Likes
6,313

Hi,

I think you may of mis-understood. The code would look like:


DATA: V_DF TYPE xxx.

* wherever the value is coming from - looks like v_ci_name in your code
V_DF = xxx.  

CALL FUNCTION 'REPLACE_TEXTSYMBOL'
  EXPORTING
    endline                = <last line of i_datos>
    language               = sy-langu
    linewidth              = 132
    option_dialog          = ' '
    replace_program        = 'X'
    replace_standard       = 'X'
    replace_system         = 'X'
    replace_text           = 'X'
    startline              = 1
  TABLES
     lines                  = i_datos.

The function has a fixed interface and works by looking at the program symbols of the calling program to perform the replacement. This is why V_DF would have to be declared as a normal data statement in the calling program.

Read only

0 Likes
6,313

Hi Pete Devereux.

I get an error like: call_function_conflict_leng

I am writing code I write:

TYPES: typ_datos TYPE text132. "132 characters

TYPES: typ_tab_datos TYPE STANDARD TABLE OF typ_datos.

DATA: i_datos TYPE typ_tab_datos.

  • i_datos has put a line: Try: &v_df&

DATA: v_df TYPE CHAR08.

v_df = 'hello'.

DESCRIBE TABLE i_datos LINES v_lineas_tabla.

CALL FUNCTION 'REPLACE_TEXTSYMBOL'

EXPORTING

endline = v_lineas_tabla "<last line of i_datos>

language = sy-langu

linewidth = 132

option_dialog = ' '

replace_program = 'X'

replace_standard = 'X'

replace_system = 'X'

replace_text = 'X'

startline = '1'

TABLES

lines = i_datos.

Thank you

Read only

0 Likes
6,313

Sorry Pete Devereux, I was confused by the table and it gave me this error.

Now I get no error, but I did not write the value that I want in a variable v_df.

The standard text and the variable created in SO10.

SO10 I created in a standard text: "Try: &v_df&"

The REPLACE_TEXTSYMBOL gives me the option of:

replace_program

replace_standard

replace_system

replace_text

I think the variable is not one of these options.

v_df = 'hello'

If the startline = 0, he writes: Try: v_df & &

If the startline = 1, he writes: Try:

_I write:_

TYPES: typ_datos TYPE text132. "132 characters

TYPES: typ_tab_datos TYPE STANDARD TABLE OF typ_datos.

DATA: i_datos TYPE typ_tab_datos.

DATA: v_df TYPE CHAR08.

v_df = 'hello'.

DESCRIBE TABLE it_lines LINES v_lineas_tabla.

CALL FUNCTION 'REPLACE_TEXTSYMBOL'

EXPORTING

endline = v_lineas_tabla "<last line of it_lines>

language = sy-langu

linewidth = 132

option_dialog = 'X'

replace_program = 'X'

replace_standard = 'X'

replace_system = 'X'

replace_text = 'X'

startline = 1

TABLES

lines = it_lines.

Thanks for the help.

Read only

Former Member
0 Likes
6,313

Hi,

Thats strange - works ok on my system (ECC6). The full code that I have is:

DATA:
  lt_text TYPE STANDARD TABLE OF tline,
  v_df    TYPE char30 VALUE 'text to be replaced'.

START-OF-SELECTION.
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id       = 'ST'
      language = sy-langu
      name     = 'ZREPLACE_SYMBOL'
      object   = 'TEXT'
    TABLES
      lines    = lt_text.

  DESCRIBE TABLE lt_text LINES sy-tfill.
  CALL FUNCTION 'REPLACE_TEXTSYMBOL'
    EXPORTING
      endline                = sy-tfill
      startline              = 1
    tables
      lines                  = lt_text.

The text symbol in my standard text is replaced by the content of v_df. Are you sure your symbol in the text is correct? Which editor are you using? I know if you use the front end editor (MS Word in my case) then typing in &v_df& will not be correct as it is not regognised as a symbol. You have to use "Insert Command" or Include Symbols/Program Symbols or switch editor (Goto/Change Editor) and use the old SAPScript editor - then you can just type your symbol.

Hope this helps.

Read only

0 Likes
6,313

Thank you very much for the trouble.

I have done what I indicated, but the variable does not change the value that I said.

Failure to recognize and change the variable value by a blank.

Read only

0 Likes
6,313

In that case I can only suggest two more alternatives.

1. Do it the old fashioned way:

REPLACE ALL OCCURRENCES OF '&V_DF&' IN TABLE lt_text WITH v_df.

However, line wrapping may be a problem

2. Try and use the wrapper function TEXT_SYMBOL_REPLACE which in turn calls REPLACE_TEXTSYMBOL. Code for this would look something like:

DATA:
  lt_text   TYPE STANDARD TABLE OF tline,
  ls_header TYPE thead,
  v_df      TYPE char30 VALUE 'text to be replaced'.

START-OF-SELECTION.
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id       = 'ST'
      language = sy-langu
      name     = 'ZREPLACE_SYMBOL'
      object   = 'TEXT'
    IMPORTING
      header   = ls_header
    TABLES
      lines    = lt_text.

  CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
    EXPORTING
      header = ls_header
    TABLES
      lines  = lt_text.

The wrapper function calls some other initialisation stuff that may help in your case. Worth giving a try,

Thanks,

Pete

Read only

0 Likes
6,313

Thank you very much.

The first option works fine, but they told me the same thing as you, it is bad form.

I have to do it the first way, but taking into account that there may be several variables.

Thank you very much for your help, really

Read only

Former Member
0 Likes
6,313

Before calling REPLACE_TEXTSYMBOL you must call SET_TEXTSYMBOL_PROGRAM like that:

CALL FUNCTION 'SET_TEXTSYMBOL_PROGRAM'
EXPORTING
program = sy-repid
event = 'OPEN_FORM'.

DESCRIBE TABLE lt_lines LINES sy-tfill.
CALL FUNCTION 'REPLACE_TEXTSYMBOL'
EXPORTING
endline = sy-tfill
startline = 1
TABLES
lines = lt_lines.