2016-12-23 19 views
0

私はSAP JCoで作業しています。そして、DATE '12を.16.2016' 設定しているときに例外を取得してcom.sap.conn.jco.ConversionException:(122)JCO_ERROR_CONVERSION:String to Dateフィールド

例外: com.sap.conn.jco.ConversionException:(122)JCO_ERROR_CONVERSION:'12 .16.2016' の値を変換できませんjava.lang.String型からフィールドDATEにSTRUCTUREに移動します。

私のコードは、JCO.Functionsのすべてのパラメータは文字列でなければなりません

public static void YP_ECA_VIN(String date, String plant) throws Exception { 
    try { 
     JCoDestination destination; 
     JCoRepository sapRepository; 
    destination = JCoDestinationManager.getDestination(DST1); 
    JCoDestinationManager.getDestination(DST1);  
    JCoContext.begin(destination); 
    sapRepository = destination.getRepository();   
    if (sapRepository == null) { 
     System.out.println("Couldn't get repository!"); 
     JCoContext.end(destination); 
     System.exit(0); 
    } 
    JCoFunctionTemplate template =  sapRepository.getFunctionTemplate("YP_ECA_VIN");  
    if (template == null) { 
     System.out.println("Couldn't get template for YP_ECA_VIN!"); 
    } else { 
     JCoFunction function = template.getFunction(); 
     function.getImportParameterList().setValue("DATE", "12.16.2016"); 
     function.getImportParameterList().setValue("PLANT", plant); 
     function.execute(destination); 
     int numTRows = 0; 
     int numTCoulmns = 0; 
     JCoTable table = function.getExportParameterList().getTable("OUTPUT"); 
     // some code 
    } 
+1

機能モジュールの署名も投稿します。 – vwegert

答えて

0

です。日付値も文字列として設定してください。 SAPでは、日付文字列の形式は「yyyyMMdd」、たとえば、「20161223」です。

+0

現在:com.sap.conn.jco.ConversionException:(122)JCO_ERROR_CONVERSION: の値を'20161223 'の型をjava.lang.Stringの型からSTRUCTURE型のフィールドDATE – dinesh

+0

に変換できない場合は、フィールドをチェックする必要がありますまた、このようなエラーが発生する可能性があるため、テーブルを構造体として考慮していないことを確認してください。 – Pritam

0

DATEという名前のRFMインポートパラメータは、明らかに日付型ではなく、構造型です。この場合、JCo側でJCoStructureインスタンスを使用し、Stringでは使用しないでください。

しかし、私はむしろ、ABAP側でリモート汎用モジュールインタフェースYP_ECA_VINを定義するときに間違いを犯したと思います。このインポートパラメータDATEは、実際にはABAPの日付型にすることをお勧めします。