Table SAP RFC 的参数为空

Table parameters to SAP RFC are empty

我试图将 table 参数从 .net 传递给 RFC 但没有成功。

我正在关注这个例子。 pass type table parameter

1) C# 代码:

        int low = 2015;
        int high = 2016;
        string sign = "I";
        string option= "BT";

        RfcConfigParameters parametros = SapConector_fch.ConexionAsap_fch(SapConector_fch);
        RfcDestination DestinoRFC = SapConector_fch.probarConexionASap_fch(parametros, this.Page);            
        RfcRepository repositorio = DestinoRFC.Repository;
        IRfcFunction zrfc_valorhh = repositorio.CreateFunction("ZRFC_VALORHH");

         IRfcTable it_ano = zrfc_valorhh.GetTable("ANO");
        //IRfcStructure it_ano = zrfc_valorhh.GetStructure("ANO");


          it_ano.Append();
          it_ano.SetValue("SIGN", sign);
          it_ano.SetValue("OPTION", option);
          it_ano.SetValue("LOW", low);
          it_ano.SetValue("HIGH", high); 


        try
        {
            zrfc_valorhh.Invoke(DestinoRFC);
        }
        catch (RfcAbapException ex)
        {
            Console.WriteLine(ex.Message);
            ClientScript.RegisterStartupScript(this.GetType(), "Exepcion al llamar el RFC", "alert('" +"Exepcion al llamar el RFC " +  ex.Message + "');", true);
        }

2) 我知道什么时候 table 参数 "ANO" 变空了,因为我在 sap 中抛出了一个异常。
异常是 EMPTYPARAMETER。

    FUNCTION ZRFC_VALORHH.
   *"*"Interfase local
   *"  TABLES
   *"      IT_VALORESHH STRUCTURE  ZSTRUCT_VALORESHH
   *"      ANO STRUCTURE  RNG_GJAHR
   *"  EXCEPTIONS
   *"      NODATA
   *"      EMPTYPARAMETER
   *"----------------------------------------------------------------------

  IF ano IS INITIAL.
    RAISE EMPTYPARAMETER.
  ENDIF.

3) 我也试过这个答案,但没有用。 another solution

请帮忙-

作为文档的 vwegert already commented you are not checking whether the table is initial but instead you are checking whether the header line of the internal table is initial. If you are not familiar with internal tables with header line, please refer to this part。实际上,您应该只知道它们存在,但您不应该再使用它们,因为它们已被弃用,甚至还不允许在 OO 上下文中使用。

"problem"是带TABLES关键字的功能模块。它将参数声明为内部 table。如果函数启用了 RFC,这是唯一一个甚至推荐使用它们的地方(我记不太清了,但我认为这与性能有关)。因此,要检查内部 table 和 header 行是否为空,您需要编写

IF ano[] IS INITIAL.
    RAISE EMPTYPARAMETER.
ENDIF.

IF lines( ano ) IS INITIAL.
    RAISE EMPTYPARAMETER.
ENDIF.

如果您将 table 类型作为 IMPORTINGEXPORTING 参数作为值传递(使用启用了 RFC 的功能模块,则不可能这样做)否则)。

FUNCTION ZZZTEST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(I_INPUT) TYPE  STRING_TABLE
*"  EXPORTING
*"     VALUE(E_EXPORT) TYPE  STRING_TABLE
*"----------------------------------------------------------------------

ENDFUNCTION.

对于 TABLES 参数,您不会收到此类警告。

如果您想将范围作为 TABLES 传递,您仍然可以这样做,因为 RANGE OF 只是定义一个具有特殊结构的内部 table。这是一个例子...