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
 

 

Reading and Matching records within the same file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Reading and Matching records within the same file.
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 Moderator


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

PostPosted: Mon Apr 27, 2009 9:40 pm    Post subject:
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    Post subject: Reply to: Reading and Matching records within the same file.
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 Moderator


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

PostPosted: Mon Apr 27, 2009 10:02 pm    Post subject:
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    Post subject: Reply to: Reading and Matching records within the same file.
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 Moderator


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

PostPosted: Tue Apr 28, 2009 12:49 am    Post subject:
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    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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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