hero
Home About Hardware Guide

Categories

Archive

October 2024

September 2024

August 2024

July 2024

June 2024

May 2024

April 2024

March 2024

February 2024

January 2024

December 2023

November 2023

October 2023

September 2023

August 2023

July 2023

June 2023

May 2023

April 2023

March 2023

February 2023

January 2023

December 2022

back to home

Matryoshka Dolls - Surviving SAP's Multi-Nested RFC Parameters Maze

01 May 2024 • 4 mins

Back in the 90s, calling SAP RFC function modules was pretty straightforward. There were import, export, and table parameters. The imports and exports could either be scalar or structured—and that was the end of the story.

Over the years, more complex parameters where pressed into this structure, and “Changings” became supported by modern SAP systems.

In today’s article, we’ll cover multi-nested tables and how to handle them in XQL. This is one of the XQL features that is supported from Peakboard version 3.8 or later.

The RFC function module

For this article, we’ll have a look at a sample RFC with an import parameter called I_SELOPT. This parameter is a table-like import parameter. But it’s not just a simple table—it’s a mutli-nested table.

That means each row can have a cell that is itself another table. The most common use case for this are tables designed for dynamic data selection. Each row refers to a certain field, and the table per row refers to a set of select options. Multi-nested tables provide a complete generic selection without the need for changing the import parameters when an additional filter field is necessary.

image

Let’s dig deeper into the associated type, ZTABRANGE. It points to the structure ZSINGLERANGE.

image

Within the line type ZSINGLERANGE, we find the scalar field name called FIELDNAME, and also the table for the generic filter called SELOP.

image

The table type ZTRSDSSELOPT refers to the line type RSDSSELOPT.

image

The standard line type RSDSSELOPT contains four single values to represent a filter line:

  • SIGN: I for include, E for exclude.
  • OPTION: An operator (for example, EQ for equals, or BT for between).
  • LOW: the lower value.
  • HIGH: the optional upper value.

image

How to build the XQL

We start with a very simple version and build a non-multi-nested XQL table to call the function module. The table we build has just one column called FIELDNAME and two rows with values, MATNR and WERKS.

EXECUTE FUNCTION 'Z_PB_MAT_SELECTION'
   EXPORTS
      I_SELOPTS = ((FIELDNAME),
         ('MATNR'),
         ('WERKS'))
   CHANGING
      C_MATTAB INTO @RETVAL

Now, we need to add one more table to each selection row. The column name for the set of tables is called SELOP. And each SELOP cell is a table with the four columns mentioned earlier.

In our example, the first SELOP table has exactly one row. It contains a select option row for the material number 100-100.

The second SELOP row has two filter rows. In the first filter, we have the criteria EQUALS 1000, and the second filter row is BETWEEN 2000 and 3000.

Note that you have to be very careful with the brackets, and it’s highly recommended to use the notation that’s shown in this example, with the correct line breaks and indents.

EXECUTE FUNCTION 'Z_PB_MAT_SELECTION'
   EXPORTS
      I_SELOPTS = ((FIELDNAME, SELOP),
         ('MATNR', ((SIGN,OPTION,LOW,HIGH), 
                    ('I','EQ','100-100', '')) ),
         ('WERKS', ((SIGN,OPTION,LOW,HIGH), 
                    ('I','EQ','1000', ''), 
                    ('I','BT','2000', '3000')) 
                  ))
   CHANGING
      C_MATTAB INTO @RETVAL
Matryoshka Dolls - Surviving SAP's Multi-Nested RFC Parameters Maze

Newsletter

Want to get notified when a new article is published? Sign up below!