2008 Jun 13 9:29 AM
Hi,
I have written a query like this.
DATA: number TYPE C VALUE 0.
DATA: l_name LIKE thead-tdname.
l_length = strlen( l_name ).
IF l_length < 10.
CONCATENATE number l_name INTO l_name.
ENDIF.
I want to apend a zero infront of the number if its total length is less than 10.But sometimes some character values are getting stored in l_name variable.Then in that case i want to give an if condition like if l_name is not equal to numeric value then the control should come out of if condition.How can I give this condition in my program?
2008 Jun 13 9:35 AM
hi,
You can use the condition l_name cn '0123456789'. for checking whether it contains any characters other than numerics.
Regards,
Veeresh
Hi,
I have written a query like this.
DATA: number TYPE C VALUE 0.
DATA: l_name LIKE thead-tdname.
l_length = strlen( l_name ).
IF l_length < 10.
CONCATENATE number l_name INTO l_name.
ENDIF.
I want to apend a zero infront of the number if its total length is less than 10.But sometimes some character values are getting stored in l_name variable.Then in that case i want to give an if condition like if l_name is not equal to numeric value then the control should come out of if condition.How can I give this condition in my program?
2008 Jun 13 9:35 AM
HI,
Try using fn. module:
CONVERSION_EXIT_ALPHA_INPUT
Pass the variable to which you want to append zeros and this fn. module will append and return.
2008 Jun 13 9:35 AM
hi,
You can use the condition l_name cn '0123456789'. for checking whether it contains any characters other than numerics.
Regards,
Veeresh
2008 Jun 13 9:36 AM
Hi Hema,
Just wondering why don't you just use data type N (numeric), it will automatically appending zero.
Thanks,
Victor.
2008 Jun 13 9:36 AM
HI,
Check the below code....
If l_name CA sy-abcde.
exit.
else.
l_length = strlen( l_name ).
IF l_length < 10.
CONCATENATE number l_name INTO l_name.
ENDIF.
ENDIF.
Rgds,
Bujji
2008 Jun 13 9:37 AM
hi!
Raise a check using the relational operator 'CS' and compare whether the variable contains Numeric r character.
if the condition is true, then call the FM - CONVERSION_EXIT_ALPHA_INPUT to include Zero prefix to the value.
Reward me if useful.
Regards,
Nagulan
2008 Jun 13 9:43 AM
hi.....
you can pass your variable in the function 'conversion_exit_alpha_input.
Whatever blankpces you have inyour variable,it will be replaces by zeroes.The zeroes will be appended in front of the number.
This is a better method to append zeroes.
2008 Jun 13 9:48 AM
Hi Hema,
Try the below code.
Example
DATA :n_c(10) TYPE n,
c_n(10) TYPE c.
START-OF-SELECTION.
n_c = '10'.
IF n_c IS INITIAL.
WRITE: 'Char'.
ELSE.
WRITE: n_c.
ENDIF.
your changed code
DATA: l_name LIKE thead-tdname,
l_n(10) TYPE n.
l_name = '10'.
l_n = l_name.
if l_n is not initial.
Numaric
else.
Char.
endif.
// l_name = 'AB'.
// l_n = l_name.
Reward if found helpful
Regards,
Boobalan Suburaj
2008 Jun 13 9:52 AM
Hi,
Try using FM CONVERSION_EXIT_ALPHA_INPUT
or
datav : num(10) type n,
num1 type i value '90880'.
num = num1.
write : num.
Thanks,
Sriram Ponna.
2008 Jun 13 10:06 AM
hiii
use like below code
ls_data-matnr = ls_excel-value.
w_matnr = ls_data-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_matnr
IMPORTING
output = w_matnr.
ls_data-matnr = w_matnr.reward if useful
thx
twinkal
2008 Jun 13 10:12 AM
hi,
instead of doin this ,there is a function module
CONVERSION_EXIT_ALPHA_INPUT for 0 padding..
use this one..
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |