I am beginner in mainframe, trying to learn. I need little or guidance
I generated a xml file using XMLGEN utility. Now I need to convert this xml to flat file(comma separated hopefully)
my xml file(containing lot of records) is in following format
<?xml version="1.0"?>
<FILE DSN="data">
<sample RECORD="00001">
<NUMBER>1111</NUMBER>
<DATE>2015</DATE>
<TIME>0000</TIME>
<NO>1</NO>
<N01>1</N01>
<N02>2002</N02>
<N03>0</N03>
<N04>0</N04>
</sample>
<sample RECORD="00002">
<NUMBER>2222</NUMBER>
<DATE>2014</DATE>
<TIME>1111</TIME>
<NO>1</NO>
<N01>1000</N01>
<N02>2002</N02>
<N03>10</N03>
<N04>10</N04>
</sample>
No I am using this JCL to generate flat output file
//STEP01 EXEC PGM=SORT
//*
//SORTIN DD DSN=File1,DISP=OLD
//SORTOUT DD DSN=File2,DISP=OLD
//*
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=INIT,PARSE=(%1=(STARTAFT=C'NUMBER>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%2=(STARTAFT=C'DATE>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%3=(STARTAFT=C'TIME>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%4=(STARTAFT=C'NO>',
ENDBEFR=C'</>',FIXLEN=1))),
IFTHEN=(WHEN=INIT,PARSE=(%5=(STARTAFT=C'N01>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%6=(STARTAFT=C'N02>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%7=(STARTAFT=C'N03>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%8=(STARTAFT=C'N04>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=NONE,BUILD=(1,4,%1,15:%2,%3,%4,%5,%6,%7,%8))
//*
//SORTIN DD DSN=File1,DISP=OLD
//SORTOUT DD DSN=File2,DISP=OLD
//*
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=INIT,PARSE=(%1=(STARTAFT=C'NUMBER>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%2=(STARTAFT=C'DATE>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%3=(STARTAFT=C'TIME>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%4=(STARTAFT=C'NO>',
ENDBEFR=C'</>',FIXLEN=1))),
IFTHEN=(WHEN=INIT,PARSE=(%5=(STARTAFT=C'N01>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%6=(STARTAFT=C'N02>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%7=(STARTAFT=C'N03>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=INIT,PARSE=(%8=(STARTAFT=C'N04>',
ENDBEFR=C'</>',FIXLEN=4))),
IFTHEN=(WHEN=NONE,BUILD=(1,4,%1,15:%2,%3,%4,%5,%6,%7,%8))
But I am getting output as
1111
2015
0000
1
1</N0
2002
0</N0
0</N0
2222
2014
1111
1
1000
2002
10</N0
10</N0
Now I have two issues. I want my output(1record in 1 line values separated by ,) as
1111,2015,0000,1,1,2002,0,0
2222,2014,1111,1,1000,2002,10,10
and values of last 4 columns can vary from no value to 4 digits. but when I give as fixlen=4, it is picking up next characters
if value is less than 4 digits.
Please help me on this one, any guidance or advise on what changes I should make to my jcl to get required o/p will be greatly appreciated
thanks a lot