Need to create 2 output files based on input file column

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
neo_charan7
Member
Posts: 22
Joined: Wed Apr 15, 2009 11:51 pm
Location: london

Need to create 2 output files based on input file column

Post by neo_charan7 » Tue Apr 28, 2009 7:21 pm

I have the input file with below records

AAA;CANADA,TRADE ANALYTICS
BBB;BOTSWANA,FINANCE SYSTEMS
CCC AMERICAS
DDD;DUN AND BRADSTREETUSA

If the field 4 in input file is ; i need to write those records into one output file.

If the field 4 in input file is other than ; i need to write those records into another output file.

maheshvamsi
Active Member
Posts: 52
Joined: Wed Mar 25, 2009 11:56 pm
Location: Banglore

Post by maheshvamsi » Tue Apr 28, 2009 7:44 pm

try below code.

Code: Select all

//SORT6 EXEC PGM=SORT                              
//SYSOUT DD SYSOUT=*                               
//SORTIN DD *                                      
AAA;CANADA,TRADE ANALYTICS                         
BBB;BOTSWANA,FINANCE SYSTEMS                       
CCC AMERICAS                                       
DDD;DUN AND BRADSTREETUSA                          
/*                                                 
//OUT1 DD disp=shr,dsn=file1
//OUT2 DD disp=shr,dsn=file2
//SYSIN DD *                                       
  SORT FIELDS=COPY                                  
  OUTFIL FNAMES=OUT1,INCLUDE=(4,1,CH,EQ,C';')   
  OUTFIL FNAMES=OUT2,INCLUDE=(4,1,CH,NE,C';')   
/*
Thanks

MaheshVamsi

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Apr 28, 2009 8:35 pm

neo,

Here's a DFSORT job that will do what you asked for:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//SYSIN DD *
 OPTION COPY
 OUTFIL FNAMES=OUT1,INCLUDE=(4,1,CH,EQ,C';')
 OUTFIL FNAMES=OUT2,SAVE
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

neo_charan7
Member
Posts: 22
Joined: Wed Apr 15, 2009 11:51 pm
Location: london

Post by neo_charan7 » Thu May 07, 2009 6:44 pm

Thanks Frank and Vamsi.

I have more condition suppose ; is not in a fixed position in the input file
for example

AAA ; AUSTRALIA DOLLARS
BSW BOTSWANA;SOUTH AFRICA
EXE UNITED KINGDOM;POUNDS
TXT UNITED STATES DOLLARS

output file should have all the first 3 records since they are having semi colons.

maheshvamsi
Active Member
Posts: 52
Joined: Wed Mar 25, 2009 11:56 pm
Location: Banglore

Post by maheshvamsi » Thu May 07, 2009 7:20 pm

Little bit modification to your contol card can achieve this.

Assuming Record length as 80

Code: Select all

  OPTION COPY 
  OUTFIL FNAMES=OUT1,INCLUDE=(1,80,SS,EQ,C';') 
  OUTFIL FNAMES=OUT2,SAVE
Thanks

MaheshVamsi

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others