on 04-15-2014 8:16 AM
You can bind one structure with one entity.
If your are fields coming from multiple structures/tables you might consider a local type or a dictionary object comprising of all the required fields. Then you can bind it to the entity ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Atanu,
I define a new structure and write some coding as below in Gateway Service class, if I use the folloiwng hyperlink which the logic includes two search conditions(i.e., I = 230431 and I = 193626), then set breakpoint in the coding below and do debugging, one variant it_filter_select_options in the following coding can only get 'I = 193626'. Do you know how to change something in the hyperlink to make two search conditions included into this variant? I guess it would need to add brackets or something like this, but I don't know where to add them?
Kind Regards
Andie
Hi Andie,
Can you try below code snippet for above URI.
You have to declare the filter reference variable using MPC(ex : z_cl_mpc) class
Data im_sign_object_id type z_cl_mpc=>sign_object_id.
Data im_option_object_id type z_cl_mpc=> im_option_object_id.
Data im_low_object_id type z_cl_mpc=> im_low_object_id.
IF it_filter_select_options IS NOT INITIAL.
* Maps filter table lines to function module parameters
LOOP AT lt_filter_select_options INTO ls_filter.
LOOP AT ls_filter-select_options INTO ls_filter_range.
CASE ls_filter-property.
WHEN 'sign_object_id'.
IF sy-subrc = 0.
im_sign_object_id = ls_filter_range-low.
ENDIF.
WHEN 'option_object_id'.
IF sy-subrc = 0.
im_option_object_id = ls_filter_range-low.
ENDIF.
WHEN 'low_object_id'.
IF sy-subrc = 0.
im_low_object_id = ls_filter_range-low.
ENDIF.
WHEN OTHERS.
" Log message in the application log
me->/iwbep/if_sb_dpc_comm_services~log_message(
EXPORTING
iv_msg_type = 'E'
iv_msg_id = '/IWBEP/MC_SB_DPC_ADM'
iv_msg_number = 020
iv_msg_v1 = ls_filter-property ).
" Raise Exception
RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception
EXPORTING
textid = /iwbep/cx_mgw_tech_exception=>internal_error.
ENDCASE.
ENDLOOP.
ENDLOOP.
ENDIF
Thanks,
Syam
Hello Andie,
In My Opinion, the way which you would like to send filter parameters according to the shared URL by you is not something GW supports.
You cannot send $filter multiple times.
Kindly perform BATCH operation for QUERY to accomplish this, where you can send multiple operations in a single request to GW.
Regards,
Ashwin
Hello Andie,
Yes. You can send multiple filter parameters in a single request. Kindly have a look at the below blog.
Batch Request in Netweaver Gateway(Multiple Operations into a Single Request)
Regards,
Ashwin
Hello Andie,
To get the Token the URL which you have to use should be something like this ( any GET Service )
http://<XXXXXX>/sap/opu/odata/sap/<Your_Service_Name>/<Your_Entity_Set_Name>
Once you get the Token, then fire the BATCH with the below URL using $batch by sending the Payload.
http://<XXXXXX>/sap/opu/odata/sap/<Your_Service_Name>/$batch
Regards,
Ashwin
Hi Ashwin,
I use the following URL but get Interal Server Error.
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/MonitorActivityList
Kind Regards
Andie
Hi Ashwin,
This error has been fixed and I can get Token now, but there is another error message below displayed when doing batch as below.
The BODY is as below:
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/jsonxml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'193626' HTTP/1.1
--batch--
Kind Regards
Andie
Hello Andie,
The error is because you are using GET method .
Please change the Method to POST and add $batch at the end of the URL as below.
Kindly be careful with the spaces in the Payload.
Please use the below payload.
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'193626' HTTP/1.1
--batch--
Check again by doing all the above.
Regards,
Ashwin
Hello Andie,
Please put break point in DPC and check if call is coming till your DPC.
Just reminding you again be careful with the spaces maintained in the payload which i shared.
Maintain the same spacing.
If you are getting 202 accepted and there is no response the check the Body and the spacing between the operation in side it.
Kindly share the response code and the details so that it will help to locate the problem.
Regards,
Ashwin
Hi Ashwin,
It cannot jump into breakpoint, I use the following Body and get error messages as below.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id%20eq%20'I'and%20option_object_id%20eq%20'EQ'and%20low_object_id%20eq%20'193626' HTTP/1.1
--batch--
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Error message:
Kind Regards
Andie
Hello Andie,
Could you please share the URL you are sending ?
Please try with the below Body .
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I' and option_object_id eq ''EQ' and low_object_id eq '230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I'and option_object_id eq 'EQ'and low_object_id eq '193626' HTTP/1.1
--batch--
Regards,
Ashwin
Hi Ashwin,
I got the same error message.
[ Body ]
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '193626' HTTP/1.1
--batch--
Kind Regards
Andie
Hello Andie,
Can you check each filter operation individually once ? to just make sure URI is correct and its working when fired individually in browser.
Check with the below body again please.
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '193626' HTTP/1.1
--batch--
Regards,
Ashwin
Hi Ashwin,
I only use one search filter condition in the following body, but still get the same error message.
///////////////////////////////////////////////////////////////////////////////////////////////////
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=low_object_id eq '230431' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/xml
GET MonitorActivityList/?$filter=low_object_id eq '193626' HTTP/1.1
--batch--
///////////////////////////////////////////////////////////////////////////////////////////////////
Kind Regards
Andie
Hello Andie,
Please check the following things in the browser first and make sure below are working.
http://XXXXXX/sap/opu/odata/sap/<Service_Name>/<Entity_Set_Name>?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '230431'
http://XXXXXX/sap/opu/odata/sap/<Service_Name>/<Entity_Set_Name>?$filter=sign_object_id eq 'I' and option_object_id eq 'EQ' and low_object_id eq '193626'
if the above 2 URL's are not working then try below.
http://XXXXXX/sap/opu/odata/sap/<Service_Name>/<Entity_Set_Name>?$filter=sign_object_id eq '' and option_object_id eq '' and low_object_id eq '230431'
http://XXXXXX/sap/opu/odata/sap/<Service_Name>/<Entity_Set_Name>?$filter=sign_object_id eq '' and option_object_id eq '' and low_object_id eq '193626'
If the above things are working , then please try as shown below first and check if you are getting response.
If you are getting response for the above mentioned body , then please add filter parameters in the body and check again ( filter parameters which you would have tested individually in the browser as mentioned at the starting ).
Please check the above mentioned things and share the details.
Regards,
Ashwin
Hi Ashwin,
There is no problem to open the following URL directly in browser, but I got error message as below.
Kind Regards
Andie
Hello Andie,
We need not to pass as GW Client itself will handle CSRF Token.
Please follow the below steps.
1. Get the metadata of your service.
2. Click on Use as Request button.
3. Now delete metadata and paste your body in the place of that.
4. Fire the service in the way how you used to trigger by giving correct URL and with Method as POST.
Regards,
Ashwin
Hello Andie,
Its not always necessary to test in gateway client. You can test in rest client / advanced rest client as well.
Please check things which i said last time in rest client / advanced rest client ( refer to May 7, 2014 8:53 AM reply of mine ).
Please check those and revert.
Regards,
Ashwin
Hi Ashwin,
There is no problem to open the following URL directly in browser, but fails when put it in the body using batch as I mentioned above.
Kind Regards
Andie
Hi Ashwin,
Now I can get successful status code:202 Accepted using Firefox RESTClient based on the folloiwng body, and can jump into breakpoint set in method GET_ENTITYSET, but variant it_filter_select_options cannot get any values. Do you know how to solve this issue?
//////////////////////////////////////////////////////////////////////////////////////
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET MonitorActivityList/?$filter= low_object_id eq '117172' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET MonitorActivityList/?$filter= low_object_id eq '117182' HTTP/1.1
--batch--
//////////////////////////////////////////////////////////////////////////////////////
Kind Regards
Andie
Hello Andie,
Can you please try removing ' / ' in GET MonitorActivityList/?$filter= low_object_id eq '117182' & GET MonitorActivityList/?$filter= low_object_id eq '117172' ?
Just send GET MonitorActivityList?$filter= low_object_id eq '117172' & GET MonitorActivityList?$filter= low_object_id eq '117182'.
Can you please try this way and check ?
Regards,
Ashwin
Hi Ashwin,
The URL and body is as below.
------------------------------[ URL ]--------------------------------------------------
https://pgdmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS
https://pgdmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/$batch
------------------------------[ Body ]--------------------------------------------------
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET MonitorActivityList?$filter=activity_id%20eq%20'117172' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET MonitorActivityList?$filter=activity_id%20eq%20'117182' HTTP/1.1
--batch--
-----------------------------------------------------------------------------
In the Gateway Service class, I use the following coding and set breakpoint there, program can jump to there twice and the variant it_filter_select_options can get one entry each time. How can I know how many search conditions in batch job to define loop times?
................................
WHEN 'MonitorActivityList'.
lt_filter_select_options = it_filter_select_options.
................................
Kind Regards
Andie
Hello Andie,
Thanks for sharing information.
In your case call is going twice to your Data Provider Class ( 1st call will be filling your lt_filter_select_options with activity_id property & value ' 117172 ' . 2nd call will be filling your lt_filter_select_options with activity_id property & value ' 117182 ' ).
This is the expected behavior. This is how BATCH works Andie.
Here you need not to know how many search conditions in batch job to define loop times as GW itself will handle delegating calls based on the number of operation you are performing in your single request. I mean to say, here in your body , you have 2 operation with different filter values in a single request. So GW knows that it has to call your BE logic 2 times.
All you need to do is just loop through the lt_filter_select_options table and extract the property and its corresponding value and pass it to your logic which is performing search.
With this you would be able to perform Query operation in BATCH mode and get the response in the order with which you would have specified in the body of the BATCH.
Regards,
Ashwin
Hi Ashwin,
I know the logic you said, but I have to collect all the search conditions before invoking one funtion module of doing search within GW class, so how can I know which time I need to invoke this function module in the coding? The function module for doing search can be invoked each time.
Kind Regards
Andie
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.