Skip to content

Instantly share code, notes, and snippets.

@davorpa
Last active November 18, 2019 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davorpa/0e846cf895cac78118e8703097bb3bbc to your computer and use it in GitHub Desktop.
Save davorpa/0e846cf895cac78118e8703097bb3bbc to your computer and use it in GitHub Desktop.
SAP ABSL validation snippet for Indian PAN Number
// https://help.sap.com/viewer/cbcebe3cfb1647a8b0322c18dbb0b481/2019.11/en-US/7594ffd473e21014b19dc98f75a551c4.html?q=findregex
// https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenregex_syntax_specials.htm
// https://answers.sap.com/questions/10845683/sap-hrabap-pan-card-validation-check-in-pa-30-subt.html
var valid = true;
var CurrentCommon = this.Common.GetFirst();
if (CurrentCommon.IsSet())
{
var PAN_NO = CurrentCommon.PAN_NO;
if (!PAN_NO.Trim().IsInitial())
{
if (PAN_NO.Length() > 10 || PAN_NO.Length() < 10)
{
raise MsgPAN_NOLength.Create("E"); // Pan No. are fixed 10 chars values
valid = false;
}
else if (PAN_NO.FindRegex("[a-zA-Z]{5}[[:digit:]]{4}[a-zA-Z]{1}") != 0)
{
raise MsgPAN_NORegex.Create("E"); // Enter Valid Pan No. in the format 5char/4Numeric/1char
valid = false;
}
}
}
return valid;
@davorpa
Copy link
Author

davorpa commented Nov 18, 2019

In your BO definition declare 2 messages:

message MsgPAN_NOLength text "PAN No. are fixed 10 chars values";
message MsgPAN_NOLength text "Enter Valid PAN No. in format 5char/4Numeric/1char";

and remember the raise declaration

businessobject YourXXXBO raises MsgPAN_NOLength , MsgPAN_NOLength { ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment