Comparing files using syncsort and Cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Comparing files using syncsort and Cobol

Postby tony1131 » Thu Mar 21, 2013 9:59 pm

I have a little experience with jcl/mainframe/cobol but not a lot. I am suppose to do a syncsort of a file then compare (to find NONmatches I believe) using cobol. This is what I have so far for my sync sort.

000004 //STEP02  EXEC PGM=SYNCSORT                                            
 000005 //SYSOUT   DD  SYSOUT=*                                                
 000006 //SYSPRINT DD  SYSOUT=*                                                
 000007 //EZTVFM   DD  UNIT=SYSDA,SPACE=(TRK,(9999,999),RLSE)                  
 000008 //SORTIN   DD  DSN=filea,DISP=SHR            
 000009 //SORTOUT  DD  DSN=Tfileb,              
 000010 //             DISP=SHR                                                
 000011 //*            DISP=(,CATLG,DELETE),                                    
 000012 //*            LRECL=25,RECFM=FB,BLKSIZE=25000,                        
 000013 //*            SPACE=(27998,(7000,700),RLSE),UNIT=HSMDA                
 000014 //SYSIN    DD *                                                        
 000015   SORT FIELDS=(1,5,ZD,A)                                                
 000016 /*                                                                      
 000017 //*                                                                    



Now from what I understand is that I have to write a cobol program that takes the sorted "fileb" and compare it with another file that I have not received yet so it is not shown in the code above. I'll call it filec. Then whenever there is a file that doesn't match it outputs it into another file. I am generally having a hard time just with the syntax of how to do this. And understanding if I can write the cobol underneath the syncsort in another step. As you can tell I am pretty new to this lol. Any help will be appreciated
tony1131
 
Posts: 12
Joined: Thu Mar 21, 2013 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Comparing files using syncsort and Cobol

 

Re: COmparing files using syncsort and Cobol

Postby enrico-sorichetti » Thu Mar 21, 2013 10:39 pm

cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: COmparing files using syncsort and Cobol

Postby NicC » Fri Mar 22, 2013 12:42 am

You can, probably, also do the compare in Syncsort. The experts will need to know your dataset characteristics (RECFM and LRECL) and the key characteristics (start position, length, data type (CH, ZD etc)) for each dataset. They will also need sample input from each file and expected outputs. If you look through the sort posts you will see what I mean.

Also, to make things easier to read you should use the code tags for stuff you see on the screen. When I have finished this post I will code your original post. Note that using the quick reply button you do not get to see anything about code tags but if you use the postreply button or the full editor button you will see the code button. Search the forum for details on how to use (basically highlight the stuff to code and click the code button).
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COmparing files using syncsort and Cobol

Postby tony1131 » Fri Mar 22, 2013 12:46 am

they want me to do it using Cobol as practice
tony1131
 
Posts: 12
Joined: Thu Mar 21, 2013 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COmparing files using syncsort and Cobol

Postby tony1131 » Fri Mar 22, 2013 12:48 am

the txt file attached above seems helpful. I'm trying to figure out how to execute a program properly in the jcl now
tony1131
 
Posts: 12
Joined: Thu Mar 21, 2013 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COmparing files using syncsort and Cobol

Postby Akatsukami » Fri Mar 22, 2013 1:32 am

tony1131 wrote:the txt file attached above seems helpful. I'm trying to figure out how to execute a program properly in the jcl now

Not at all difficult. Some or all of this may already be known to you; I'm trying to be all-inclusive here.

When you compiled your COBOL source code, the compiler generated a object module, unsurprisingly placed in an object library. This object module, together with others that represent statically-linked subroutines, and a host of machine-language routine are linked into a load module by a program called the linkage editor or binder (do not confuse this last with the process of binding a DB2 package). Again unsurprisingly, the load module is placed in a load library.

Your JCL will then look like this:
//PATIENCE JOB  other parameters
//STEPN    EXEC PGM=RORA
//STEPLIB  DD   DS=YOUR.LOADLIB,DISP=SHR
//SYSPRINT DD   SYSOUT=*
//FOO      DD   DSN=HLQ.INFILE,DISP=SHR
//BAR      DD   DSN=HLQ.OUTFILE,other parameters
//CEEDUMP   DD  SYSOUT=x

The JOB card establishes this as a job (often miscalled a "JCL" by the ill-educated), a batch unit of work. The "other parameters" can vary greatly from
site to site; it is best to acquire a job card from a working job at your site, to ensure compliance with local standards.

The EXEC card establishes a job step, the execution of a program. I've named this step STEPN; you don't have to give a step a name, but you may well want or need to refer to it late in the job.

The DD cards are "data definition" cards (although seldom referred to by that name), each defining a data resource to be used by the step. The names are significant:
  • STEPLIB defines the load library to be searched first for the program. System utilities and, often, production programs are in libraries or memory areas know to the operating system; steps running them may therefore not use a STEPLIB.
  • SYSPRINT defines a data set to which messages are written and is usually allocated to the system spool (SYSOUT=*). Most system programs write to SYSPRINT, so its use is pretty standard.
  • FOO and BAR are data sets used by your program (you will of course have established your own names when writing the program). Again, "other parameters" vary greatly depending on what you're trying to do).
  • CEEDUMP. It's a sad fact of life that abends -- unrecoverable errors -- are likely to occur when testing a program (one of my professors at university said that any program that worked properly the first time it was run was too trivial to have been worth writing). When this happens, CEEDUMP provides a formatted dump -- printing of selected memory locations -- that can aid you in diagnosing and correcting the error.
There is of course a great deal more to JCL than this, but this may get you started.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: COmparing files using syncsort and Cobol

Postby tony1131 » Fri Mar 22, 2013 7:24 pm

thanks for taking the time to write such a detailed explanation, this helps a great deal. I'm going to be working on this for a lot of day. I'm sure I will have other questions lol.
tony1131
 
Posts: 12
Joined: Thu Mar 21, 2013 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COmparing files using syncsort and Cobol

Postby dick scherrer » Fri Mar 22, 2013 8:52 pm

Hello and welcome to the forum,

Someone will be here when there are questions/problems.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: COmparing files using syncsort and Cobol

Postby NicC » Fri Mar 22, 2013 9:34 pm

Further JCL: System utilities do not need a steplib - the OS 'knows' where they 'hang out.' Application programs, i.e. wot you write, do not need a STEPLIB if a JOBLIB is in the JCL. This comes before the first EXEC. However, you may need to point an individual step to a different load library so a steplib or steplib override will be required. An override does what it sounds like - it overrides some/all of the characteristics of a particular DD statement. It is coded in the format
//stepname DD values
. Hence the need, usually, for a stepname. If the DDname does not exist then your override does not override but ADDS a new DDname.

Note that job steps ran be rolled into one piece of JCL called a PROCEDURE so instead of having loads of JCL in your run deck you have one line along the lines of
//   EXEC procname
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COmparing files using syncsort and Cobol

Postby tony1131 » Fri Mar 22, 2013 9:48 pm

I think I found the correct load libraries to use here, Don't believe I will need to use override as you mentioned.

However after I do the syncsort I need to have my header record to stay at the top, and trailer record to stay at the bottom. Know of any way to do this?
tony1131
 
Posts: 12
Joined: Thu Mar 21, 2013 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post