Data structure for key-value list in RFC-enabled function module?

1.2k views Asked by At

I am writing a new RFC callable function in ABAP which should be able to import a list of key-values mapping.

The RFC calling application will use Python with the PyRFC library.

I am unsure whether I should create a new custom data structure of if I can re-use an existing data structure.

The import argument should be able to contain a list of this:

('key1', ['key1val1', 'key1val2', ...])
('key2', ['key2val1', 'key2val2', ...])
....

If possible I would like to re-use an existing data structure.

One ugly hack would be to design the API like this: use a string and parse at as json. But this is a work-around which I would like to avoid.

I found the data structure WDY_KEY_VALUE but there the value is a string. I would need a structure where the value is a list of strings.

2

There are 2 answers

1
Haojie On BEST ANSWER

You can create a deep structure with KEY defined with type STRING and VALUE defined with type STRINGTAB.

enter image description here

3
iPirat On

modelling such data is perfectly possible in ABAP DDIC:

  1. create table type z_t_values with row being built in type string

  2. create structure type z_s_key_values with fields key type string and values type z_t_values

  3. create table type z_t_key_values with row type z_s_key_values

now, the type z_t_key_values corresponds to your example input: it is a table of rows, each row contains a single key and a table of values