IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparing two sequential files


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mohan Kothakota

New User


Joined: 12 Apr 2016
Posts: 15
Location: INDIA

PostPosted: Mon Apr 16, 2018 6:35 pm
Reply with quote

Hi All,

I have two sequential files, one file with LRECL = 80 (FB) and other file LRECL = 3000 (VB).

The first file with LRECL = 80 is input where account number (key field) with other details will be provided.

I have to search the second file using the key fields and update the second file using the details/values of the first file.

I have followed below logic

START
Open INPUT first-file
Open I-O second-file


Read FIRST-FILE
PERFORM VERIFY-RECORDS (verification for the second file)

VERIFY-RECORDS.
Compared KEY values of the Input file with all records

IF matched then REWRITE the second-file

CLOSE FILES

END

somehow I am not getting desired results. Can anyone share other ideas please.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Apr 16, 2018 6:44 pm
Reply with quote

Quote:
somehow I am not getting desired results. Can anyone share other ideas please.
My first idea would be to post meaningful data. "not getting desired results" -- could mean, among other things:
- program abends with a system code
- program abends with a COBOL code
- program runs to normal completion but produces no results
- program runs to normal completion but produces incorrect results
- program generates a file status code during processing

Furthermore:
- are the two files sorted on the key?
- if not, why are you not sorting them before starting the process? Unsorted, you have to read the second file from the beginning for each record to find the match so you have to do a lot more work.
- what results do you desire?
- how do the actual results differ from what you desire?
- is your desired results what the system can produce or are you wanting something impossible to produce?
Back to top
View user's profile Send private message
Mohan Kothakota

New User


Joined: 12 Apr 2016
Posts: 15
Location: INDIA

PostPosted: Mon Apr 16, 2018 7:19 pm
Reply with quote

Hi Robert,

Sorry for the confusion. Please find my response

- Program abends with System code.

- Files have been sorted before running the program.

- I have record in the second file but I want to update some fields in it. So I am using the first file as Input.
Using the Input, the second file needs to be updated.

The desired result is the second file needs to get updated same as first file values.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Apr 16, 2018 7:37 pm
Reply with quote

Quote:
- Program abends with System code.
OK -- WHAT SYSTEM CODE DID IT ABEND WITH?
Your answer is responsive but meaningless. A system abend S0C7 is quite different from a system abend S001 is quite different from a system abend SB37 and each has a different resolution. There are hundreds, if not thousands, of system abend codes and without telling us which one, there is nothing we can do to help you.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Tue Apr 17, 2018 1:49 am
Reply with quote

Looks like the ABEND code is equal to the word "SYSTEM", isn't it? icon_fU.gif
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Tue Apr 17, 2018 1:49 am
Reply with quote

Preliminary my guess is that using any of standard SORT utilities for this task requires approx. 300 times less coding compared to COBOL solution, isn't it?

My second guess: SORT utility can provide 100 times better performance on huge datasets, compared to primitive hand-made COBOL code.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Tue Apr 17, 2018 2:38 am
Reply with quote

You are comparing two sequential data sets. Did you follow the logic in the "sticky" topic (among the first 5 topics in this part of the forum) - amende for your particular requirement?
Back to top
View user's profile Send private message
Mohan Kothakota

New User


Joined: 12 Apr 2016
Posts: 15
Location: INDIA

PostPosted: Tue Apr 17, 2018 3:47 pm
Reply with quote

Hi Robert,

I am getting SOC7,

Below is the Input

Code:
05  IPD350-ACTUALS.                           
   10  IPD350-HOURS             PIC  S9(05)V99.
   10  IPD350-DOLLARS           PIC  S9(07)V99.
   10  IPD350-UNITS             PIC  S9(07)
.


Values of Input

Code:
IPD350-HOURS       :   14.39 
IPD350-DOLLARS     :   148.22
IPD350-UNITS       :   275   


I am moving to below fields

Code:
10  RLD-CUR-MTH-ACTUALS       COMP-3.       
    15  RLD-CMA-HOURS   PIC  S9(05)V99.     
    15  RLD-CMA-DOLLARS PIC  S9(07)V99.     
    15  RLD-CMA-UNITS   PIC  S9(07).   



I tried with and without COMP-3 for Input but still getting SOC7.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Tue Apr 17, 2018 4:52 pm
Reply with quote

show the hexadecimal values of the input ...
NOT an edited value
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 17, 2018 5:13 pm
Reply with quote

Have you done the elementary debugging of figuring out which line of code and which variable(s) are causing the S0C7? If not, start by finding the line of code and the variable(s) involved. You may need to rewrite the code to prevent the S0C7.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Tue Apr 17, 2018 7:28 pm
Reply with quote

Robert Sample wrote:
Have you done the elementary debugging of figuring out which line of code and which variable(s) are causing the S0C7? If not, start by finding the line of code and the variable(s) involved. You may need to rewrite the code to prevent the S0C7.


Just recently the topic starters with low level of understanding in IT technologies were directed straightforward to the Beginners Forum.

The level of this question is even worse than "zero degree"; does it make sense to carefully explain here the very standard, and obvious steps in program coding, and debugging?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 17, 2018 9:30 pm
Reply with quote

Mohan Kothakota, I concur with sergeyken -- you need to stop posting on this forum and visit Beginners and Students Forum instead. The types of questions you are posting, and the responses you provide to questions, indicate that you have no place on an Experts Forum such as this one. You would be far better off switching, no matter how much "experience" you claim to have.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Wed Apr 18, 2018 1:13 am
Reply with quote

Note that Robert has correctly written your abend as S0C7 (with a zero), not SOC7 (with an oh) as you have it.

Picky, picky, picky, right? Well, that's the nature of this kind of work.

We DO pronounce it sock7, but it's a zero in the code.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 18, 2018 1:19 am
Reply with quote

As another example of why you belong on the Beginners Forum, if the input data is truly as you have it listed (with decimal points), then that explains why you got the S0C7 -- decimal points are not numeric and will cause S0C7 abends when encountered in numeric MOVE statements and arithmetic operations. The V in a COBOL PICTURE clause is an IMPLIED decimal point -- as in, it does not really exist in the data. Furthermore, 14.39 being read into a PIC S9(05)V99 should be coming in as 000143I (which is 1439 with an overpunched plus sign on the last byte, as is normal and proper for zoned decimal signed values). It could be read in as 0001439 (without a sign) -- but in any case, it needs to be read with leading zeros and no decimal point.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Wed Apr 18, 2018 3:51 am
Reply with quote

Robert Sample wrote:
As another example of why you belong on the Beginners Forum, if the input data is truly as you have it listed (with decimal points), then that explains why you got the S0C7 -- decimal points are not numeric and will cause S0C7 abends when encountered in numeric MOVE statements and arithmetic operations. The V in a COBOL PICTURE clause is an IMPLIED decimal point -- as in, it does not really exist in the data. Furthermore, 14.39 being read into a PIC S9(05)V99 should be coming in as 000143I (which is 1439 with an overpunched plus sign on the last byte, as is normal and proper for zoned decimal signed values). It could be read in as 0001439 (without a sign) -- but in any case, it needs to be read with leading zeros and no decimal point.


Just answering that 2 + 2 = 4 wouldn't help in similar cases.
Tomorrow you'll get seriously a question like this: "Sorry, I'm new to COBOL; how can I calculate 3 + 3 ? "

Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files and write Matched/Unm... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top