2022 Jun 28 8:25 AM
Hi All
I'm trying to convert a JSON File into ABAP Deep entity table
JSON File Format
{ "Orders": {
"Order": [
{
"Customer": "Test1",
"SaleType": "",
"Item Nav": [
{
"ItmNumber": "1",
"Material": "11",
},
{
"ItmNumber": "2",
"Material": "22",
}
]
},
{
"Customer": "Test2",
"SaleType": "",
"Item Nav": [
{
"ItmNumber": "1",
"Material": ""
},
{
"ItmNumber": "2",
"Material": ""
}
]
}
]
}
}
TYPES : BEGIN OF ts_sales_item_data,<br> ItmNumber TYPE char5,<br> Material TYPE char5,<br> END OF ts_sales_item_data.
TYPES: BEGIN OF ty_deep_entity,
customer TYPE char10,
saletype TYPE vkorg,
headertoitem TYPE TABLE OF ts_sales_item_data WITH DEFAULT KEY,
END OF ty_deep_entity.
DATA: it_result TYPE TABLE OF ty_deep_entity,
<br> wa_result TYPE ty_deep_entity.
<br>CALL METHOD cl_fdt_json=>json_to_data
<br> EXPORTING
<br> iv_json = result
<br> CHANGING
<br> ca_data = wa_result.
For some reason - I don't see any records into wa_result.
Hi All
I'm trying to convert a JSON File into ABAP Deep entity table
JSON File Format
{ "Orders": {
"Order": [
{
"Customer": "Test1",
"SaleType": "",
"Item Nav": [
{
"ItmNumber": "1",
"Material": "11",
},
{
"ItmNumber": "2",
"Material": "22",
}
]
},
{
"Customer": "Test2",
"SaleType": "",
"Item Nav": [
{
"ItmNumber": "1",
"Material": ""
},
{
"ItmNumber": "2",
"Material": ""
}
]
}
]
}
}
TYPES : BEGIN OF ts_sales_item_data,<br> ItmNumber TYPE char5,<br> Material TYPE char5,<br> END OF ts_sales_item_data.
TYPES: BEGIN OF ty_deep_entity,
customer TYPE char10,
saletype TYPE vkorg,
headertoitem TYPE TABLE OF ts_sales_item_data WITH DEFAULT KEY,
END OF ty_deep_entity.
DATA: it_result TYPE TABLE OF ty_deep_entity,
<br> wa_result TYPE ty_deep_entity.
<br>CALL METHOD cl_fdt_json=>json_to_data
<br> EXPORTING
<br> iv_json = result
<br> CHANGING
<br> ca_data = wa_result.
For some reason - I don't see any records into wa_result.
2022 Jun 28 8:36 AM
It's not valid JSON format. For instance, it would be valid if you wrap it between { and }.
2022 Jun 28 1:46 PM
Sandra - Does that look right now ..Even than i'm having issues..Is there an issue in ABAP Code
2022 Jun 28 2:10 PM
The type of the argument of parameter CA_DATA doesn't reflect the JSON structure. There is "Order" which is an array of customers, but the type of your argument contains only one customer. I don't see how JSON_TO_DATA can find the relationship between the JSON structure and the type of the argument.
2022 Jun 28 5:14 PM
Hi,
please chck the Method
/ui2/cl_json=>deserialize(
You can also check the reverse way to serialized your table structure to JSON
to check the correct syntax.
The JSON type SalesType will be transferred to the abap field sales_type
with the camel case mode:
lv_json = /ui2/cl_json=>serialize(
data = it_result
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
compress = abap_true
).
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |