Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Write R1 and R2 to OP1 and R1 to OP2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 120
Location: USA

PostPosted: Fri Mar 03, 2017 11:18 am    Post subject: Write R1 and R2 to OP1 and R1 to OP2
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: 2276
Location: @my desk

PostPosted: Fri Mar 03, 2017 8:21 pm    Post subject:
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: 120
Location: USA

PostPosted: Fri Mar 03, 2017 8:27 pm    Post subject:
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: 2276
Location: @my desk

PostPosted: Sun Mar 05, 2017 10:11 am    Post subject:
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: 120
Location: USA

PostPosted: Mon Mar 06, 2017 6:55 am    Post subject:
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: 1788
Location: UK

PostPosted: Mon Mar 06, 2017 3:13 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Mar 06, 2017 3:44 pm    Post subject: Reply to: Write R1 and R2 to OP1 and R1 to OP2
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: 120
Location: USA

PostPosted: Mon Mar 06, 2017 6:58 pm    Post subject:
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: 2276
Location: @my desk

PostPosted: Mon Mar 06, 2017 7:39 pm    Post subject:
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: 120
Location: USA

PostPosted: Mon Mar 06, 2017 9:52 pm    Post subject:
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: 2276
Location: @my desk

PostPosted: Mon Mar 06, 2017 10:10 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can you write 2 recs on SORTOUT when ... Sysaron DFSORT/ICETOOL 6 Thu Feb 23, 2017 12:07 am
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm
No new posts how to DYNAMICALLY write sort cond to... mohamedmubee COBOL Programming 13 Fri Aug 26, 2016 11:46 pm
No new posts Compare 2 files & write Indicator... nagendrapgupta SYNCSORT 5 Sun May 15, 2016 10:42 am
No new posts DFSORT to match two files and write John F Dutcher DFSORT/ICETOOL 6 Thu May 12, 2016 5:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us