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

checking length of variable

Former Member
0 Likes
3,808

i hav got a requirement where i get character varaible( but it wil be a number) as input and i am required to check if its a 8 digit or 9 digit number, according to which i need to select data from diff tables.

how can i go abt this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,837

Hi,

u can do like this.

data:num(3),var(10) value 'name'.

num = strlen( var ).

write:/ num.

rgds,

bharat.

7 REPLIES 7
Read only

Former Member
0 Likes
2,837

Hi balaji,

DESCRIBE FIELD <f> [LENGTH <l>] [TYPE <t> [COMPONENTS <n>]]

[OUTPUT-LENGTH <o>] [DECIMALS <d>]

[EDIT MASK <m>] [HELP-ID <h>].

DATA: float TYPE f,

out TYPE i,

len TYPE i.

DESCRIBE FIELD float LENGTH len OUTPUT-LENGTH out.

Reward if useful!

Read only

Former Member
0 Likes
2,837

Hi,

Use code as below :

data : len type i, amt(13).

amt = '11223429'.

len = strlen( amt ).

If len eq 8.

select .............

elseif len eq 9.

select.............

endif.

Regards,

Sandeep Kaushik

Read only

Former Member
0 Likes
2,837

Use the following code.

data: len type i.

len = strlen( that input field ).

Kishi.

Read only

Former Member
0 Likes
2,838

Hi,

u can do like this.

data:num(3),var(10) value 'name'.

num = strlen( var ).

write:/ num.

rgds,

bharat.

Read only

Former Member
0 Likes
2,837

Hi Balaji,

Calculate its length using STRLEN . This might help u in knowing the the no of disgits.

Hope this is useful to u.

Rewards points if useful.

Regrds,

Vijayakumar V

Read only

Former Member
0 Likes
2,837

hi,

1 .declare the variable 'X' of type string.

2. assign len = strlren(X) where len is of type i.

then u can chk the variable len to get the length of th variabke.

Regards,

viji

Read only

Former Member
0 Likes
2,837

data  : field1  type   (string /c/n/i )  ,
          field2  type  n  .  

field2 = Strlen(field1) .

so that the <b>field2</b> will have lenght of the<b> field1</b> .

reward points if it is usefull ..

Girish