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

concatenation doubt

Former Member
0 Likes
848

Hi All,

I want to concatenate all the values of za, zb, zc into zd with a '-' seperating them, i want the value of zd to be 432-313-218. will the following work.

data: zd type i,

za type i,

zb type i,

zc type i.

za = 432.

zb = 313.

zc = 218.

concatenate za '-' zb '-' zc into zd.

write zd.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
821

Hi,

You can use concatenate only for character fields. First should transfer the integer fields to characters and you can use the function.

Svetlin

6 REPLIES 6
Read only

Former Member
0 Likes
821

Hi,

Data: zd(15),

za(3),

zb(3),

zc(3).

za = 432.

zb = 313.

zc = 218.

concatenate za zb zc into zd separated by '-'.

write zd.

Regards

Sudheer

Read only

Former Member
0 Likes
822

Hi,

You can use concatenate only for character fields. First should transfer the integer fields to characters and you can use the function.

Svetlin

Read only

0 Likes
821

thanks sudheer.

svetlin,

could u tell me how i can transfer from int to char.

Read only

0 Likes
821

See this sample code.

report ztest.

data: zd type i,

za type i,

zb type i,

zc type i.

data mystring(30).

za = 432.

zb = 313.

zc = 218.

perform string_concatenate using za.

perform string_concatenate using zb.

perform string_concatenate using zc.

write mystring.

form string_concatenate using myint.

data: lvar(16),

delim(1) value '-'.

lvar = myint.

condense lvar.

if mystring is initial.

clear delim.

endif.

concatenate mystring lvar into mystring separated by delim.

condense mystring.

endform. "string_concatenate

Read only

0 Likes
821

Hi,

Concatenate..Syntax:-

1) CONCATENATE <c1> …<cn> INTO <c> [SEPARATED BY <s>].

2) CONCATENATE STR ‘:’ STR2 INTO STRING.

You can directly assign an integer field to a char field.

So it becomes as a character.

Ex:-

Data: number type i,

numc(5) type c.

number = 211.

numc = number.

So numc is now a character type field and you can concatenate it to some other character field.

Thanks,

Sreekanth

Message was edited by: Sreekanth G

Read only

0 Likes
821

sreekanth and svetlin thanks so much.