cancel
Showing results for 
Search instead for 
Did you mean: 

Create Meter Reading Results for multiple registers

daniel_mccollum
Active Contributor
0 Kudos

In the MeterReadingResults entity, there is a structure for dependent meter reading results

I've been trying several iterations of input data to try & allow the creation of meter reading results from this service, for multiple registers at a time, & had no success in structuring the data.

However when stepping through the code,

* 1. Map deep request structure to internal tables for meterreading     

there is a method to take the dependent results, & map them to a single table for update in the database.

When I enter a dataset in debug, the multiple entries are saved successfully.

the relevant code block I am trying to structure my input to match is

* map result and dependent results to one table                          *

**************************************************************************
MOVE-CORRESPONDING is_meter_reading_result_deep TO ls_meter_reading_result.
APPEND ls_meter_reading_result TO lt_meter_reading_results.
APPEND LINES OF is_meter_reading_result_deep-dependentmeterreadingresults 
TO lt_meter_reading_results.

the structure I am using successfully for a single reading is:

<?xml version="1.0" encoding="utf-8"?>

<entry xml:base="http://magic:8000/sap/opu/odata/sap/ZMAGIC/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

 <category term="ERP_UTILITIES_UMC.MeterReadingResult" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

 <content type="application/atom+xml;type=entry; charset=utf-8">

  <m:properties xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

   <d:MeterReadingResultID/>

   <d:DeviceID>11111111</d:DeviceID>

   <d:RegisterID>001</d:RegisterID>

   <d:ReadingResult>116.000000000000</d:ReadingResult>

   <d:ReadingDateTime>2017-04-26T11:23:17</d:ReadingDateTime>

   <d:MeterReadingReasonID>02</d:MeterReadingReasonID>

   <d:SerialNumber>211111111</d:SerialNumber>

  </m:properties>

 </content>

</entry>

Is there any advice on where to insert the dependantMeterReadingResults so I can update mutliple registers of a device in one call?

Accepted Solutions (0)

Answers (1)

Answers (1)

yevgen_trukhin
Advisor
Advisor

Hi Daniel, in order to perform this you would need to use relation dependentMeterReadingResults from MeterReading to MeterReading.


Sample payload to give you a hint:

<link href="MeterReadingResults(MeterReadingResultID='61853',DeviceID='10022778',RegisterID='001')/DependentMeterReadingResults" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/DependentMeterReadingResults" type="application/atom+xml;type=feed" title="DependentMeterReadingResults">

<m:inline>

<id>system/MeterReadingResults(MeterReadingResultID='61853',DeviceID='10022778',RegisterID='001')/DependentMeterReadingResults</id>

<title type="text">MeterReadingResults</title>

<updated>2013-07-25T19:46:18Z</updated>

<author>

<name/>

</author>

<entry>

<content type="application/xml">

<m:properties>

<d:DeviceID>10022778</d:DeviceID>

<d:RegisterID>001</d:RegisterID>

<d:ReadingResult>123</d:ReadingResult>

<d:ReadingDateTime>2013-07-25T19:46:18</d:ReadingDateTime>

</m:properties>

</content>

</entry>

<entry>

<content type="application/xml">

<m:properties>

<d:DeviceID>10022778</d:DeviceID>

<d:RegisterID>001</d:RegisterID>

<d:ReadingResult>123</d:ReadingResult>

<d:ReadingDateTime>2013-07-25T19:46:18</d:ReadingDateTime>

</m:properties>

</content>

</entry>

</feed>

</m:inline>

</link>

<content type="application/xml">

<m:properties>

<d:DeviceID>10022778</d:DeviceID>

<d:RegisterID>001</d:RegisterID>

<d:ReadingResult>123</d:ReadingResult>

<d:ReadingDateTime>2013-07-25T19:46:18</d:ReadingDateTime>

</m:properties>

I modified the payload to get rid of system URLs but I hope you get the idea.

Best Regards, Yevgen

daniel_mccollum
Active Contributor
0 Kudos

Thanks Yevgen, I will work through the hint. Thanks for the insight.