1

Im trying to pass a table parameter to a RFC from .net with no success.

I am folowing this example. pass type table parameter

1) C# CODE:

        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) I know when the table parameter "ANO" comes empty because an exception is thrown wich is made by me in sap.
The exeption is 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) I also tried this answer but not working. another solution

Please Help-

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
funkeeiads
  • 327
  • 2
  • 6
  • 20
  • 3
    Could you please try if `IF ano[] IS INITIAL` gives you a better result? If it does, I'll add an answer explaining it... – vwegert Mar 20 '16 at 07:42

1 Answers1

2

As 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 of documentation. Actually you should only know that they exist but you should not use them anymore as they are deprecated an even not allowed in OO context yet.

The "problem" is with TABLES keyword for function modules. It declares parameter as such an internal table. It is the only place where usage of them is even recommended if the function is RFC enabled (I do not remember exactly but I think it has to do with performance). Therefore to check whether the internal table with header line is empty you need to write

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

or

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

This is what you get if you pass table types for IMPORTING or EXPORTING parameters if you pass them as values (with RFC enabled function modules there is no possibility to do otherwise).

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

ENDFUNCTION.

Exporting param Importing param

For TABLES parameter you do not get such warnings.

If you want to pass ranges as TABLES you can still do that because RANGE OF does nothing more than defining an internal table with a special structure. Here is an example...

Range structure FM with ranges as tables

Community
  • 1
  • 1
Jagger
  • 10,350
  • 9
  • 51
  • 93
  • 1
    If they are deprecated, how to pass table parameters (Like ranges)? or there is a better way to do this? – funkeeiads Mar 20 '16 at 13:29
  • 2
    they are deprecated for developing function modules, which means you *shouldn't* use them for new function modules. It does not mean you *can't* use them anymore and it also doesn't mean you can't use them over RFC. SAP has plenty of function modules using table parameters and they would have to change all of those before they could go any further and remove table parameters at all. The recommended way to use table parameters now is table types in import/export. – Dirk Trilsbeek Mar 20 '16 at 16:13