Advertisement
golim22

Untitled

Sep 19th, 2022
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.69 KB | Source Code | 0 0
  1. /*
  2.     Add your SAP Business ByDesign scripting language implementation for:
  3.         Business Object: ServiceRequest
  4.         Node: Root
  5.         Action: wsCall
  6.        
  7.     Note:
  8.       - To access the elements of the business object node,
  9.         use path expressions, for example, this.<element name>.
  10.       - To use code completion, press CTRL+J.
  11.        
  12. */
  13.  
  14. import ABSL;
  15.  
  16. import AP.FO.BusinessPartner.Global;
  17. import AP.Common.GDT; //for LANGUAGEINDEPENDENT_EXTENDED_Text
  18. import AP.PC.IdentityManagement.Global; //current user
  19. import AP.FO.ProductDataMaintenance.Global;
  20.  
  21. //validate user input
  22. var IsCorrect = false;
  23.  
  24. //user input is not empty
  25. if (!this.S4UserInput.IsInitial() && !this.S4ObjectType.IsInitial())
  26. {  
  27.     //if it's delivery or sales order or purchase order or invoice
  28.     if (this.S4ObjectType == "DEL" || this.S4ObjectType == "SOID" || this.S4ObjectType == "POID" || this.S4ObjectType == "INV")
  29.     {
  30.         //check length, should be 10 digits or less
  31.         if (this.S4UserInput.Length() <= 10)
  32.         {
  33.             //check if user input contains only numbers
  34.             if (this.S4UserInput.Matches("^[0-9]*$")) //regex patter to match only digits
  35.             {
  36.                 this.S4UserInput.ReplaceRegex("^0+", ""); // remove leading zeros to avoid check for Sales Order starts with 0004* and 4*...
  37.                 if (this.S4ObjectType == "POID")
  38.                 {
  39.                     if (this.S4UserInput.StartsWith("19"))
  40.                     {
  41.                         IsCorrect = true;//mark flag as true, allow webservice call
  42.                     }
  43.                     else { raise Msg_CustomSR.Create("W", "STO ID should start with 19*."); }
  44.                 }
  45.                 else if (this.S4ObjectType == "SOID")
  46.                 {
  47.                     if (this.S4UserInput.StartsWith("4"))
  48.                     {
  49.                         IsCorrect = true;//mark flag as true, allow webservice call
  50.                     }
  51.                     else { raise Msg_CustomSR.Create("W", "Sales Order ID should start with 4* or 0004*."); }
  52.                 }
  53.                 else if (this.S4ObjectType == "DEL")
  54.                 {
  55.                     if (this.S4UserInput.StartsWith("8") || this.S4UserInput.StartsWith("3"))
  56.                     {
  57.                         IsCorrect = true;//mark flag as true, allow webservice call
  58.                     }
  59.                     else { raise Msg_CustomSR.Create("W", "Delivery ID should start with 8* for Sales Orders or 3* for Purchase Orders."); }
  60.                 }
  61.                 else if (this.S4ObjectType == "INV")
  62.                 {
  63.                     if (this.S4UserInput.StartsWith("9"))
  64.                     {
  65.                         IsCorrect = true;//mark flag as true, allow webservice call
  66.                     }
  67.                     else { raise Msg_CustomSR.Create("W", "Invoice ID should start with 9* or 009*."); }
  68.                 }
  69.                
  70.             }
  71.             else { raise Msg_CustomSR.Create("W", "For Delivery, Invoice, Sales Order, STO use only digits. List of permitted characters - 1234567890."); }
  72.         }
  73.         else { raise Msg_CustomSR.Create("W", "For Delivery, Invoice, Sales Order, STO do not exceed 10 characters limit."); }
  74.     }
  75.  
  76.     //if it's railcar or customer PO number
  77.     else if (this.S4ObjectType == "RAILCAR" || this.S4ObjectType == "CUSTPON")
  78.     {
  79.         //check length, should be 20 digits or less. Register is very important (lowercase or UPPERCASE).
  80.         //depending on the case, user may get different results.
  81.         //spaces at the end are also critical
  82.         if (this.S4UserInput.Length() <= 20)
  83.         {
  84.             IsCorrect = true;//mark flag as true, allow webservice call
  85.  
  86.             //if (this.S4ObjectType == "RAILCAR")
  87.             //{
  88.             //if (this.S4UserInput.StartsWith("SOXX"))
  89.             //{
  90.             //IsCorrect = true;//mark flag as true, allow webservice call
  91.             //}
  92.             //else { raise Msg_CustomSR.Create("W", "RAILCAR number should start with SOXX*."); }
  93.             //}
  94.             //else if (this.S4ObjectType == "CUSTPON")
  95.             //{
  96.             //IsCorrect = true;//mark flag as true, allow webservice call
  97.             //}
  98.  
  99.         }
  100.         else { raise Msg_CustomSR.Create("W", "For Rail Car, Customer PO number do not exceed 20 characters limit."); }  
  101.     }
  102. }
  103. else { raise Msg_CustomSR.Create("W", "User Input or Object Type dropdown is empty"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement