我有一个要调用的BAPI函数,它接受输入一个字符串并返回一个字符串列表作为输出。我在我的java代码中使用了jco3.jar文件但是找不到任何内置的方法来处理字符串列表(String [])作为输出参数,尽管我们有ByteArray / CharArray。
function.getExportParameterList()。getString(“I_DOCNUM”); //如果返回参数 - “I_DOCNUM”仅为String类型,但不适用于String List,则它将起作用。< / p>
请帮帮我。提前谢谢。
Java代码
JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
System.out.println("Attributes:");
System.out.println(destination.getAttributes());
System.out.println(destination.getRepository());
destination.ping();
JCoFunction function = destination.getRepository().getFunction("INBOUND_IDOCS_FOR_TID");
if(function == null)
throw new RuntimeException("INBOUND_IDOCS_FOR_TID not found in SAP.");
function.getImportParameterList().setValue("TID", "0A80351B1927589833E57997");
try
{
function.execute(destination);
}
catch(AbapException e)
{
System.out.println(e.toString());
return;
}
System.out.println("STFC_CONNECTION finished:");
System.out.println(" Echo: " + function.getExportParameterList().getString("I_DOCNUM"));
功能模块: -
INBOUND_IDOCS_FOR_TID.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(TID) TYPE EDIDS-TID
*" CHANGING
*" VALUE(I_DOCNUM) TYPE IDOC_TT
*" EXCEPTIONS
*" NO_IDOC_FOUND
*"----------------------------------------------------------------------
data: wa_docnum like edidc-docnum.
select docnum from edids into wa_docnum
where ( status eq '50'
or status eq '56' )
and tid eq tid.
append wa_docnum to i_docnum.
endselect.
if sy-subrc ne 0.
raise no_idoc_found.
endif.
ENDFUNCTION.
答案 0 :(得分:2)
IDOC_TT是一种表格类型。因此,您可以使用
访问此参数JCoTable tabIDocnums = function.getChangingParameterList().getTable("I_DOCNUM");
然后遍历表的行并使用以下命令访问每行的单个字段值:
String strIDocNumber = tabIDocnums.getString("EDI_DOCNUM");
通过字段索引或更高性能:
String strIDocNumber = tabIDocnums.getString(0);