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

COBOL Program to search for five digit company id


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

New User


Joined: 23 May 2022
Posts: 1
Location: India

PostPosted: Mon May 23, 2022 10:41 pm
Reply with quote

I have a file with logical record length of 80. From columns 53-80 - I need to search for five digit company id then write the same to output file. Input file is having company id any where between 53-80 columns that includes description as well. Please advise a sample program.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1533

PostPosted: Mon May 23, 2022 11:01 pm
Reply with quote

suneelk wrote:
I have a file with logical record length of 80. From columns 53-80 - I need to search for five digit company id then write the same to output file. Input file is having company id any where between 53-80 columns that includes description as well. Please advise a sample program.


Quote:
1) Read your input data, one record at the time.
2) For each record, compare its ID field with the value you are interested in.
3) If match is found, then write the currently read record into your output dataset; otherwise do nothing.
4) When input data ended, stop run the program; otherwise continue to #1.

That is the advice.

P.S.
There are hundreds, and hundreds of sample programs in tons of existing manuals and references on COBOL programming, if you had ever seen any...
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 376
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Mon May 23, 2022 11:32 pm
Reply with quote

"value you are interested in"

Old school method is looping using reference modification until you have entered 5 consecutive numeric digits. Still may be erroneous as it assumes only a single occurrence of a 5 digit number and ignores 6 or more digit numbers being present.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 376
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Tue May 24, 2022 1:29 am
Reply with quote

Quote:
using reference modification until you have entered 5 consecutive numeric digits


should be: using reference modification until you have found 5 consecutive numeric digits
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2905
Location: NYC,USA

PostPosted: Tue May 24, 2022 5:59 am
Reply with quote

You can easily do this using DFSORT. Use SS in include condition.
www.ibm.com/docs/en/zos/2.1.0?topic=records-substring-search-include-omit
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 Injecting HTTPHEADER parameters in th... PL/I & Assembler 0
No new posts Concurrent writing records to VSAM fr... JCL & VSAM 9
No new posts interactive cics program using CICS s... CICS 5
No new posts Compiler and run JCL for basic PL/I p... PL/I & Assembler 10
No new posts Getting TWA in CICS program while con... CICS 14
Search our Forums:

Back to Top