Mainframe JCL DFSORT repeat block of lines



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

Mainframe JCL DFSORT repeat block of lines

Postby sesha26 » Wed Jun 16, 2021 2:24 am

Hello everyone,

I am new to DFSORT, i need help from you all
on repeating certain block of lines multiple times in my output DSN using Dfsort repeat (certain block of lines 1000 times)

Example:
Input file DSN

A111111
B111222
C111222
C111234
D111222
E111111

In output DSN I need to repeat block of lines from (B111222 to D111222) exclude repeating A line and E line as header and trailer.

Expected output DSN

A111111
B111222
C111222
C111234
D111222
B111222
C111222
C111234
D111222
B111222
C111222
C111234
D111222
E111111

Thanks in advance
sesha26
 
Posts: 3
Joined: Wed Jun 16, 2021 2:10 am
Has thanked: 3 times
Been thanked: 0 time

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Wed Jun 16, 2021 5:19 pm

1) use code tags in your post if you want somebody to pay attention to your code

2) what did you try yourself, and where are ANY results of your attempts?

3) why do you suppose that DFSORT is a suitable tool for your task?

4) what are the rules to distinguish between your “header/trailer lines”, and others, to be repeated? How many times to repeat this group? As for your given example, I suppose the best way should be: using the ISPF editor, and do this “task” manually, with RR3 line command (e.g. “repeat the group 3 times”). If not, please explain why?
Javas and Pythons come and go, but JCL and SORT stay forever.

These users thanked the author sergeyken for the post:
sesha26 (Wed Jun 16, 2021 5:32 pm)
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Wed Jun 16, 2021 6:29 pm

Please, follow the note #1 in my post. Otherwise your mess of code will be ignored by readers.
Javas and Pythons come and go, but JCL and SORT stay forever.

These users thanked the author sergeyken for the post:
sesha26 (Wed Jun 16, 2021 6:47 pm)
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Wed Jun 16, 2021 6:46 pm

Please, read my post carefully, and follow the note #1.

I tell you: with no code tags, nobody is going to dig into your mess of code. Take care of the readers…

BTW, if you arranged your code properly, many, many problems might become obvious for yourself, even without help from the forum!
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Wed Jun 16, 2021 7:01 pm

It MUST be looking like this:
//ZKLEQS6I JOB (NEPBT),'SAMPLE SORT',MSGCLASS=U,CLASS=G,                
//         NOTIFY=&SYSUID                                              
//*   ========== REPEAT ALL RECORDS =======            
//STEP02 EXEC PGM=SORT                                            
//SORTIN  DD  DSN=EPBQ.SES.OUTFIL,DISP=SHR                
//SORTOUT DD  DSN=EPBQ.SES.OUTFIL1,DISP=SHR          
//OUT1    DD  DSN=EPBQ.SES.OUTFIL1,DISP=SHR                
//SYSOUT  DD  SYSOUT=*                                                
//SYSIN   DD  *                                                          
 SORT FIELDS=COPY                                                
 OUTFIL REPEAT=5                                                  
//* 

Not: must be properly aligned, and all unnecessary information removed!

Do the same with the rest of other garbage, before further discussion.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Wed Jun 16, 2021 7:14 pm

Please, re-read the SORT manual:
REPEAT can be used to repeat each output record a specified number of times.

This is definitely not what you need.

After you get used to be accurate in your postings, we may discuss further details.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sesha26 » Wed Jun 16, 2021 7:45 pm

Excuse me.

I am new to forum and mainframe.
not sure what caused the mis-alignment, I tried to fix it now.
hoping it looks readable now

I would need repeating certain block of lines multiple times in my output DSN using Dfsort repeat (certain block of lines 1000000 times) from input file



//ZKLEQS6I JOB (NEPBT),'SAMPLE SORT',MSGCLASS=U,CLASS=G,                
//         NOTIFY=&SYSUID                                              
//*   ========== REPEAT ALL RECORDS =======            
//STEP02 EXEC PGM=SORT                                            
//SORTIN  DD  DSN=EPBQ.SES.OUTFIL,DISP=SHR                
//SORTOUT DD  DSN=EPBQ.SES.OUTFIL1,DISP=SHR          
//OUT1    DD  DSN=EPBQ.SES.OUTFIL1,DISP=SHR                
//SYSOUT  DD  SYSOUT=*                                                
//SYSIN   DD  *                                                          
 SORT FIELDS=COPY                                                
 OUTFIL REPEAT=5    
 




>>> first line is header record (starting with '1' in 1st position)
>>> second line to 7th line are details record (starting with '5', '6', '8' in 1st position)
>>> last line is trailer record (starting with '9' in 1st position)
>>> my objective is to repeat block of lines ( starting with '5','6','7') 1000000 of times excluding header and trailer records

input DSN


101 05100001718322376222003241103R094101BANK OF AAABBBC        DOMINO AMJET INC   00152848
5220GREYS ANATOMY                       1832237622CCDPAYMENT   171106200324000 1091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                          091000010000953
9000017000024000001980606801347000339248233000360363272
 



