Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DFSORT XML query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Indrajit_57
Warnings : 1

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Tue Sep 06, 2011 5:51 pm    Post subject: DFSORT XML query
Reply with quote

Hi,

My requirement is that I have a XML file which can have the following data

Code:

            <SequenceNum>5</SequenceNum>               


The <SequenceNum> can start at any position in the line. The actual value can have maximum length of 8 bytes.

I want to initialize the SequenceNum value to 1 and increment thereafter.

For example if the input file is : -

Code:

<TransmissionHeader_1000>                                               
    <TransRecordHeader>                                                 
        <SequenceNum>5</SequenceNum>
    </TransRecordHeader>                                                 
    <FileReferenceNum>201202300000113922</FileReferenceNum>             
    <CDFVersionNum>3.00</CDFVersionNum>                                 
    <RunModeIndicator>P</RunModeIndicator>                               
    <ProcessorNum>00000003720</ProcessorNum>                             
    <SchemaVersionNum>10.01.02.00</SchemaVersionNum>                     
</TransmissionHeader_1000>                                               
<IssuerEntity ICANumber="00000000000" IssuerNumber="00600000000">       
    <IssuerInformation_3000>                                             
        <HierarchyRecordHeader>                                         
            <SequenceNum>6</SequenceNum>                               
            <StatusCode>A</StatusCode>                                   
        </HierarchyRecordHeader>                                         


My output should be

Code:

<TransmissionHeader_1000>                                               
    <TransRecordHeader>                                                 
        <SequenceNum>1</SequenceNum>                                   
    </TransRecordHeader>                                                 
    <FileReferenceNum>201202300000113922</FileReferenceNum>             
    <CDFVersionNum>3.00</CDFVersionNum>                                 
    <RunModeIndicator>P</RunModeIndicator>                               
    <ProcessorNum>00000003720</ProcessorNum>                             
    <SchemaVersionNum>10.01.02.00</SchemaVersionNum>                     
</TransmissionHeader_1000>                                               
<IssuerEntity ICANumber="00000000000" IssuerNumber="00600000000">       
    <IssuerInformation_3000>                                             
        <HierarchyRecordHeader>                                         
            <SequenceNum>2</SequenceNum>                                 
            <StatusCode>A</StatusCode>                                   
        </HierarchyRecordHeader>
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Sep 07, 2011 2:17 am    Post subject:
Reply with quote

Indrajit_57,

Assuming that <SequenceNum> can start anywhere in the input record, but can be placed starting at position 5 in the output record (since it's freeform), you can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
<TransmissionHeader_1000>
    <TransRecordHeader>
           <SequenceNum>5</SequenceNum>
    </TransRecordHeader>
    <FileReferenceNum>201202300000113922</FileReferenceNum>
    <CDFVersionNum>3.00</CDFVersionNum>
    <RunModeIndicator>P</RunModeIndicator>
    <ProcessorNum>00000003720</ProcessorNum>
    <SchemaVersionNum>10.01.02.00</SchemaVersionNum>
</TransmissionHeader_1000>
<IssuerEntity ICANumber="00000000000" IssuerNumber="00600000000">
    <IssuerInformation_3000>
        <HierarchyRecordHeader>
               <SequenceNum>6</SequenceNum>
            <StatusCode>A</StatusCode>
        </HierarchyRecordHeader>
//SORTOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY
 INREC IFTHEN=(WHEN=(1,80,SS,EQ,C'<SequenceNum>'),
    BUILD=(5:C'<SequenceNum>',SEQNUM,8,FS,C'</SequenceNum>'),
    HIT=NEXT),
  IFTHEN=(WHEN=(5,13,CH,EQ,C'<SequenceNum>'),
    BUILD=(5:5,40,SQZ=(SHIFT=LEFT)))
/*


SORTOUT would have:

Code:

<TransmissionHeader_1000>
    <TransRecordHeader>
    <SequenceNum>1</SequenceNum>
    </TransRecordHeader>
    <FileReferenceNum>201202300000113922</FileReferenceNum>
    <CDFVersionNum>3.00</CDFVersionNum>
    <RunModeIndicator>P</RunModeIndicator>
    <ProcessorNum>00000003720</ProcessorNum>
    <SchemaVersionNum>10.01.02.00</SchemaVersionNum>
</TransmissionHeader_1000>
<IssuerEntity ICANumber="00000000000" IssuerNumber="00600000000">
    <IssuerInformation_3000>
        <HierarchyRecordHeader>
    <SequenceNum>2</SequenceNum>
            <StatusCode>A</StatusCode>
        </HierarchyRecordHeader>
Back to top
View user's profile Send private message
Indrajit_57
Warnings : 1

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Thu Sep 08, 2011 11:08 am    Post subject:
Reply with quote

Thanks Frank, it worked perfectly.

I have one question though, is it possible to start the <SequenceNum> from the same position where it was there in the input file?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Sep 09, 2011 4:24 am    Post subject:
Reply with quote

Kolusu and I came up with the following way to do that with DFSORT. We assumed that your input file has RECFM=FB and LRECL=80, and that you don't have a " (quote) in position 1 in any of your input records.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
<TransmissionHeader_1000>
    <TransRecordHeader>
           <SequenceNum>5</SequenceNum>
    </TransRecordHeader>
    <FileReferenceNum>201202300000113922</FileReferenceNum>
    <CDFVersionNum>3.00</CDFVersionNum>
    <RunModeIndicator>P</RunModeIndicator>
    <ProcessorNum>00000003720</ProcessorNum>
    <SchemaVersionNum>10.01.02.00</SchemaVersionNum>
</TransmissionHeader_1000>
<IssuerEntity ICANumber="00000000000" IssuerNumber="00600000000">
    <IssuerInformation_3000>
        <HierarchyRecordHeader>
               <SequenceNum>6</SequenceNum>
            <StatusCode>A</StatusCode>
        </HierarchyRecordHeader>
//SORTOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY                                                     
 INREC IFOUTLEN=80,                                               
  IFTHEN=(WHEN=(1,80,SS,EQ,C'<SequenceNum>'),                     
    BUILD=(C'"',1,80),HIT=NEXT),                                 
  IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),                                 
    FINDREP=(SHIFT=NO,IN=C'<SequenceNum>',                       
       OUT=C'<SequenceNum>"                      '),HIT=NEXT),   
  IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),                                 
      OVERLAY=(82:SEQNUM,8,FS,C'</SequenceNum>',                 
        1:1,104,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),           
  IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),                                 
    FINDREP=(IN=C'"',OUT=C''))                                   
/*

Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us