Application Development 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: 

Validating problem

Former Member
0 Kudos

I developed a code a to validate the serial number (SERNR) ...... The serial number entered is 9 characters... But at the runtime...it is preceeded by 9 zeros making valid entered number invalid.How can i remove those extra zeroes..

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can do this a number of ways. First you could simply SHIFT it.

SHIFT SERNR left deleting leading '0'.

Regards,

Rich Heilman

0 Kudos

Could u explain in detail with the example of the sample code....

Also what is the syntax of the Shift statement

Former Member
0 Kudos

You may also use NO-ZERO with WRITE statement.

NO-ZERO

-


If a field contains only zeros, these are replaced by blanks. For type C and N fields, leading zeros are replaced automatically.

WRITE: '000123',

/ '000123' NO-ZERO.

Output:

000123

123

Thanks,

Santosh

Former Member
0 Kudos

If i understand you correctly, you have SERNR as a user-input option, and at runtime, it is left-padded with zeroes. This means that your input parameter is of type N, whose default-value is filled with zeroes.

One way to overcome this would be to change the definition of the parameter to type I or type C, depending upon whether you expect characters or not.

Further, there are conversion-modules to convert a user-input value to the internal format. Check SE37 with the name CONVERALPHAINPUT - you could use either the generic FM, or a specific one for your field.