cancel
Showing results for 
Search instead for 
Did you mean: 

XML to JSON convert streaming not working

ekekakos
Participant
0 Kudos

Hello, I have this flowxml to json.jpg.

I am receiving the following XML from an RFC Function Module.

 

 

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rfc:Z_CUSTOMER_BALANCE.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
	<ET_CUSTOMERS_BALANCE>
		<item>
			<CUSTOMER>0001000011</CUSTOMER>
			<CUSTOMER_NAME>ELIAS KEKAKOS</CUSTOMER_NAME>
			<CURRENCY>EUR</CURRENCY>
			<BALANCE>39640.8200</BALANCE>
			<MESSAGE/>
		</item>
	</ET_CUSTOMERS_BALANCE>
	<E_BALANCE>39640.8200</E_BALANCE>
	<E_CURRENCY>EUR</E_CURRENCY>
	<E_CUSTNAME>ELIAS KEKAKOS</E_CUSTNAME>
	<E_CUSTOMER>0001000011</E_CUSTOMER>
	<E_RETURN_MESSAGE/>
</rfc:Z_CUSTOMER_BALANCE.Response>

 

 

 

and the JSON is the below

 

 

 

{
    "Z_CUSTOMER_BALANCE.Response": {
        "ET_CUSTOMERS_BALANCE": {
            "item": {
                "CUSTOMER": "0001000011",
                "CUSTOMER_NAME": "ELIAS KEKAKOS",
                "CURRENCY": "EUR",
                "BALANCE": "39640.8200",
                "MESSAGE": ""
            }
        },
        "E_BALANCE": "39640.8200",
        "E_CURRENCY": "EUR",
        "E_CUSTNAME": "ELIAS KEKAKOS",
        "E_CUSTOMER": "0001000011",
        "E_RETURN_MESSAGE": ""
    }
}

 

 

 

I want the Z_CUSTOMER_BALANCE.Response/ET_CUSTOMERS_BALANCE/item to permanently table even if it has 1 record or more. I enabled the Streaming option with the above XML element, but not only the JSON with 1 record in ITEM did not change, but when I have more than 1 it still is not table [ ] as you can see below.

 

 

 

{
    "Z_CUSTOMER_BALANCE.Response": {
        "ET_CUSTOMERS_BALANCE": {
            "item": {
                "CUSTOMER": "0001000022",
                "CUSTOMER_NAME": "ELIAS KEKAKOS",
                "CURRENCY": "EUR",
                "BALANCE": "238.6900",
                "MESSAGE": ""
            },
            "item": {
                "CUSTOMER": "0001000035",
                "CUSTOMER_NAME": "ELIAS KEKAKOS2",
                "CURRENCY": "EUR",
                "BALANCE": "20639.1000",
                "MESSAGE": ""
            }
      },
        "E_BALANCE": "0.0000",
        "E_CURRENCY": "",
        "E_CUSTNAME": "",
        "E_CUSTOMER": "",
        "E_RETURN_MESSAGE": ""
    }
}

 

 

 

What I am expecting is the below

 

 

{
    "Z_CUSTOMER_BALANCE.Response": {
        "ET_CUSTOMERS_BALANCE": {
            "item": [
                {
                    "CUSTOMER": "0001000035",
                    "CUSTOMER_NAME": "ELIAS KEKAKOS",
                    "CURRENCY": "EUR",
                    "BALANCE": "20639.1000",
                    "MESSAGE": ""
                },
                {
                    "CUSTOMER": "0001000041",
                    "CUSTOMER_NAME": "ELIAS KEKAKOS2",
                    "CURRENCY": "EUR",
                    "BALANCE": "1610.1900",
                    "MESSAGE": ""
                }
            ]
        },
        "E_BALANCE": "0.0000",
        "E_CURRENCY": "",
        "E_CUSTNAME": "",
        "E_CUSTOMER": "",
        "E_RETURN_MESSAGE": ""
    }
}

 

 

or with 1 record under the ITEM

 

 

{
    "Z_CUSTOMER_BALANCE.Response": {
        "ET_CUSTOMERS_BALANCE": {
            "item": [
                {
                    "CUSTOMER": "0001000035",
                    "CUSTOMER_NAME": "ELIAS KEKAKOS",
                    "CURRENCY": "EUR",
                    "BALANCE": "20639.1000",
                    "MESSAGE": ""
                }
            ]
        },
        "E_BALANCE": "20639.1000",
        "E_CURRENCY": "EUR",
        "E_CUSTNAME": "ELIAS KEKAKOS",
        "E_CUSTOMER": "0001000035",
        "E_RETURN_MESSAGE": ""
    }
}

 

 

As it does if I select ALL(under Streaming) but it is for every element.

Can someone tell me what is wrong?

Thanks

Elias

 

 

thomas_mller13
Participant
0 Kudos
It is difficult to understand what your problem is. In my opinion the JSON is correct. There is an item table.
ekekakos
Participant
0 Kudos
See again the question because I added what I am expecting. If the records are more than 1 under the element ITEM this is what it returns in JSON.
ekekakos
Participant
0 Kudos
It seems that there is no answer maybe I am not understandable. In a JSON it is the same to send an element as table with the following ways: 1. {"table": [ {"a": 1, "b": 2 }, {"c": 1, "d": 2 } ] } and 2. {"table": {"a": 1, "b": 2 }, {"c": 1, "d": 2 } }.
View Entire Topic
Ryan-Crosby
Active Contributor

You need to add xmlns:rfc=urn:sap-com:document:sap:rfc:functions to your Namespace Mapping in the Runtime Configuration, and declare the XML element rfc:Z_CUSTOMER_BALANCE.Response/ET_CUSTOMERS_BALANCE/item in your streaming configuration (notice the addition of the namespace prefix).  The converter cannot find your specified XML element because in effect it does not exist in your XML payload.

 

Regards,

Ryan Crosby

ekekakos
Participant
0 Kudos
I am getting the error "Enter JSON prefix". What to put in the JSON PREFIX
Ryan-Crosby
Active Contributor

@ekekakos not the Namespace Mapping in the converter, the Namespace Mapping in the Runtime Configuration of the integration flow.

Screenshot 2024-04-12 at 08.27.12.png

ekekakos
Participant
Thank you very much for your valuable help.