--- title: "fill-map-from-fields()" slug: "basic-fill-map-from-fields" updated: 2026-08-11T12:22:51Z published: 2026-08-11T12:22:51Z canonical: "docs.lobstersoftware.com/basic-fill-map-from-fields" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # fill-map-from-fields() This function fills a map **a** with key-value pairs. Keys are named after the fields that are in the same node and above the current field, the values are the current values of these fields. Subnodes and empty fields are ignored. Parameter **b** allows the specification of a prefix that is added to the key name. If the key prefix **b** contains a substring *[#]*, the number specified in **c** will be used as a replacement for the character *#*. Setting **d** to *true* will lead to the use of calculation fields as well, otherwise, they are ignored. The optional parameter **e** can be a processing instruction of how to manipulate the key-value pair before putting it into the map. Overwriting a value to an already existing key leads to the termination of the function with an error. This ensures the uniqueness of the key-value pairs. This check can be switched off partially or completely by processing instructions in parameter **e**. This function is primarily used as preparation for the call of the [call-sap-rfc()](/v1/docs/en/basic-call-sap-rfc) function but can also be used for other purposes. The naming conventions for the keys follow the ones being expected by the mentioned function. Fields of nodes can represent different things. In order to tell the function, there is a convention for parameters **b** and **c**. | Type of field | Parameter b | Parameter c | Resulting key per field | | --- | --- | --- | --- | | A list of single fields. | | | Names of the fields. | | A structure containing a list of fields. | ** | | *structureName*-*fieldName*. | | A table with the fields representing the columns. | *tablename[#]* | Index of the row. | *tableName[1]-columnName* (with c=1). | | A table with the fields representing the columns. | *tablename[#]* | | *tableName[1]-columnName* (for first table line). See auto index. | If the name prefix in **b** ends with *[#]*, parameter **c** must contain a positive integer. In that case the placeholder *#* will be replaced with the value of **c**, otherwise, the function will break with an error message (in explicit mode) if the processing instruction *idx:inc* for the internal calculation is not active. If parameter **b** is left empty, the name of the target node is used to try to extrapolate the parameter structure (implicit mode). The following naming convention is used. 1. Node name starts with *SAP_Fields*. The fields in this node will be interpreted as import parameters of the RFC. 2. Node name starts with *SAP_Struc_*. The fields are interpreted as structural components of the SAP structure *.* 3. Node name starts with *SAP_Table_.* The fields are interpreted as components of the SAP table structure *.* This naming convention is automatically fulfilled if the target structure has been created by using the online RFC interface structure import feature. ## Parameters | Parameter | Description | | --- | --- | | a | Name of the map to be filled. | | b | Prefix for the created keys if needed. | | c | Table index if needed. | | d | (optional) *true* if calculation fields should also be used. Default: *false*. | | e | (optional) Processing instruction(s). | ## Examples using the explicit mode The target node *DestNode* has been entered two times, with the following values having been assigned to the fields (field *Counter* is a calculation field). | | Counter | Field1 | Field2 | Field3 | | --- | --- | --- | --- | --- | | Iteration 1 | 1 | 1Value1 | 1Value2 | 1Value3 | | Iteration 2 | 2 | 2Value1 | 2Value2 | 2Value3 | The following function calls will take place. | Parameter a | Parameter b | Parameter c | Parameter d | Result | | --- | --- | --- | --- | --- | | FieldMap | | | true | 2 | | StructMap | MyStructure | | false | 2 | | TableMap | MyTable[#] | Target field: Counter | false | 2 | The contents of the maps after iteration *1*: | **FieldMap** | {Counter=1, Field1=1Value1, Field2=1Value2, Field3=1Value3} | | --- | --- | | **StructMap** | {MyStructure-Field1=1Value1, MyStructure-Field2=1Value2, MyStructure-Field3=1Value3} | | **TableMap** | {MyTable[1]-Field1=1Value1, MyTable[1]-Field2=1Value2, MyTable[1]-Field3=1Value3} | The contents of the maps after iteration *2*: | **FieldMap** | {Counter=1, Field1=2Value1, Field2=2Value2, Field3=2Value3} | | --- | --- | | **StructMap** | {MyStructure-Field1=2Value1, MyStructure-Field2=2Value2, MyStructure-Field3=2Value3} | | **TableMap** | {MyTable[1]-Field1=1Value1, MyTable[1]-Field2=1Value2, MyTable[1]-Field3=1Value3, MyTable[2]-Field1=2Value1, MyTable[2]-Field2=2Value2, MyTable[2]-Field3=2Value3} | ## Example using the implicit mode Using this function in preparation for the *"*call-sap-rfc()*"* function, the filling of the values can be done using the implicit mode by leaving **b** empty and let the evaluation of the parameter's type happen by the target node's names. This is shown using the example RFC_READ_TABLE. After calling the structure generation functionality (see [Load template](/v1/docs/en/phase-3-source-structure-menu-template)**)**, you get the automatically generated Target tree in which each node represents a list of fields for input parameters, a structure or a table. ![images/download/attachments/201673921/733-version-1-modificationdate-1747043265359-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/733-version-1-modificationdate-1747043265359-api-v2.png) Then all the field values can be set. ![images/download/attachments/201673921/734-version-1-modificationdate-1747043265360-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/734-version-1-modificationdate-1747043265360-api-v2.png) The nodes of not needed structures or tables can be removed from the tree but all components (fields) of a structure or table need to be kept in the tree and be filled with a value. Fields for which no value is available can be filled with dummy (e.g. a blank in fields of type *String* or *0* in fields of a numeric type). In this example, this function is called in the field *fill_FIELDS* and similar fields each residing at the end of the single node. The function "fill-map-from-fields()" is called within an additional last field, here *fill_Fields*. The expected parameter **c** as index for tables can remain empty in explicit and implicit mode if the value is calculated internally (see auto index). Since the key-value pair is not written into the map for fields with no assigned value, unassigned structure or table components would be missing in the map. To avoid this, you must either assign a fixed value to each and every non-filled structure or table component or you can use the processing instruction *val:addempty* in order to ensure that even empty fields are written into the map. See the following section. ## Optional processing instruction "e" Processing instructions start with prefix *key:*, *con:* or *val:*. Everything else is ignored. Multiple instructions separated by | are allowed. | Prefix | Is applied to | Instruction | Effect | Note | | --- | --- | --- | --- | --- | | key: | Field name. | {description} | Instead of the field name, the field attribute *description* is used if not empty. | | | key: | Field name. | {keep} | The field name will be used as it is. | | | key: | Field name. | {sqlkey} | Instead of the field name, the field attribute *SQL key* is used. | | | key: | Field name. | regex=replacement | The regular expression *regex* in the field name is replaced by *replacement*. | | | con: | Structure and table name. | {description} | Instead of the node name, the node attribute *description* is used if not empty. | Only possible in implicit mode. | | con: | Structure and table name. | regex=replacement | Regex replacement within structure or table name. | Only possible in implicit mode. | | val: | Field value. | addempty | Adds the key to the map even for empty fields. | Every component has to be defined for structure and table types. | | val: | Field value. | fill | Fills the value up to the field length, corresponding to fill attributes of the field from left or right. Does not work for empty value. | Only with field length>0 and if filler character is specified. | | val: | Field value. | format | Fills numeric fields from the left with 0 and string fields from the right with SPACE. Does not work for empty value. | Only with field length> 0 and if val:fill does not apply. | | val: | Field value. | overwrite | Generally allows overwriting existing values. Allows overwriting a value for an already existing key. | | | val: | Field value. | empty_ovw | Allows overwriting if the old value was empty. Allows overwriting a value to an already existing key if the old value was empty. | | | val: | Field value. | equal_ovw | Allows overwriting if old and new value are the same. Allows overwriting a value to an already existing key with the same value. | | | idx: | Table index. | inc | The table index (if necessary) is calculated from the previous table lines and not from the node iteration if parameter **c** is empty. | See auto index. | | idx: | Table index. | nochk | In implicit mode (SAP mode), the check whether the table line index starts with one and is gapless is switched off. | It is not checked whether the index is gapless for table types. | > [!NOTE] > **NOTE:** > > The instruction *val:addempty* adds empty fields that are otherwise ignored. Even unfilled structure components for structure or table types are generated in this case. Thus, the error *input parameter missing* in the subsequently called function *call-sap-rfc(…)* is avoided. However, it is not possible to detect whether a default value exists within the SAP repository for this structure component or not. The value of an empty field is therefore not the default value, which is possibly defined in SAP, but *no value*. Whether the RFC/BAPI itself will replace the empty component value with the default value and whether it can cope with empty values at all must be tested for individual cases. For comments to value *no value* please refer to the notes to function [get empty flag()](/v1/docs/en/logical-empty). Formatting of the field value by processing statement *val:...* Sometimes it is necessary to format or fill the field values before sending them to the RFC. Since the field formatting and fixed values are only applied after the complete Function chain, they do not yet take effect at the time this function is executed. However, the function is able to read these field attributes and to execute corresponding formatting of the key-value pairs written in the map if the processing instruction *val:fill* resp. *val:format* is specified. If *val:fill* and *val:format* are active at the same time (e.g. *val:fillformat*), *val:fill* takes precedence at fields that have a filler character assigned; *val:format* is used for the others. ## Fields, structures or tables with an SAP namespace In SAP, names of fields structures or tables may be in the context of an "SAP namespace". - /*Namespace*/*Fieldname* , e.g.: */XYZ/ADDRESS_ID* - /*Namespace*/*Tablename*, e.g.: */ABC2/ADDRESS* Slashes are not allowed in node or field names of a Profile. When importing the RFC interface as a target structure – as described above – the slashes / are therefore replaced by underscores _. The table */ABC2/ADDRESS* is therefore generated as a node with name *SAP_Table__****ABC2****_ADDRESS* and the field is named *SAP_Fld__****XYZ****_ADDRESS_ID*. A subsequent call of function "*call-sap-rfc()"* will then not find the appropriate keys within the map. This either leads to an error or the values are not passed to the RFC. To write the proper key into the map, you can use the processing instructions. The *key:* instruction influences the field names and the *con:* instruction relates to the node names. Prefix *con:* stands for the context (the node). For structures and tables you can either enter the right name with namespace in the node attribute *Description*, and use the processing instruction *con:{description}*. Or you can adjust the node name with a regular expression *con:regex=replacement*. You can use prefix *key:* instead of prefix *con:* for the correction of field names (resp. structure or table element names) analogously. For target fields, you can additionally use the field attribute *SQL column name* that is read out with the processing instruction *key:{sqlkey}*. ## Example using regular expressions - In order to replace *_ABC2_* with */ABC2/* within a node name, use the processing instruction *con:\Q_ABC2_\E=/ABC2/* in parameter **e**. - In order to replace *_XYZ_* with */XYZ/* within all field names, use the processing instruction key:*\Q_XYZ_\E=/XYZ/* in parameter **e**. The entire processing instruction in parameter **e** then is *con:\Q_ABC2_\E=/ABC2/|key:\Q_XYZ_\E=/XYZ/*. The order of the two instructions is arbitrary. **NOTE:** In a regular expression, the text enclosed between *\Q* and *\E* is used literally (as it is). ## Auto index for table types When addressing SAP table types (especially in the implicit mode with tables), the table index is expected in parameter **c** or is calculated internally if parameter **c** is empty. Usually, the index is calculated with the iteration level of the node. But if the node is not accessed because of a function on the node, the iteration level is still incremented, without a table line being passed to the map. This leads to a gap in the index sequence. Function "*call-sap-rfc()"* cannot handle gaps like that and treats an index gap as the end of a table with the result of not all table lines being transferred to the SAP system. To avoid this error, a check for table types, whether the entries start with index *1* and have no gap, has been implemented. This check is only executed for tables (in explicit and implicit mode). This check is very CPU intensive and can be switched off with the processing instruction *idx:nochk* in parameter **e** if not needed. To ensure a gapless index addressing of the table entries if some of the nodes are not accessed, please use a counter variable in parameter **c** or the processing instruction *idx:inc* in parameter **e** if parameter **c** is empty. The increment mode searches for the last entry in this table and uses it to calculate the current index. Without the processing instruction *idx:inc*, the iteration level of the node is used for table types and empty parameter **c** in implicit mode. In explicit mode, an exception is created, because the calculation of the index with the iteration level is not available in that case. > [!NOTE] > **NOTE:** > > The increment mode is very CPU intensive and should only be used if the iteration level method might lead to gaps in the index sequence and therefore to errors when passing the table to the SAP RFC. Structured representation of the input data in Phase 3. The target tree receives the values transferred via mapping and passes them on to Phase 4, Phase 5, or Phase 6. The external metadata storage of a connected SAP system. The Lobster Data Platform reads IDoc types, segment types and RFC structures from this. The SAP system is accessed via the `SapConnectionService`. Function chains in Lobster consist of sequences of functions that are used to define conditions or to process data. The possibility of encapsulating them in macros and reusing them allows for central maintenance and compact use. Changes to a macro affect all profiles with that macro. Function chains can be determined both system-wide and client-specific. A profile is the central configuration unit in the Lobster Data Platform. It receives data, processes it, and forwards it. Configuration is done graphically, with no programming required. Remote Function Call. SAP protocol for the synchronous call of function modules in an SAP system. The Lobster Data Platform can read and write data from SAP via SAP RFC.