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 add trailing blanks to a string?

Former Member
0 Kudos
1,823

Hi all!

I am wondering if it is possible to add trailing blanks to a string?

Namely what I'm trying to do is to create a flat file as shown below. By adding strings to a char table.

As can be seen below, the first (header) and last (tail) line of the file must have trailing blanks. All the lines should contain 18 signs, so the heder should have three trailing blanks and tail two.

H71217420061018

D00000002300770010

D00000002208010010

T000000200000242

I have tryed with concatenate to get blanks at the end of the string but it didn't work and the content of the string was the same as before the contatenate:

CONCATENATE ls_ts_data ' ' INTO ls_ts_data.

So to sum it up the question is how to get the trailing blanks in a string?

Thanks in advance!

Cheers,

Armin

1 ACCEPTED SOLUTION

Former Member
0 Kudos
242

HI Krusko,

Refer the code below. You may get your issue solved.

DATA: wrkst TYPE wrkst VALUE '20061010565656556',

ws_wrkst TYPE wrkst,

wrkst1 TYPE char10,

wrkst2 TYPE char4.

WRITE wrkst TO ws_wrkst <b>RIGHT-JUSTIFIED</b>.

wrkst1 = ws_wrkst+44(4).

clear ws_wrkst.

WRITE wrkst TO ws_wrkst <b>left-JUSTIFIED</b>.

wrkst2 = ws_wrkst+0(10).

write: wrkst1 , wrkst2.

In your case you can do the <b>RIGHT-JUSTIFIED</b>

Reward points if this helps.

Manish

Message was edited by: Manish Kumar

3 REPLIES 3

Former Member
0 Kudos
243

HI Krusko,

Refer the code below. You may get your issue solved.

DATA: wrkst TYPE wrkst VALUE '20061010565656556',

ws_wrkst TYPE wrkst,

wrkst1 TYPE char10,

wrkst2 TYPE char4.

WRITE wrkst TO ws_wrkst <b>RIGHT-JUSTIFIED</b>.

wrkst1 = ws_wrkst+44(4).

clear ws_wrkst.

WRITE wrkst TO ws_wrkst <b>left-JUSTIFIED</b>.

wrkst2 = ws_wrkst+0(10).

write: wrkst1 , wrkst2.

In your case you can do the <b>RIGHT-JUSTIFIED</b>

Reward points if this helps.

Manish

Message was edited by: Manish Kumar

0 Kudos
242

Hi Armin,

Concatenating a blank can be done using "Alt+255".

For this create a character variable as follows,

data : white_space(1) value ' '.

here the space that is defaulted should not be created using space key of the keyboard instead use Alt+255(numbers typed from your Numkeys in your keyboard). This will include a white space into the variable white_space which can be concatenated to any string.

Thanks,

Prasath N

Message was edited by: prasath natesan

Former Member
0 Kudos
242

Wow "Alt+255"! Would have never have figured it out! That deserves a tenner for sure!

Thanks a lot for the helpful answers guys!

Cheers!

/Armin