‎2007 Jan 31 2:09 PM
I am entereing a number whose length is 9 characters longs... The system should proceed only if the length is equal to 9 characters.. How could i check that...
‎2007 Jan 31 2:13 PM
I think the syntax is
data w_length(10).
data w_field(9).
w_field = '12345678'.
w_length = STRLEN( w_field )
Anyway the command is STRLEN.
‎2007 Jan 31 2:13 PM
strlen
<b>Report zex33.
parameter : str(9).
data : len type i.
len = STRLEN( str ).
if len eq 9.
write : / str.
else.
write : / 'String length is not equal to 9'.
endif.</b>
‎2007 Jan 31 2:14 PM
Let's say the user enters SERNR
What would be the statement to check whether is it 9 characters or not....
‎2007 Jan 31 2:13 PM
Hi alexander,
you can store the inpur number in a field defined as string
then you can use STRLEN keyword to get the length
hope this helps
‎2007 Jan 31 2:13 PM
Hi,
Use <b>STRLEN</b> to get lenth of the field.
Regards,
Balavardhan.K
‎2007 Jan 31 2:14 PM
use the DESCRIBE statetment to get the length of the field..
~Suresh
‎2007 Jan 31 2:14 PM
Hi,
Assign the value to string & calculate the length of string (strlen). if it is less than 9 then throw an error message.
Ashvender
‎2007 Jan 31 2:14 PM
‎2007 Jan 31 2:15 PM
check V1 = <b>strlen(field).</b>
if V1 = 9.
do the processing.
endif.
‎2007 Jan 31 2:21 PM
Here is the code... I have to make sure that I_SERNR then it has to process the code... How can i do that...
DATA: I_EQUI LIKE EQUI.
DATA: I_SERNR LIKE EQUI-SERNR.
I_SERNR = SERNR.
SHIFT I_SERNR LEFT DELETING LEADING '0'.
DATA: SERNR LIKE EQUI-SERNR.
DATA: MATNR TYPE MATNR.
IF SY-TCODE = 'MB31'.
SELECT SINGLE * FROM EQUI INTO I_EQUI
WHERE EQTYP = 'S'
AND MATNR = MATNR
AND SERNR = SERNR.
IF SY-SUBRC EQ 0.
MESSAGE E398(00) WITH 'SERIAL NUMBER ALREADY EXISTS'.
ELSE.
IF I_SERNR0(1) = '2' OR I_SERNR0(1) = '3' OR I_SERNR+0(1) = '6'.
IF I_SERNR1(2) = SY-DATUM2(2).
IF I_SERNR3(2) LE SY-DATUM4(2).
IF I_SERNR5(4) GT '0000' AND I_SERNR5(4) LT '9999'.
ELSE.
MESSAGE E398(00) WITH 'PLEASE ENTER RANGE WITHIN 0000 AND 9999'.
ENDIF.
ELSE.
MESSAGE E398(00) WITH 'PLEASE ENTER A DATE IN THE PAST'.
ENDIF.
ELSE.
IF I_SERNR1(2) LT SY-DATUM2(2).
IF I_SERNR5(4) GT '0000' AND I_SERNR5(4) LT '9999'.
ELSE.
MESSAGE E398(00) WITH 'PLEASE ENTER RANGE WITHIN 0000 AND 9999'.
ENDIF.
ELSE.
MESSAGE E398(00) WITH 'PLEASE ENTER A DATE IN THE PAST'.
ENDIF.
ENDIF.
ELSE.
MESSAGE E398(00) WITH 'INVALID MANUFACTURING SITE'.
ENDIF.
ENDIF.
ELSE.
SELECT SINGLE * FROM EQUI INTO I_EQUI
WHERE EQTYP = 'S'
AND MATNR = MATNR
AND SERNR = SERNR.
IF SY-SUBRC NE 0.
MESSAGE E398(00) WITH 'PLEASE ENTER A VALID SERIAL NUMBER'.
ENDIF.
ENDIF.
‎2007 Jan 31 2:22 PM
‎2007 Jan 31 2:39 PM
Hi,
Do like this:
data: length type i.
data: v_string type string.
v_string = I_SERNR.
Write this code before IF statement(SY-TCODE = 'MB31').
length = strlen( v_string ).
if length <> 9.
message e000(0) with 'Value length is not = 9'.
endif.
Ashvender
‎2007 Jan 31 2:50 PM
DATA: I_EQUI LIKE EQUI.
DATA: I_SERNR LIKE EQUI-SERNR.
I_SERNR = SERNR.
SHIFT I_SERNR LEFT DELETING LEADING '0'.
* DATA: SERNR LIKE EQUI-SERNR.
* DATA: MATNR TYPE MATNR.
<b>
data: len type i.
len = strlen( i_sernr ).
if len <> 9.
message e001(00) with 'SERNR value not = 9'.
endif.</b>
IF SY-TCODE = 'MB31'.
SELECT SINGLE * FROM EQUI INTO I_EQUI
WHERE EQTYP = 'S'
AND MATNR = MATNR
AND SERNR = SERNR.
IF SY-SUBRC EQ 0.
MESSAGE E398(00) WITH 'SERIAL NUMBER ALREADY EXISTS'.
ELSE.
........
Regards,
Rich Heilman
‎2007 Jan 31 3:58 PM
In this current the serial number 2,3 digits are validated against year, 4,5 digits are validated against month. When I enter 13 for the month it is accepting and validating. Also I have to make to sure the valid years are current year and past year, valid months are current month and past month... how to achieve it .....
‎2007 Jan 31 5:37 PM
Hi,
I hope following code will solve your problem.
DATA : v_len TYPE i.
PARAMETERS : p_num(9) TYPE n.
AT SELECTION-SCREEN ON p_num.
v_len = STRLEN( p_num ).
IF v_len <> 9.
IF v_len < 9.
MESSAGE 'Length of p_num is Less Than 9' TYPE 'E'.
ELSE.
MESSAGE 'Length of p_num is Greater Than 9' TYPE 'E'.
ENDIF.
ENDIF.
Reward points if the answer is helpful.
Regards,
Mukul