cancel
Showing results for 
Search instead for 
Did you mean: 

Odata function import - input as complex type

Former Member
0 Kudos

Hello

Is it possible to make an input as a complex type ?

for example we want to check set of values which are in table, all for one temperature .

and we will use structure:


1) -temperature

    -table

          -tableval1

          -tableval2

          -tableval3

Question is how to set such input type in segw ?

Thanks from mountains

Lucas

Accepted Solutions (0)

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Lukasz,

I do not see any provision to use a complex type parameters as input.

Hence we cannot send fields of ur complex type as input to ur Function Import.

We can only define data element and send only the fields which we define as function import parameters.

U can accomplish that through ur GET operations. Where u can send complex type parameters as input as well.

Regards,

Ashwin

Former Member
0 Kudos

Hello Ashwin,

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



Question how to do it is still open.

Thanks for you previous answer.

Lucas

AshwinDutt
Active Contributor
0 Kudos

Hello Lucas,

The way u would like to pass is not possible through a Function Import as there is no provision for sending complex type parameters as input along with the parameters of your entity as well.

We know that READ works on Keys and we cannot define complex type as key . So we cannot implement READ/Get_Entity here.

So u need to implement QUERY/Get_Entity_Set to accomplish your scenario :

Steps for ur reference ->

1. Create Complex Type :

2. Create an Entity and Add that Complex Type along with your Entity parameters as below :

Entity - Input

EntitySet - InputSet

Complex Type - MeasuredValue

3. Implement /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET / QUERY operation :


U can access ur Complex Type Parameters as part of filters as below :


URL ->


/sap/opu/odata/sap/ZASH_TEST_MANJ_SRV/InputSet?$filter=Temp eq '10' and Datein eq datetime'2014-02-02T00:00:00' and Measure/V1 eq 'V1' and Measure/V2 eq 'V2'


Regards,

Ashwin


Former Member
0 Kudos

Thank you for answer.

The way you create this example does not reflect relation 1:n

We know that temperature value to measured values in in relation 1:n 

We don't know n , its could be 5 or 100.

As i understand you approach with complex type will be good when we know that for example for every temperature there will be 5 measured values. but we don't know this. Its dynamic value from runtime, not static.

I mixup while writing post complex type with table type. Correct valus which i want to pass are:

- temerature

- date

- measured value table (n-values, dynamic from runtime)

          -  valueID1, measured value1

         - valueID2, measured value2

         - valueID3, measured value3

          ....

         - valueIDn, measured valuen

For now i know 2 ways:

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

2) create update statement with table (crud update approache):


- temerature, date, valueID1, measured value1

....

- temerature, date, valueIDn, measured valuen

It makes redundantion.

Both solutions are not ideal.

Thanks for your help!

AshwinDutt
Active Contributor
0 Kudos

Hello Lukasz,

Comments as per my knowledge :

1. Converting your table parameters as string and converting that back to your internal table in DPC is not a standard approach i feel.

2. Accomplishing this GET operation through an Modifying request (CUD - POST PUT DELETE) is also not a part of standard i feel.

U can use BATCH :

Each operation inside your body/payload is considered as separate individual operations in a single request. For each operation the same logic is called.

Say If u have 5 entries in your table, then your logic is called 5 times rather than calling once ( like how it happens in our FM).This also u need to consider should i go with BATCH as there is a trade off when it comes to performance in fetching data.

This is s standard approach and this is how BATCH works.

There would be separate response for each of your table of inputs u send inside a payload and u will have to capture all that which will constitute the complete response for the data u sent as a payload.

Regards,

Ashwin