Hello SAP guru's
i got a requirement sap-odoo integration, that api should be called during invoice save and pdf generated in both sap and odoo, they have given json format and functional specification like below.. i don't know how to write code json code in the program im stuck after loop statement, don't know what code i have to write.. json format and functional specification is given below
Please find below the JSON formats for SAP - Odoo Communication:
Input format from SAP to Odoo:
{
"SAP Invoice Number": [
{
"OrderRef": "401301234",
"OrderUID" : "BB12345",
"SKU": "FMS72003600M02528",
"QTY": 30,
"UOM": "NOS",
},
{
"OrderRef": "401301234",
"OrderUID" : "BB12346",
"SKU": "FMS72003600M04528",
"QTY": 10,
"UOM": "NOS",
},
.....
.....
]
}
Return from Odoo to SAP:
{
"SAP_Invoice": <Sent above>,
"STATUS": <success or error>,
"MSG": <Error message in case of error, URL of the invoice PDF in case of success>
}

Request clarification before answering.
The basics about handling JSON in ABAP are described here:
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_json.htm
There are also additional libraries or APIs available.
Make yourself clear what you want and then check out what kind of transformation or parsing/rendering you can use
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DATA: lt_flight TYPE STANDARD TABLE OF sflight,
lrf_descr TYPE REF TO cl_abap_typedescr,
lv_json TYPE string.
SELECT * FROM sflight INTO TABLE lt_flight.
* serialize table lt_flight into JSON, skipping initial fields and converting ABAP field names into camelCase
lv_json =/ui2/cl_json=>serialize( data = lt_flight compress = abap_true pretty_name = /ui2/cl_json=>pretty_mode-camel_case ).
WRITE / lv_json.
CLEAR lt_flight.
* deserialize JSON string json into internal table lt_flight doing camelCase to ABAP like field name mapping
/ui2/cl_json=>deserialize(EXPORTING json = lv_json pretty_name =/ui2/cl_json=>pretty_mode-camel_case CHANGING data = lt_flight ).
* serialize ABAP object into JSON string
lrf_descr = cl_abap_typedescr=>describe_by_data( lt_flight ).
lv_json =/ui2/cl_json=>serialize( lrf_descr ).
WRITE / lv_json.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Class /ui2/cl_json is a simple way to convert json to abap and vice versa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 13 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.