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

Write R1 and R2 to OP1 and R1 to OP2


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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Fri Mar 03, 2017 11:18 am
Reply with quote

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

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Mar 03, 2017 8:21 pm
Reply with quote

bhaskar_kanteti,

Will you have any value other than R1 and R2 in your input?
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Fri Mar 03, 2017 8:27 pm
Reply with quote

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

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Mar 05, 2017 10:11 am
Reply with quote

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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Mon Mar 06, 2017 6:55 am
Reply with quote

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

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Mar 06, 2017 3:13 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 06, 2017 3:44 pm
Reply with quote

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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Mon Mar 06, 2017 6:58 pm
Reply with quote

Thank you Bill for providing more information.

NIC, I will look into the manual for more details. Thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Mar 06, 2017 7:39 pm
Reply with quote

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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Mon Mar 06, 2017 9:52 pm
Reply with quote

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

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Mar 06, 2017 10:10 pm
Reply with quote

You're welcome!. Glad you figured it out.
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 Write line by line from two files DFSORT/ICETOOL 7
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts JCL to write the log on to a PDS file JCL & VSAM 10
No new posts COBOL - create and write to output fi... COBOL Programming 0
Search our Forums:

Back to Top