on 2025 Feb 17 8:55 AM
Dear All,
The business user uploaded a CSV file to BO, and now I am required to use JAVA code to call SAP SDK to export it to the local directory of the server. My Java code has already connected to CMS and found the corresponding infoObject May I ask what should be done next? Which SDK should I use? Which method should be used to export files? Do everyone have any ideas? Thank you in advance.
My BO version is SAP BusinessObjects BI Platform 4.2 Support Pack 8 Patch 2
Version: 14.2.8.3503
Here is my code:
package com.chb.ods;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.*;
import com.crystaldecisions.sdk.plugin.desktop.excel.IExcel;
import com.crystaldecisions.sdk.plugin.desktop.report.IReport;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class FileUploadApp {
private static final Logger logger = Logger.getLogger(FileUploadApp.class.getName());
public static void main(String[] args) {
try {
// 配置日志文件
FileHandler fileHandler = new FileHandler("D:\\JAVADoc\\Code\\FileUploaddemo5\\downloadFileFromBO.log", true);
fileHandler.setFormatter(new SimpleFormatter());
logger.addHandler(fileHandler);
logger.setLevel(Level.ALL);
// 重定向System.out和System.err到日志文件
// PrintStream printStream = new PrintStream(new FileOutputStream("D:\\JAVADoc\\Code\\FileUploaddemo2\\downloadFileFromBO.log", true));
// System.setOut(printStream);
// System.setErr(printStream);
// 1. 登录到CMS
//System.out.println("logon start!");
logger.info("logon start!");
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
IEnterpriseSession enterpriseSession = sessionMgr.logon("Administrator", "Abcd1234", "ODSBOUAT01:6400", "secEnterprise");
logger.info("logon completed!");
// 2. 获取InfoStore服务
IInfoStore infoStore = (IInfoStore) enterpriseSession.getService("InfoStore");
logger.info("getInfoStore completed!");
// 3. 查询报表对象
String query = "SELECT SI_ID, SI_NAME, SI_INSTANCE,SI_KIND FROM CI_INFOOBJECTS WHERE SI_NAME='cif093pf.381086.20240830.dat'";
IInfoObjects infoObjects = infoStore.query(query);
logger.info("query completed!");
// 4. 下载报表到本地
// byte[] reportContent = fileObject.getContent();
// String filePath = "/odsetl/APP/fileupload/MyReport.csv";
// try (OutputStream outputStream = new FileOutputStream(filePath)) {
// outputStream.write(reportContent);
// logger.info("Report downloaded successfully to: " + filePath);
// }
// IFiles[] files = fileObject.getFiles();
// if (files.length > 0) {
// InputStream inputStream = files[0].getLocale().getInputStream();
// String filePath = "/odsetl/APP/fileupload/MyReport.txt";
// try (OutputStream outputStream = new FileOutputStream(filePath)) {
// byte[] buffer = new byte[4096];
// int bytesRead;
// while ((bytesRead = inputStream.read(buffer)) != -1) {
// outputStream.write(buffer, 0, bytesRead);
// }
// logger.info("File downloaded successfully to: " + filePath);
// } finally {
// inputStream.close();
// }
// }
} else {
logger.info("Report not found.");
}
logger.info("douwnload completed!");
// 5. 注销
enterpriseSession.logoff();
} catch (SDKException e) {
logger.info("SDKException occurred: " + e.getMessage());
e.printStackTrace();
} catch (Exception e) {
logger.info("Exception occurred: " + e.getMessage());
e.printStackTrace();
}
}
}
Request clarification before answering.
it is not clear why you need to export the CSV file again to the server's local directory!!??
If the user uploaded it, it will be located on the server in the input filestore directory.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.