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: 

Simple question regarding strings....

Former Member
0 Kudos

Hi All,

I have defined strings as

data: string1 type string,

string2 type string.

But we should not define like this we have to define as

data: string1,string2 type string.

If I define like this system is show as

string1 type c and length is 1

string2 type string.

How to define multiple strings like this

data: string1,string2 type string.

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos
data: string1 type string,
string2 type string.

The above syntax is right.

IF you define like this,

data: string1,string2 type string.

System will always asisgn by defualt CHAR 1 to the variabes which don't have any type aasociated.

So, whenever you want to have same strcutre you need to defined explicitly for each and every variables. That's why the first syntax is correct.

Regards,

Naimesh Patel

0 Kudos

Hi there,

You're trying to tell system to define string1 but no type is given, therefore

system will assing to it the defaut type which in ABAP is char 1.

Regards,

Marcin

former_member1109645
Participant
0 Kudos

Hi,

Consider this example

data : string1.

string1 = 'A'.

write string1.

if a variable is defined like this it is implicit that string1 is of type char and of length 1.

example2(as yours)

data : string1,string2 type string.

the above statement is equal to

data string1.

data string2 type srring1.

so the system understands that 1st variable which is string1 is of type char and length 1.

regards,

kannan

Former Member
0 Kudos

Hi Gowri,

It is not possible in ABAP. You have to define each variable inividually like

data: v1 type string,

v2 type string.

Regards,

Atish