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
 

 

Pattern matching using COBOL

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

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Thu Feb 07, 2013 5:22 pm    Post subject: Pattern matching using COBOL
Reply with quote

Hello Everybody,

I'm looking for help to scrape a report for specific fields with irregular pattern.

The input file is of RECFM = FBA and LRECL = 133

It has multiple reports with different report headers written one after other at different intervals.

Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 -----------------------------------------------------------------------
000002 1R3020-03/R1.0 000YG1 0500                                             
000003 0                                                          DETAIL LIST 
000004 0-----------------------------------------------------------------------
000005    POINT: RECV YG1                         FILE: 12355 000021           
000006  -----------------------------------------------------------------------
000007 0                                                  F I L E   T O T A L S
000008 0    BATCH COUNT    BLOCK COUNT       ADD COUNT           TOTAL        T
000009              1             01            08             3120642         
000010 0-----------------------------------------------------------------------
000011     *- - - - - - - - R E J E C T S - - - - - - - - - - -*  *- - - - - -
000012                      COUNT            AMOUNT              COUNT  PCT   
000013  -----------------------------------------------------------------------
000014 -                                                                       
000015 -               3011-56 *** NO APPLICATIONS PROCESSED                   
000016 0 *** CONSOLIDATED TOTAL PAGE  -  APPLICATION, FILE AND POINT TOTALS ARE
000017 1R3050-02/R1.0 000YG1 0500                                             
000018 0                                                                       
000019                                       03120642-0 MARS NATIONAL         


The code snipped shows two reports, R3020-03 and R3050-02 written one after another but there can be any other report written prior or after R3020-03

All report headers start with carriage control, 1 at position 1

I need to fetch specific values (highlighted in red color below) from one of the report with header, R3020-03

The number of lines within the report, R3020-03 are not always equal

The position of report header, R3020-03 is always same i.e column no:2 but the other values, File number FILE: 12355 000021 and message 3011-56 *** NO APPLICATIONS PROCESSED can be in any line or column within the report

Messages always follow a regular prefix pattern of NNNN- where (N is an integer) and not all R3050-02 reports have this message.

Please advice, how this can be accomplished using COBOL

Note: Our shop does have Syncsort, if in case it helps

Thanks!
Ramanan
Back to top
View user's profile Send private message

Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Thu Feb 07, 2013 6:11 pm    Post subject:
Reply with quote

You can redefine your 133 line several times
or
You can use reference modification technique (column:length)
Code:
           IF  WS-PRINT-LINE (002:18) = 'FILE: 12355 000021'
           OR  WS-PRINT-LINE (003:18) = 'FILE: 12355 000021'
           OR  WS-PRINT-LINE (004:18) = 'FILE: 12355 000021'
           ...                                             
           OR  WS-PRINT-LINE (116:18) = 'FILE: 12355 000021'
               <etc.>                                       
           END-IF                                           
Back to top
View user's profile Send private message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Thu Feb 07, 2013 7:17 pm    Post subject:
Reply with quote

Thanks Gary, but i just gave an example for File number and message, those are not constant values...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Feb 07, 2013 7:25 pm    Post subject:
Reply with quote

If you are going to do pattern matching, you had better start by knowing the pattern you want to match. If you cannot even identify that, then you have no hope at all of completing this task.

Mainframe print files will have a 1 in the first column for carriage control (assuming the program that wrote the file respects carriage control); this 1 reflects the start of a new page. Whether that new page means a new report has started, or merely that the last report has continued to another page, will depend upon the application. And we cannot tell you what the application does -- only someone working at your site can do that. So basically it sounds like you have a batch of research to do.
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Thu Feb 07, 2013 7:32 pm    Post subject: Reply to: Pattern matching using COBOL
Reply with quote

Good day!
You would read the 133 chars record comparing the the report ID that you want to find. Once found you will set a flag to redirect the process to move the input into a WS occur (133) field. Then you could use subscript or index as your pos-marker in the WS occur field then do a loop using reference modification (pos-marker:18) as Gary mention for the variables 'FILE: 12355 000021' or '3011-56 *** NO APP'.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Thu Feb 07, 2013 8:35 pm    Post subject:
Reply with quote

Ramanan-R wrote:
Thanks Gary, but i just gave an example for File number and message, those are not constant values...

Okay Ramanan-R.

Once you find out exactly what text you want to search for in a variable manner, the Reference Modification technique works very well and is easy to code.

Good luck.
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 Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Matching and unmatching records scdinesh DFSORT/ICETOOL 11 Tue Feb 07, 2017 12:41 am


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