View previous topic :: View next topic
Author
Message
FCKler_1984 New User Joined: 03 Jun 2022Posts: 3 Location: Germany
Hi all,
I tried to find a solution in the search, but there was no matching entry for my problem with the END Parameter in my SORT Statement:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,16,CH,EQ,C'<SelectNr>123456'),
END=(5,20,CH,EQ,C'<LogoPos>U</LogoPos>'),PUSH=(80:5,10)),
IFTHEN=(WHEN=GROUP,BEGIN=(5,16,CH,EQ,C'<SelectNr>789012'),
END=(5,20,CH,EQ,C'<LogoPos>U</LogoPos>'),PUSH=(80:5,10))
END
The statement works fine for all records in my XML File having the following structure:
<SelectNr>1234560910123456</KartenNr>
<Wert2>2000</Wert2>
<Wert3>2206</Wert3>
<Wert4>2507</Wert4>
<Wert6>TEST 12345</Wert5>
<Wert7>J</Wert7>
<Wert8>03</Wert8>
<LogoPos>U</LogoPos>
But it also works for records, which only match the BEGIN-Statement
Code:
BEGIN=(5,16,CH,EQ,C'<SelectNr>123456')
The condition of the END-Statement
Code:
END=(5,20,CH,EQ,C'<LogoPos>U</LogoPos>')
is not true in that cases, for example:
<SelectNr>1234560910123456</SelectNr>
<Wert2>2000</Wert2>
<Wert3>2206</Wert3>
<Wert4>2507</Wert4>
<Wert6>TEST 12345</Wert5>
<Wert7>J</Wert7>
<Wert8>03</Wert8>
But SORT still executes the PUSH-command:
until the end of the file, because there is no more matching XML-Tag with <LogoPos> .
Hope you can help me to understand this behaviour or find my error :-)
Many thanks for the help
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2126 Location: USA
BEGIN= starts the group, which continues either until END= , or endlessly.
It's impossible to guess: is there any new END= somewhere in the future?
I believe you need to detect the group by BEGIN=(...,C'<SelectNR>') only. In this case any new <SelectNR> will end the previous group.
Back to top
FCKler_1984 New User Joined: 03 Jun 2022Posts: 3 Location: Germany
Hi sergeyken,
thank you for your quick response.
So I have to live with this "problem" and there is no error in my SORT-Statement.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1319 Location: Bamberg, Germany
When you just want to have all groups, independently if they are complete or not, BEGIN= is sufficient (as sergeyken has pointed out). But separation to complete/incomplete groups is also possible with SORT means.
Back to top
FCKler_1984 New User Joined: 03 Jun 2022Posts: 3 Location: Germany
Hi Joerg,
can you please give me an example? In my case I only need the complete groups. But it can't hurt to know both options
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1319 Location: Bamberg, Germany
Code:
//WHATEVER EXEC PGM=ICEMAN
//F1 DD *
<SelectNr>1234560910123456</SelectNr>
<Wert2>2000</Wert2>
<Wert3>2206</Wert3>
<Wert4>2507</Wert4>
<Wert6>TEST 1234F</Wert5>
<Wert7>J</Wert7>
<Wert8>03</Wert8>
<SelectNr>1234560910123456</SelectNr>
<Wert2>2000</Wert2>
<Wert3>2206</Wert3>
<Wert4>2507</Wert4>
<Wert6>TEST 12345</Wert5>
<Wert7>J</Wert7>
<Wert8>03</Wert8>
<LogoPos>U</LogoPos>
<SelectNr>1234560910123456</SelectNr>
<Wert2>2000</Wert2>
<Wert3>2206</Wert3>
<Wert4>2507</Wert4>
<Wert6>TEST 1234N</Wert5>
<Wert7>J</Wert7>
<Wert8>03</Wert8>
/*
//F2 DD *
WHATEVER
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=F1,FIELDS=(41,4,A,45,4,D)
JOINKEYS F2=F2,FIELDS=(41,4,A,45,4,D),SORTED,NOSEQCK
JOIN UNPAIRED,F1,ONLY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(49:C'N')),
IFTHEN=(WHEN=GROUP,
END=(1,10,CH,EQ,C'<SelectNr>'),
BEGIN=(1,9,CH,EQ,C'<LogoPos>'),
PUSH=(49:50,1))
SORT FIELDS=(41,8,ZD,A)
OUTFIL FNAMES=(SORTOUT),
OMIT=(49,1,CH,EQ,C'N'),
REMOVECC,
BUILD=(1,40)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,10,CH,EQ,C'<SelectNr>'),PUSH=(41:ID=4,SEQ=4))
END
/*
//JNF2CNTL DD *
OPTION STOPAFT=1
END
/*
Output:
Code:
****** **************************** Datenanfang *******
000001 <SelectNr>1234560910123456</SelectNr>
000002 <Wert2>2000</Wert2>
000003 <Wert3>2206</Wert3>
000004 <Wert4>2507</Wert4>
000005 <Wert6>TEST 12345</Wert5>
000006 <Wert7>J</Wert7>
000007 <Wert8>03</Wert8>
000008 <LogoPos>U</LogoPos>
****** **************************** Datenende *********
Back to top
Please enable JavaScript!