E9.2 Call BSFN from Groovy

Stank1964

Well Known Member
in the interest of sharing with the group here.

Deepak over at the Oracle help line shared this with me from development. He said they will not support it and I have not gotten it to work yet, but here is the code....


import com.oracle.e1.common.OrchestrationAttributes;
import com.oracle.e1.aisclient.*;
import com.oracle.e1.aisclient.runbsfn.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;

HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

String ais_url = (String)inputMap.get("ais_url");

LoginEnvironment loginEnv = new LoginEnvironment(ais_url, "JDE", "JDE", null);

if (loginEnv != null) {

try {

String abNo = (String)inputMap.get("abNo");

BSFNRequest bsfnRequest = new BSFNRequest(loginEnv);
bsfnRequest.setName("F0101GetAddressInformation");
bsfnRequest.setIsAsynch(false);

// Set Input Values
bsfnRequest.getInParams().add(new DSTRInputValue(1, abNo));

// Set Return Ids
bsfnRequest.getOutputIds().add(new Long(3));
bsfnRequest.getOutputIds().add(new Long(4));

BSFNResponse responseObject = bsfnRequest.execute();

if (responseObject.getResult().getErrors() != null) {
BSFNError errorValue = responseObject.getResult().getErrors().get(0);
String error = errorValue.getFileName() + " - " + errorValue.getLineNumber() + " - " + errorValue.getGlossaryText();
returnMap.put("error", error);
} else {
String outValue1 = responseObject.getResult().getOutput().get(0).getValue().toString();
returnMap.put("outValue1", outValue1);
String outValue2 = responseObject.getResult().getOutput().get(1).getValue().toString();
returnMap.put("outValue2", outValue2);
}
} catch (Exception e) {
String error = e.getMessage();
returnMap.put("error", error);

}
finally {

AISClientUtilities.logout(loginEnv);
}
}

return returnMap;
}
 
This is interesting, but I have to wonder why you wouldn't just use a BSFN Custom Request (same spot you spin up a Groovy Custom Request)? The UI is very good and familiar if you ever dealt with BF calls in RDA/FDA
 
This is interesting, but I have to wonder why you wouldn't just use a BSFN Custom Request (same spot you spin up a Groovy Custom Request)? The UI is very good and familiar if you ever dealt with BF calls in RDA/FDA
Yeah can’t see the need for this. Storing user id and clear text password work not be permitted in my house!
 
This is interesting, but I have to wonder why you wouldn't just use a BSFN Custom Request (same spot you spin up a Groovy Custom Request)? The UI is very good and familiar if you ever dealt with BF calls in RDA/FDA
Suppose you need to call the BSFN based on an array returned from a forms or data request... The BSFN provides more data to add column(s) to the array.
 
UI/UX design is the process of creating user interfaces and user experiences for software products. It is a combination of user interface (UI) design, which focuses on the look and feel of an application or website, and user experience (UX) design, which focuses on how users interact with a product. This includes aspects such as ease of use, accessibility, responsiveness, and efficiency. The goal is to create a product that is both pleasing to the eye and easy to use.
Please stop using AI to create posts. Thank you.
 
in the interest of sharing with the group here.

Deepak over at the Oracle help line shared this with me from development. He said they will not support it and I have not gotten it to work yet, but here is the code....


import com.oracle.e1.common.OrchestrationAttributes;
import com.oracle.e1.aisclient.*;
import com.oracle.e1.aisclient.runbsfn.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;

HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

String ais_url = (String)inputMap.get("ais_url");

LoginEnvironment loginEnv = new LoginEnvironment(ais_url, "JDE", "JDE", null);

if (loginEnv != null) {

try {

String abNo = (String)inputMap.get("abNo");

BSFNRequest bsfnRequest = new BSFNRequest(loginEnv);
bsfnRequest.setName("F0101GetAddressInformation");
bsfnRequest.setIsAsynch(false);

// Set Input Values
bsfnRequest.getInParams().add(new DSTRInputValue(1, abNo));

// Set Return Ids
bsfnRequest.getOutputIds().add(new Long(3));
bsfnRequest.getOutputIds().add(new Long(4));

BSFNResponse responseObject = bsfnRequest.execute();

if (responseObject.getResult().getErrors() != null) {
BSFNError errorValue = responseObject.getResult().getErrors().get(0);
String error = errorValue.getFileName() + " - " + errorValue.getLineNumber() + " - " + errorValue.getGlossaryText();
returnMap.put("error", error);
} else {
String outValue1 = responseObject.getResult().getOutput().get(0).getValue().toString();
returnMap.put("outValue1", outValue1);
String outValue2 = responseObject.getResult().getOutput().get(1).getValue().toString();
returnMap.put("outValue2", outValue2);
}
} catch (Exception e) {
String error = e.getMessage();
returnMap.put("error", error);

}
finally {

AISClientUtilities.logout(loginEnv);
}
}

return returnMap;
}
That was exactly what I was looking for, it worked like a charm, thank you very much! One question tho. Can I use the current logged session to instance BSFNRequest? The user will be already authenticated when this function runs, can't I use this authentication to login? I can't hardcode the username and pass on the code, nor save it on a table.
I've tried to use the class JWTLoginEnvironment passing the orchAttr as the token parameter with no success. Any ideas on how I can do that?
I've opened a SR on Oracle but I don't think they will help me with that.
Thanks!
 
Unfortunately, my understanding is that the answer is no per Oracle tech. It makes sense to me that that is the right answer as we all know this is a product that was loosely conceived and is still evolving.
 
Back
Top