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: 

How to initialize data field of type string with all blanks

Former Member
0 Kudos
340

I would like to set blanks in a field which is declared as type String. Any idea?

Data: str type string.

I need to move 3000 bytes of blanks / spaces into it.

Thanks.

4 REPLIES 4

Former Member
0 Kudos
123

Hi Parimala,

I am not sure if this is possible. You can try with a character data type.

DATA: L_VAR(3000) type C.

CLEAR l_VAR WITH SPACE.

But i think SAP will not allow spaces. It will by default turncate the spaces.

What are your trying to achieve by moving 3000 bytes of blank spaces?

Cheers

VJ

0 Kudos
123

Try this. IT works for me.



report zrich_0001 .

data: str type string.
data: c(3000) type c.
data: length type i.

c+2999(1) = 'X'.

str = c.

translate str using 'X '.

length = strlen( str ).

write:/ length.

Regards,

Rich Heilman

0 Kudos
123

Its a long story...I'm parsing xml data and from there need to create another xml. The data can go beyond 60 K...and therefore I cannot use char type.

I cannot use

<b>newStr+offset(reclen) = fldvalue</b>

or

<b>move fldvalue to newStr+offset</b>

both of these are not allowed in string and xstring. I can use

<b>replace section offset offset length 1eng of newStr with fldvalue.</b>

However, I need to have something in this newStr in order to use the above statement. And this were I thought I would initialize my newStr with spaces.

I've run into a road block with this and can't go further.

I appreciate any help on this. Thank you.

0 Kudos
123

so you want to have space in "newStr" and replace it with a value.

right? instead of space fill it with some special character say a "|" and then replace them .

may be if you could explain the big picture (xml parsing - what are you trying to do) may be we could come up with a totally different approach to the issue.

Regards

Raja