cancel
Showing results for 
Search instead for 
Did you mean: 

Validation Rule to check length of a variable

Former Member
0 Kudos
612

Hi,

I would like to know if there is a way to create a validation rule to check length of a field (without using user exit, etc). I understand the STRLEN cannot be used for validation rule.

Thanks!

Regards,

Vivian

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

Hi,

You can create a validation rule to check the length of a field . Let's say that you want a WBS element to be of 6 characters. You need to follow the below steps:

T- Codes Used: OPSI (Maintain Validations).

Steps:

u2022 T-Code: OPSI -> Click on Project Definition -> Click on create validation (ZPS0001); a new validation will appear , name that validation as PS Validation -> Click on create step, name that step as u201CCheck proj def is 6 digitsu201D, expand this step and there will be 3 options: PRE REQUISITE,CHECK,MESSAGE ->( PRE REQUISITE will remain empty), Click on CHECK and write the program in the specified area as written under:

PROJ-PSPID :7-7: = ''

AND PROJ-PSPID :6-6: <> ''

AND PROJ-PSPID :5-5: <> ''

AND PROJ-PSPID :4-4: <> ''

AND PROJ-PSPID :3-3: <> ''

AND PROJ-PSPID :2-2: <> ''

AND PROJ-PSPID :1-1: <> ''

Now press F5 or Shift+F5 to check the syntax error, the green light in the status will tell you that the syntax written above is correct and complete ->Click on MESSAGE Click on maintain messages ->Click in the field opposite to message number, it will become editable, now write the message u201CProject definition can only be 6 digitsu201D and click on SAVE and go back (F3) ->Assign that message number to that step and click on SAVE.

Thanks,

Dhruv kumar Malhotra