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

JCL SORT


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

New User


Joined: 15 Dec 2022
Posts: 8
Location: BHOPAL

PostPosted: Thu Mar 16, 2023 11:49 am
Reply with quote

I want to check the GRAND TOTALS .00 if it is GRAND TOTALS .00 than we have to add "No Data" in line 5 and we are also adding HEADER1& TRAILER1 in report And if GRAND TOTALS .00 not than it will simply add HEADER1& TRAILER1 in report

Code:
SORT FIELDS=COPY             
 OUTFIL REMOVECC,           
   HEADER1=(1:'BEGIN',/,   
      1:'KEY2',/,           
      1:'LOB ',/,           
      1:'BEGIN',/,         
      1:'KEY A3'),         
   TRAILER1=(1:'END',/,   
      1:'END')         


Input file:

Code:

000001 1  3/15/2023                                       
000002             RECORDS CHANGED   
000003                                                     
000004 0p      NO.         PRE                  PM         
[b]000005 [/b]                                                   
000006 1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009 0       NO.         PRE                  PM         
000010                                                     
000011  GRAND TOTALS           .00              .00       
000012                                                     


Let me know the sort logic, Help me if u KNOW[/code]
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Mar 16, 2023 12:41 pm
Reply with quote

Why not add the line to the original report? Also, you have several .00 totals, which should be the correct one?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Mar 16, 2023 1:31 pm
Reply with quote

Code:
//WHATEVER EXEC PGM=ICEMAN                                   
//F1       DD *                                               
1  3/15/2023                                                 
            RECORDS CHANGED                                   
                                                             
0p      NO.         PRE                  PM                   
                                                             
1  3/15/2023                                                 
            RECORDS CHANGED                                   
                                                             
0       NO.         PRE                  PM                   
                                                             
 GRAND TOTALS           .00              .00                 
                                                             
