BI 4.1 Java SDK – setting Webi prompts
While working for Business Object Java SDK 4.0 , we went through couple of business scenario where we did customization on BI Launchpad and perform schedule webi reporting. There is well known API which helps to set up desired prompts and their value to schedule the same. We have upgraded the BI from BI 4.0 to BI 4.1 and the customization we performed for setting prompt broke. BI 4.1 doesn’t support set prompt API anymore.
There is recommendation to use RESTFul API from Business Objects support team but using RESTFul API is good with others functionality except to deal with setting prompts.
We found a different approach to set prompt value back to report engine to run report on new prompt field values.
The following method helps to set prompts:
We have single value prompt, Multi value prompt and optional prompt to deal with.
Please find the attached sample code.
what we need to do to perform the job:
1) Workspace instance
2) WorkspaceService instance
3)Parameter list to pass
with the help of it, we can retrieve Answer prompt instance. we have to work extensively if the answer prompt become null. we have to set it up manually by checking all type of prompt field.
Answer answer = srcPrompt.getAnswerInformation().getPreviousAnswer();
//sample code
if (answer instanceof SingleValueAnswer) {
//System.out.println(“SingleValueAnswer”);
AnswerValue answerValue = ((SingleValueAnswer) answer).getAnswerValue();
// setting up prompt value for single value prompt
// check up for optional prompt
if(srcPrompt.isOptional() ){
if( reportExcellPrompt[j].getValue() == null ||
” “.equalsIgnoreCase(reportExcellPrompt[j].getValue()) || “”.equalsIgnoreCase(reportExcellPrompt[j].getValue()) ){
// leave those as usual, taken care by own
} else {
Field lfg = answerValue.getCaptionField();
lfg.setString(reportExcellPrompt[j].getValue());
answerValue.setCaptionField(lfg);
}
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
// System.out.println(“formatAnswerInfo(answerValue) ” + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
else {
Field lfg = answerValue.getCaptionField();
lfg.setString(reportExcellPrompt[j].getValue());
answerValue.setCaptionField(lfg);
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
// System.out.println(“formatAnswerInfo(answerValue) ” + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
} else if (answer instanceof MultiValueAnswer) {
//System.out.println(“MultiValueAnswer”);
EList<AnswerValue> answerList = ((MultiValueAnswer) answer).getAnswerValues();
// check up for optional prompt
if(srcPrompt.isOptional() ){
// retrieving the prompt from multi value and split those into comma separetd String array []
if( reportExcellPrompt[j].getValue() == null ||
” “.equalsIgnoreCase(reportExcellPrompt[j].getValue()) ||
“”.equalsIgnoreCase(reportExcellPrompt[j].getValue())){
// skipping the values as there is null values to set back to prompt
dstPrompt.setSkipped(true);
} else {
// optional prompt but values to set back to prompt from excel sheet
String multiPromptVl = new String(reportExcellPrompt[j].getValue());
String[] prmptMultiFiledVl = new String [multiPromptVl.split(“;”).length];
int h= 0;
for(String prompt : multiPromptVl.split(“;”)){
prmptMultiFiledVl[h] = prompt;
h++;
// building multi answer values and set it back to the list
String caption = prmptMultiFiledVl[0];
Member memberValue = createMember(caption, null, dataType, pvl);
if (memberValue != null){
((MultiValueAnswer)answer).getAnswerValues().add(createAnswerValue(srcPrompt, caption, null, dataType, pvl));
}
}
answerList = ((MultiValueAnswer) answer).getAnswerValues(); // retrieve the multi value answer from list to set
// iterate through individual prompt and set the prompt value back
for(int p =0; p < answerList.size(); p++){
AnswerValue answerValue = answerList.get(p);
// setting up prompt value for single value prompt
Field lfg = answerValue.getCaptionField();
lfg.setString(prmptMultiFiledVl[p]);
answerValue.setCaptionField(lfg);
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
//System.out.println(“formatAnswerInfo(answerValue) ” + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
}
}
Hi Abhijit,
I faced the same issue on upgrade. You will need to use the raylight calls to set your parameters/schedule WEBI reports. What I have done is create a utility class to handle all the Restful calls. In this class we call http://"+Your CMS+":6405/biprws/raylight/v1/documents/"+Report_Id+"/parameters in order to obtain the parameter template xml that you will need when scheduling the report via a similar scheduling template.
You will need a client to make your calls. I used the
com.sun.jersey.api.client.Client to make the Restful calls. Once i get my template from /parameters, I update the prompt values in the resulting xml, then make a call passing prompts xml as a post.
private String callWs(String uri, String token, String post){
Client pc = Client.create();
WebResource presource = pc.resource(uri);
ClientResponse presponse = presource.type("application/xml")
.header("X-SAP-LogonToken", token)
.post(ClientResponse.class,post);
String poutput = presponse.getEntity(String.class);
return poutput;
}
Check out the link below Ted has excelent examples to get you going:
RESTful Web Services SDK
http://scn.sap.com/docs/DOC-61343
Thank you for your inputs. I already worked with RESTful Web Service API and implemented a project. It's good one but it have some limitation for report refresh with complex prompt value passing and setting back. The XML structure on parameter retrieval is too complex to set the parameter answer back to report engine.
You can see the attached link where I shared the work we did through RESTful Web Service SDK.