Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Logic fo selecting records from an input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Tue Mar 31, 2009 10:33 pm    Post subject: Logic fo selecting records from an input file
Reply with quote

Hi All,

I need to select records from an input file having claim key as 700, 491 or 834 and place these records in a new output file.

Here is the logic that I put in my program:-

IF CLAIM-KEY = '700' OR '491' OR '834'
PERFORM 2730-CLAIM-FILE
DISPLAY 'RECORDS SELECTED'
END-IF.

and in perform para I put logic as

2730-CLAIM-FILE
WRITE CLAIM-REC FROM INPUT FILE.
DISPLAY ' RECORDS WRITTEN'.

The problem that I am facing is it is selecting records only having key 700 and placing in The output file and it is not selecting records with key 491 and 834.
I checked the input file it has records for all the 3 keys but it is selecting only for key 700.

Could anyone let me know what could be the reason behind this or any logic that I need to add. Also let me know if my logic is correct. Since this project is close to its deadline date.

Thanks,
Kumar.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Mar 31, 2009 10:40 pm    Post subject:
Reply with quote

Which compiler are you using? What is the definition of CLAIM-KEY? Show us some input records with the 3 data values and the output file with the 700 but not other records.

Basically, your IF logic is correct. Therefore there is something else going on -- either your variable isn't right, the data doesn't match the conditions you indicate, or ....
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Tue Mar 31, 2009 10:50 pm    Post subject: Reply to: Logic fo selecting records from an input file
Reply with quote

CLAIM-KEY is we have 12 byte claim no. eg:- 700-234323-01-1 the first 3 byte is called the CLAIM-KEY. So based on this claim key we have to select records.

Input file.

700234323011454545444444444444444444444543224232323232
834882137282822029900929029192019298880993767888888000
491563738298922900197766789008756780987634567890986797

Output file below showing records selected only for key 700.

700234323011454545444444444444444444444543224232323232

Kindly let me know if you have any solution for this.

Thanks,
Kumar.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 31, 2009 11:22 pm    Post subject:
Reply with quote

Hello,

Try this:
IF CLAIM-KEY(1:3) = '700' OR '491' OR '834'

Have you posted the exact code from the program or just something similar?

From the code posted, the reason is not visable. . .

Is there somewhere else in the code where processing decisions are made on the 3-position "claim-key"? The missing records may not have even made it to the "if". . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 3:22 am    Post subject:
Reply with quote

Is your IF statement inside a loop? If not, it's only being executed once as Dick mentioned.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Apr 01, 2009 3:25 am    Post subject:
Reply with quote

Good point, Terry -- the assumption is that there's a loop around the READ (as in most programs) but there's no evidence of one from what has been posted so far.
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Wed Apr 01, 2009 1:23 pm    Post subject: Reply to: Logic fo selecting records from an input file
Reply with quote

Thanks for your response. The code that I posted is the actual code. Let me check first if it is loop because after my IF there is a Move for the IF prior to my IF. I think i need to place my IF after the Move that already existed in the program.

I'll try this out and let U'll know if it is working or not. In the mean time let me know if any more hints.

Thanks,
kumar.
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Wed Apr 01, 2009 1:58 pm    Post subject: Reply to: Logic fo selecting records from an input file
Reply with quote

No it is still not working out. It is selecting records only with claim key as 700.

Thanks.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Apr 01, 2009 4:54 pm    Post subject:
Reply with quote

How many records in the input file? How many of each type that you're trying to grab? How many 700 records in the output file?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 7:30 pm    Post subject:
Reply with quote

Increment a counter every time you execute that IF statement and display it at end of program. Better yet, in addition, display CLAIM-KEY every time your IF executes.
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Wed Apr 01, 2009 8:01 pm    Post subject: Reply to: Logic fo selecting records from an input file
Reply with quote

I found the problem, the Input file had some bad records like 'xxxxx' for one particular field for the key i was selecting, so it was not selecting records due to this reason. I took some good records without 'xxxxx' for the key, then it worked fine.

Thanks All for all your help.

Thanks,
Kumar.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:10 pm    Post subject:
Reply with quote

We appreciate your feedback concerning your solution. I guess I don't see why bad records would prevent the good records from being selected though.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 01, 2009 8:25 pm    Post subject:
Reply with quote

Hello,

We may not see more in this topic, but i suspect there are either more issues with the code or issues with the data content. . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:40 pm    Post subject:
Reply with quote

I think your're right, Dick, but I tried anyway!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed Apr 01, 2009 8:45 pm    Post subject:
Reply with quote

kumar1234 wrote:
IF CLAIM-KEY = '700' OR '491' OR '834'
PERFORM 2730-CLAIM-FILE
DISPLAY 'RECORDS SELECTED'
END-IF.

When I read the question, the first thing that stroke me is that there is both an END-IF and a period.
Is this exactly how it is coded in the program ?
Can this be part of the problem ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:57 pm    Post subject:
Reply with quote

Shouldn't make any difference. END-IF, period, or both should all generate the same code for that particular IF statement.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 17 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us