Needed Help on using SORT OUTFIl fileds

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Prettycool
Member
Posts: 5
Joined: Thu Nov 28, 2013 5:39 pm

Needed Help on using SORT OUTFIl fileds

Post by Prettycool » Sat Feb 15, 2014 1:42 pm

Hi All,

I have two input files one is FB and the other is a VB file. I have to compare 1-7 field from first file to 20-27 of File 02 and when a match is found a set of records have to be copied from second file to output which is VB file.

Input file 01 - FB file
0000001
0000003
0000004

Input file 02 - VB file
123456001001SFAA 0000001
123456001002SFBA Wil have other data
123456001003SFCA will have other data
123456002001SFAA 0000002
123456001002SFBA Wil have other data
123456001003SFCA will have other data
123456003001SFAA 0000003
123456003002SFBA Wil have other data
123456003003SFCA will have other data

Output file - VB file
123456001001SFAA 0000001
123456001002SFBA Wil have other data
123456001003SFCA will have other data
123456003001SFAA 0000003
123456003002SFBA Wil have other data
123456003003SFCA will have other data


I do not have a particular key to sort the records of file 02 as i have data(characters) in the next set of records because of this I'm unable to wirte a SAS as i need to sort them before I compare two file.

Please let me know of any possibilities.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Feb 15, 2014 3:15 pm

Which SORT product do you have?

IFTHEN=(WHEN=(GROUP with BEGIN=( for SFAA and PUSH to get your key value onto an exentsion in all records in the group (should be at the beginning of the records, since they are VB).

Then JOINKEYS.

Prettycool
Member
Posts: 5
Joined: Thu Nov 28, 2013 5:39 pm

Post by Prettycool » Sun Feb 16, 2014 11:42 am

Thank you. We have sort,syncsort and icetool. Can you tell me which one would do it better? I will have to process records in millions.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sun Feb 16, 2014 7:59 pm

Just for your edification: sort is NOT your sort product - it is an alias for Syncsort. This way your sysprogs can switch from syncsort to dfsort without you knowing. You simply execute SORT and that selects the program that the alias points to. Ditto for ICETOOL - it will point to SYNCTOOL.
Regards
Nic

Prettycool
Member
Posts: 5
Joined: Thu Nov 28, 2013 5:39 pm

Post by Prettycool » Mon Feb 24, 2014 8:14 pm

Nic thankyou for the edification.

William I'm really sorry I'm late to try this out but I really need this. The first file has LRECL 28 and is FB file and F2 file is of 1500 Lrec and is VB file.

Code: Select all

//SORT1    EXEC PGM=SYNCSORT                              
//SORTJNF1 DD DSN=FILE1,DISP=SHR                          
//SORTJNF2 DD DSN=FILE2,DISP=SHR                          
//SORTOUT  DD DSN=OUTFILE,                                
//            DISP=SHR                             
                            
//SYSOUT   DD SYSOUT=(*)                                  
//SYSUDUMP DD SYSOUT=(*)                                  
//SYSIN    DD *                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(13,4,CH,EQ,C'SFAA'),    
       END=(13,4,CH,EQ,C'SFCA'),PUSH=(20:1,9))           
  JOINKEYS FILES=F1,FIELDS=(1,7,A)                        
  JOINKEYS FILES=F2,FIELDS=(20,7,A)                      
  REFORMAT FIELDS=(F2:1,1500)                             
  OPTION=COPY
Am ' near to what you have told? Now here m stuck with defining file 2. i.e at INREC and I'm giving IFTHEN here how do i tell the it belongs to FILE2.

As you said In PUSH I'm giving it at the begining but when I'm giving in Joinkeys should that be (20,7) or (1,7)?.

I need output from F2 file all the grouped ones. can you please correct my code and explain a little on the fields please.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Feb 24, 2014 10:51 pm

I will have to process records in millions
Suggest you test with 10s or 100s, NOT millions of records . . .
I have to compare 1-7 field from first file to 20-27 of File
but when I'm giving in Joinkeys should that be (20,7) or (1,7)?.
These need to become consistent. 20-27 and 20 for 7 are not the same.
Have a good one

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