‎2007 Jan 04 9:10 PM
Hi,
im using an integer to increment a counter and i need to move it in to a char. what if i need a zero '0' before the count if the number is less than 10 in my char field.
Regards,
ravi.
‎2007 Jan 04 9:17 PM
Try:
DATA: f1(10) VALUE '123'.
WRITE: /001 f1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = f1
IMPORTING
output = f1.
WRITE: /001 f1.
Rob
‎2007 Jan 05 4:11 AM
use this demo code -
data: d_integer type i ,
d_char(2) type N.
d_integer = 4.
d_char = d_integer.
write: d_char.
amit
‎2007 Jan 04 9:28 PM
Hi Ravi,
DATA V_INT TYPE I VALUE '5'.
DATA V_CHAR(16).
DATA V_NUMBER(2).
IF V_INT < '10'.
V_CHAR = V_INT.
CONDENSE V_CHAR NO-GAPS.
CONCATNATE '0' V_CHAR INTO V_NUMBER.
ELSE.
V_CHAR = V_INT.
CONDENSE V_CHAR NO-GAPS.
V_NUMBER = V_CHAR.
ENDIF.
Thanks,
Vinay
‎2007 Jan 05 1:17 AM
Hi Ravi
We can do the same by declaring a variable of type N with required length.
We can perform airthematic operations as long as only numericals exist.
The advantage with data type N is by default we will be having LEADING ZEROES for numbers.
data: l_int type i value '2',
l_num(2) type N.
l_num = l_int.
write:/ 'Type I:', l_int,
/ 'Type N:', l_num.Kind Regards
Eswar
‎2007 Jan 05 3:37 AM
Dear Ravi,
Go through the following chunk of code:
DATA: GV_IDX1 TYPE I,
GV_IDX2(2) TYPE N.
DO.
GV_IDX1 = GV_IDX1 + 1.
GV_IDX2 = GV_IDX1.
WRITE: / GV_IDX1,
GV_IDX2.
IF GV_IDX1 GT 10.
EXIT.
ENDIF.
ENDDO.
The O/P will be:
1 01
2 02
3 03
. .
. .
9 09
10 10
Use Data Type NUMC inorder to carry out this type of operation.
Regards,
Abir
************************************
Don't forget to award Points *
‎2007 Jan 05 3:43 AM
i dont know whether your counter is less than 100 or not if it is so then
you can use type n which will place 0 before your variable
data : v_data(2) type n.
otherwise
you can check the counter whether it is lt 10 or not
if counter lt 100.
v_data = counter.
<now char field > = v_data.
else.
directly take char fied = counter.
regards
shiba dutta