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
 

 

String Manipulation Using COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: String Manipulation Using COBOL
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

Site Director


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

PostPosted: Wed Nov 25, 2009 10:07 am    Post subject:
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    Post subject:
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    Post subject: String Manipulation using COBOL
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    Post subject: Reply to: String Manipulation Using COBOL
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

Site Director


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

PostPosted: Wed Nov 25, 2009 8:39 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Nov 25, 2009 9:56 pm    Post subject: Reply to: String Manipulation Using COBOL
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    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 Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
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 Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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