Example - Application Stack

public void appStack() throws Exception
{
 
loginEnv.getUsedCapabilities().add("applicationStack");
ApplicationStack appStackAddress = new ApplicationStack();
FormRequest formRequest = new FormRequest(loginEnv);
formRequest.setReturnControlIDs("1");
formRequest.setFormName("P01012_W01012B");
 
formRequest.setReturnControlIDs("54|1[19,20]");
formRequest.setFormServiceAction("R");
formRequest.setMaxPageSize("5");
FSREvent findFSREvent = new FSREvent();
 
findFSREvent.setFieldValue("54", "E");
findFSREvent.doControlAction("15"); // Find button
formRequest.addFSREvent(findFSREvent);
 
 
ObjectWriter writer = loginEnv.getObjectMapper().writerWithDefaultPrettyPrinter();
out.println(writer.writeValueAsString(formRequest));
 
//open P01012_W01012B
String response = appStackAddress.open(loginEnv, formRequest);
out.println(writer.writeValueAsString(loginEnv.getObjectMapper().readTree(response)));
 
//check if in find browse
if (appStackAddress.getLastAppStackResponse().checkSuccess("P01012_W01012B"))
{
//select a record
ActionRequest actionRequest = new ActionRequest();
actionRequest.setReturnControlIDs("28"); //the form changes these return control IDs are for the next form
actionRequest.setFormOID("W01012B");
FSREvent selectFSREvent = new FSREvent();
selectFSREvent.selectRow("1", 3);
selectFSREvent.doControlAction("14"); //select button
actionRequest.addFSREvent(selectFSREvent);
 
response = appStackAddress.executeActions(loginEnv, actionRequest);
out.println(writer.writeValueAsString(loginEnv.getObjectMapper().readTree(response)));
 
//check if in fix inspect
if (appStackAddress.getLastAppStackResponse().checkSuccess("P01012_W01012A"))
{
//Change name - now on form A
ActionRequest actionRequestName = new ActionRequest();
actionRequestName.setReturnControlIDs("54|1[19,20]"); //form is going to change again these are for the next form
actionRequestName.setFormOID("W01012A");
FSREvent updateFSREvent = new FSREvent();
 
updateFSREvent.setFieldValue("28", "AIS APP Stack TEST"); //change name field
updateFSREvent.doControlAction("11"); //ok
   
actionRequestName.addFSREvent(updateFSREvent);
 
response = appStackAddress.executeActions(loginEnv, actionRequestName);
out.println(writer.writeValueAsString(loginEnv.getObjectMapper().readTree(response)));
 
 //IMPORTANT: here you would have to de-serialize the response to check if there were errors on the form after pressing okay, if so you could continue to close the A form and go back to the B form
if (appStackAddress.getLastAppStackResponse().checkSuccess("P01012_W01012A"))
{
//press find again (to see name change) then close the stack
ActionRequest actionRequestClose = new ActionRequest();
FSREvent closeFSREvent = new FSREvent();
actionRequestClose.setReturnControlIDs("54|1[19,20]"); //form is changing these are the controls of the returned form
actionRequestClose.setFormOID("W01012A");
closeFSREvent.doControlAction("12"); //close   
actionRequestClose.addFSREvent(closeFSREvent);
 
response = appStackAddress.close(loginEnv, actionRequestClose);
out.println(writer.writeValueAsString(loginEnv.getObjectMapper().readTree(response)));
}
}
 
}
 
}