How to take one record every time and pass it to a step



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

How to take one record every time and pass it to a step

Postby neverfail2try » Sun Mar 31, 2013 2:20 am

Hi all, please help me with this. I have written a JCL which uses DFSORT and does the following function
1) Input file one : Consists of 50 rows with records length 9.
2) Input file two: Consists of 100 rows with records length 3.

Problem : I have to take one record every time from input file 2 and paste it in the position 4 to 6 in all the rows of input file 1 which means there will be 5000 records in the output file.
file 1:
aaabbbccc
dddeeefff
ggghhhiii

file 2:
111
222
333

Desired Output file :
aaa111ccc
ddd111fff
ggg111iii
aaa222ccc
ddd222fff
ggg222iii
aaa333ccc
ddd333fff
ggg333iii

The JCL which I have written is allowing only the first record number provided in the SYSIN DD statement. I am just getting the output as :
aaa111ccc
ddd111fff
ggg111iii

I have used the above example just for explanation purpose, the real JCL looks like below:

//STEP010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*   
//SORTIN DD *         
//SORTOUT  DD  DSN=**.****.OUTPUT1,                         
//             DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE)
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  OUTREC FIELDS=(1,9,50:SEQNUM,5,ZD,START=00001,INCR=1)     
/*                                                           
//STEP020  EXEC  PGM=SORT                                   
//SYSOUT    DD  SYSOUT=*                                   
//SORTIN DD *                                               
111
222
333                                                                                                   
//*SORTOUT DD SYSOUT=*                                     
//SORTOUT  DD DSN=**.****.OUTPUT2,                         
//            DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE)
//SYSIN    DD    *                                         
  OPTION COPY                                               
  OUTFIL REPEAT=3,OVERLAY=(50:SEQNUM,5,ZD)                 
/*                                 
//STEP030 EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                                     
//SORTJNF1     DD DISP=SHR,DSN=**.****.OUTPUT1           
//SORTJNF2     DD DISP=SHR,DSN=**.****.OUTPUT2           
//SORTOUT DD DSN=**.****.OUTPUT3,DISP=(NEW,CATLG,DELETE),
//           SPACE=(CYL,(10,10),RLSE)                   
//SYSIN DD *                                             
  JOINKEYS F1=SORTJNF1,FIELDS=(50,5,A),SORTED           
  JOINKEYS F2=SORTJNF2,FIELDS=(50,5,A),SORTED           
  REFORMAT FIELDS=(F1:1,3,F2:1,3,F1:7,9)               
  SORT FIELDS=COPY                                       
/*                         


Please tell me how should I proceed with this. I want to know of something which picks one record from the second input file and executes the job. After that, again it picks the second record and executes it. I am also open to any new methods of achieving this.
neverfail2try
 
Posts: 5
Joined: Sun Mar 31, 2013 1:57 am
Has thanked: 3 times
Been thanked: 0 time

Re: How to take one record every time and pass it to a step

Postby NicC » Sun Mar 31, 2013 3:19 am

The JCL which I have written is allowing only the first record

is rubbish as JCL has nothing to do with individual records. JCL tells the OS what programs to run and what resources those programs need. In sort it is the sort control records that control what sort does - not JCL. (JCL is not even executed - it is read by the OS and then tossed away - maybe days before the job executes.)

As you are having problems with DFSort I have moved the topic to the DFSort part of the forum.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
neverfail2try (Sun Mar 31, 2013 12:28 pm)
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to take one record every time and pass it to a step

Postby BillyBoyo » Sun Mar 31, 2013 5:33 am

If you want to match every record on one file to every record on the other file, you need to have a key field to match on which is the same value for all records on both files.

Since you don't have this, you need to add it, with JNFnCNTL files. Once that is done, your JOINKEYS step is about there:

//STEP030 EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                                     
//SORTJNF1     DD DISP=SHR,DSN=your input file of nine bytes
//SORTJNF2     DD DISP=SHR,DSN=your input file of three bytes
//SORTOUT DD DSN=**.****.OUTPUT3,DISP=(NEW,CATLG,DELETE),
//           SPACE=(TRK,1)                   
//SYSIN DD *                                             
  JOINKEYS F1=SORTJNF1,FIELDS=(10,1,A),SORTED,NOSEQCK
  JOINKEYS F2=SORTJNF2,FIELDS=(04,1,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,3,F2:1,3,F1:7,9)               
  SORT FIELDS=COPY                                       
/*                         
//JNF1CNTL DD *
  INREC OVERLAY=(10:C'X')
//JNF2CNTL DD *
  INREC OVERLAY=(04:C'X')

These users thanked the author BillyBoyo for the post:
neverfail2try (Sun Mar 31, 2013 12:28 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to take one record every time and pass it to a step

Postby neverfail2try » Sun Mar 31, 2013 12:16 pm

NicC wrote:
The JCL which I have written is allowing only the first record

is rubbish as JCL has nothing to do with individual records. JCL tells the OS what programs to run and what resources those programs need. In sort it is the sort control records that control what sort does - not JCL. (JCL is not even executed - it is read by the OS and then tossed away - maybe days before the job executes.)

As you are having problems with DFSort I have moved the topic to the DFSort part of the forum.


I beg your pardon for my ignorance and thanks for explaining.
neverfail2try
 
Posts: 5
Joined: Sun Mar 31, 2013 1:57 am
Has thanked: 3 times
Been thanked: 0 time

Re: How to take one record every time and pass it to a step

Postby neverfail2try » Sun Mar 31, 2013 12:19 pm

BillyBoyo wrote:If you want to match every record on one file to every record on the other file, you need to have a key field to match on which is the same value for all records on both files.

Since you don't have this, you need to add it, with JNFnCNTL files. Once that is done, your JOINKEYS step is about there:



Thank you very much Sir. I made some changes according to my requirement in the lines which you pasted and also added the SORT for removing the duplicates and it ran completely fine. Thanks again.
neverfail2try
 
Posts: 5
Joined: Sun Mar 31, 2013 1:57 am
Has thanked: 3 times
Been thanked: 0 time

Re: How to take one record every time and pass it to a step

Postby BillyBoyo » Sun Mar 31, 2013 5:07 pm

If you can post your Control Cards, sample input and expected output, we may be able to "get rid of" the SORT.

This is with your 7,9 definition, which may be a typo.

Putting your three-byte file as the "first" joinkeys file will cause the order of that file to be used for the order of your REFORMAT records, and thus the order of your SORTOUT. Duplicates, on your nine- or 15-byte file can be dealt with as below.

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  JOINKEYS   F1=SORTJNF1,FIELDS=(04,1,A),SORTED,NOSEQCK
  JOINKEYS   F2=SORTJNF2,FIELDS=(16,1,A),SORTED,NOSEQCK
  REFORMAT   FIELDS=(F2:1,3,F1:1,3,F2:7,9)
  SORT FIELDS=COPY
  OUTFIL SECTIONS=(1,3,3,3,HEADER3=(1,15)),REMOVECC,NODETAIL
//JNF1CNTL   DD *
  INREC OVERLAY=(04:C'X')
//JNF2CNTL   DD *
  INREC OVERLAY=(16:C'X')
//SORTJNF1 DD *
111
222
333
//SORTJNF2 DD *
AAABBBCCC123456
DDDEEEFFF123455
DDDEEEFFF123456
GGGHHHIII123456


The output is:

AAA111CCC123456
DDD111FFF123455
GGG111III123456
AAA222CCC123456
DDD222FFF123455
GGG222III123456
AAA333CCC123456
DDD333FFF123455
GGG333III123456


If you want to keep the "last" record of any duplicate key, you change the HEADER3 to TRAILER3.

For your three-byte file, the code (to avoid a SORT) is a little different:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  JOINKEYS   F1=SORTJNF1,FIELDS=(04,1,A),SORTED,NOSEQCK
  JOINKEYS   F2=SORTJNF2,FIELDS=(16,1,A),SORTED,NOSEQCK
  REFORMAT   FIELDS=(F2:1,3,F1:1,3,F2:7,9)
  SORT FIELDS=COPY
  OUTFIL SECTIONS=(1,3,3,3,TRAILER3=(1,15)),REMOVECC,NODETAIL
//JNF1CNTL   DD *
  INREC IFOUTLEN=4,
        IFTHEN=(WHEN=INIT,
                  OVERLAY=(04:C'X')),
        IFTHEN=(WHEN=GROUP,
                  KEYBEGIN=(1,3),
                  PUSH=(5:SEQ=1)),
        IFTHEN=(WHEN=(5,1,CH,NE,C'1'),
                  OVERLAY=(4:Z))
//JNF2CNTL   DD *
  INREC OVERLAY=(16:C'X')
//SORTJNF1 DD *
111
222
333
333
//SORTJNF2 DD *
AAABBBCCC123456
DDDEEEFFF123455
DDDEEEFFF123456
GGGHHHIII123456


Produces:

AAA111CCC123456
DDD111FFF123456
GGG111III123456
AAA222CCC123456
DDD222FFF123456
GGG222III123456
AAA333CCC123456
DDD333FFF123456
GGG333III123456
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to take one record every time and pass it to a step

Postby neverfail2try » Mon Apr 01, 2013 12:16 pm

Thanks a lot Sir, it works.
neverfail2try
 
Posts: 5
Joined: Sun Mar 31, 2013 1:57 am
Has thanked: 3 times
Been thanked: 0 time

Re: How to take one record every time and pass it to a step

Postby BillyBoyo » Mon Apr 01, 2013 12:47 pm

It is very important that you understand it, so you can change it when necessary and apply the solution to other requirements. If you have doubts, post them here.

These users thanked the author BillyBoyo for the post:
neverfail2try (Tue Apr 02, 2013 11:57 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post