Check the file sorted or not!



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Check the file sorted or not!

Postby venkymf » Wed Dec 19, 2012 12:32 am

Hi All,

I am having a file with 80 bytes which is not sorted in 01-09 position, here my question is if a file is not sorted in a particular position(01-09), then while submitting this file in jcl ,I need to get abend code because file is not sorted. Please look into the below info.

inputfile:
_________10_________20_________30_________40_________
888888888
999999999
555555555
777777777
333333333
111111111
444444444
222222222
000000000

I need to check the file whether it is sorted or not. Please help me on this.

Regards,
Venky.
venkymf
 
Posts: 4
Joined: Wed Dec 19, 2012 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: Check the file sorted or not!

Postby NicC » Wed Dec 19, 2012 1:39 am

Nothing to do with JCL - it does not give a hoot about your data as it does not read it. The program that reads it needs to decide whether your data is in the correct sequence or not. Basic programming. And if the data needs to be in sequence why not sort it before your program gets its metaphorical hands on it?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Check the file sorted or not!

Postby venkymf » Wed Dec 19, 2012 1:48 am

thanks Nicc, Okay Please provide me the basic programming logic how to do it in cobol.

Regards,
Venky.
venkymf
 
Posts: 4
Joined: Wed Dec 19, 2012 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: Check the file sorted or not!

Postby Akatsukami » Wed Dec 19, 2012 1:53 am

Wow. You can't figure this out on your own? FTR, I wondered how difficult a task this was, and wrote and tested a PL/I program that did it; it took me 48 minutes. Here is the core of that program; consider it pseudo-code.
read file (tulin) into (record);     
key2 = substr(record,keyfrm,keylen); 
                                     
do while (¬eof_tulin);               
  key1 = substr(record,keyfrm,keylen);
                                     
  if (key1<key2) then                 
    call cee3abd(666,1);             
                                     
  key2 = key1;                       
  read file (tulin) into (record);   
end;                                 
"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: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Check the file sorted or not!

Postby enrico-sorichetti » Wed Dec 19, 2012 1:59 am

Please provide me the basic programming logic how to do it in cobol.


if You cannot imagine Yourself such a basic logic You should meditate on a career switch to a less neuron demanding profession :mrgreen:
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: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Check the file sorted or not!

Postby venkymf » Wed Dec 19, 2012 2:11 am

enrico, I think you have joined in this forum in 2008 and you will be having lot of experience in mainframe and once you also a beginner in mainframe right? that time you wont have any ideas and by the way getting experiences day by day we will become perfect.

Today only I have joined in this forum and that too I am beginner in Mainframe. Instead of commenting my question....Please it is better to provide a solution for that understood enrico!! :mrgreen:

Regards,
Venky.
venkymf
 
Posts: 4
Joined: Wed Dec 19, 2012 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: Check the file sorted or not!

Postby Robert Sample » Wed Dec 19, 2012 2:23 am

venkymf, you may be a newcomer to mainframes, but if you expect to have a career using computers, you need to realize that logical thinking is a major component of computer programs. If you cannot figure out that a file is not sorted if any two records are out of sequence (realizing that "sorted" could be ascending or descending -- both are used at different times), then you need to start learning how to think logically, or find a different career path.

JCL does nothing but execute programs, so posting your question in the JCL section indicates you are definitely very new to mainframes.

Furthermore, mainframes pretty much always have a sort program available -- IBM, Computer Associates, and Syncsort all sell them -- so there is, basically, no chance you would ever work at a site without a sort program. Hence the very premise of your question is suspect -- when a comptetent programmer can code up a sort in two minutes or less, why would anyone ever want to cause an abend if a file is not sorted?

Finally, interpersonal skills are valued in IT. Taking pot shots at respected, long-term members of this forum is a quick way to guarantee your posts will not be answered since who would want to expose themselves to your vitriol when there are others wanting help that are not so sharp in their replies?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Check the file sorted or not!

Postby enrico-sorichetti » Wed Dec 19, 2012 2:24 am

finding out if a sequence of object is ordered is not an information technology issue, it is just basic logic.

so being a mainframe beginner is just a excuse

if You had shown the logic and asked how to translate int into cobol statements my answer would have been quite different :mrgreen:
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: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Check the file sorted or not!

Postby Akatsukami » Wed Dec 19, 2012 2:28 am

venkymf wrote:enrico, I think you have joined in this forum in 2008 and you will be having lot of experience in mainframe and once you also a beginner in mainframe right? that time you wont have any ideas and by the way getting experiences day by day we will become perfect.

Today only I have joined in this forum and that too I am beginner in Mainframe. Instead of commenting my question....Please it is better to provide a solution for that understood enrico!! :mrgreen:

Regards,
Venky.

Venky-kun, stop and think for a moment:
  • What does it mean to say that a data set is "sorted"?
  • How would you go about checking that yourself?
  • What are the COBOL verbs corresponding to the actions that you would take?
FTR, when I got my first job in this field, I already knew PL/I (and a couple-three other languages that have turned out to be completely useless in my career :)) and had a nodding acquaintance with COBOL. I had also had several courses in which such things as algorithms and data structures were discussed abstractly. That was expected of me; going to senpai the first days or weeks and whining "Could you write this program for me?" would have gotten me fired on the spot. If, as seems all too common these days, your saying "I know COBOL" really means "I know how to spell 'COBOL', but nothing else about it", I strongly recommend that you actually learn the language (and other relevant things that you can spell but not use).

I could have written this program 35 years ago as a newbie, on my first day at my first job. I am sure that Dr. Sorichetti, whose experience is broader and deeper than mine, could have done likewise, quite possibly better. If you cannot, well, maybe Dr. Sorichetti is right and you should consider switching fields.
"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: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Check the file sorted or not!

Postby venkymf » Wed Dec 19, 2012 3:02 am

enrico,

we can do it by reading the file, like for example we will read 1st record and then we will compare it with the other next records, if the 1st record is greater then the next record then we will display 'records are not in ascending order' or viceversa. Please don't mind I am a beginner.

Please help in cobol know. Thank you.


Regards,
Venky.
venkymf
 
Posts: 4
Joined: Wed Dec 19, 2012 12:14 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post