03-05-2009 7:16 AM
hi all
i have a data type: TP_RLNUM(16) TYPE N
how can i make a (coding)to check the input of this value must have 16 number -means lenght 16?
thanks xperts..
03-05-2009 7:20 AM
Hi,
C, N, D, T, X data types are the member of character faimily.
so the way u do with character c, the same method we use for numeric field.
data: a type i,
TP_RLNUM(16) TYPE N
a = strlen( TP_RLNUM ),
IF A = 16.
03-05-2009 7:20 AM
Hi,
C, N, D, T, X data types are the member of character faimily.
so the way u do with character c, the same method we use for numeric field.
data: a type i,
TP_RLNUM(16) TYPE N
a = strlen( TP_RLNUM ),
IF A = 16.
03-05-2009 7:21 AM
TP_RLNUM(16) itself means that it cant take more than 16.
why coding?
03-05-2009 7:21 AM
Sorry somewhat my last mail was posted and it was incomplete.
Hi,
C, N, D, T, X data types are the member of character faimily.
so the way u do with character c, the same method we use for numeric field.
data: a type i,
TP_RLNUM(16) TYPE N
a = strlen( TP_RLNUM ),
IF A = 16.
*****write ur logic here******.
endif.
Hope this will help u.
Cheers,
Rudhir
03-05-2009 7:36 AM
Hi,
Variables of type n lenght 16 will always have 16 characters :
e.g. if value = 7
variable = '0000000000000007'.
03-05-2009 8:02 AM
Hi,
You can also do this using RTTS (Run Time Type Services).
DATA: tp_rlnum(16) TYPE n. "your data object
DATA: r_eldescr TYPE REF TO cl_abap_elemdescr.
r_eldescr ?= cl_abap_typedescr=>describe_by_data( tp_rlnum ). "get element's attributes
WRITE: 'Output length of the data object is', r_eldescr->output_length. "display its length
This approach give you opportunity to check every single attribute of your data object. I.e. now you can see its type as well:
write: 'Type is:', r_eldescr->type_kind.
Regards
Marcin
03-05-2009 8:12 AM
PARAMETERS p_num(16) TYPE n.
AT SELECTION-SCREEN.
DATA: out TYPE char16,
len TYPE i.
out = p_num.
SHIFT out LEFT DELETING LEADING '0'.
len = STRLEN( out ).
IF len NE 16.
ENDIF.
03-05-2009 8:17 AM
Hi,
To check the length by strlen( TP_RLNUM ) alwys giv u 16 becz ur data type itself says that.
Rather then that check the first character of ur no that should not be 0 it means that ur no is always 16 digits.
data: a type i.
a= TP_RLNUM + 0(1).
if a <> 0.
write ur logic here.
endif
Thanks ,
Smita