on 2023 Jun 20 7:06 PM
Hello experts,
I have a synchronous RFC <-> REST scenario in PO 7.5 SP24; but the Json structure of the response has the following format:
{
"id": "GR",
"name": "DUMMY DESCRIPTION",
"objectType": "PRD.GoldenRecord",
"parent": "INT.L4-1ABC123",
"values": {
"PMDM.AT.20002598": {
"calculated": false,
"contextLocal": true,
"value": {
"value": "Data info",
"valueId": "300",
"unit": null
}
},
"CHDR.AT.MARA.ERSDA": {
"calculated": false,
"contextLocal": true,
"value": {
"value": "2018-01-01",
"valueId": null,
"unit": null
}
}
}
}
As you can see, there are segment names that have "." intermediate dot in it, and, when trying to map that name in Data types in PO, it tells me that the name cannot contain ".", so I generated the fields without the dots; additionally, in the receiver REST adapter I have configured the "JSON to XML name mapping" section placing the JSON name (with dots) towards its name without dots to be the target name in XML, but in the end, I get the following error:
My config in the REST Adapter:
The question is, how can I adjust my development so that those names with "middle period" are replaced with another name without the period? Is there any other configuration I can do in the Adapter to adjust this so that my mapping works correctly?
Thank you very much for your guidance in resolving this situation.
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
In your scenario, where you have segment names with intermediate dots (".") in the JSON structure, and you cannot directly use the dots in the field names within SAP Process Orchestration (PO) due to restrictions, you can follow the steps below to adjust your development:
Modify Data Types: Since you cannot directly use field names with dots in Data Types, you have already generated the fields without dots. This approach is correct. The field names in your Data Types should match the modified field names without dots.
Configure JSON to XML Name Mapping: In the receiver REST adapter configuration, you have already configured the "JSON to XML name mapping" section. Here you can specify how the JSON field names should be mapped to the XML structure. To handle the names with dots, you need to specify the mapping to replace the dots with another name without the period.
For example, let's say you have a field in your Data Type called PMDM_AT_20002598
to match the JSON field "PMDM.AT.20002598"
. In the JSON to XML name mapping section, you would define a mapping as follows:
PMDM.AT.20002598
PMDM_AT_20002598
Similarly, you would define mappings for other fields with dots in their names.
By specifying the appropriate mappings, you can ensure that the JSON field names with dots are correctly transformed to their corresponding field names without dots in the XML structure.
By following these steps, you should be able to handle the JSON field names with dots in your synchronous RFC <-> REST scenario and ensure proper mapping in SAP Process Orchestration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's an example code snippet that demonstrates how you can adjust your development to handle field names with dots in your scenario:
REPORT z_handle_json_with_dots.
DATA: lv_json_payload TYPE string,
lv_modified_payload TYPE string,
lt_field_replacements TYPE STANDARD TABLE OF string,
lv_field_name TYPE string,
lv_replacement TYPE string.
lv_json_payload = `{
"id": "GR",
"name": "DUMMY DESCRIPTION",
"objectType": "PRD.GoldenRecord",
"parent": "INT.L4-1ABC123",
"values": {
"PMDM.AT.20002598": {
"calculated": false,
"contextLocal": true,
"value": {
"value": "Data info",
"valueId": "300",
"unit": null
}
},
"CHDR.AT.MARA.ERSDA": {
"calculated": false,
"contextLocal": true,
"value": {
"value": "2018-01-01",
"valueId": null,
"unit": null
}
}
}
}`.
APPEND `PMDM_AT_20002598=PMDM.AT.20002598` TO lt_field_replacements.
APPEND `CHDR_AT_MARA_ERSDA=CHDR.AT.MARA.ERSDA` TO lt_field_replacements.
lv_modified_payload = lv_json_payload.
LOOP AT lt_field_replacements INTO DATA(ls_field_replacement).
SPLIT ls_field_replacement AT '=' INTO lv_replacement lv_field_name.
REPLACE ALL OCCURRENCES OF lv_field_name IN lv_modified_payload WITH lv_replacement.
ENDLOOP.
WRITE lv_modified_payload.
In this ABAP code snippet, the JSON payload is stored in the lv_json_payload
variable. We also define an internal table lt_field_replacements
to hold the field name replacements. Each entry in this table contains the original field name and the replacement field name without dots.
After defining the JSON payload and the field replacements, we loop through the entries in lt_field_replacements
and replace the field names in the lv_modified_payload
variable using the REPLACE
statement.
Finally, we output the modified JSON payload using the WRITE
statement. You can adjust this code snippet to incorporate it into your existing ABAP program or function module.
Remember to update the lt_field_replacements
table with the necessary field name replacements specific to your scenario.
User | Count |
---|---|
73 | |
21 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.