2010 Mar 23 11:10 AM
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
2010 Mar 23 12:22 PM
it says strlen not defined isnt this a keyword
2010 Mar 23 11:15 AM
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.
2010 Mar 23 11:17 AM
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.
2010 Mar 23 11:17 AM
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
2010 Mar 23 11:22 AM
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.
2010 Mar 23 11:30 AM
2010 Mar 23 11:56 AM
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.
2010 Mar 23 12:22 PM
2010 Mar 23 12:33 PM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |