diff --git a/docs/documentation/api-specification/program-api.md b/docs/documentation/api-specification/program-api.md index ea1b77b..21422ee 100644 --- a/docs/documentation/api-specification/program-api.md +++ b/docs/documentation/api-specification/program-api.md @@ -24,113 +24,430 @@ nav_order: 2 ## Description The Program API contains APIs that can be used to get information from the current program. -## Features +## Methods -### getUser -Returns the current user +### Indicator(get) +Retrieve value of indicators. +
+Returns: `boolean`
-Example: +Example: ```groovy public class testProgram extends ExtendM3Trigger { private final ProgramAPI program - private final InteractiveAPI interactive + + public testProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + boolean indicatorValue = program.indicator.get(60); + + ... + } +} +``` + +### LDAZD(get) +Retrieve fields mapped in LDAZD. +
+Parameter: `String 'key'` +
+Returns: `value of the field, null if get fails` +
+ +Example: +```groovy +public class testProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public testProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + int currentCompany = (Integer)program.getLDAZD().CONO; + + ... + } +} +``` +### LDAZZ(get) +Retrieve fields mapped in LDAZZ. +
+Parameter: `String 'key'` +
+Returns: `value of the field, null if get fails` +
+ +Example: +```groovy +public class testProgram extends ExtendM3Trigger { + private final ProgramAPI program; - public testProgram(ProgramAPI program, InteractiveAPI interactive) { - this.program = program - this.interactive = interactive + public testProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + int orderNum = (Integer)program.getLDAZZ().ORNO; + + ... + } +} +``` + +### getProgramName +Retrieve the name of the current program. +
+Returns: `String 'currentProgram'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String currentProgram = program.getProgramName(); + + ... + } +} +``` + +### getMarket +Retrieve the market of the current job. Will always return a valid system component, will never be "ALL". +
+Returns: `String 'market'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String currentMarket = program.getMarket(); + if(currentMarket != "MSE") { + return; + } + + ... + } +} +``` + +### getUser +Retrieves the current username. +
+Returns: `String 'user'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; } public void main() { if (program.getUser() != "CRIUBA36") { - return + return; } + + ... + } +} +``` + +### getProgramType +Retrieves the current program type(e.g. interactive). +
+Returns: `String 'programType'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String currentProgramType = program.getProgramType(); + + ... + } +} +``` + +### getNumberOfInputParameters +Retrieves the programs' number of input parameters. +
+Returns: `int 'numberOfInputParameters'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + int numberOfInputParameters = program.getNumberOfInputParameters(); + + ... + } +} +``` + +### getJobNumber +Retrieves the current job number. +
+Returns: `int 'jobNumber` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + int currentJobNumber = program.getJobNumber(); + + ... + } +} +``` + +### getTableRecord +Retrieves records from a specific table in the program. +
+Parameter: `String 'table'` +
+Returns: `TableRecordAPI` + +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + TableRecordAPI mitwhl = program.getTableRecord("MITWHL"); + String whlo = mitwhl.MWWHLO; + + ... + } +} +``` + +### getMessageId +Retrieves the current message ID(program heading). +
+Returns: `String 'messageID'` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String messageID = program.getMessageId(); + + ... + } +} +``` + +### getMessageData +Retrieve message data. +
+Returns: `String 'messageData` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String messageData = program.getMessageData(); - interactive.showCustomInfo("Current User: " + program.getUser()) + ... } } ``` -### getTableRecord -To be able to retrieve a record from a specific table in the program +### getMessage +Retrieve message. +
+Returns: `String 'message'`
Example: ```groovy -public class TestProgram extends ExtendM3Trigger { - private final ProgramAPI program - private final ExtensionAPI extension - private final InteractiveAPI interactive +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; - public TestProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive) { - this.program = program - this.extension = extension - this.interactive = interactive + public exampleProgram(ProgramAPI program) { + this.program = program; } public void main() { - TableRecordAPI mitwhl = program.getTableRecord("MITWHL") - String whlo = mitwhl.MWWHLO - if (program.getUser() != "CRIUBA36") { - return - } + String message = program.getMessage(); - interactive.showCustomInfo("Current Warehouse: " + whlo) + ... } } ``` -### LDAZD -To be able to retrieve fields mapped in LDAZD +### getTenantId +Retrieve the current tenant ID. +
+Returns: `String 'tenantID`
+ Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + String tenantID = program.getTenantId(); + + ... + } +} +``` + +### existsInCallStack +Checks if the given program is in the current call stack. +
+Parameters: `String program` +
+Returns: `boolean` +
+Example: ```groovy -public class testProgram extends ExtendM3Trigger { - private final ProgramAPI program - private final ExtensionAPI extension - private final InteractiveAPI interactive +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; - public testProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive) { - this.program = program - this.extension = extension - this.interactive = interactive + public exampleProgram(ProgramAPI program) { + this.program = program; } public void main() { - int currentCompany = (Integer)program.getLDAZD().CONO - if (program.getUser() != "CRIUBA36") { - return - } + boolean programExists = program.existsInCallStack(String program); - interactive.showCustomInfo("Current Company: " + currentCompany) + ... } } ``` -### LDAZZ -To be able to retrieve field mapped in LDAZZ + +### isShutdownInProgress +Checks if program shutdown is in progress. +
+Returns: `boolean`
+ Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + boolean programShutdown = program.isShutdownInProgress(String program); + + ... + } +} +``` + +### exitFlag +Checks if the exit flag is active. +
+Returns: `boolean` +
+Example: ```groovy -public class testProgram extends ExtendM3Trigger { - private final ProgramAPI program - private final ExtensionAPI extension - private final InteractiveAPI interactive +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; - public testProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive) { - this.program = program - this.extension = extension - this.interactive = interactive + public exampleProgram(ProgramAPI program) { + this.program = program; } public void main() { - int orderNum = (Integer)program.getLDAZZ().ORNO - if (program.getUser() != "CRIUBA36") { - return - } + boolean exitFlagActive = program.exitFlag(); + + ... + } +} +``` + +### existsError +Checks if the error flag is true(alternative to program.indicator.get(60)). +
+Returns: `boolean` +
+ +Example: +```groovy +public class exampleProgram extends ExtendM3Trigger { + private final ProgramAPI program; + + public exampleProgram(ProgramAPI program) { + this.program = program; + } + + public void main() { + boolean existsError = program.existsError(); - interactive.showCustomInfo("Order Number: " + orderNum) + ... } } ```