Web API OData $Select Option Returning All Fields
I have a GET statement as follows:
...://AAA.azure-mobile.net/api/plist?$select=id,PropertyName
where "AAA" is the my mobile service. Even though this statement asks to return only two fields, it returns all of the field. I don't see a syntax error but maybe there is something I am missing? Thanks.
Hi OliverTCOS,
Thanks for your post to our forum.
Your request url looks fine in my side. And if the method "plist" works fine, then the $select will select the is and propertyName field only for you. As for your scenes, I suggest you checking your server side method and make sure there is a [Queryable]
attribute for "plist" like below.
Collection entities:
[Queryable]
public IQueryable<Category> GetCategories()
Single entity:
[Queryable]
public SingleResult<Category> GetCategory([FromODataUri] int key)
And also make sure your web api odata package version supports $select and $expand.
Besides, I suggest you taking a look at similar issue and get more information
http://stackoverflow.com/questions/17617946/odata-select-not-working-on-web-api
https://aspnetwebstack.codeplex.com/workitem/326
Regards,
Fuxiang
Similar Messages
-
Select-options for date field.
Hi all,
i need to give select options for Date field.How can i give that.
Thanks & Regards
Ravi.Hi Ravi,
Use the Component WDR_SELECT_OPTIONS to include select options in Web Dynpro ABAP. Follow these steps:
1. In your Component , "Used Componet" tab add Component WDR_SELECT_OPTIONS . Component Use can be any name that you want to give, eg SELECT_OPTIONS
2. Go to the View where you want to include the Date Select Options. I am assuming that you already have an Attribute of Type DATS in your context.
3. View: Properties Tab:Create Controller Usage and select
SELECT_OPTIONS WDR_SELECT_OPTIONS
SELECT_OPTIONS WDR_SELECT_OPTIONS INTERFACECONTROLLER
4. View Layout Tab:Include a View Container. In this view container we will show the Date Select Options.
5. View Attributes Tab: Create Following two attributes:
M_HANDLER type IF_WD_SELECT_OPTIONS
M_WD_SELECT_OPTIONS type IWCI_WDR_SELECT_OPTIONS
6: View Methods Tab: Create a method eg CREATE_SELECTION_SCREEN. Call this method in the WDDOINIT of the view.
7:CREATE_SELECTION_SCREEN: Write following Code:
* Data Declaration
data:
lt_range_table TYPE REF TO DATA.
data:
lr_componentcontroller TYPE REF TO IG_COMPONENTCONTROLLER,
lr_componentusage TYPE REF TO IF_WD_COMPONENT_USAGE.
* Execution
* Create Used Component
lr_componentusage = wd_this->wd_cpuse_select_options( ).
if LR_COMPONENTUSAGE->HAS_ACTIVE_COMPONENT( ) is initial.
lr_componentusage->create_component( ).
endif.
* Get pointer to interface controller of select options
wd_this->M_WD_SELECT_OPTIONS = wd_this->wd_cpifc_select_options( ).
* initialize selction screen
wd_this->M_HANDLER = wd_this->M_WD_SELECT_OPTIONS->init_selection_screen( ).
* Create Range Table for: Date
CALL METHOD WD_THIS->M_HANDLER->CREATE_RANGE_TABLE
EXPORTING
I_TYPENAME = 'DATS'
RECEIVING
RT_RANGE_TABLE = lt_range_table.
* Add Selection Field for: Date
CALL METHOD WD_THIS->M_HANDLER->ADD_SELECTION_FIELD
EXPORTING
I_ID = '<name of date attribute in the context>'
* I_WITHIN_BLOCK = MC_ID_MAIN_BLOCK
* I_DESCRIPTION =
* I_IS_AUTO_DESCRIPTION = ABAP_TRUE
IT_RESULT = lt_range_table
* I_OBLIGATORY = ABAP_FALSE
* I_COMPLEX_RESTRICTIONS =
* I_USE_COMPLEX_RESTRICTION = ABAP_FALSE
* I_NO_COMPLEX_RESTRICTIONS = ABAP_FALSE
* I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_NONE
* I_VALUE_HELP_ID =
* I_VALUE_HELP_MODE =
* I_VALUE_HELP_STRUCTURE =
* I_VALUE_HELP_STRUCTURE_FIELD =
* I_HELP_REQUEST_HANDLER =
* I_LOWER_CASE =
* I_MEMORY_ID =
* I_NO_EXTENSION = ABAP_FALSE
* I_NO_INTERVALS = ABAP_FALSE
* I_AS_CHECKBOX = ABAP_FALSE
* I_AS_DROPDOWN = ABAP_FALSE
* IT_VALUE_SET =
* I_READ_ONLY = ABAP_FALSE
* I_DONT_CARE_VALUE =
* I_EXPLANATION =
I_TOOLTIP = 'Select Date'.
8: To Fetch Data entered in the selection field, write following code on action of button click:
data:
lt_date type REF TO DATA.
FIELD-SYMBOLS:
<fs_date> TYPE table.
* retrieve Date from Select Options
CALL METHOD WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD
EXPORTING
I_ID = '<attrib_name>'
RECEIVING
RT_RANGE_TABLE = lt_date.
* assign Date Field Symbol
ASSIGN lt_date->* to <fs_date>.
9: Windows Window Tab: In the View Conatiner, embed the WND_SELECTION_SCREEN view from SELECT_OPTIONS component Usage of WDR_SELECT_OPTIONS component.
Regards,
Reema. -
LightSwitch with Web API OData service not accepting Action Parameters
I created a custom OData v3 endpoint with ASP.Net Web API 2.2 (similar to http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint ). I also have a Lightswitch VS 2013 update 2 HTML client that uses the
endpoint as a data source. This configuration works pretty well.
Problem, Actions (ActionConfiguration) works except for passing in parameters (note: I followed these instructions -- http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/odata-actions ). I use an ajax async HTTP request from
the Lightswitch HTML client:
var pUrl = 'http://localhost:58998/OData/BOMS_CATEGORY_LIST(1)/FindCatID';
$.ajax({
type: 'post',
data: { 'CATEGORY_NAME':'Sample', 'CATEGORY_TYPE':'SUPPLY' },
url: pUrl,
success: function success(result) {
screen.propSampCatID = result.value;
Using Fiddler to trace, I believe the Content-Type is the problem.
The client uses --
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
In Fiddler, if I put a code break and then copy the entire request that comes from the client and then use that verbage exactly to submit a request from Fiddler BUT replace the Content-Type with:
Content-Type: application/json
it works as expected.
Unfortunately, based on testing, specifying contentType: application/json in the ajax request does not work.
NOTE: I just updated all the packages in the OData solution but that did not fix the problem.
1. In general, does anyone know how to fix/what I am doing wrong?
2. If not, any work-around suggestions?
3. I am posting this here and on the ASP.Net-Web API forum since I am not sure where the issue lies.
4. Aside from the parameters, the Action works as expected (i.e. a result is returned to the client)
5. The parameters Count is 0 as opposed to the parameters being null, which tells me that the Actionconfiguration is not even adding the parameters to the Dictionary as opposed to not setting the values.
Thanks in advance,
VanohrmerOK. I seem to have this working now. I tried a bunch of things, but I think that the issue was in my Ajax request (I had to use the JSON.stringify() function on the parameters in conjunction with the contentType of application/json):
var pUrl =
'http://localhost:58998/OData/BOMS_CATEGORY_LIST(1)/FindCatID';
var pData = {
'CATEGORY_NAME':'Sample',
'CATEGORY_TYPE':'SUPPLY'
$.ajax({
type: 'post',
processData: false,
data: JSON.stringify(pData),
url: pUrl,
success: function success(result) {
screen.propSampCatID = result.value;
dataType: 'json',
contentType: 'application/json' -
How to return all field names in a table
How do you write a report to return all field names in a table? I prefer the field names in a column.
Thanks
WayneHi,
In Oracle it is,
Select column_name from user_tab_cols where table_name = 'Table_Name';
Note: Table_Name should be in capital letters
In MS SQL Server it is,
SELECT Column_Name + ', '
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Table_Name'
Hope this helps!
Thanks
-Azhar -
How to create select-options for 3 fields out of 5 by FREE_SELECTIONS_INIT
Hi Experts,
I am using the Function Modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG to create the select-options dynamically on the selection screen.
My problem is that I am passing a field list of 10 fields in the FIELDS_TAB of the function.
Now it creates the select-options for all 10 fields. I want to create select-options for only 5 fields initially and let the user select out of the remaining 5 fields to create the select-options.
How to achieve this.?
I tried by passing the 5 fields in FIELDS_NOT_SELECTED table but they get hidden and once hidden I am not able to get them back in my field list.
Please help me out.
Useful answers will be suitably rewarded.
Thanks in advance.
Regards,
HimanshuHi Experts,
I am using the Function Modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG to create the select-options dynamically on the selection screen.
My problem is that I am passing a field list of 10 fields in the FIELDS_TAB of the function.
Now it creates the select-options for all 10 fields. I want to create select-options for only 5 fields initially and let the user select out of the remaining 5 fields to create the select-options.
How to achieve this.?
I tried by passing the 5 fields in FIELDS_NOT_SELECTED table but they get hidden and once hidden I am not able to get them back in my field list.
Please help me out.
Useful answers will be suitably rewarded.
Thanks in advance.
Regards,
Himanshu -
Web Dynpro ABAP - Select Option and ALV Component Usage
Hi,
I'm new in ABAP Web Dynpro and i was trying to follow the SDN tutorial
Web Dynpro ABAP - Select Option and ALV Component Usage
In this video, we create a new Web Dynpro ABAP component that uses both Select Options and ALV. Developers can learn the basic mechanisms for working with both of these reusable components.
Following the link: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/39c54fe7-0b01-0010-0eb6-d63ac2bdd637
I implemented and generated the web dynpro with success but when i execute a test i get a dump on select-option definition.
Note
The following error text was processed in the system ECD : Exception condition "TYPE_NOT_FOUND" raised.
The error occurred on the application server ITAWSECCS01D_ECD_00 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: DESCRIBE_BY_NAME of program CL_ABAP_TYPEDESCR=============CP
I went in debug and the piece of code dumping is:
lt_range_table =
wd_this->m_handler->create_range_table( i_typename = 'S_PROJ' ).
Is there someone who can help me?
Thanks in advance,
Stefano.Hi,
I'm new in ABAP Web Dynpro and i was trying to follow the SDN tutorial
Web Dynpro ABAP - Select Option and ALV Component Usage
In this video, we create a new Web Dynpro ABAP component that uses both Select Options and ALV. Developers can learn the basic mechanisms for working with both of these reusable components.
Following the link: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/39c54fe7-0b01-0010-0eb6-d63ac2bdd637
I implemented and generated the web dynpro with success but when i execute a test i get
an error as
Note
The following error text was processed in the system EI6 : Exception condition "TYPE_NOT_FOUND" raised.
The error occurred on the application server EC6IDES_EI6_01 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: DESCRIBE_BY_NAME of program CL_ABAP_TYPEDESCR=============CP
I have created a table zmy_table and trying to make USERID field as a select-options.I've written the code as shown below .
data: itab type standard table of zmy_table,
wa type zmy_table.
data:
node_employee type ref to if_wd_context_node,
elem_employee type ref to if_wd_context_element,
stru_employee type wd_this->element_employee ,
item_userid like stru_employee-userid.
navigate from <CONTEXT> to <EMPLOYEE> via lead selection
node_employee = wd_context->get_child_node( name = wd_this->wdctx_employee ).
@TODO handle not set lead selection
if ( node_employee is initial ).
endif.
get element via lead selection
elem_employee = node_employee->get_element( ).
@TODO handle not set lead selection
if ( elem_employee is initial ).
endif.
alternative access via index
Elem_Employee = Node_Employee->get_Element( Index = 1 ).
@TODO handle non existant child
if ( Elem_Employee is initial ).
endif.
get single attribute
elem_employee->get_attribute(
exporting
name = `USERID`
importing
value = item_userid ).
select *
from zmy_table
into table itab
where userid = item_userid.
node_employee = wd_context->get_child_node( 'EMPLOYEE' ).
node_employee->bind_elements( itab ).
Is there someone who can help me and can tell am i doing wrong?
Thanks in advance,
Dheeraj -
How to return all fields when updating?
When I update a lead, it only returns fields that are modified but not all fields in the XML.
I noticed the LeadID and LeadFullname values are still being returned when updating which is good.
How can I make it so it will return ALL fields that have values and not just the modified ones when updating?
ThanksI have to query it after getting it back from the queue.
-
Reading all select-option and parameter fields
Hello All,
I have a reaquire ment like ' i Will take a report name as input from user , and i need to read all the fields declared with PARAMETERS and SELECT-OPTIONS. '
one thing i can read the program and go line by line or scan the program.
apart from this is there any other way to get all such fields declared with PARAMETERS and SELECT-OPTIONS
Thanks & Regards
Amarender Reddy BHi,
You can fetch it from table TVARV
Regards,
Prashant -
Web Dynpro Abap: Select-Options: Save Selection Data
Hello,
I am using select-options in web dynpro abap. Need to add a feature where the user can save his selection values as a variant.
All I can think of is getting all the selection values and saving these into a Z table.
Can you suggest a better way?
Thank you.
IreneHi Irene,
Alas, it's currently not possible. You could write your own wrapper though adding a save button. Inside of the action handler you could retrieve the range tables of all fields, convert their content to a structure you like and save it a fitting db table. My suggestion is to use XML and a DB table with a XSTRING field in the data section to store the range table values.
Using personalization will allow you to customize your ui and to hide certain select option fields.
Best regards,
Thomas -
Select-options for input field
hi,
Is it possible to use 'Select-options' in web dynpro for the input field like we use in abap?
Ex. material is the input field. i want to select range also for this input field using 'Select-options'
I have tried only with ovs(f4 help) for the input field. can u pls tel me how to use if it is possible ?
Thanks,
Aishwarya.DATA: LT_RANGE_TABLE TYPE REF TO DATA,
RT_RANGE_TABLE TYPE REF TO DATA,
READ_ONLY TYPE ABAP_BOOL,
TYPENAME TYPE STRING. DATA: LR_COMPONENTCONTROLLER TYPE REF
TO IG_COMPONENTCONTROLLER,
L_REF_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.
create the used component
L_REF_CMP_USAGE = WD_THIS->WD_CPUSE_SELECT_OPTIONS( ).
IF L_REF_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
L_REF_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.
WD_THIS->M_WD_SELECT_OPTIONS = WD_THIS->WD_CPIFC_SELECT_OPTIONS( ).
init the select screen
WD_THIS->M_HANDLER =
WD_THIS->M_WD_SELECT_OPTIONS->INIT_SELECTION_SCREEN( ).
WD_THIS->M_HANDLER->SET_GLOBAL_OPTIONS(
I_DISPLAY_BTN_CANCEL = ABAP_FALSE
I_DISPLAY_BTN_CHECK = ABAP_FALSE
I_DISPLAY_BTN_RESET = ABAP_FALSE
I_DISPLAY_BTN_EXECUTE = ABAP_FALSE ).
*create a range table that consists of this new data element
LT_RANGE_TABLE = WD_THIS->M_HANDLER->CREATE_RANGE_TABLE(
I_TYPENAME = 'matnr' ).
add a new field to the selection
WD_THIS->M_HANDLER->ADD_SELECTION_FIELD(
I_ID = 'matnr'
IT_RESULT = LT_RANGE_TABLE
I_READ_ONLY = READ_ONLY ).
This is my code followed by saptechnical. but when i exec, am getting err like the type matnr is invalid. -
Making input select option or input field mandatory....
Hello Gurus,
I have been through some material to create select options in web dynpro ABAP. Now I want to make one of the fields mandatory so that if user executes it without filling data in that filed, it gives error message or enforces user to input in the manadtory field.
I know how to do this in ABAP but how do I achieve the same in ABAP webdynpro ?
Please help.
Regards,
Jainam.Hi ,
Set i_obligatory parameter as X. This will set the select options as mandatory and standard error message will popup in case it is not filled.
wd_this->m_handler->add_selection_field(
i_id = 'S_CARR_ID'
it_result = lt_range_table
* i_obligatory = 'X' , " To make it mandatory -
Validation of Select Options for a field
Hi All,
I need to write a validation logic for a select option for VTWEG (Distribution Channel).
select-options: s_vtweg for komg-vtweg.
I need to check whether the user has entered the correct value based on the search help. The check table of this particular field is TVTW.
Following is the code i wrote under the AT SELECTION-SCREEN block:
IF NOT S_VTWEG-LOW IS INITIAL.
SELECT SINGLE VTWEG INTO KOMG-VTWEG FROM TVTW
WHERE VTWEG IN S_VTWEG.
IF SY-SUBRC NE 0.
CONCATENATE ' Please enter the correct
Distribution Channel '
Z_MSG INTO Z_MSG.
SET CURSOR FIELD 'S_VTWEG-LOW'.
MESSAGE E000 WITH Z_MSG.
ENDIF.
ENDIF.
It works fine when the user enters a wrong value in the S_VTWEG-LOW field, where as if i gives more than one wrong value in the range or giving individual values its not working. Let me know how to do the validation check for multiple values entered individually or in ranges.
Could you please suggest how to resolve this problem.
Thank You,
SureshYou could do something like this.....here looping at the select-option table and check the values for low and high.
report zrich_0003.
tables: komg.
data: z_msg(100) type c.
select-options: s_vtweg for komg-vtweg.
at selection-screen.
loop at s_vtweg.
if not s_vtweg-low is initial.
select single vtweg into komg-vtweg from tvtw
where vtweg = s_vtweg-low.
if sy-subrc ne 0.
concatenate ' Please enter the correct
distribution channel '
z_msg into z_msg.
set cursor field 'S_VTWEG-LOW'.
message e001(00) with z_msg.
endif.
endif.
if not s_vtweg-high is initial.
select single vtweg into komg-vtweg from tvtw
where vtweg = s_vtweg-high.
if sy-subrc ne 0.
concatenate ' Please enter the correct
distribution channel '
z_msg into z_msg.
set cursor field 'S_VTWEG-HIGH'.
message e001(00) with z_msg.
endif.
endif.
endloop.
Regards,
Rich Heilman -
Web API OData authentication and batch requests
Hello,
We have and OWIN middleware integrated into our web application pipeline which serves the purposes of authentication of OData requests by JWT token. On successful authentication we set the Thread and HttpContext principal to custom Principal object of ours.
The problem arises when performing OData batch requests. The sub-requests of batch are executed in separate threads and with no HttpContext associated with it so we loose the authenticate principal in those requests. I guess this is due to the way OData batch
requests are executed but our server logic strongly depends on custom Principal. The way we currently work around this is by using a custom ActionFilterAttribute that we apply to ODataControllers:
public class LoginAttribute : ActionFilterAttribute
public override void OnActionExecuting(HttpActionContext actionContext)
if (HttpContext.Current != null && HttpContext.Current.User as CustomPrincipal != null)
return;
// TEMPORARY (need more robust solution): pushing batch request principal to a sub-request thread
if (actionContext.Request.IsBatchRequest() && actionContext.RequestContext.Principal is CustomPrincipal)
Thread.CurrentPrincipal = actionContext.RequestContext.Principal;
return;
This works fine. But we are not sure this is the right way to handle it. Does anybody know what is the recommended solution for the problem described?Hi Dmitry Marcautsan,
According to your description, the issue is related to the ASP.NET Web API, I'd suggest you post
here to get better support.
Thanks for your understanding.
Best Regards,
Amy Peng
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Search Help in Select - Options for Time field
Hi,
I have a select option which is a time field.
For date field the F4 help is automatically generated.
How to get F4 help for time field.
Regards,
RemoSelection-Options or normal field - it doesn't matter. There is no system delivered value help for a time field. This is documented in the online help:
There is no automatic F4 help for data element TIMS.
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/9f724642314aabe10000000a42189b/frameset.htm
You would have to create your freely programmed value help if you want something like the time value help available in the SAPGUI. -
Web dynpro abap Select-option: upload data from clipboard
Hi Experts,
I have a select option in my ABAP Webdynpro application. My requirement is to give the "upload from clipboard" functionality for this select option as it is possible in normal R3. Please help me on this issue as it is client requirement.
Thank you in advance.
NarendraNarendranath Reddy wrote:
Hello Thomos,
> thanks for your valuable reply.
>
> I found the clipboard button in WDR_SELECT_OPTIONS component which is disabled. Is it possible to enable that button using
> enhancement and write the code as required ?
>
> Thanks & regards
> Narendra
No. The button was disabled because the underlying framework support hasn't been delivered yet. We need this feature implemented in the underlying JavaScript engine (which customers/partners shouldn't attempt to change or extend) before Web Dynpro can use it.
Maybe you are looking for
-
How to Populate oblastsuccessfullogin via OAM in OID ???
Can anybody please tell me how can I populate OID field name 'oblastsuccessfullogin' using OAM ? What do I need to do on OID (LDAP) end? and what steps I need to take in OAM to configure this? Our users are authenticated via OAM as soon as they provi
-
No autofill or passwords in Safari and Chrome Safari Mountain Lion
After upgrading to Mountain Lion Safari and Crome even Norton Identity safe can't Autofill, use my keychain save passwords or even ask me to save a new password..In Safari I do have check Autofill tab Use name and passwords but nothing , in Chrome I
-
Whiteboard & Powerpoint share failing !!
Hello All, I am having issues with sharing the Whiteboard and Powerpoint with external users. The error which I am getting is "Some sharing features are unavailable due to server connectivity issues" which seems to be a generic error. I cant say if t
-
Dear Gurus, I tried creating a new material A00001212 in MM01 (Material Master Record), Select material type HAWA, press enter. System keeps displaying or the systems changes A00001212 in to material 99990 and error shows " Number 99990 not defined
-
Installing Solaris 10 with RAID + ZFS ?
Hi, i've recently built a home-made server for racking with a local co-location provider, I've currently got Fedora 9 on it, but would really wish to have Solaris 10 to get ZFS support. Got a couple of questions before i wreck my fedora 9 install, if