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

Read a string until we get a numeric value.


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

New User


Joined: 15 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Jun 19, 2008 11:25 am
Reply with quote

7003-51211 YN NYLKOORB
I want to read the above string until we get a numeric value and then will take 10 bytes, which will result in 7003-51211 and after next space we will take YN and after that we will take until we hit two consecutive spaces ie we will get NYLKOORB.

Please let me know how can i perform the same.
Do i need to use string or inspect?
And also let me know the syntax.
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: Thu Jun 19, 2008 12:02 pm
Reply with quote

Hello radha reddy and welceom to the fourms,

Are the values in the record always like the example you've shown? If not please post examples of the different ways the data might be stored.

If the values are always in that fixed format, simple moves may do what you need.
Back to top
View user's profile Send private message
radha reddy

New User


Joined: 15 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Jun 19, 2008 12:49 pm
Reply with quote

Hi scherrer,

Thanks u for the reply.

Format will be almost same or it can be like 7003-51211 YN SLLIH YLREVEB.

i want the solution the way i have mentioned above to make sure that it handles all the formats.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Thu Jun 19, 2008 1:20 pm
Reply with quote

Morning radha reddy !

I think, by using the commands Inspect and String/Unstring with Pointer, you could build a little loop over the input-sentence and extract your strings.
Back to top
View user's profile Send private message
radha reddy

New User


Joined: 15 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Jun 19, 2008 2:35 pm
Reply with quote

Can i know the exact syntax for using inspect and string to get the required solution.
Back to top
View user's profile Send private message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Thu Jun 19, 2008 2:53 pm
Reply with quote

HI,

Read the String as ARRAY by character way and use ISNUMERIC option and get the numeric value repeat the loop 10 times and get the string into temparary varilable and use it

This is without using STRING and INSPECT function.
Back to top
View user's profile Send private message
HappySrinu

Active User


Joined: 22 Jan 2008
Posts: 194
Location: India

PostPosted: Thu Jun 19, 2008 3:16 pm
Reply with quote

if you got the Quick reference, pls check the exact syntax on QW INSPECT & QW string on any command prompt line in ISPF.

if you don't have ..

>>--INSPECT--identifier-1--TALLYING-----------------------------------------

>----identifier-2--FOR------CHARACTERS--------------------------------------
| +-| phrase 1 +-+
+---ALL------------identifier-3-------------------
+-LEADING-+ +-literal-1----+ +-| phrase 1

phrase 1:
+----BEFORE-------------------identifier-4----------------------------------
+-AFTER--+ +-INITIAL-+ +-literal-2----+

For String:
>>--STRING----------------------------------------------------------->
>--------identifier-1------DELIMITED------------identifier-2--------->
+-literal-1----+ +-BY-+ +-literal-2----|
+-SIZE---------+

>--INTO--identifier-3------------------------------------------------>
+-----------POINTER--identifier-4-+
+-WITH-+
+---------OVERFLOW--imperative-statement-1-+
+-ON-+
Back to top
View user's profile Send private message
radha reddy

New User


Joined: 15 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Jun 19, 2008 4:05 pm
Reply with quote

Hi Srinu,

Thank you for the syntax.

I have the general syntax, but i was asking for the actual syntax for my problem.

Anyhow i am trying with FUNCTION NUMVAL, i will let you know once i finish.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 19, 2008 5:32 pm
Reply with quote

Radha ,

First use INSPECT as follows

Code:

.
INSPECT WS-VAR REPLACING ALL SPACES BY '#'

UNSTRING WS-VAR DELIMITED BY '#' INTO WS-VAR-1,WS-VAR-2 ....


here im using only spaces as the delimiter for unstring ...
you must be aware of how many parts your variable can be broken into ... now if your string is " 7003 51211 YN NYLKOORB " how do you want the o/p to be ???
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Jun 19, 2008 5:56 pm
Reply with quote

IMHO, try using an in-line PERFORM with reference-modification checks against each byte of the target string.

Because you'd be checking individual bytes, instead of using NUMERIC (which internally generates a TRT), you can check for NOT < ZERO and NOT > '9', which internally will generate two CLI's, which are a much cheaper set of instructions than a single "Translate and Test".

INSPECT TALLYING calls a COBOL run-time routine, whereas, the in-line PERFORM stays within the program.

Just my .02 cents....

Bill
Back to top
View user's profile Send private message
radha reddy

New User


Joined: 15 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Jun 19, 2008 7:29 pm
Reply with quote

Thanks a lot.

I Discussed with my supervisor and conviced him that we go with simple move using reference modification.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
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 Error to read log with rexx CLIST & REXX 11
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top