IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reading and Matching records within the same file.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
PL1user

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Mon Apr 27, 2009 9:13 pm
Reply with quote

Hi

I am working on a requirement where I need to deal with XML files. The XML file need to be formatted to a specific format before I start processing it.

For Example, if my file looks like this,

A
B
AAAAAAAAAAAA
/B
B
BBBBBBBBBBBB
/B
/A


I want this file to be formatted as,

A/A
B/B
AAAAAAAAAAAA
B/B
BBBBBBBBBBBB

I have to append '/A' to the first record where 'A' is present.
I have to append the first '/B' with the first 'B' & the second 'B' with the second '/B'

Is there a way I can do this using DFSORT ? Any ideas would be really helpful.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Apr 27, 2009 9:40 pm
Reply with quote

Sorry, but your "rules" are not clear. You need to do a better job of explaining them. Are 'A' and 'B' actual values or do they just represent some other values? Maybe a more extensive and/or realistic example would help.
Back to top
View user's profile Send private message
PL1user

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Mon Apr 27, 2009 9:49 pm
Reply with quote

<XMLFile>
<SetOne>
<Name>XYZ</Name><Country>UK</Country>
</SetOne>
<SetTwo>
<Name>ABC</Name><Country>INDIA</Country>
</SetTwo>
</XMLFile>

This needs to be formatted as,
<XMLFile></XMLFile>
<SetOne></SetOne>
<Name>XYZ</Name><Country>UK</Country>
<SetTwo></SetTwo>
<Name>ABC</Name><Country>INDIA</Country>

Basically I want the start and end tag to be on the same record. If you note the above example, in cases where the end tags are not on the same record, I am extracting the end tag and appending it to the start tag.

Please let me know if I am not clear.

Thanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Apr 27, 2009 10:02 pm
Reply with quote

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 *
<XMLFile>
<SetOne>
<Name>XYZ</Name><Country>UK</Country>
</SetOne>
<SetTwo>
<Name>ABC</Name><Country>INDIA</Country>
</SetTwo>
</XMLFile>
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(1,2,CH,EQ,C'</')
  OUTFIL IFTHEN=(WHEN=(1,80,SS,NE,C'/'),
    OVERLAY=(31:C'</',2,20,1:1,80,SQZ=(SHIFT=LEFT)))
/*
Back to top
View user's profile Send private message
PL1user

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Mon Apr 27, 2009 11:08 pm
Reply with quote

<XMLFILE>
<SETONE>
<NAME>XYZ</NAME><COUNTRY>UK</COUNTRY>
</SETONE>
<SETTWO>
<NAME>ABC</NAME><COUNTRY>INDIA</COUNTRY>
</SETTWO>
</XMLFILE>

Thanks a lot Frank. But there is one more condition which I should have put this on my earlier post. Your code would just stick a </SETONE> or </SETTWO> or </XMLFILE> when there is no '</' in the entire record.

But lets suppose my file is like this,

<XMLFILE>
<SETONE>
<NAME>XYZ</NAME><COUNTRY>UK</COUNTRY>
<SETTWO>
<NAME>ABC</NAME><COUNTRY>INDIA</COUNTRY>
</SETTWO>
</XMLFILE>

There is a <SETONE> but no </SETONE>. In this case, I should not blindly write a </SETONE>. I should be abending.Can you please suggest how this can be handled ? Thankyou
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Apr 28, 2009 12:49 am
Reply with quote

It sounds like you need to define the "rules" for your error checking and implement them with a program. I don't know how much error checking you want to do, what you would consider to be an error, or if "abending" means issuing a particular error message or just terminating with any old message. To get that kind of control usually requires writing a program with the needed logic.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top