Expected Output (details records starting with 5, 6, and 8 repeated large number of times)

101 05100001718322376222003241103R094101BANK OF AAABBBC        DOMINO AMJET INC       00152848
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN              0091000011327478
820000001200132000460000430645000000454004001832237622                           091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                          091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN              0091000011327478
820000001200132000460000430645000000454004001832237622                           091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN              0091000011327478
820000001200132000460000430645000000454004001832237622                          091000010000953
9000017000024000001980606801347000339248233000360363272
 



Actual Output (each line repeated , but I need to repeat blocks of lines except the header and trailer)


101 05100001718322376222003241103R094101BANK OF CAAAUCA        DOMINO AMJET INC       00152848
101 05100001718322376222003241103R094101BANK OF CAAAUCA        DOMINO AMJET INC       00152848
101 05100001718322376222003241103R094101BANK OF CAAAUCA        DOMINO AMJET INC       00152848
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY           0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY           0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                          091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY           0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY           0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY           0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER         0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER         0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER         0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                          091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                         091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
820000001200132000460000430645000000454004001832237622                          091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
5220GREYS ANATOMY                       1832237622CCDPAYMENT   1711062003240001091000010000953
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62201100133180100017475      00000120001HSAU58        DEREK SHEPHERD          0091000011327475
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62701100133180140027476      00000250002HSAU58        MEREDITH GREY            0091000011327476
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62201100133180850037477      00011374003HSAU58        RICHARD WEBBER          0091000011327477
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
62701100133158560047478      00012536004HSAU58        TEDDY ALTMAN             0091000011327478
820000001200132000460000430645000000454004001832237622                         091000010000953
820000001200132000460000430645000000454004001832237622                         091000010000953
820000001200132000460000430645000000454004001832237622                         091000010000953
9000017000024000001980606801347000339248233000360363272
9000017000024000001980606801347000339248233000360363272
9000017000024000001980606801347000339248233000360363272
 
sesha26
 
Posts: 3
Joined: Wed Jun 16, 2021 2:10 am
Has thanked: 3 times
Been thanked: 0 time

Re: Mainframe JCL DFSORT repeat block of lines

Postby sesha26 » Wed Jun 16, 2021 11:09 pm

Thank you!!
sesha26
 
Posts: 3
Joined: Wed Jun 16, 2021 2:10 am
Has thanked: 3 times
Been thanked: 0 time

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Thu Jun 17, 2021 12:59 am

sesha26 wrote:Thank you!!

The SORT statement may require extra parameter EQUALS, to keep the original order of similar records.

You can play with the example to adjust the details.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Mainframe JCL DFSORT repeat block of lines

Postby sergeyken » Thu Jun 17, 2021 6:08 pm

If ICETOOL is not available(?) for some strange reason, it is always possible to call DFSORT in two sequential JCL steps.
//*
// EXPORT SYMLIST=*
// SET COUNTER=3
//*
//STEPNUMS EXEC PGM=DFSORT
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD  *
101 05100001718322376222003241103R094101BANK OF AMERICA DOMINO AMJET IN
5220GREYS ANATOMY 1832237622CCDPAYMENT 1711062003240001091000010000953
62201100133180100017475 00000120001HSAU58 DEREK SHEPHERD 00910000113274
62701100133180140027476 00000250002HSAU58 MEREDITH GREY 009100001132747
62201100133180850037477 00011374003HSAU58 RICHARD WEBBER 00910000113274
62701100133158560047478 00012536004HSAU58 TEDDY ALTMAN 0091000011327478
820000001200132000460000430645000000454004001832237622 091000010000953
9000017000024000001980606801347000339248233000360363272
//*
//SORTOUT  DD  UNIT=SYSDA,SPACE=(CYL,(100,100),RLSE),
//             DIP=(NEW,PASS),DSN=&&NUMBERED
//*
//SYSIN    DD *,SYMBOLS=EXECSYS
 SORT FIELDS=COPY
 OUTFIL REPEAT=&COUNTER,            REPLICATE ALL RECORDS
        IFTHEN=(WHEN=GROUP,
                KEYBEGIN=(1,80),    RE-NUMBER ORIGINAL RECORD
                PUSH=(81:SEQ=10))   POSITIONS AS ON INPUT
 END
//*
//STEPSORT EXEC PGM=DFSORT,COND=(4,LT)
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD  DISP=(OLD,DELETE),DSN=&&NUMBERED
//SORTOUT  DD  SYSOUT=*
//*
//SYSIN    DD *
 INCLUDE COND=(81,10,ZD,EQ,+1,      EXCLUDE DUPLICATES
            OR,1,1,SS,NE,C'19')     FOR HEADER AND TRAILER
 INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'9'),     PROVIDE TRAILER TO SORT END
               OVERLAY=(81:C'9999999999'))
 SORT FIELDS=(81,10,ZD,A,           RE-ORDER DUPLICATES
              01,01,CH,A)           AS REQUIRED
 OUTFIL BUILD=(1,80)                EXCLUDE WORK COUNTER FIELDS
 END
//*
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post