Search code examples
abapsaprfcbapi

Names of RFC parameters are unique?


I am working on an interface for communicating with SAP RFC functions. I have some questions regarding parameter hierarchy and uniqueness of parameter and table naming to which I can't seem to find an answer anywhere online.

  1. Are the deep hierarchical structures allowed when communicating via RFC? Here are some examples of input parameters:

    • Example A (Structure within Structure):

      Field F1
      Field F2
      Structure S1 
          Field S1.F1
          Structure S1.S1
              Field S1.S1.F1
              Field S1.S1.F2
          Field S1.F2
          Field S1.F3
      
    • Example B (Table within Structure):

      Field F1
      Field F2
      Structure S1
          Field S1.F1
          Table S1.T1
              Structure S1.T1.S1 (Row 1)
                  Field S1.T1.S1.F1
                  Field S1.T1.S1.F2
              Structure S1.T1.S2 (Row 2)
                  Field S1.T1.S2.F1
                  Field S1.T1.S2.F2
          Field S1.F2
          Field S1.F3
      
    • Example C (Table within Table):

      Field F1
      Field F2
      Table T1
          Structure T1.S1 (Row 1)
              Field T1.S1.F1
              Table T1.S1.T1
                  Structure T1.S1.T1.S1 (Row 1)
                      Field T1.S1.T1.S1.F1
                      Field T1.S1.T1.S1.F2
                  Structure T1.S1.T1.S2 (Row 2)
                      Field T1.S1.T1.S2.F1
                      Field T1.S1.T1.S2.F2
          Structure T1.S2 (Row 2)
              Field T1.S2.F1
              Table T1.S2.T1
                  Structure T1.S2.T1.S1 (Row 1)
                      Field T1.S2.T1.S1.F1
                      Field T1.S2.T1.S1.F2
                  Structure T1.S2.T1.S2 (Row 2)
                      Field T1.S2.T1.S2.F1
                      Field T1.S2.T1.S2.F2
      
  2. Are the names of fields, structures and tables per hierarchical level unique? Or are the tables handled separately and could for example have the same name as a field or a structure?


Solution

  • RFC, including parameter types, is described in the documentation of each RFC Interface (documentation in each programming language RFC SDK, or ABAP documentation). You may use RFC both as client and server.

    If you use RFC SDK (any programming language except ABAP) to create an RFC server (to expose RFC functions), I guess the types of the parameters support the same types as in ABAP (but I can't be sure so please refer to the documentation of each SDK in case of exceptions).

    In ABAP, you can know the types of parameters supported in RFC by combining these two articles:

    If you don't have the time to combine them, here's a summary of parameter types for RFC-enabled function modules:

    • A parameter can be of any type, elementary (what you call "fields"), structure, table.
    • Structures can have components of any of the 3 types above.
    • Tables which are not TABLES parameters can have lines of any of the 3 types above.
    • Tables which are TABLES parameters must have lines of type flat, which means that the line cannot contain fields of type STRING or XSTRING, nor tables.
    • The names of fields, structures and tables are unique per hierarchical level, whatever their parameter category, IMPORTING, EXPORTING, CHANGING or TABLES, e.g.
      • a component of a structure at level 1 may have the same name as a parameter at level 1.
      • a field and a structure at level 1 cannot have the same name
    • One exception to the previous rule is that two parameters can have the same name at level 1 if they are of type IMPORTING and EXPORTING (they are considered the same as one CHANGING parameter of that name - see SAP note 357348 - Import and export parameters of the same name).

    The rows of one table all have the same type, so your diagrams mentioning S1 and S2 are incorrect, you could just mention S1. Note that a table parameter can have lines also of type elementary and table.

    Here is an example of valid parameters of an RFC-enabled function module:

    Field F1
    Structure S1 
        Field S1.F1
        Structure S1.S1
            Field S1.S1.F1
        Table T1 
            Structure T1.S1
                Field T1.S1.F1
        Table T2
            Field T2.F1
        Table T3
            Table T3.T1
                Field T3.T1.F1
    Table T1 
        Table T1.T1
            Field T1.T1.F1
    Table T2
        Structure T2.S1
            Field T2.S1.F1
    Table T3
        Field T3.F1
    

    Reference: