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
 

 

Read a string until we get a numeric value.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Read a string until we get a numeric value.
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

Site Director


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

PostPosted: Thu Jun 19, 2008 12:02 pm    Post subject:
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    Post subject:
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: 757
Location: Germany

PostPosted: Thu Jun 19, 2008 1:20 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: Read a string until we get a numeric value.
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: 195
Location: India

PostPosted: Thu Jun 19, 2008 3:16 pm    Post subject: Reply to: Read a string until we get a numeric value.
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    Post subject:
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jun 19, 2008 5:56 pm    Post subject: Re: Read a string until we get a numeric value.
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    Post subject:
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    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 Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 5 Wed Jul 26, 2017 7:35 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm


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