| midrange.com code scratchpad | 
				
					| 
							
								| Name:Jon Paris - XML-INTO Meter Reading Sample | Scriptlanguage:Plain Text | Tabwidth:4 | Date:04/25/2017 11:30:37 pm | IP:Logged |  | 
				
					| Description:This is the code example for XML-INTO mentioned in the thread: https://archive.midrange.com/rpg400-l/201704/msg00125.html | 
				
					| Code: 
							
								
								
								| 
    **free
dcl-s  xmldata char(9999) Inz('<?xml version="1.0" encoding="utf-8" standalone="yes"?>+
<MeterReadingDocument xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
 <ImportExportParameters CreateResubmitFile="false">+
   <DataFormat DSTTransitionType="ITRON_Compliant" ReadingTimestampType="Utc" />+
 </ImportExportParameters>+
 <Channels>+
   <Channel ReadingsInPulse="false" IsRegister="true" IsReadingDecoded="false" +
    MarketType="Gas">+
     <ChannelID EndPointChannelID="32842936:1" />+
     <Readings>+
       <Reading Value="0009290249" ReadingTime="2017-03-31T13:44:46" />+
     </Readings>+
     <OptionalChannelDatas>+
       <OptionalChannelData Name="ERTType" Value="2" />+
       <OptionalChannelData Name="Tamper1" Value="0" />+
       <OptionalChannelData Name="Tamper2" Value="2" />+
     </OptionalChannelDatas>+
   </Channel>+
   <Channel ReadingsInPulse="false" IsRegister="true" +
            IsReadingDecoded="false" +
            MarketType="Gas">+
     <ChannelID EndPointChannelID="41409881:1" />+
     <Readings>+
       <Reading Value="0000281274" ReadingTime="2017-04-18T11:51:00" />+
     </Readings>+
     <OptionalChannelDatas>+
       <OptionalChannelData Name="ERTType" Value="12" />+
       <OptionalChannelData Name="Tamper1" Value="0" />+
       <OptionalChannelData Name="Tamper2" Value="0" />+
     </OptionalChannelDatas>+
   </Channel>+
 </Channels>+
</MeterReadingDocument>');
 dcl-c n 20;
dcl-c nn 10;
 dcl-ds MeterReadingDocument Qualified;
  ImportExportParameters  LikeDS(ImportExportParameters_T);
  Channels                LikeDS(Channels_T);
end-ds MeterReadingDocument;
  dcl-ds ImportExportParameters_T  Template Qualified;   
  CreateResubmitFile char(n);
  DataFormat  LikeDS(DataFormat_T);
end-ds;                         
 dcl-ds DataFormat_T Template;             
  DSTTransitionType     char(n);
  ReadingTimestampType  char(n);
end-ds;                       
 dcl-ds Channels_T  Template  Qualified;                
  countChannel int(10);
  Channel  Dim(nn)  LikeDS(Channel_T);
end-ds Channels_T;                         
 dcl-ds Channel_T  Template  Qualified;       
  ReadingsInPulse   char(n);
  IsRegister  char(n);
  IsReadingDecoded   char(n);
  MarketType   char(n);
  ChannelID    LikeDS(ChannelID_T);
  Readings     LikeDS(Readings_T);
  OptionalChannelDatas  LikeDS(OptionalChannelDatas_T);
end-ds;
 dcl-ds  ChannelID_T Template;         
  EndPointChannelID  char(n);
end-ds;                    
 dcl-ds Readings_T  Template  Qualified;           
  countReading int(10);
  Reading  dim(nn) LikeDS(Reading_T);  
end-ds;                    
 dcl-ds Reading_T  Template;  
  Value  char(n);
  ReadingTime char(n);
end-ds;                  
 dcl-ds OptionalChannelDatas_T  Template  Qualified; 
    countOptionalChannelData int(10);
    OptionalChannelData dim(nn)  LikeDS(OptionalChannelData_T); 
end-ds;
 dcl-ds OptionalChannelData_T  Template   Qualified; 
  Name  char(n);
  Value   char(n);
end-ds;                             
  xml-into MeterReadingDocument %XML(XMLData:
                                   'countprefix=count case=any');
 
*INLR = *ON;  |  | 
				
					|  |