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

Problem with IFTHEN=(WHEN=GROUP,BEGIN=...END=...)


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

New User


Joined: 03 Jun 2022
Posts: 3
Location: Germany

PostPosted: Fri Jun 03, 2022 5:55 pm
Reply with quote

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:

Code:
 PUSH=(80:5,10)     


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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2126
Location: USA

PostPosted: Fri Jun 03, 2022 6:24 pm
Reply with quote

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
View user's profile Send private message
FCKler_1984

New User


Joined: 03 Jun 2022
Posts: 3
Location: Germany

PostPosted: Fri Jun 03, 2022 6:35 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1319
Location: Bamberg, Germany

PostPosted: Sat Jun 04, 2022 8:56 am
Reply with quote

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
View user's profile Send private message
FCKler_1984

New User


Joined: 03 Jun 2022
Posts: 3
Location: Germany

PostPosted: Tue Jun 07, 2022 10:50 am
Reply with quote

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 icon_cool.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1319
Location: Bamberg, Germany

PostPosted: Tue Jun 07, 2022 11:21 am
Reply with quote

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
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 Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
Search our Forums:

Back to Top