Without further settings, ABAP fieldnames are mapped to uppercase JSON fieldnames, but a JSON request (incoming data) could also use lowercase fieldnames.
If this mapping is not sufficient, an other mapping cound be adjusted following the next steps.
Using transaktion SM30 to adjust the mapping (using the EPO service id as key).
Field | Description |
---|---|
Service | EPO service for incoming services (=provided webservices), EPO service ID for outgoing services (=consumed webservices) |
Message direction | Direction of a message; 'I' = inbound (request for an incoming call or response of an outgoing call) 'O' = outbound (response from an incoming call or request of an outgoing call) |
ABAP fieldname | Name of an ABAP structure field |
Ext. fieldname | Name of an external JSON field |
It is possible to specify a default mapping method, using an empty ABAP fieldname - write one of these keywords into the external fieldname
(e.g. 'USER_NAME' <=> 'user_name')
(e.g. 'USER_NAME' <=> 'USER_NAME')
(e.g. 'USER_NAME' <=> 'userName')
(e.g. 'USER_NAME' <=> 'UserName')
This default mapping works in both directions and is applied to all fields, where no explicit mapping is defined.
Transaction /EPO1/EXC, open the menu items
Processing FM
/EPO1/GFMC_JSON_PROCESSINGFM
this function module will read the settings regarding the field mapping; other function modules might not be able to use and interpret these information
Field Mapping
check this checkbox to enable the field mapping; the service name of the operation is the first key field in the table /EPO1/FIELD_MAP
During the data processing (both directions: request and response), the mapping is done with the method /EPO1/CL_FIELD_NAME_MAPPING=>MAP, which reads the table /EPO1/FIELD_MAP.
For outbound calls there are 2 classes in the EPO Connector, which handle principially all tasks involved with calling any JSON REST API.
If the programmer wants to create the JSON request and to interpret the response JSON individually the methods which are included in class /EPO1/CL_JSON_BASE_OUT can be used separately.
ABAP to JSON:
Use function module /EPO1/EXC_ABAP_TO_JSON (all json format options 0,1,2,t,tb,tbi, recommended are 0 or 2 for JavaScript Apps) or method /EPO1/CL_TOOLS=>ABAP_TO_JSON (JSON creation with json format options t=transformation, tb=transformation, line breaks and tbi=transformation, line breaks and intent)
JSON to ABAP:
Use method /EPO1/CL_TOOLS=>JSON_TO_ABAP for filling ABAP variables from a JSON string.
Both methods can be called, passing the EPO service ID to I_SERVICE_ID and the transformation /EPO1/EXC_JSON_FIELD_MAPPING to I_TRANSFORMATION. This transformation uses the static method /EPO1/CL_FIELD_NAME_MAPPING=>MAP for the mapping, which reads the table /EPO1/FIELD_MAP.
Convert an ABAP structure to JSON, using the direction 'O' (outbound):
Parameter | Description |
---|---|
I_ABAP | ABAP structure |
I_STRIP_INITIAL | Remove empty elements/structures/tables |
I_DESCRIBE | Describe conversion instead of converting |
I_TABLE_FORMAT | JSON format 0, 1, 2 or t, tb, tbi. See DDIC domain /EPO1/RESPONSE_FORMAT. |
I_SERVICE_ID | The service ID is passed to the transformation (in order to select the mapping information) |
ES_CALLSTATUS | Error messages |
E_JSON | JSON as string |
E_JSON_X | JSON as xstring |
Convert an ABAP structure to JSON, using the direction 'O' (outbound):
Parameter | Description |
---|---|
I_ANY | ABAP structure |
I_LINE_BREAK | 'X' in order to add line breaks |
I_INTENT | 'X' in order to add intents (additional to the line break) |
I_STRIP_INITIAL | Remove empty elements/structures/tables |
I_TRANSFORMATION | Convert the JSON-XML, using this transformation (use /EPO1/EXC_JSON_FIELD_MAPPING) |
I_SERVICE_ID | The service ID is passed to the transformation (in order to select the mapping information) |
ES_CALLSTATUS | Error messages |
E_JSON | JSON as string |
E_JSON_X | JSON as xstring |
Convert a JSON response (string or xstring) into an ABAP structure, using the direction 'I' (inbound):
Parameter | Description |
---|---|
I_JSON | JSON as string |
I_JSON_X | JSON as xstring |
I_TRANSFORMATION | Convert the JSON-XML, using this transformation (use /EPO1/EXC_JSON_FIELD_MAPPING) |
I_SERVICE_ID | The service ID is passed to the transformation (in order to select the mapping information) |
E_ANY | ABAP structure |
ES_CALLSTATUS | Error messages |