‎2008 Apr 07 5:25 AM
hi,
anyone help me out in this case.
i have a prg. like this.
data: var1(20) type c.
data: var2(2) type c.
data: var3(2) type c.
data: var type string.
var1 = 'abcd'.
var2 = 'bp'.
var3 = 'bp'.
i want the output like..... abcd bpbp.
it means i want to leave 16 spaces after abcd in this case. if var1 is having content like ,
abcde than i want to leave 15 space after abcde because total length of var1 is 20.
if i simply concate output would be abcdbpbp.
so if i count the no. of spaces i need to leave after abcd and create one date object of type c at runtime , it would work out.
but how should i create.....?
plz let me know ASAP.
saurin shah.
‎2008 Apr 07 6:15 AM
Hi Saurin...
there are 2 main keywords used with concatenate
(1) ...."SEPARATED BY"
(2) ...."RESPECTING BLANKS"
in this case if you do the code
copy the code into a test program......................
*******************************************************************
data: var1(20) type c.
data: var2(2) type c.
data: var3(2) type c.
data : var4(4) type c.
data: var type string.
var1 = 'abcd'.
var2 = 'bp'.
var3 = 'bp'.
concatenate var2 var3 into var4.
to get bpbp
concatenate var1 var4 into var separated by SPACE.
write var.
clear var.
concatenate var1 var4 into var respecting blanks.
write var.
*******************************************************************
keep changing the value of var1 in the code to see how you can use the 2 options to your advantage...and which one suits your requirement best
Output1: " using separated by space"
abcd bpbp
here there will be 1 spacce after abcd
so it is abcde
it will be
abcde bpbp
Output2: " using respecting blanks"
abcd bpbp
ie,after abcd there will be 16 more blank spaces since its total length is 16...
using this keyword the number of space is not condensed but kept intact
but if there are 20 characters in the var1 then there will be no space eg: abcdefghijklmnopqrsbpbp...for 19 characters it will be abcdefghijklmnopqr bpbp
so you can decide which layout you need once you write the code and see th output for yourself
Pls check,revert and reward if helpful
Regards
Byju
‎2008 Apr 07 6:14 AM
Hi,
Please follow the steps below.
if a1 = 'abcd' (Total length is 20)
a2 = 'de'
a3 = 'fg'.
Use the following code...
lv_strlenA = strlen(a1)
lv_strlenA = 20 - lv_strlenA
a4+lv_strlenA = a2.
concatenate a1 a4 a3
Hope this helps....Please check and let me know if this works...
Thanks
‎2008 Apr 07 6:37 AM
thanks for help me out,
but what is a4 will u let me know plz....
‎2008 Apr 07 6:52 AM
A4 is a new field which has the values of A2 with blank spaces prefixed to it.
‎2008 Apr 07 6:15 AM
Hi Saurin...
there are 2 main keywords used with concatenate
(1) ...."SEPARATED BY"
(2) ...."RESPECTING BLANKS"
in this case if you do the code
copy the code into a test program......................
*******************************************************************
data: var1(20) type c.
data: var2(2) type c.
data: var3(2) type c.
data : var4(4) type c.
data: var type string.
var1 = 'abcd'.
var2 = 'bp'.
var3 = 'bp'.
concatenate var2 var3 into var4.
to get bpbp
concatenate var1 var4 into var separated by SPACE.
write var.
clear var.
concatenate var1 var4 into var respecting blanks.
write var.
*******************************************************************
keep changing the value of var1 in the code to see how you can use the 2 options to your advantage...and which one suits your requirement best
Output1: " using separated by space"
abcd bpbp
here there will be 1 spacce after abcd
so it is abcde
it will be
abcde bpbp
Output2: " using respecting blanks"
abcd bpbp
ie,after abcd there will be 16 more blank spaces since its total length is 16...
using this keyword the number of space is not condensed but kept intact
but if there are 20 characters in the var1 then there will be no space eg: abcdefghijklmnopqrsbpbp...for 19 characters it will be abcdefghijklmnopqr bpbp
so you can decide which layout you need once you write the code and see th output for yourself
Pls check,revert and reward if helpful
Regards
Byju