cancel
Showing results for 
Search instead for 
Did you mean: 

odata function import - structure as import parameter

Former Member
0 Kudos

Hello Experts,

I want to pass list of measured values (valueID, measured value) with info about temperature and date.

So i want to pass to function data like this:

- temerature

- date

- measured value table

         -  valueID1, measured value1

         - valueID2, measured value2

         - valueID3, measured value3


I am not able to find way how to do it. In function import parameters there is no option to do it (like on below screen from segw)


Thanks for help.

Lucas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Lukasz,

If you are looking at passing a table to Function Import, I don't think its possible.

from you example it looks like your structure Struct1 in ABAP would be

temp  NUMC

date SY-DATUM

MeasuredValues - TableType

For ODATA,

You can create three parameters for Func Import - Temp , Date , MeasuredValues ( as string ).

Then from Client you can either pass comma separated values or JSON string in this field MeasuredValues. In your ABAP code you can split the field into a table or use JSON de-searlizer and fill your struct1.

ex - /TestFunct1?Temp='XXXX'&Date='XXXXX'&MeasuredValues='ID1,0111,ID2,002,ID3,003'

Also could you explain your use-case a little more since i dont think you actually need a function import here.

Regards

Mayank

Former Member
0 Kudos

I don't like this situation.

Probably its often situation when you want to pass

1) from client

2) or to client

data with structure:


- param1

- param2

- tableType1

For now i know ways:

1) concatenate values from table to one string parameter (function import apraache)

2) create update statement with table (crud update approache) and add param1 and param2 to tableType1. Its of course redundantion and its not good approache for big data.

3) and probably best one:


But i am disappointed that its also impossible to pass table type into function import.

Am i right ?


BR Lucas

Former Member
0 Kudos

Yes Lucas, i was stuck with same situation - how to pass a table back. But i guess these are the only ways.

Another tweaking you could do to achieve this is.

You could create 2 entities with association and use deep entity to pass table in the second one.

1st enity - temp , date

2nd entity - temp , ID , value

and then have 1-n  association bw 1st & 2nd.

I dont think Batch would help you, since it will treat each request as an individual one if you are looking at having the entire table to process further.

Regards

Mayank

Former Member
0 Kudos

< removed link>

Message was edited by: Andre Fischer The link that has been provided had no relevance for the topic.

Former Member
0 Kudos

But as i know there is no possibility to pass to function import entity type parameter (only simple

types like below) Please explain your last post.

Probably you are talking about CRUD ?

BR

Lucas

Former Member
0 Kudos

Thank for answer.

Could you link to some example ? I am interested to make association like this and make code in DPC. I suppose that because of association i will achieve structure like this:

- param1

- param2

- tableType1

BR

Lucas

Former Member
0 Kudos

Hi Lukasz,

I wish people would stop referring to tables in OData, there is no such thing! Working with the right terminology would help.

In this scenario, the co-called 'table' is a list of identical data properties. In other words, entities.

A list of entities is an entityset.

There is no use case for a function import here as this is entirely achievable with CRUDQ.

Produce a proper data model and implement a CRUD based DPC. Don't have some half-baked notion of a data model  and decide it should be a function import then complain because it doesn't work. There's stuff I don't like about GW and OData but I learn to work within the constraints, or just don't use it.

BR

Ron.

Former Member
0 Kudos

Hello Ron,

You are right. I am using this terminology to be well understood by old school programmers, but you are right, i will avoid it and switch to 'entity' terminology.

My problem is to process data like this between client and server (first Read, then Update)

MeasurementInformationAssnMeasuredValues - association 1:n

1st entity: MeasurementInformation (BatchId, Temperature, Date)

2st entity: MeasuredValues (BatchId, Property, Value)

Could you refer me to some tutorial / or point steps i have to do ?

Thanks from mountains

Lucas

Former Member
0 Kudos

Hi Lucas,

You can check the create deep entity in this link for your reference.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0d92637-3d0d-2f10-ebb2-efc1f40a8...

Regards

Mayank

Former Member
0 Kudos

Sir! step away from the key/value pairs...step away!

Do you really need to use key value pair concept? It's not a great idea for OData as it dilutes the value of a discrete data model. The metadata would not expose much information about the data model if all it contained was properties that manifest at runtime. Plus the 'value' types are generic and can cause issues with content formatting.

If I was working on instrument measurements, I'd try to use types that were appropriate for each measured property. That would need each measure property to be declared in the 'MeasuredValues' entity.


I'm not actually clear why you need two entities as described? Temperature sounds like a measured value and not a property of MeasurementInformation. As a potential consumer, I'd be (and am) confused.


You have a batchID, so I'd expect a Batch entity somewhere, with a link to (historical?) measurements:


e.g.


myservice/SomeThings(batchID='12345')/MeasuredValues?$filter=Date eq <date_arg>


Which is basically saying, for this object with key 12345, get me the measured values for date x.


This would also allow some extension into other aspects of 'SomeThing' such as 'ManufactureDocs', etc, that aren't measurement-biased.


At this point we are still exploring the data model and looking at use cases before implementing anything. Decide how to access the model, then build to suit.


Over to you Lucasz


Regards


Ron.

Former Member
0 Kudos

In this doc there is info that

''Starting with SAP NetWeaver Gateway 2.0/SP2, the OData channel allows for reading and creating complex business entities in one request."


My Netweaver is 700. Only option is to use batch request ?


BR

Lucas


Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Lukasz,

Through Function Import its not possible.

For Solution Please look at the below :

Regards,

Ashwin