private boolean _checkoutView2Table (DVSDocumentFile docFile, OutputStream oStream)
{
JCO.Function function;
JCO.ParameterList pList;
JCO.Structure sDraw;
JCO.Structure sReturn;
JCO.Table tblFiles;
JCO.Table tblContent;
String strFunction;
byte[] contentBytes;
int fileSize;
int len, offset;
// -----------------------------------------------------------------------------
// Create function
strFunction = new String ("CVAPI_DOC_CHECKOUTVIEW");
function = this.createFunction(strFunction);
// Define import-parameter
function.getImportParameterList().setValue(this.m_docType, "PF_DOKAR");
function.getImportParameterList().setValue(this.m_docNumber, "PF_DOKNR");
function.getImportParameterList().setValue(this.m_docVersion, "PF_DOKVR");
function.getImportParameterList().setValue(this.m_docPart, "PF_DOKTL");
// Get content as table
function.getImportParameterList().setValue("TBL", "PF_CONTENT_PROVIDE");
// Fill files
tblFiles = function.getTableParameterList().getTable("PT_FILES");
tblFiles.appendRow();
tblFiles.setValue(docFile.getStorageCat(), "STORAGE_CAT");
tblFiles.setValue(docFile.getApplication(), "DAPPL");
tblFiles.setValue(docFile.getAppNr(), "APPNR");
tblFiles.setValue(docFile.getFileName(), "FILENAME");
tblFiles.setValue(docFile.getLoio(), "LO_OBJID");
tblFiles.setValue(docFile.getPhio(), "PH_OBJID");
tblFiles.nextRow();
// -----------------------------------------------------------------------------
// Execute function
// -----------------------------------------------------------------------------
try
{
this.m_client.execute(function);
}
catch(JCO.AbapException ae)
{
System.err.println("JCO.AbapException: <" + strFunction + "> " + ae);
ae.printStackTrace();
return(false);
}
catch(JCO.Exception e)
{
System.err.println("JCO.Exception: <" + strFunction + "> " + e);
e.printStackTrace();
return (false);
}
// Get export-parameter & tables
sDraw = function.getExportParameterList().getStructure("PSX_DRAW");
sReturn = function.getExportParameterList().getStructure("PSX_MESSAGE");
tblContent = function.getTableParameterList().getTable("PTX_CONTENT");
// Do we have content
if (tblContent.getNumRows() < 0)
{
System.err.println ("No Content");
return (false);
}
contentBytes = new byte[2550];
offset = 0;
fileSize = docFile.getFileSize();
// -----------------------------------------------------------------------------
// Write the output to the given Stream
// -----------------------------------------------------------------------------
try
{
do
{
if (fileSize == 0)
{
fileSize = tblContent.getInt ("ORLN");
docFile.setFileSize (fileSize);
}
contentBytes = tblContent.getByteArray("ORBLK");
if ((offset + 2550) <= fileSize)
len = 2550;
else
len = fileSize - offset;
if (len > 0)
{
oStream.write(contentBytes, 0, len);
offset = offset + len;
}
} while(tblContent.nextRow());
oStream.close();
}
catch (IOException e)
{
System.err.println ("Error writing to the given Stream " + e);
e.printStackTrace();
return (false);
}
return (true);
}JCO调用BAPI_DOCUMENT_CHECKOUTVIEW2
ABAP文档检查出视图
最新推荐文章于 2023-02-17 08:36:41 发布
本文介绍了一个用于从ABAP系统中检查并导出文档视图到指定输出流的方法_checkoutView2Table。该方法通过定义和执行特定的ABAP功能模块来实现,涉及参数设置、表格填充及内容读取等步骤。
1060

被折叠的 条评论
为什么被折叠?



