‎2006 Jul 07 2:30 PM
Hi,
my requirements are the following :
I must have variable with f.e a fixed length of 10.
In this variable a value will be put with a variable length.
If this length is smaller then 10, the remaining characters must be filled up with spaces, so that the actual length is always 10.
Is there a variable type that supports this ? How must i achieve this ?
with regards
Erik Dierinck
‎2006 Jul 07 2:37 PM
declare as type n.
data: v_num(10) type n value '10'.
write: v_num.
Regards,
ravi
‎2006 Jul 07 2:31 PM
‎2006 Jul 07 2:34 PM
u can declare the variable as below
data text(10) type n.
but text will always have leading zeroes and not spaces.
Sample code
PARAMETER: ckb1(10) TYPE n.
DATA: len1 TYPE i.
len1 = STRLEN( ckb1 ).
MESSAGE i000(vz) WITH len1.
-Kiran
‎2006 Jul 07 2:37 PM
declare as type n.
data: v_num(10) type n value '10'.
write: v_num.
Regards,
ravi
‎2006 Jul 07 2:48 PM
Hi,
Declare as type n.
data: num(10) type n .
num = '1'.
write: num.Regards
vijay
‎2006 Jul 07 2:52 PM
Okay,
But will this also work with a concatenation :
suppose i have three variables
var1(10) = 'test'
var1 ='test1'
var2 ='test2'
the result of the concatenation must be
"test test1 test2"
with regards
‎2006 Jul 07 2:55 PM
‎2006 Jul 07 2:57 PM
‎2006 Jul 07 2:58 PM
Hi,
you can do this way...
REPORT ZZSDSDF .
data: v1(10),v2(10),v3(10),v(30).
v1(10) = 'test'.
v2 = 'test1'.
v3 = 'test2'.
v = v1.
v+10(10) = v2.
v+20(10) = v3.
write v.Regards
vijay
‎2006 Jul 07 3:03 PM
You will need to give a placeholder during concatenation, then you can get rid of it.
report zrich_0001.
data: var1(10) type c,
var2(10) type c,
var3(30) type c,
result(30) type c.
var1 = 'Tst1'.
var2 = 'Tst2'.
var3 = 'Tst3'.
translate var1 using ' %'.
translate var2 using ' %'.
translate var3 using ' %'.
concatenate var1 var2 var3 into result.
translate result using '% '.
write:/ result.
Regards,
Rich heilman
‎2006 Jul 07 2:41 PM
hi
good
good
you can declare the variable as
data: variablename(10) type c.
then down check that variable in a loop whenever the data from the database will be less than 10 than use tha APPEND command to append 0 before that.
thansk
mrutyun
‎2006 Jul 07 2:42 PM
Hi Erik,
Use Character type for your requirement.
Declare it as
DATA : var(10) TYPE C.Consider this program,
REPORT zarun_2.
DATA : char(10) TYPE c,
len TYPE i.
char = 'TEST'.
len = STRLEN( char ).
WRITE : / char, 13 'Length:', len.
CLEAR char.
char = 'TESTSDN'.
len = STRLEN( char ).
WRITE : / char, 13 'Length:', len.
CLEAR char.
char = 'TESTSDNSAP'.
len = STRLEN( char ).
WRITE : / char, 13 'Length:', len.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi
‎2006 Jul 07 3:00 PM
Hi Erik,
You can do it in this way.
REPORT zarun_2.
DATA : char1(10) TYPE c,
char2(10) TYPE c,
char3(10) TYPE c,
result(30) TYPE c. " Or can use type <b>STRING</b>
char1 = 'test'.
char2 = 'test1'.
char3 = 'test2'.
CONCATENATE char1 char2 char3 INTO result <b>SEPARATED BY space.</b>
WRITE result.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi