2006 Oct 04 1:56 PM
hi all
how to concatenate zeros to my variable
2006 Oct 04 1:58 PM
2006 Oct 04 1:59 PM
or if you want all the remain space in the variable to be prefixed with zeros you can use numc variable.
data: var1(5) ,
var2(5) type n.
var1 = '10' .
move: var1 to var2 .
run the above code and check
Regards
Raja
2006 Oct 04 1:58 PM
hi,
You can concatenate the string directly or fill the string with '0' using overlay function also.
<b>Concatenate '00000' str into str1.</b>
overlay str1 with '00000'.
Hope this helps.
2006 Oct 04 1:59 PM
2006 Oct 04 2:00 PM
hi if you want to zero pad the variable
use the foll FM
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = variable
IMPORTING
OUTPUT = variable
.
This FM will help you zero pad the remaining characters
Message was edited by: Dominic Pappaly
2006 Oct 04 2:00 PM
actually i will get the length of the zero's to be padded in run time only how will i do that
my req is like this my parameters variable length is of 10 character but my input is of only 5 character so i need to concatenate the remaining character with zeros can anyone help me n doin this
2006 Oct 04 2:03 PM
hi,
You can use unpack to fill the remaining spaces in the variable with zero's.
unpack str1 to str1.
Hope this helps.
2006 Oct 04 2:04 PM
the best way is as described below...
pval -> your parameter.
data : lval(10) type n.
lval = pval.
<b>Here lval will have the value of pval left padded with zeroes...hope your pval is a numeric field.</b>
2006 Oct 04 2:07 PM
2006 Oct 04 2:07 PM
What I understand is during u runtime you have your output as 12345 but you want to display it as 0000012345.
data : w_len TYPE i,
w_zeros TYPE i,
w_maxlen TYPE i VALUE 10,
w_tempqty TYPE p,
w_charqty.
w_tempqty = itab-(your field name).
w_charqty = w_tempqty.
CONDENSE w_charqty.
w_len = ( STRLEN( w_charqty ) ).
w_zeros = w_maxlen - w_len.
DO w_zeros TIMES.
CONCATENATE '0' w_charqty INTO w_charqty.
ENDDO.
hope this helps.
shejal shetty.
2006 Oct 04 2:02 PM
Hi,
Here is the code.
parameters: p_val type char10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_val
IMPORTING
OUTPUT = p_val.
write: p_val.
Mark the helpful answers.
Thanks
eswar
2006 Oct 04 2:03 PM
<b>Option 1 :</b>
data : v_numc(6) type n,
v_char(3) type c.
v_char = '3'.
move v_char to v_numc.
now V_NUMC will have value '000003'.
<b>Option 2 :</b>
by using Concatenate
LETS SAY Your Variable is V_VBELN of 10 characters.
data : v_char(10) type c value '0000000000',
v_length type i.
V_LENGTH = STRLEN( V_VBELN ).
IF V_LENGTH < 10 .
*--if LENGTH less than 10, in this case only we have to pad the value with zeroes.
V_LENGTH = 10 - V_LENGTH.
<b> CONCATENATE V_CHAR+0(V_LENGTH)
V_VBELN
INTO V_VBELN.</b>
ENDIF.This will help you.
Regards,
Srikanth.<b></b>
Message was edited by: Srikanth Kidambi
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |