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: 

Concatenate " Simple but tricky question "

Former Member
0 Kudos

Hey guys

How are u, this looked like easy problem. However, I tried so many things. I want to add a space in front of character. This is 2-character lengths field.

When I was executing this command, it is not adding up space.

If I am something wrong correct me

Here is the code

DATA: i type i ,ONE(1) VALUE ' ',FINAL(2) ,TWO(1).

i = sTRLEN( t_record-trfgr ). “ first it shows 1 for H

if i LE '1'.

concatenate TWO ONE '.' into final.

CLEAR:I.

i = sTRLEN( final ). “ its still say 1

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you want to have the space after 'H' then I want to know what is the layout of your output file. What type of file you are using.

If you are using the application server file and this field is the last field in you record and you want a fixed length output, you can use length option in transfer command. You have to specify the total length of the record. If this field is in between and you are concatenating all the fields before transferring it to file then the best way is use offset instead of concatenate.

Thanks

Giridhar

13 REPLIES 13

Former Member
0 Kudos

Saquib,

<b>Concatenate ' '

t_record-trfgr

into

final.</b>

Following should also work:

<b> Concatenate

space

t_record-trfgr

into

final.</b>

Thanks

Kam

Note: Allot points for all worthful postings

Former Member
0 Kudos

Hi,

You can use the offset & length option while assigning the final field value to the target field.

Thanks,

Ravi

Former Member
0 Kudos

Here you go

data: v1 value 1, v2 value 2, v3(3), v4(4).

concatenate v1 v2 into v3.

v4+1(3) = v3.

write : / v2.

write : / v3.

write : / v4.

This should help you, if so please close this.

Thanks,

Ravi

Former Member
0 Kudos

Instead of Concatenating the variable with the space, try using shift.

Shift <variable> right. This will add one space before the variable

0 Kudos

I want add space after the variable … like ‘H(SPACE) “ Two character . I want to append it in file. No out put …

0 Kudos

Saquib,

Go with the Same Concatenate stmt.

<b>Concatenate

space

t_record-trfgr

space

space

into

final.</b>

Thanks

Kam

Former Member
0 Kudos

Hi,

You can't use concatenate to concatenate a space.

The other way of using it is

Concatenate ' ' t_record-trfgr into t_record-trfgr separated by space.

If you use separated by space it will put one blank space between each string we are concatenating.

In your case you just want to add one space before it, if it contains a single character, then you can just say

SHIFT T_RECORD-TRFGR RIGHT.

You can use the shift command to add space at the begining.

Thanks

Giridhar

0 Kudos

I think you might be trying to do something simular to this. Check it out.

Regards,

Rich HEilman

krzysztof_konitz4
Contributor
0 Kudos

Hi,

If you would like to concatenate strings which contain spaces you can first use instruction

TRANSLATE str USING ' -' and replace all occurencies of space with other char (in my example "-").

Then you can use CONCATENATE to join strings and finally TRANSLATE str USING '- ' to change back character to space.

DATA: A(5) VALUE ' 1 ',

B(5) VALUE '2 3 ',

C(10).

TRANSLATE A USING ' -'. "A contains '1'

TRANSLATE B USING ' -'. "B contains '2--3-'

CONCATENATE A B INTO C. "C contins '12--3-'

TRASLATE C USING '- '. "C contains ' 1 2 3 '

Krzys

Former Member
0 Kudos

Hi,

If you want to have the space after 'H' then I want to know what is the layout of your output file. What type of file you are using.

If you are using the application server file and this field is the last field in you record and you want a fixed length output, you can use length option in transfer command. You have to specify the total length of the record. If this field is in between and you are concatenating all the fields before transferring it to file then the best way is use offset instead of concatenate.

Thanks

Giridhar

0 Kudos

I have to send two character file in file, and it the last field. Right now some time it shows code like ' GB' , 01 and 02 .. all are 2 characters right .

When ever its comes like H, S, I .. their server bounce back . because they are supporting 2 character and there should be space at the END of character ..

Means this H should look like 'Hspace'"H " .. got it ...

Thanks

0 Kudos

Hi Saquib,

Unfortunately, SAP strips off the last blank spaces. But if you are downloading this to a application server, you can use the LENGTH option of the TRANSFER command which forces the length to be always the record length of your internal table.

Alternatively, you can add an additional character at the end and ask the receiving system to ignore it. You can always fill this last character field with a constant value say 'X' and treat it as a record end character.

Srinivas

0 Kudos

That’s something, I read before posting question over here.. But any way thanks for ur reply. I am also thinking on the same grounds.

Any way thanks you all for your kind help...

Bye