cancel
Showing results for 
Search instead for 
Did you mean: 

Validation rule Document Date

12-01-2020 4:32 AM
Grego1 Explorer
1105 views 2 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello,

I'm trying to create a validation rule through the application manage validation rules and I have some difficulties with my rule.

The rule is simple, a blocking error should appear if the document date is before 2016.

But I don't know if I have a problem with the date format but the rule is not working. Has someone already faced this issue ?

DEFINE VALIDATION DOC_DATE

    IN CONTEXT FINS_ACC_CB_1

    PARAMETERS POSTING0 : FIN_SUBSTNVALDTNCODINGBLOCK

    PRECONDITION ( (  (  ( POSTING0-CompanyCode = 'FR01' )  )  ) ) 

    CASE WHEN NOT (  (  (  ( POSTING0-DocumentDate < '20160101' )  )  ) ) 

         THEN MESSAGE E007(FINRE_UI_01) 'DocumentDate', 'DOC_DATE', $RULE-ID.

    END

Thanks 

Grégory

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

GraceZou
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Grego, your validation rule is not defined correctly. You required the document date <20160101 to pass the rule (not fail the rule validation), so you have to define it as >= 20160101.

Btw, YYYYMMDD is the correct date format, and the BAdi mentioned in one answer is not compatible with the app.

Grace

Answers (1)

Answers (1)

henk_hoogerbrug
Active Participant
0 Likes

Hello Grégory,

I don't know if you can use all operators on date fields, but have you already tried another date format ddmmyyyy?

Another option you can test is the operator "between" (e.g. between 19990101 - 20151231).

If it is not possible to use the "simple" formulas, you can write your logic in a BAdI: https://help.sap.com/viewer/0fa84c9d9c634132b7c4abb9ffdd8f06/2011.500/en-US/fed79813a60447669f096d9f...

Best Regards,

Henk Hoogerbrug