how to create a validation rule

23
Validation Transaction codes: Create Validation : GGB0 Create a Set : GS01 Requirement : For all the Transactions for the company code US11, the item text should be a mandatory field. It should be applicable for all the GL Accounts except for two. Let us built this logic through a validation. Go to Transaction GGB0 Go to the level where you want to create a validation and click on Create button.

Upload: cgollapu

Post on 14-Oct-2014

127 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: How to Create a Validation Rule

Validation

Transaction codes:

Create Validation : GGB0 Create a Set : GS01

Requirement : For all the Transactions for the company code US11, the item text should be a mandatory field. It should be applicable for all the GL Accounts except for two.

Let us built this logic through a validation.

Go to Transaction GGB0

Go to the level where you want to create a validation and click on Create button.

Page 2: How to Create a Validation Rule

On the next screen, give a name to your validation

Once the name is given, click on “Prerequisite”

Page 3: How to Create a Validation Rule

Now, Write the Logic.

Clcik on the Accounting document Header or the Document Segment depending on the field which we are using in the logic.

We are doing this for company code US11. As the company code is available in the Document Header, Click on the header to find the field.

Page 4: How to Create a Validation Rule

Select the company code and click on it, now as you can see the value is been populated on the screen.

Click on Equal to and once it appears on the screen, Click on the Tab, “Constant” and type in the value “US11”

Page 5: How to Create a Validation Rule
Page 6: How to Create a Validation Rule

Click on Document type. As this Validation is applicable for more than one Document type, a set needs to be created.

To do this, go to GS01 transaction.

Page 7: How to Create a Validation Rule

Give some meaningful name to the Set Under the table field, give the name of the table from which the field is being picked. In this case go to Transaction OBA7, and get the table.

Select the Basic set and then click on Enter.

The system asks for the field name within the tableSelect the Document type fom the drop down list

Page 8: How to Create a Validation Rule

Enter the values and save.

Once the set is created go back to the transaction “GGB0” to continue.

On the screen Click on “And” and continue

The system should check the document type in this set and the validation should apply only for those document types.

Go back to GGB0 screen

Select the Field Document Type from the Accounting Document header and click on IN

And to select the set that we have created earlier, click on “Set Directory”

Page 9: How to Create a Validation Rule

Select the set from the drop down.

Now we need to exclude two GL accounts from this Validation.

Go back to the previous screen and click on Prerequisites, This time select the Accounting Document Segment to select the field GL account field.

Page 10: How to Create a Validation Rule

Click on “And” And click on the GL field As there are two GL accounts included, a set needs to be created as well.

Page 11: How to Create a Validation Rule

On a new session go to Transaction GS01 to create a set for these two GL fields.

Press enter

Page 12: How to Create a Validation Rule

Go back to GGB0 screen,

Click on “And” and then “Not” Select the GL Account Field from the Document Line item.

And click on the GL account. Click on “IN”

Select the Set for the GL Accounts from the Set Directory.

Page 13: How to Create a Validation Rule

And this rule should apply for all the items with Posting Key 40 and 50.

As there is more than one value (40 and 50) and as there is no set maintained for this value, this logic should be put in a Parenthesis. ( )

“OR “Command cannot be used without being in a Bracket.

Hence we are going to put this in a Bracket.

Start with a Bracket.

Here we are going to click on the Posting Key field from the Account Document Line item .

Page 14: How to Create a Validation Rule

Click on Equal to and click on constant and type in 40

Again Click on the Constant button and add 50.

Close the Bracket.

Go back and click on Save.

The system will save it with a new Step number.

Click on the header level as shown below, under which the new Step has been created and click on Save again.

Page 15: How to Create a Validation Rule

With this, we have finished the Prerequisites. Now we should create a check.

We create a check rule. This Check rule will first look if the prerequisites are met.If the prerequisites are met then, the system will go through the check and apply whatever is defined in the check.

In our case, if the above prerequisites are met, then the system should make sure the Line item text field is not empty.

To do this, Click on Check under the Step we have created.

Click on the Line item text from the Document Accounting Line Item.

Page 16: How to Create a Validation Rule

Click on the line item Text. Click on “<>” which indicates “Not Equal to” And click on constant

Press enter without typing anything to indicate blank.

And click on save.

Once this is done, Click on Message under the new Step that is created earlier.

To create the error message if the previous check fails, to the Transaction SE91

Page 17: How to Create a Validation Rule

Enter the message class and press on Display.

Click on change button. And create a new message and save.

Page 18: How to Create a Validation Rule

“Enter Short text” should appear if the user does not fill in the Text field.

And the message number is 290. You can see the message number on the GGB0 screen.

Page 19: How to Create a Validation Rule

TESTING:

Let us test a Document Type to see if the validation is working.

We are testing for document type “TZ” where the validation should apply.

I have created the transaction, but did not update the Line item text.

Page 20: How to Create a Validation Rule

Click on Save.

Enter the short text and try to save it again.

Page 21: How to Create a Validation Rule

And click on Save.