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

Logic fo selecting records from an input file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Mar 31, 2009 10:40 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Mar 31, 2009 11:22 pm
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: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 3:22 am
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 01, 2009 3:25 am
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 01, 2009 4:54 pm
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: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 7:30 pm
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
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: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:10 pm
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

Moderator Emeritus


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

PostPosted: Wed Apr 01, 2009 8:25 pm
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: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:40 pm
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: 1353
Location: Israel

PostPosted: Wed Apr 01, 2009 8:45 pm
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: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 01, 2009 8:57 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 2
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top