View previous topic :: View next topic
|
Author |
Message |
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Hi,
Could you please tell me how i can achieve below output based on given input data.
Input File:
Code: |
R1 111111
R2 TERMS
R1 111112
R2 TERMS
R1 111113
R1 111114
R2 TERMS
R1 111115
R1 111116
R2 TERMS
|
Output File 1:
Code: |
R1 111111
R2 TERMS
R1 111112
R2 TERMS
R1 111114
R2 TERMS
R1 111116
R2 TERMS
|
Output File 2:
Code: |
R1 111113
R1 111115
|
If I have R1 and R2 records in input then those two records i should write to output 1.
If I have only R1 record in input then i should write to output 2.
R1 - Record Identifier
R2 - Record Identifier
111111 - Account Number
TERMS - Data corresponds to Account Number
Please let me know how i can get above output. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
bhaskar_kanteti,
Will you have any value other than R1 and R2 in your input? |
|
Back to top |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Actually I have other values other than R1 and R2. But I filtered them using SORT INCLUDE condition and wrote only R1 and R2.
Now after filtering i want into split two different outputs.
Is there a way we can write R1 and R2 to output based on certain condition when we have other R* records? If so can help me understand how i can do this as well? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Here is one way of achieving it. You can add your INCLUDE in the CTL1 card to extract only R1 and R2 records.
Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DISP=SHR,DSN => Input data set (FB/80)
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT1) ON(81,8,CH) ALLDUPS DISCARD(OUT2) USING(CTL1)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'R1'),
PUSH=(81:ID=8))
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,BUILD=(1,80)
OUTFIL FNAMES=OUT2,BUILD=(1,80)
/* |
OUT1
Code: |
R1 111111
R2 TERMS
R1 111112
R2 TERMS
R1 111114
R2 TERMS
R1 111116
R2 TERMS |
OUT2
Code: |
R1 111113
R1 111115 |
|
|
Back to top |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Hi Arun,
Thank you so much. I am getting required output using above jcl.
Can you explain me the logic behind this jcl? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
It is not the JCL that you require the logic for but the control cards. These are not the same things - try finding the keywords of the control cards in the JCL manual!
Read for yourself the DFSort manual. Ask about those bits that are not clear. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Look at the SELECT operator in the chapter on ICETOOL, and see what that can do.
Then realise there is no "key" on each record, which leads to the USING and the control cards there: specifically the WHEN=GROUP.
You don't want the excess data on the output files, so the two OUTFIL statements drop of the data that was temporarily added to provide a key for SELECT.
Note the COPY operation - a SORT, the default for SELECT - would be a waste of resources, since the IDs are allocated in sequence (if to a large enough field, which I suspect it is). |
|
Back to top |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Thank you Bill for providing more information.
NIC, I will look into the manual for more details. Thanks. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
bhaskar_kanteti,
It might be easier to understand if you try running it with just the INREC and SORT FIELDS=COPY (with a PGM=SORT Job) and take a look at the SORTOUT. That way you will be able to see the 8-byte ID (incremental numeric sequence) at pos-81 assigned for each 'group' beginning with an 'R1'.
Then the SELECT with DISCARD helps separate 'groups' with duplicate IDs(groups with both R1 and R2 records) and unique IDs(groups with just an R1 record). |
|
Back to top |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Hi Arun,
I created outputs with 8 byte ID in my JCL. Now i understand how this JCL works and the commands in SELECT with ALLDUPS and DISCARD.
Thank you so much. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You're welcome!. Glad you figured it out. |
|
Back to top |
|
|
|