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

regarding STRLEN

Former Member
0 Likes
1,382

DEAR GUYS.

ALREAYD I ASKED THIS QUESTION..but it does not worked out..before.

my question is here..

DATA p_ltab_zlotmg(30) TYPE C.

DATA MYLEN TYPE I.

MYLEN = STRLEN( p_ltab_zlotmg ).

I want to check if my len of input is greater than 13 digits.

why its not working..it always shows 0 here.

if MYLEN >13.

...error.

endif.

ALTERNATIVEly i tried this..

DESCRIBE FIELD p_ltab_zlotmg LENGTH MYLEN IN CHARACTER MODE.

but it always gives the variable lenght size declared already..

could somebody clear me..

ambichan

6 REPLIES 6
Read only

Former Member
0 Likes
966

Hi

STRLEN will work when you have some value in the variable. Try putting some value in p_ltab_zlotmg .

Cheers

Read only

Former Member
0 Likes
966

U can get the defined attrubites(like length,type) using describe stmt...

to find the length u have to use strlen

try this

DATA p_ltab_zlotmg(30) TYPE C value '12345'.

DATA MYLEN TYPE I.

MYLEN = STRLEN( p_ltab_zlotmg ).

now u will get mylen = 5...

Please close the old threads which were answered & still opened..

regards

gv

Message was edited by: Venkat

Message was edited by: Venkat

Read only

Former Member
0 Likes
966

If there is any data in p_ltab_zlotmg, then STRLEN should return you a value other than 0.


DATA p_ltab_zlotmg(30) TYPE C.
DATA mylen TYPE I.

p_ltab_zlotmg = 'ABCD'.
mylen = STRLEN( p_ltab_zlotmg ).
*-- in this case MYLEN will be 4.
p_ltab_zlotmg = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
*-- In this case it will be 26
if MYLEN >13. 
...error.
endif.

Read only

Former Member
0 Likes
966

TRY F1

STRLEN

Length of a string (type STRING or XSTRING) or a character field (particularly type C) up to its last <b>non-space </b>character (its occupied length).

regards

Read only

Former Member
0 Likes
966

DESCRIBE just describes the attributes of the field. Since you asked for the length attribute, it will always give you 30 because that is the defined length.

For the runtime occupied lenght you will use STRLEN.

If answered please close the post.

Srinivas

Read only

Former Member
0 Likes
966

hi, please aware that the STRLEN can't calculate the length, if the field is all filled with SPACE.

thanks