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

get table control field length

Karan_Chopra_
Active Participant
0 Likes
1,240

in table control i have a field with with char length 15 but i have to give a validation if lenght not equal to 6 giv error messgage with out changin the field length of table control

i used

DESCRIBE FIELD gi_pmpb_bchid-batchid LENGTH ln IN CHARACTER MODE.

IF ln <> 6.

MESSAGE e013(zc8isms).

ELSE.

but here length is coming as 15 only even if i enter 6 digits in field on TC

plz help

1 ACCEPTED SOLUTION
Read only

Karan_Chopra_
Active Participant
0 Likes
1,112

it says strlen not defined isnt this a keyword

in table control i have a field with with char length 15 but i have to give a validation if lenght not equal to 6 giv error messgage with out changin the field length of table control

i used

DESCRIBE FIELD gi_pmpb_bchid-batchid LENGTH ln IN CHARACTER MODE.

IF ln <> 6.

MESSAGE e013(zc8isms).

ELSE.

but here length is coming as 15 only even if i enter 6 digits in field on TC

plz help

8 REPLIES 8
Read only

Former Member
0 Likes
1,112

Hi

You can do one thing. Take the user input value into a string variable.

By using the length function of string, do the validation.

Read only

Former Member
0 Likes
1,112

Looks like you have some leading zeroes in your variable but which are not shown on your screen. Try to get rid of them and then get the length of the string.

Read only

Former Member
0 Likes
1,112

Hi...

put the field on a data of type string, and with STRLEN( WORD1 )

you have the len of the string.


DATA: In TYPE I,
          WORD(15).

word = gi_pmpb_bchid-batchid.
In = STRLEN( WORD)

IF ln 6.
MESSAGE e013(zc8isms).
ELSE.
....
endif.

regard

Marco

Read only

Former Member
0 Likes
1,112

DESCRIBE returns the attributes of a data object. Length operators, like STRLEN, on the other hand, return a length of the data content.

if strlen( <mytable-fieldname> ) gt 6.

etc...

or lv_len = strlen( <mytable-fieldname> ).

if lv_len (of type i) gt 6.

etc...

put this in code, press F1 on STRLEN for informative help on finding lengths, whether field or table.

Read only

0 Likes
1,112

well spotted!

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,112

Its the length of the column, not the data present in the cell.

Use the internal table value.

try this,

if strlen( wa-val ) le 6.

error.

endif.

Read only

Karan_Chopra_
Active Participant
0 Likes
1,113

it says strlen not defined isnt this a keyword

Read only

0 Likes
1,112

Hi,

Give one space between the variable and open bracket and close bracket of the function STRLEN.

eg. STRLEN(< 1 space> <your variable> <1 space >).

Hope this may help you.

Regards,

Smart Varghese