BusinessObjects Board

bi 4.2 sdk setprompts() does not work for prompt multi

Hi everybody,

I try to execute an sdk java program that I migrated from XI3 to BI4.2 SP3

but it does not run correctly.

the program schedule webi reports with prompts that are indicated in an xml properties file.
the schedule run correctly but when a document contains prompts with multi values, the setPrompts() function does not insert the values of the prompts.

if someone has already incounter this problem, please give me an idea to correct my code.
this is a snippet :

import com.businessobjects.rebean.wi.*;
import com.businessobjects.sdk.plugin.desktop.webi.IWebi;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.infostore.ISchedulingInfo;
import com.crystaldecisions.sdk.plugin.desktop.program.IProgramBase;


System.out.println("================= INITIALISATION =================");
System.out.println((new StringBuilder("=== “)).append(path).append(NomDoc[0]).toString());
for (int i = 0; i < NomDoc.length; i++) {
final IInfoObjects objs = oInfoStore.query((new StringBuilder(“Select * From CI_INFOOBJECTS Where SI_KIND in (‘Webi’,‘FullClient’) And SI_INSTANCE=0 And SI_NAME = '”))
.append(NomDoc[i].replaceAll(”’", “’’”)).append("’ and SI_PARENT_CUID =’").append(last_id).append("’").toString());
System.out.println((new StringBuilder(“Select * From CI_INFOOBJECTS Where SI_KIND in (‘Webi’,‘FullClient’) And SI_INSTANCE=0 And SI_NAME = '”))
.append(NomDoc[i].replaceAll("’", “’’”)).append("’ and SI_PARENT_CUID =’").append(last_id).append("’").toString());
for (int compteur_doc = 0; compteur_doc < objs.size(); compteur_doc++) {
final IInfoObject obj = (IInfoObject) objs.get(compteur_doc);
final String chemin = GetParentArbo.getParentfolderPath(oInfoStore, obj.getCUID());
GetParentArbo.path = “”;
for (int a = 0; a < bloc.length; a++) {
System.out.println("");
System.out.println("================= TRAITEMENT =================");
bloc[a] = bloc[a].replace("@rmaeq", rmaeq).replace("@rmaem", Date.getLastMonthLastDate(“dd/MM/yyyy”)).replace("@DernierJourOuvreDuMois", DernierJourOuvreDuMois)
.replace("@num_mois_prec", num_mois_prec).replace("@num_annee_prec", num_annee_prec).replace("@num_annee", num_annee).replace("@end_month(2)", end_month2)
.replace("@begin_month(2)", begin_month2);
System.out.println((new StringBuilder(“Planification avec les valeurs '”)).append(bloc[a]).append("’").toString());
//p_parameters = bloc[a].split("\244");
p_parameters = bloc[a].split(";");
final IWebi webi = (IWebi) objs.get(compteur_doc);
final DocumentInstance documentInstance = reportEngine.openDocument(webi.getID());

				documentInstance.refresh();
				
				/*try{
					documentInstance.getDataProviders().runQueries();
				}catch(Exception e){
					System.out.println(e);
				}*/
				
				final Prompts prompts = documentInstance.getPrompts();
				System.out.println((new StringBuilder("Nombre d'invites : ")).append(prompts.getCount()).toString());
				if (p_parameters[0].equals("")) {
					titre = INSTANCE_TITLE;
				} else if (prompts.getCount() != p_parameters.length) {
					throw new Exception("le nombre d'invites ne correspond pas avec celui attendu");
				}
				titre = INSTANCE_TITLE;
				
				System.out.println("----PROCESSING----");
				for (int j = 0; j < prompts.getCount(); j++) {
					final Prompt prompt = prompts.getItem(j);
					final String p_parameter = p_parameters[j].trim();
					if(!p_parameter.equals("")){
						if (prompt.getType() == PromptType.Mono) {
							if(prompt.hasLOV() ){ 
								String curPromptVal = p_parameters[j]; 
								ValueFromLov[] set = new ValueFromLov[1]; 
								Lov lov = prompt.getLOV(); 
								Values vals=lov.getAllValues(); 
								set[0]=null;
								for(int lovI=0;lovI<vals.getCount();lovI++){ 
									if(vals.getValue(lovI).equals(curPromptVal)){ 
										set[0] = vals.getValueFromLov(lovI);break; 
									} 
								} 
								System.out.println("Mono - Inside prompt has LOV >> set >> "+p_parameter); 
								titre = titre.replace(prompt.getName(), p_parameter);
								if(!(set.equals(null) &amp; prompt.isOptional()))
									prompt.enterValues(p_parameter.split(","));
								else
									prompt.enterValues(set);
							}else{
								final String vals[] = new String[1];
								vals[0] = p_parameters[j];
								System.out.println("Mono - no Lov >> set >> "+vals[0]);
								titre = titre.replace(prompt.getName(), vals[0]);
								prompt.enterValues(vals);
							}
						} else {
							if(prompt.hasLOV() ){ 
								String[] curPromptVals = p_parameter.split(","); 
								ValueFromLov[] set = new ValueFromLov[curPromptVals.length]; 
								Lov lov = prompt.getLOV(); 
								Values vals=lov.getAllValues(); 
								int index=0; 
								for (String curPromptVal : curPromptVals){ 
									for(int lovI=0;lovI<vals.getCount();lovI++){ 
										if(vals.getValue(lovI).equals(curPromptVal)){ 
											set[index] = vals.getValueFromLov(lovI);
											break; 
										} 
									} 
									index++; 
								} 
								System.out.println("Multi - Inside prompt has LOV >> set >> "+set[index-1].getValue().toString());
								titre = titre.replace(prompt.getName(), set[index-1].getValue().toString());
								prompt.enterValues(set); 
							}else{
						
								int iPosBegin = 0;
								int iPosEnd = 0;
								int iNbValue = 0;
								final String lsParam = p_parameters[j];
								while (iPosEnd != -1) {
									iPosEnd = lsParam.indexOf(";", iPosBegin);
									iPosBegin = iPosEnd + 1;
									iNbValue++;
								}
								final String vals[] = new String[iNbValue];
								iPosBegin = 0;
								iPosEnd = 0;
								iNbValue = 0;
								final Calendar cal = Calendar.getInstance();
								final int month = cal.get(2) + 1;
								while (iPosEnd != -1) {
									iPosEnd = lsParam.indexOf(";", iPosBegin);
									iNbValue++;
									if (iPosEnd == -1) {
										vals[iNbValue - 1] = lsParam.substring(iPosBegin, lsParam.length());
									} else {
										vals[iNbValue - 1] = lsParam.substring(iPosBegin, iPosEnd);
									}
									titre = titre.replace(prompt.getName(), vals[iNbValue - 1]);
									iPosBegin = iPosEnd + 1;
								}
								if (!(prompt.isOptional() &amp; vals[iNbValue - 1].replace(" ", "").equals(""))) {
									System.out.println("Multi - no Lov >> set >> "+vals[0]);
									prompt.enterValues(vals);
								}
							}
						}
					}
				}

				//PromptsUtil.populateWebiPrompts(prompts, webi);
				documentInstance.refresh();
				//try{
				//	documentInstance.getDataProviders().runQueries();
				//}
				//catch(Exception e){System.out.println(e);};
				documentInstance.setPrompts();
				documentInstance.save();
				System.out.println("----AFTER SETPROMPTS----");
				for (int j=0; j<prompts.getCount();j++){
					final Prompt prompt = prompts.getItem(j);
					if (prompt.getType() == PromptType.Mono) {
						if(prompt.getCurrentValues().length>0){
							System.out.println("Mono -> CurrentValues de "+prompt.getName()+" "+prompt.getCurrentValues()[0].toString());
						}
						if(prompt.getPreviousValues().length>0){
							System.out.println("Mono -> PreviousValues de "+prompt.getName()+" "+prompt.getPreviousValues()[0].toString());
						}
						if(prompt.getDefaultValues().length>0){
							System.out.println("Mono -> DefaultValues de "+prompt.getName()+" "+prompt.getDefaultValues()[0].toString());
						}
					}else{
						if(prompt.getCurrentValues().length>0){
							System.out.println("Multi -> CurrentValues de "+prompt.getName()+" "+prompt.getCurrentValues()[0].toString());
						}
						if(prompt.getPreviousValues().length>0){
							System.out.println("Multi -> PreviousValues de "+prompt.getName()+" "+prompt.getPreviousValues()[0].toString());
						}
						if(prompt.getDefaultValues().length>0){
							System.out.println("Multi -> DefaultValues de "+prompt.getName()+" "+prompt.getDefaultValues()[0].toString());
						}
					
					}
				}

THANKS A LOT


mamentague (BOB member since 2017-05-16)

A lot of stuff around Webi reports has been deprecated from the Java SDK. Instead, you’ll use the RESTful Web Services SDK to set the parameters and create the schedule.

In versions earlier thatn 4.2 SP5, the RESTful Web Services SDK runs on the Web Application Container Server. Starting with 4.2 SP5, there is an option to deploy it to the web server (Tomcat, etc.). The beauty of this SDK is that you don’t have to download any libraries that compile into your code. Instead, you communicate with the web service via HTTP GET and HTTP POST commands and the response from the server will be in either XML or JSON format (depending on what you select.) This is the direction that SAP is headed in for ALL of the SDKs, so it would be good to learn it sooner rather than later.

-Dell


hilfy :us: (BOB member since 2007-04-16)

Did you get this working. I have code which I need to migrate from 3.1 to 4.2 BO SDK. Any sample working code in 4.2 will help.
Thanks


mgr74 (BOB member since 2018-07-16)