on 08-20-2013 7:33 AM
Hi All,
There is a table input in a RFC which has to execute in get_entityset method. $Filter is allowing to take the input into range table but my input table is not a range table.
Is it possible to pass a non-range table data from URL for a gateway service?
Thanks,
Suresh Yerra.
Dear Arun Chembra, Arnab Das and Krishna Kishor Kammaje,
Thanks for the help.
Here is useful and complete information of this message to resolve my issue:
-----------------------------------------------------------------------------------------------------------------------------------
Hi Suresh,
If you want to read multiple records together you can use batch read concept.
Thanks,
Arun Chembra
-----------------------------------------------------------------------------------------------------------------------------------
Hi Suresh,
Please check the below links and let me know if you have any question.
http://scn.sap.com/thread/3403864
Thanks,
Arun Chembra
-----------------------------------------------------------------------------------------------------------------------------------
Reply from Arnab Das:
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WCollection/?$filter= PROJECT_ID eq '124557'' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WCollection/?$filter= PROJECT_ID eq '124558'' HTTP/1.1
--batch--
-----------------------------------------------------------------------------------------------------------------------------------
Hi Arnab Das,
Thanks for the reply. I did same as you said. But I am getting error like:
Status Code: 405 Method Not Allowed
In response body, it is giving message like:
The specified HTTP method is not allowed for the resource identified by the Data Service Request URI
Any Idea on these issues?
Thanks,
Suresh
-----------------------------------------------------------------------------------------------------------------------------------
Reply from Arnab Das:
Hi Suresh,
i was also facing the same error .. please refer to this below link .. issue got solved ..
Thanks for your reply.
http://scn.sap.com/thread/3403864
or
------------------------------URL-------------------------------
Pass URL as
http://**************/sap/opu/odata/sap/<Main_Service_Name>/$batch
HEADER
Authorization: Basic c3VtYExMjM=(SAP ID & PASSWORD)
x-csrf-token: mdtxFGA==(give the valid TOKEN)
Content-Type: multipart/mixed; boundary=batch
BODY part
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter= PROJECT_ID eq '12345'' and WBS_ID eq '123' HTTP/1.1
"""""""""" <should be at least 2 enter>or it wont work
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter= PROJECT_ID eq '12345' and WBS_ID eq '124' HTTP/1.1
"""""""<should be at least 3 enter> or it wont work
--batch--
-----------------------------------------------------------------------------------------------------------------------------------
Suresh,
I see that you have used a 'GET' in Firefox. It has to be a 'POST'.
Thanks
Krishna
-----------------------------------------------------------------------------------------------------------------------------------
Thanks Krishna Kishor Kammaje.
I changed to POST and working fine.
But I checked the method by using external break point and came to know that, it is not taking any inputs in lt_filter_select_options.
Thanks,
Suresh
-----------------------------------------------------------------------------------------------------------------------------------
Hi all,
Finally I got this. I have replaced the space with '%20'in the GET request in body part.
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter=PROJECT_ID%20eq%20'12345'%20and%20WBS_ID%20eq%20'123' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter=PROJECT_ID%20eq%20'12345'%20and%20WBS_ID%20eq%20'124' HTTP/1.1
--batch--
Thanks,
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the picture, you are trying to get entry(Read) by URL with key value, however, you defined service under entry set(Query). Please understand the difference between (Read) & (Query).
Create | POST | Insert <table> from <workarea> |
Read | GET | Select Single * From <table> into <workarea> |
Update | PUT/PATCH | Update <table> set <workarea> |
Delete | DELETE | Delete from <table> |
Query | GET | Select * From <table> Into Table |
Function Import | GET/POST | Everything covered by GET and POST. But only use if scenario does not fit into CRUDQ operations. |
I need to send an input table as parameter, I build the batch request with multiple row to fill the table, but when I do the POST call, NWGW call the RFC row by row (not send one table with multiple rows, send table with one row and call RFC multiple times). When I set the breakpoint in the RFC the system opens one session for every row I sent.
My batch request is (in this case the breakpoint open two sessions):
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET XXX/?$filter=Matnr%20eq%20'1007232' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET XXX/?$filter=Matnr%20eq%20'1007233' HTTP/1.1
--batch--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ajay,
If you could explain your use case, we would be able to help you better. Otherwise, the solution is same. If you are going with BATCH, it will open a new session every time. This is how it is designed to operate. Otherwise if you are taking the values in a range table, it will take all possible values in one shot.
Regards,
Ekansh
Hi Suresh,
I am trying to create service for the same scenario (For RFC with 1 table input and 1 table output.)
I have followed al the steps just like you did, but I am not getting any response and even the debugger is not getting triggered.
Could you guide me if there are any additional steps to this? As I am just doing it for learning purpose , there is not much of a code written in my FM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WCollection/?$filter= PROJECT_ID eq '124557'' HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WCollection/?$filter= PROJECT_ID eq '124558'' HTTP/1.1
--batch--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arnab Das,
Thanks for the reply. I did same as you said. But I am getting error like:
Status Code: 405 Method Not Allowed
In response body, it is giving message like:
The specified HTTP method is not allowed for the resource identified by the Data Service Request URI
Any Idea on these issues?
Thanks,
Suresh
Hi Suresh,
i was also facing the same error .. please refer to this below link .. issue got solved ..
Thanks for your reply.
http://scn.sap.com/thread/3403864
or
------------------------------URL-------------------------------
Pass URL as
http://**************/sap/opu/odata/sap/<Main_Service_Name>/$batch
HEADER
Authorization: Basic c3VtYExMjM=(SAP ID & PASSWORD)
x-csrf-token: mdtxFGA==(give the valid TOKEN)
Content-Type: multipart/mixed; boundary=batch
BODY part
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter= PROJECT_ID eq '12345'' and WBS_ID eq '123' HTTP/1.1
"""""""""" <should be at least 2 enter>or it wont work
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
Accept: application/json
GET WBCollection/?$filter= PROJECT_ID eq '12345' and WBS_ID eq '124' HTTP/1.1
"""""""<should be at least 3 enter> or it wont work
--batch--
Hi Suresh,
You don't have to write any additional logic, you just have to redefine/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN and /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END.
Please find the below link:
http://help.sap.com/saphelp_gateway20sp06/helpdata/en/90/dc8363306c47d3b2fca1398f5de94b/content.htm
Thanks,
Arun Chembra
Hi Arnab Das,
I did everything as you said... but not working batch input. I don't know where am doing wrong. So here I am writing my example step by step.
Step 1: RFC
Step 2: GW project creation using segw
Importing model from RFC
Step 3:
Step 4:
Step 5: Create entity set
Step 6: Map to data source
Step 7:
Step 8: Click on Propose mapping
Step 9: Generate
Step 10:
Code of TAB_RESULT_GET_ENTITYSET:
==========================================================================
method TAB_RESULT_GET_ENTITYSET.
*-------------------------------------------------------------
* Data declaration
*-------------------------------------------------------------
DATA tab_input TYPE zif_z1158_add=>__z1158_num.
DATA tab_output TYPE zif_z1158_add=>__z1158_res.
DATA ls_tab_input LIKE LINE OF tab_input.
DATA ls_tab_output LIKE LINE OF tab_output.
DATA lv_rfc_name TYPE tfdir-funcname.
DATA lv_destination TYPE rfcdest.
DATA lv_subrc TYPE syst-subrc.
DATA lv_exc_msg TYPE /iwbep/mgw_bop_rfc_excep_text.
DATA lx_root TYPE REF TO cx_root.
DATA lo_filter TYPE REF TO /iwbep/if_mgw_req_filter.
DATA lt_filter_select_options TYPE /iwbep/t_mgw_select_option.
DATA lv_filter_str TYPE string.
DATA ls_paging TYPE /iwbep/s_mgw_paging.
DATA lt_key_tab TYPE /iwbep/t_mgw_tech_pairs.
DATA ls_filter TYPE /iwbep/s_mgw_select_option.
DATA ls_filter_range TYPE /iwbep/s_cod_select_option.
DATA lo_dp_facade TYPE REF TO /iwbep/if_mgw_dp_facade.
DATA ls_gw_tab_input LIKE LINE OF et_entityset.
DATA lv_skip TYPE int4.
DATA lv_top TYPE int4.
*-------------------------------------------------------------
* Map the runtime request to the RFC - Only mapped attributes
*-------------------------------------------------------------
* Get all input information from the technical request context object
* Since DPC works with internal property names and runtime API interface holds external property names
* the process needs to get the all needed input information from the technical request context object
* Get filter or select option information
lo_filter = io_tech_request_context->get_filter( ).
lt_filter_select_options = lo_filter->get_filter_select_options( ).
lv_filter_str = lo_filter->get_filter_string( ).
* Check if the supplied filter is supported by standard gateway runtime process
IF lv_filter_str IS NOT INITIAL
AND lt_filter_select_options IS INITIAL.
" If the string of the Filter System Query Option is not automatically converted into
" filter option table (lt_filter_select_options), then the filtering combination is not supported
" 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 = 025 ).
" Raise Exception
RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception
EXPORTING
textid = /iwbep/cx_mgw_tech_exception=>internal_error.
ENDIF.
* Get key table information
lt_key_tab = io_tech_request_context->get_source_keys( ).
ls_paging-top = io_tech_request_context->get_top( ).
ls_paging-skip = io_tech_request_context->get_skip( ).
* 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 'IMNUM2'.
ls_tab_input-num2 = ls_filter_range-low.
WHEN 'IMNUM1'.
ls_tab_input-num1 = ls_filter_range-low.
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.
* Append lines of table parameters in the function call
IF ls_tab_input IS NOT INITIAL.
APPEND ls_tab_input TO tab_input.
ENDIF.
* Get RFC destination
lo_dp_facade = /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
lv_destination = /iwbep/cl_sb_gen_dpc_rt_util=>get_rfc_destination( io_dp_facade = lo_dp_facade ).
*-------------------------------------------------------------
* Call RFC function module
*-------------------------------------------------------------
lv_rfc_name = 'Z1158_ADD'.
IF lv_destination IS INITIAL OR lv_destination EQ 'NONE'.
TRY.
CALL FUNCTION lv_rfc_name
TABLES
tab_input = tab_input
tab_output = tab_output
EXCEPTIONS
system_failure = 1000 message lv_exc_msg
OTHERS = 1002.
lv_subrc = sy-subrc.
*in case of co-deployment the exception is raised and needs to be caught
CATCH cx_root INTO lx_root.
lv_subrc = 1001.
lv_exc_msg = lx_root->if_message~get_text( ).
ENDTRY.
ELSE.
CALL FUNCTION lv_rfc_name DESTINATION lv_destination
TABLES
tab_input = tab_input
tab_output = tab_output
EXCEPTIONS
system_failure = 1000 MESSAGE lv_exc_msg
communication_failure = 1001 MESSAGE lv_exc_msg
OTHERS = 1002.
lv_subrc = sy-subrc.
ENDIF.
*-------------------------------------------------------------
* Map the RFC response to the caller interface - Only mapped attributes
*-------------------------------------------------------------
*-------------------------------------------------------------
* Error and exception handling
*-------------------------------------------------------------
IF lv_subrc <> 0.
* Execute the RFC exception handling process
me->/iwbep/if_sb_dpc_comm_services~rfc_exception_handling(
EXPORTING
iv_subrc = lv_subrc
iv_exp_message_text = lv_exc_msg ).
ENDIF.
*-------------------------------------------------------------------------*
* - Post Backend Call -
*-------------------------------------------------------------------------*
IF ls_paging-skip IS NOT INITIAL.
* If the Skip value was requested at runtime
* the response table will provide backend entries from skip + 1, meaning start from skip +1
* for example: skip=5 means to start get results from the 6th row
lv_skip = ls_paging-skip + 1.
ENDIF.
* The Top value was requested at runtime but was not handled as part of the function interface
IF ls_paging-top <> 0
AND lv_skip IS NOT INITIAL.
* if lv_skip > 0 retrieve the entries from lv_skip + Top - 1
* for example: skip=5 and top=2 means to start get results from the 6th row and end in row number 7
lv_top = ls_paging-top + lv_skip - 1.
ELSEIF ls_paging-top <> 0
AND lv_skip IS INITIAL.
lv_top = ls_paging-top.
ELSE.
lv_top = lines( tab_output ).
ENDIF.
* - Map properties from the backend to the Gateway output response table -
LOOP AT tab_output INTO ls_tab_output
* Provide the response entries according to the Top and Skip parameters that were provided at runtime
FROM lv_skip TO lv_top.
* Only fields that were mapped will be delivered to the response table
ls_gw_tab_input-num1 = ls_tab_output-num1.
ls_gw_tab_input-num2 = ls_tab_output-num2.
ls_gw_tab_input-res = ls_tab_output-res.
ls_gw_tab_input-sno = ls_tab_output-sno.
APPEND ls_gw_tab_input TO et_entityset.
CLEAR ls_gw_tab_input.
ENDLOOP.
endmethod.
=======================================================================
Step 11: Redefine
step 12:
Step 13:
The below link is working fine
http://xxxxxxxxx.xxxx.xxx:xxxx/sap/opu/odata/sap/Z1158_ADD_SRV/TAB_RESULT?$filter=ImNum1 eq 11 and ImNum2 eq 21
Step 14: For batch, I am using firefox
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT?$filter=ImNum1 eq 1 and ImNum2 eq 2 HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT?$filter=ImNum1 eq 4 and ImNum2 eq 3 HTTP/1.1
--batch--
step 15: But it is giving as below:
Thanks,
Suresh
Hi Krishna Kishor Kammaje,
Thanks for your patience.
The control reached the break point. I am very much sure.
Body part:
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT?$filter= ImNum1 eq 1 and ImNum2 eq 2 HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT?$filter= ImNum1 eq 4 and ImNum2 eq 3 HTTP/1.1
--batch--
Response Body (Raw):
--4A21CBE437E952DCCA5F303EE1B006EC0
Content-Type: application/http
Content-Length: 641
content-transfer-encoding: binary
HTTP/1.1 200 OK
Content-Type: application/atom+xml;type=feed
Content-Length: 530
dataserviceversion: 2.0
<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://xxxxxx.xxx.xx:8080/sap/opu/odata/sap/Z1158_ADD_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://agshyd07.hyd.in:8080/sap/opu/odata/sap/Z1158_ADD_SRV/TAB_RESULThttp://schemas.microsoft.com/a... type="text">TAB_RESULT</title><updated>2013-08-29T05:54:54Z</updated><author><name/></author><link href="TAB_RESULT" rel="self" title="TAB_RESULT"/></feed>
--4A21CBE437E952DCCA5F303EE1B006EC0
Content-Type: application/http
Content-Length: 641
content-transfer-encoding: binary
HTTP/1.1 200 OK
Content-Type: application/atom+xml;type=feed
Content-Length: 530
dataserviceversion: 2.0
<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://xxxxxxx.xxx.xx:8080/sap/opu/odata/sap/Z1158_ADD_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://agshyd07.hyd.in:8080/sap/opu/odata/sap/Z1158_ADD_SRV/TAB_RESULThttp://schemas.microsoft.com/a... type="text">TAB_RESULT</title><updated>2013-08-29T05:55:03Z</updated><author><name/></author><link href="TAB_RESULT" rel="self" title="TAB_RESULT"/></feed>
--4A21CBE437E952DCCA5F303EE1B006EC0--
========================================================================
Body part:
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT/?$filter= ImNum1 eq 1 and ImNum2 eq 2 HTTP/1.1
--batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET TAB_RESULT/?$filter= ImNum1 eq 4 and ImNum2 eq 3 HTTP/1.1
--batch--
Thanks,
Suresh
This time I do not see anything wrong. Goto 'Local' tab in the debugger and see if there is any other signature variable that is filled with the filter string.
Other thing to check is run a simple GET request with $filter. (without $batch) Does it work? do u see filter options then?. if it does not work, then we need to see filter modelling closely.
If nothing contacting SAP Support seems to be the way.
Thanks
Krishna
Hi Suresh,
For testing the service can you use Advance Rest Client in chrome?
Check the below link i think this will solve your issue , still you are facing any issue please let me know ....
http://scn.sap.com/thread/3280028
Thanks ,
Arun CHembra
Hi Arun,
Even I checkd with Advance Rest Client in chrome. And getting same.
Here is my netweaver system details:
I came to know that batch concept was introduced from SP4. Batch concept is working fine in my system when I checked with the SAP-delivered RMTSAMPLEFLIGHT service. But batch and filter together is not working fine.
Thanks,
Suresh
Hi Suresh,
If you want to read multiple records together you can use batch read concept.
Thanks,
Arun Chembra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suresh,
Please check the below links and let me know if you have any question.
http://scn.sap.com/thread/3403864
Thanks,
Arun Chembra
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.