Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Add your SAP Business ByDesign scripting language implementation for:
- Business Object: ServiceRequest
- Node: Root
- Action: wsCall
- Note:
- - To access the elements of the business object node,
- use path expressions, for example, this.<element name>.
- - To use code completion, press CTRL+J.
- */
- import ABSL;
- import AP.FO.BusinessPartner.Global;
- import AP.Common.GDT; //for LANGUAGEINDEPENDENT_EXTENDED_Text
- import AP.PC.IdentityManagement.Global; //current user
- import AP.FO.ProductDataMaintenance.Global;
- //validate user input
- var IsCorrect = false;
- //user input is not empty
- if (!this.S4UserInput.IsInitial() && !this.S4ObjectType.IsInitial())
- {
- //if it's delivery or sales order or purchase order or invoice
- if (this.S4ObjectType == "DEL" || this.S4ObjectType == "SOID" || this.S4ObjectType == "POID" || this.S4ObjectType == "INV")
- {
- //check length, should be 10 digits or less
- if (this.S4UserInput.Length() <= 10)
- {
- //check if user input contains only numbers
- if (this.S4UserInput.Matches("^[0-9]*$")) //regex patter to match only digits
- {
- this.S4UserInput.ReplaceRegex("^0+", ""); // remove leading zeros to avoid check for Sales Order starts with 0004* and 4*...
- if (this.S4ObjectType == "POID")
- {
- if (this.S4UserInput.StartsWith("19"))
- {
- IsCorrect = true;//mark flag as true, allow webservice call
- }
- else { raise Msg_CustomSR.Create("W", "STO ID should start with 19*."); }
- }
- else if (this.S4ObjectType == "SOID")
- {
- if (this.S4UserInput.StartsWith("4"))
- {
- IsCorrect = true;//mark flag as true, allow webservice call
- }
- else { raise Msg_CustomSR.Create("W", "Sales Order ID should start with 4* or 0004*."); }
- }
- else if (this.S4ObjectType == "DEL")
- {
- if (this.S4UserInput.StartsWith("8") || this.S4UserInput.StartsWith("3"))
- {
- IsCorrect = true;//mark flag as true, allow webservice call
- }
- else { raise Msg_CustomSR.Create("W", "Delivery ID should start with 8* for Sales Orders or 3* for Purchase Orders."); }
- }
- else if (this.S4ObjectType == "INV")
- {
- if (this.S4UserInput.StartsWith("9"))
- {
- IsCorrect = true;//mark flag as true, allow webservice call
- }
- else { raise Msg_CustomSR.Create("W", "Invoice ID should start with 9* or 009*."); }
- }
- }
- else { raise Msg_CustomSR.Create("W", "For Delivery, Invoice, Sales Order, STO use only digits. List of permitted characters - 1234567890."); }
- }
- else { raise Msg_CustomSR.Create("W", "For Delivery, Invoice, Sales Order, STO do not exceed 10 characters limit."); }
- }
- //if it's railcar or customer PO number
- else if (this.S4ObjectType == "RAILCAR" || this.S4ObjectType == "CUSTPON")
- {
- //check length, should be 20 digits or less. Register is very important (lowercase or UPPERCASE).
- //depending on the case, user may get different results.
- //spaces at the end are also critical
- if (this.S4UserInput.Length() <= 20)
- {
- IsCorrect = true;//mark flag as true, allow webservice call
- //if (this.S4ObjectType == "RAILCAR")
- //{
- //if (this.S4UserInput.StartsWith("SOXX"))
- //{
- //IsCorrect = true;//mark flag as true, allow webservice call
- //}
- //else { raise Msg_CustomSR.Create("W", "RAILCAR number should start with SOXX*."); }
- //}
- //else if (this.S4ObjectType == "CUSTPON")
- //{
- //IsCorrect = true;//mark flag as true, allow webservice call
- //}
- }
- else { raise Msg_CustomSR.Create("W", "For Rail Car, Customer PO number do not exceed 20 characters limit."); }
- }
- }
- else { raise Msg_CustomSR.Create("W", "User Input or Object Type dropdown is empty"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement