XML FILE SORTING



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

XML FILE SORTING

Postby RAVIPRAD29 » Sun Apr 19, 2020 12:27 am

Hi all,

I have a requirement to split xml file into 2 files based on condition ( 'ID' FIELD)
The HEADER and INFORMATION should be there in all files along with the condition.

Input file:-
<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<ID>11111
<TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>BEN</NAME>
</HEADER>
<ID>22222
<TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>JOHN</NAME>
</HEADER>
<ID>11111
<TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>MARK</NAME>
</HEADER>
<ID>22222
<TRANSACTION>


Expected Output:-
File1:-
condition:: (if 5,5,ch,eq,c'11111')

<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<ID>11111
<TRANSACTION>


<TRANSACTION>
<HEADER>
<NAME>JOHN</NAME>
</HEADER>
<ID>11111
<TRANSACTION>

File2:-
condition:: condition:: (if 5,5,ch,eq,c'22222')
<?xml version="1.0" encoding="UTF-8"?>

<TRANSACTION>
<HEADER>
<NAME>BEN</NAME>
</HEADER>
<ID>22222
<TRANSACTION>


<TRANSACTION>
<HEADER>
<NAME>MARK</NAME>
</HEADER>
<ID>22222
<TRANSACTION>
RAVIPRAD29
 
Posts: 3
Joined: Sun Apr 19, 2020 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: XML FILE SORTING

Postby NicC » Sun Apr 19, 2020 3:00 am

Please use the code tags when posting data as well as code.

Have you investigated this document?
http://www.ibm.com/support/pages/smart-dfsort-tricks
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: XML FILE SORTING

Postby RAVIPRAD29 » Sun Apr 19, 2020 6:39 pm

Thanks fot the reply NicC.

I am basically looking for solution to split XML based on key Column ('ID' FIELD) with DFSORT

I tried with below sort card ,but I am not getting the desire result

//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,13,CH,EQ,C'<TRANSACTION>'),
END=(1,14,CH,EQ,C'</TRANSACTION>'),PUSH=(601:ID=8))
OUTFILE FNAMES=OUT01,BUILD=(1,600),INCLUDE=(5,5,CH,EQ,C'11111')

I am just getting just 1 line instead of entire group as indiacted belwo

<ID>11111
<ID>11111

Can you please let me know on these since this bit urgent requirement.
RAVIPRAD29
 
Posts: 3
Joined: Sun Apr 19, 2020 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: XML FILE SORTING

Postby NicC » Sun Apr 19, 2020 7:54 pm

It is not urgent if you are posting on a forum where questions are answered by volunteers if and when they feel like it. And they are less likely to feel like it if you say 'urgent', or similar, and ignore requests to present your code and data correctly - using the code tags (see the "POST REPLY" button).
Have you studied that document - it has many ways to split a dataset?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: XML FILE SORTING

Postby sergeyken » Sun Apr 19, 2020 9:41 pm

RAVIPRAD29 wrote:Thanks fot the reply NicC.

I am basically looking for solution to split XML based on key Column ('ID' FIELD) with DFSORT

I tried with below sort card ,but I am not getting the desire result

//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,13,CH,EQ,C'<TRANSACTION>'),
END=(1,14,CH,EQ,C'</TRANSACTION>'),PUSH=(601:ID=8))
OUTFILE FNAMES=OUT01,BUILD=(1,600),INCLUDE=(5,5,CH,EQ,C'11111')

I am just getting just 1 line instead of entire group as indiacted belwo

<ID>11111
<ID>11111

Can you please let me know on these since this bit urgent requirement.


RTFM, RTFM, RTFM, and RTFM. And next: RTFM, RTFM, RTFM and RTFM again.

One hint: SORT is not good tools for such task. It can be used exactly as a hammer could be used to hammer screws, and bolts.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 408
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: XML FILE SORTING

Postby RAVIPRAD29 » Sun Apr 19, 2020 10:36 pm

Hi NicC,

Thanks for your timely and valuable input and since many of my colleagues told me that XML sorting in DFSORT is complicated compared to COBOL and PL1 sorting. So i am trying out different options to find a solution for the complicated process and hence was looking out fot valuable inputs from xperienced and versatile professionals like you and sorry for maybe sounding impatient in trying to find a solution.

Also I have adeed the code tags for my query as below and also to SORT code now , and apologies for not adding it earlier since I am new to this forum and was not aware of these options.

I have a requirement to split xml file into 2 files based on condition ( 'ID' FIELD)The HEADER and INFORMATION should be there in all files along with the condition.


 
Input file:-
<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<ID>11111
</TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>BEN</NAME>
</HEADER>
<ID>22222
</TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>JOHN</NAME>
</HEADER>
<ID>11111
</TRANSACTION>

<TRANSACTION>
<HEADER>
<NAME>MARK</NAME>
</HEADER>
<ID>22222
</TRANSACTION>


Expected Output:-
File1:-
condition:: (if 5,5,ch,eq,c'11111')

<?xml version="1.0" encoding="UTF-8"?>
<TRANSACTION>
<HEADER>
<NAME>ALEX</NAME>
</HEADER>
<ID>11111
</TRANSACTION>


<TRANSACTION>
<HEADER>
<NAME>JOHN</NAME>
</HEADER>
<ID>11111
</TRANSACTION>

File2:-
condition:: condition:: (if 5,5,ch,eq,c'22222')
<?xml version="1.0" encoding="UTF-8"?>

<TRANSACTION>
<HEADER>
<NAME>BEN</NAME>
</HEADER>
<ID>22222
</TRANSACTION>


<TRANSACTION>
<HEADER>
<NAME>MARK</NAME>
</HEADER>
<ID>22222
</TRANSACTION>
 


i have gone through the document which you referred me following which i was
able to get a partial result with the below SORT card and just need your input
once again if this needs to be rectified or corrected.

 

//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,13,CH,EQ,C'<TRANSACTION>'),
END=(1,14,CH,EQ,C'</TRANSACTION>'),PUSH=(601:ID=8))
OUTFILE FNAMES=OUT01,BUILD=(1,600),INCLUDE=(5,5,CH,EQ,C'11111')

 


'
I am just getting just 1 line instead of entire group as indiacted below

<ID>11111
<ID>11111

RAVIPRAD29
 
Posts: 3
Joined: Sun Apr 19, 2020 12:14 am
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post