/*                                                           
//F2       DD .. <* same as above                             
//SYSOUT   DD SYSOUT=*                                       
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  OPTION COPY                                                 
  JOINKEYS F1=F1,FIELDS=(81,1,A),SORTED,NOSEQCK               
  JOINKEYS F2=F2,FIELDS=(81,1,A),SORTED,NOSEQCK               
  REFORMAT FIELDS=(F1:1,80,F2:82,1)                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD)),         
    IFTHEN=(WHEN=(82,8,ZD,EQ,+5,AND,81,1,CH,EQ,C'X'),         
      OVERLAY=(C'No Data'))                                   
  OUTFIL FNAMES=(SORTOUT),
    :                                   
    BUILD=(1,80)                                             
  END                                                         
/*                                                           
//JNF1CNTL DD *                                               
  INREC OVERLAY=(82:X)                                       
  END                                                         
/*                                                           
//JNF2CNTL DD *                                               
  INCLUDE COND=(1,80,SS,EQ,C'GRAND TOTALS')                   
  INREC IFTHEN=(WHEN=(1,80,SS,EQ,C' .00 '),BUILD=(82:C'X'))   
  END                                                         
/*
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Mar 16, 2023 5:51 pm
Reply with quote

rajesh7523 wrote:
I want to check the GRAND TOTALS .00 if it is GRAND TOTALS .00 than we have to add "No Data" in line 5 and we are also adding HEADER1& TRAILER1 in report And if GRAND TOTALS .00 not than it will simply add HEADER1& TRAILER1 in report

Code:
SORT FIELDS=COPY             
 OUTFIL REMOVECC,           
   HEADER1=(1:'BEGIN',/,   
      1:'KEY2',/,           
      1:'LOB ',/,           
      1:'BEGIN',/,         
      1:'KEY A3'),         
   TRAILER1=(1:'END',/,   
      1:'END')         


Input file:

Code:

000001 1  3/15/2023                                       
000002             RECORDS CHANGED   
000003                                                     
000004 0p      NO.         PRE                  PM         
[b]000005 [/b]                                                   
000006 1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009 0       NO.         PRE                  PM         
000010                                                     
000011  GRAND TOTALS           .00              .00       
000012                                                     


Let me know the sort logic, Help me if u KNOW[/code]

I have re-read this screed about 10 times, but was not able to understand your goal.

Please, give the exact sample: how your output must look like???
Back to top
View user's profile Send private message
rajesh7523

New User


Joined: 15 Dec 2022
Posts: 8
Location: BHOPAL

PostPosted: Thu Mar 16, 2023 6:29 pm
Reply with quote

If we give this i/p file

Code:

000001 1  3/15/2023                                       
000002             RECORDS CHANGED   
000003                                                     
000004 0p      NO.         PRE                  PM         
000005                                                 
000006 1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009 0       NO.         PRE                  PM         
000010                                                     
000011  GRAND TOTALS           .00                     
000012
 


than Expected o/p

Code:

000001  BEGIN
000002  KEY2
000003  LOB
000004  BEGIN
000005  KEY A3         
000006  1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009  0p      NO.         PRE                  PM         
000010  No Data                                               
000011  1  3/15/2023                                       
000012             RECORDS CHANGED   
000013                                                     
000014   0       NO.         PRE                  PM         
000015                                                     
000016   GRAND TOTALS           .00                     
000017
000018   END
000019   END
 


And if we give i/p this

Code:

000001 1  3/15/2023                                       
000002             RECORDS CHANGED   
000003                                                     
000004 0p      NO.         PRE                  PM         
000005  8754  88           63                   91                                               
000006 1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009 0       NO.         PRE                  PM         
000010            88          63                   91                                           
000011  GRAND TOTALS         63.00                     
000012
 


Than Expected o/p

Code:

000001  BEGIN
000002  KEY2
000003  LOB
000004  BEGIN
000005  KEY A3         
000006  1  3/15/2023                                       
000007             RECORDS CHANGED   
000008                                                     
000009  0p      NO.         PRE                  PM         
000010  8754  88           63                   91                                               
000011  1  3/15/2023                                       
000012             RECORDS CHANGED   
000013                                                     
000014   0       NO.         PRE                  PM         
000015            88          63                   91                                       
000016   GRAND TOTALS          63.00                     
000017
000018   END
000019   END
 


Is it clear or still you have doubt
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Mar 16, 2023 9:22 pm
Reply with quote

I'm leaving addition of headers/trailers as your own excersize.

Code:
//SORT     EXEC PGM=ICETOOL                           
//TOOLMSG  DD  SYSOUT=*                               
//DFMSG    DD  SYSOUT=*                               
//*                                                   
//SORTIN   DD  *                                       
1  3/15/2023                                           
            RECORDS CHANGED                           
                                                       
0P      NO.         PRE                  PM           
                                                       
1  3/15/2023                                           
            RECORDS CHANGED                           
                                                       
0       NO.         PRE                  PM           
                                                       
 GRAND TOTALS           .00                           
1  3/15/2023                                           
            RECORDS CHANGED                           
                                                       
0P      NO.         PRE                  PM           
 8754  88           63                   91           
1  3/15/2023                                               
            RECORDS CHANGED                                 
                                                           
0       NO.         PRE                  PM                 
           88          63                   91             
 GRAND TOTALS         63.00                                 
                                                           
//*                                                         
//GROUPS   DD  SPACE=(TRK,(10,10))                         
//TOTALS   DD  SPACE=(TRK,(10,10))                         
//*                                                         
//SORTOUT  DD  SYSOUT=*                                     
//*                                                         
//TOOLIN   DD  *                                           
 COPY FROM(SORTIN) TO(GROUPS,TOTALS)   USING(GRPS)         
 COPY JKFROM       TO(SORTOUT)         USING(JOIN)         
//*                                                         
//GRPSCNTL DD  *                                           
 INREC IFTHEN=(WHEN=GROUP,                                 
               END=(2,13,CH,EQ,C'GRAND TOTALS'),           
               PUSH=(81:ID=5)),                             
       IFTHEN=(WHEN=(2,13,CH,EQ,C'GRAND TOTALS'),           
               OVERLAY=(86:15,15,UFF,EDIT=(TTTTTTTTTT)))   
 OUTFIL FNAMES=(GROUPS)                                     
 OUTFIL FNAMES=(TOTALS),                                   
        INCLUDE=(2,13,CH,EQ,C'GRAND TOTALS')             
//*                                                       
//JOINCNTL DD  *                                         
 JOINKEYS F1=GROUPS,                                     
          FIELDS=(81,5,A),SORTED                         
 JOINKEYS F2=TOTALS,                                     
          FIELDS=(81,5,A),SORTED                         
 JOIN UNPAIRED,F1                                         
 REFORMAT FIELDS=(F1:1,80,F2:81,15,?)                     
 OUTFIL IFTHEN=(WHEN=(96,1,CH,EQ,C'B',                   
                  AND,01,11,CH,EQ,C'0P      NO.',         
                  AND,86,10,ZD,EQ,+0),                   
                BUILD=(1,80,/,C'No data')),               
        IFTHEN=(WHEN=NONE,BUILD=(1,80))                   
//*                                                       


Code:
********************************* TOP OF DATA **********
1  3/15/2023                                           
            RECORDS CHANGED                             
                                                       
0P      NO.         PRE                  PM             
No data                                                 
                                                       
1  3/15/2023                                           
            RECORDS CHANGED                             
                                                       
0       NO.         PRE                  PM             
                                                       
 GRAND TOTALS           .00                             
1  3/15/2023                                           
            RECORDS CHANGED                             
                                                       
0P      NO.         PRE                  PM             
 8754  88           63                   91             
1  3/15/2023                                           
            RECORDS CHANGED                             
                                                       
0       NO.         PRE                  PM             
           88          63                   91         
 GRAND TOTALS         63.00                             
                                                         
******************************** BOTTOM OF DATA *********
Back to top
View user's profile Send private message
rajesh7523

New User


Joined: 15 Dec 2022
Posts: 8
Location: BHOPAL

PostPosted: Thu Mar 16, 2023 10:36 pm
Reply with quote

And if i want to skip all records or delete the entire record when INREC or OUTREC condition satisfies??

In above i/p file, condition is checking if GRAND TOTAL 00

then only we are skipping or deleting entire records

I i/p file format is VBA

let me know the logic
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Mar 16, 2023 11:09 pm
Reply with quote

rajesh7523 wrote:
And if i want to skip all records or delete the entire record when INREC or OUTREC condition satisfies??

Then you need to add appropriate parameters to corresponding statements.
Do you suggest me to do it instead of you?
rajesh7523 wrote:

In above i/p file, condition is checking if GRAND TOTAL 00
then only we are skipping or deleting entire records

Wrong. GRAND TOTAL 00 is checked to find the group where to add your special comment.
rajesh7523 wrote:

I i/p file format is VBA

let me know the logic

The logic (e.g. algorithm) does not depend on record format (which is also not FILE FORMAT!!!!)
You MUST try to understand the suggested logic for RECFM=FB yourself.
Next step would be - updating some parameters (not logic!) to handle RECFM=VB/VBA
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top