Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

lenght for numeric field

Former Member
0 Likes
2,277

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..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,764

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.

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..

7 REPLIES 7
Read only

Former Member
0 Likes
1,765

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.

Read only

Former Member
0 Likes
1,764

TP_RLNUM(16) itself means that it cant take more than 16.

why coding?

Read only

Former Member
0 Likes
1,764

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

Read only

dev_parbutteea
Active Contributor
0 Likes
1,764

Hi,

Variables of type n lenght 16 will always have 16 characters :

e.g. if value = 7

variable = '0000000000000007'.

Read only

MarcinPciak
Active Contributor
0 Likes
1,764

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

Read only

Former Member
0 Likes
1,764
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.
Read only

Former Member
0 Likes
1,764

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