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

String Manipulation Using COBOL


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

New User


Joined: 03 Sep 2007
Posts: 16
Location: India

PostPosted: Wed Nov 25, 2009 9:44 am
Reply with quote

Hi All,

I have below requirements and I appriciate if someone can help me.

I have a address Line of 30 Bytes lenght i.e. let's say Address PIC X(30).

I need to search this Address string for a particular string "CONFIDENTIAL" or "confidential" (Both Capital o small case letter may exist). If I found a hit then i will follow another logic.

Second requirment -

In the same string of X(30), I need to search for a particular date patteren like '%_/_/_%' or '%_-_-_%'.

Can anybody guide me if it's possible to do this Logic using COBOL?

Thanks for help.
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 Nov 25, 2009 10:07 am
Reply with quote

Hello,

Using an inspect for the string, and an array (or more than 1), or reference modification, you can accomplish the pattern match within a couple of loops.

You need to determine which patterns are valid and then alllow for all valid patterns in the code. Until you have well established the "rules" coding would be premature.
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 Nov 25, 2009 10:10 am
Reply with quote

I think INSPECT finds occurrences of 'confidential' regardless of case. Test it and let us know.
Back to top
View user's profile Send private message
Deepak Dash

New User


Joined: 03 Sep 2007
Posts: 16
Location: India

PostPosted: Wed Nov 25, 2009 1:59 pm
Reply with quote

Hi Terry,

Thanks. INSPECT does work and also gives me the count. Can you please let me know how do I find the date patteren in my string?

like '%_/_/_%' or '%_-_-_%'.

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

New User


Joined: 25 May 2005
Posts: 3
Location: Hyderabad

PostPosted: Wed Nov 25, 2009 2:39 pm
Reply with quote

similarly you can do 'INSPECT' for '/ 'or '-' , 3rd and 6th byte using reference modification
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 Nov 25, 2009 8:39 pm
Reply with quote

Hello,

INSPECT won't be much help for doing the pattern match. It might be used to find the first position, but i'd not try to say until the rules have all been shown.

The code will need to parse across the data until a potential beginning-of-pattern is found. Will the pattern always start and end with %? Could there be more than one pattern in the data? What is to happen when a pattern is found? Are single-digit month and day valid?
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 Nov 25, 2009 9:05 pm
Reply with quote

Dick, I think Deepak is using % as a wildcard character, not literally a percent sign.
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 Nov 25, 2009 9:56 pm
Reply with quote

Hi Terry,

Very possibly. . . Maybe something more useful will follow. . .

d
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top