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

string template syntax error

folkernaumann
Explorer
0 Likes
1,772

Hi,

using string templates for the first time. Every example i found, seems very simple, like


DATA(string) = |Hello World!|.

But i always get a syntax error:

Field "|HELLO" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

So what am i missing? System is running SAP NW 7.4.

best regards

Folker

1 ACCEPTED SOLUTION
Read only

folkernaumann
Explorer
0 Likes
1,702

Hey all,

the answer is: string templates only work in Unicode-programs. I am working on a non-Unicode System and Unicode checking was disabled in the program.

thanks for your help

Folker

9 REPLIES 9
Read only

Former Member
0 Likes
1,702

Hello,

You didn't defined the variable which will be type string. Try this:

DATA variable TYPE string.
variable = 'Hello World!'.

Read only

asim_isik
Active Participant
0 Likes
1,702

Hi Folker ,

You can define a variable without using type.

Like; data string.

But this will be 1 character variable.

So you can write like this ;

data string value 'Hello World!'.

but string actually contains only 'H'.

You should write like this ;

data lv_string type string value 'Hello World!'.

Read only

former_member210008
Active Participant
0 Likes
1,702

Hi, Folker.

I'm on 7.40 sp08, all works fine. Try to use backquotes for test.

data(string) = `some text`.

Read only

0 Likes
1,702

Hi Evgeniy,

i tried this:


DATA string1 TYPE string.

DATA string2 TYPE string.

string1 = |Hello World!|.       

string2 = `Hello World!`.      

DATA(string3) = `Hello World!`.

string2 and string3 are working fine, string1 results in the same syntax error like described above. It just looks like pipes are not recognized as keywords.

Read only

0 Likes
1,702

Hello,

Strange, the following code is working for me :

DATA string1 TYPE string.

string1 = '|Hello world|'.

I am on NW 7.4 EHP7.

br,

Christophe

Read only

0 Likes
1,702

Hi Christophe,

for me too, but only because it has ' ' around the pipes.

string1 = '|Hello world|'.


Have you tried it without quotes?


string1 = |Hello world|.


btw what's the best way to determine your platform (NW, AS ABAP)?


br

Folker

Read only

0 Likes
1,702

Hello Folker,

Yes I tried w/o quotes and it's working also.

To determine your plateform go to sytem>status>Product version and you click on the button to see the details.

Tks.

Br,

christophe

Read only

0 Likes
1,702

I found that string pipes were implemented in 7.3 so it should work on any 7.40. Maybe you have old/broken sapgui?..

Try to run DEMO_STRING_TEMPLATE_ALIGN_PAD. Will it work for you?

Read only

folkernaumann
Explorer
0 Likes
1,703

Hey all,

the answer is: string templates only work in Unicode-programs. I am working on a non-Unicode System and Unicode checking was disabled in the program.

thanks for your help

Folker