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

Calculating position of a string within a string


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

New User


Joined: 06 May 2010
Posts: 17
Location: INDIA

PostPosted: Wed May 26, 2010 8:51 am
Reply with quote

Hi,

I want to calculate position of a part of a string within a string. How I can do that?

Ex:

These are the two records. I want to search the position of character
"NMN" and "UIIO" in the below records.

110013NMN IBM MAINFRAME0010TEL 99224455660009UIIO12456789
110009NMN MAINFRAME0010TEL 99224455660009UIIO12456789
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed May 26, 2010 9:45 am
Reply with quote

Hello,

Write a loop and parse across the field using reference modification until you find the value(s) and record the position(s). . .
Back to top
View user's profile Send private message
biswaranjan

New User


Joined: 06 May 2010
Posts: 17
Location: INDIA

PostPosted: Wed May 26, 2010 9:47 am
Reply with quote

can you please give an example? I'm new to COBOL..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed May 26, 2010 9:53 am
Reply with quote

Hello,

We will help you implement your code - we will not write the code for you.

Suggest you search in the forum for topics that talk about reference modification.

At the top of the page is a link to "IBM Manuals". The COBOL Language Reference completely explains reference modification.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 26, 2010 10:32 am
Reply with quote

You might want to look for INSPECT also
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed May 26, 2010 4:20 pm
Reply with quote

Terminology note: terminology is critical to IT, where similarly named concepts can mean extremely different things. COBOL does not have strings. COBOL has variables. These variables can be numeric, alphanumeric, alphabetic, or even national -- but they are not strings. COBOL has STRING and UNSTRING verbs that work on alphanumeric variables but they are still not strings.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts ICETOOL to SUM String DFSORT/ICETOOL 1
No new posts Mark Previous & next lines when a... DFSORT/ICETOOL 9
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Help with C character vs C string All Other Mainframe Topics 3
Search our Forums:


Back to Top