cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to pass Json as parameter

0 Kudos
2,325

I'm passing some ids in the form of JSON to backend sap server. The query I wrote is hitting the method but I'm unable to find in which variable I will get the input values.

Thanks and Regards

Naveen

img-20200625-wa0008.jpg

Accepted Solutions (0)

Answers (2)

Answers (2)

prashil
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Naveen,

You might need to elaborate this little more. I see that you have written a read call to GetEntitySet.

I understand that you need to pass these ID's to the backend, may be to filter out the results.

You cannot send JSON object to read call. What you need instead is to send this ID's as a filter parameter ?$filter.

Read call is suppose only to get the information from the backend based on the request you made.

The request can have filters, orderby or select statement.

I hope it clarify your doubt.

Thanks

Prashil

ilachaudhary297
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi.

You can add one field of type string to your entity and pass values to it using below code.

JSON.stringify(this.<table entry/variable>).

Thanks.

ilachaudhary297
Product and Topic Expert
Product and Topic Expert
0 Kudos

If you doing function import. Use below code to get jason data.

DATA : Lt_data type <structure> " fields which you are getting from frontend.

** ************************** BAckend
READ TABLE it_parameter WITH KEY name = 'JSONData' ASSIGNING FIELD-SYMBOL(<fs_parameter>).
IF sy-subrc EQ 0.
/ui2/cl_json=>deserialize( EXPORTING json = <fs_parameter>-value
pretty_name = abap_false
CHANGING data = lt_data ).

****************Frontend

this.getOwnerComponent().getModel().callFunction("/<fucntion import>", { method: "POST", urlParameters: { JSONData: JSON.stringify(this.<entries array>),

0 Kudos

Thanks for your reply.

How do i do it for GetEntitySet (Query)