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

How to replace a variable in SO10

Former Member
0 Likes
2,684

Hi,

I need to replace a variable &data& in SO10 to his value but it doesn't work.

I use the FM 'TEXT_SYMBOL_REPLACE' to replace the words in the SO10.

Could you help me please?

In the transaction SO10, we have &eric&.

DATA:

lt_text TYPE STANDARD TABLE OF tline.

data : eric type char30 value 'Test'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

object = 'TEXT'

id = 'ST'

name = 'EMAIL'

language = sy-langu

IMPORTING

header = header

TABLES

lines = lines

EXCEPTIONS

not_found = 1

OTHERS = 2.

CALL FUNCTION 'TEXT_SYMBOL_REPLACE'

EXPORTING

header = header

program = sy-repid

REPLACE_TEXT = 'X'

TABLES

lines = lines.

Regards,

Shushu

Edited by: Shushu93 on Jul 6, 2010 2:42 PM

Edited by: Shushu93 on Jul 6, 2010 2:45 PM

Edited by: Shushu93 on Jul 6, 2010 2:46 PM

Edited by: Shushu93 on Jul 6, 2010 2:46 PM

Edited by: Shushu93 on Jul 6, 2010 2:47 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,768

REPLACE keyword can be used with the TABLE Itab addition...to find and replace the value inside the table. Perhaps that would work better for you.

7 REPLIES 7
Read only

Former Member
0 Likes
1,769

REPLACE keyword can be used with the TABLE Itab addition...to find and replace the value inside the table. Perhaps that would work better for you.

Read only

0 Likes
1,768

sorry i am new in abap.

Could you be more explicit, please?

thank you.

Edited by: Shushu93 on Jul 6, 2010 3:02 PM

Read only

0 Likes
1,768

type 'replace' in ABAP editor, put your cursor on that and press F1...you'll find the replace keyword documentation.

Read only

0 Likes
1,768

Ok thanks.

However, I know that i can do a loop to change the values of the table line

but I prefer to use the FM TEXT_SYMBOL_REPLACE to replace the variable

Do you know how to use it?

Read only

0 Likes
1,768

Can Somebody help me please?

Read only

0 Likes
1,768

Hi,

I threw this code together quickly for you:

 
REPORT  ZFM_TEST.

DATA: ls_head TYPE thead,
      lt_lines TYPE STANDARD TABLE OF tline,
      ls_lines TYPE tline,
      l_total_lines TYPE i.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    ID                      = 'ST'
    LANGUAGE                = 'E'
    NAME                    = 'ZTEXT'
    OBJECT                  = 'TEXT'
  IMPORTING
    HEADER                  = ls_head
  TABLES
    LINES                   = lt_lines
  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.

  LOOP AT lt_lines INTO ls_lines.

    Write: 'Unformatted:', ls_lines-tdline.

  ENDLOOP.

  DESCRIBE TABLE lt_lines LINES l_total_lines.

  CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
    EXPORTING
      endline = l_total_lines
      header  = ls_head
    TABLES
      lines   = lt_lines.

  IF SY-SUBRC = 0.

    LOOP AT lt_lines INTO ls_lines.

      Write:/ 'Formatted:', ls_lines-tdline.

    ENDLOOP.
  ENDIF.
ENDIF.

Regards,

Phil

Read only

0 Likes
1,768

Thank you for your help.