MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question on Parsing - Urgent

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
rekuth123
Beginner


Joined: 12 Jul 2005
Posts: 7
Topics: 2

PostPosted: Tue Jul 12, 2005 1:30 pm    Post subject: Question on Parsing - Urgent Reply with quote

Case: I
A5.CHR_VL_TYP_NM 3 GRAM

In this case I want to retrieve 3

Case: II
A5.CHR_VL_TYP_NM 30 TO 200 MILLIGRAM

In this case I want to retrieve 30 and 200

Case: III
A5.CHR_VL_TYP_NM 0.99 TO 1 MILLIGRAM

In this case I want to retrieve 0.99 and 1

Case: IV
A5.CHR_VL_TYP_NM MILLIGRAM PSEUDOEPHEDRINE SULFATE

In this case I donot want to retrieve anything as it does not have any numbers.

Can you tell me how can I achieve this in Cobol?
I hope that I should use Parsing Techniques (UNSTRING).
Is there any other more easy/efficient way available? If so could you please let me know?

Also please let me know how shuld I achieve this using UNSTRING command
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 12, 2005 2:01 pm    Post subject: Reply with quote

rekuth123,

Why isn't 5 in A5. picked when it is a number? If you don't want to pick 5 then what are the rules governing that ?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rekuth123
Beginner


Joined: 12 Jul 2005
Posts: 7
Topics: 2

PostPosted: Tue Jul 12, 2005 3:01 pm    Post subject: Reply with quote

Sorry. I think I should have been little bit clear.

A5.CHR_VL_TYP_NM (Character Value Type Name) is the field name
and I need to process the different values (3 GRAM, 30 to 200 Mg etc)available for this field. Thanks
Back to top
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Tue Jul 12, 2005 3:35 pm    Post subject: Reply with quote

Here is one solution:

Code:

 working-storage section.

 01  field-in pic x(80)
     value 'A5.CHR_VL_TYP_NM 30 TO 200 MILLIGRAM'.

 01  ws-ptr pic s9(04).

 01  hold-field pic x(80).
 01  test-field pic x(80).

 procedure division.

     display 'in:' field-in.
     move +1        to ws-ptr.
     move 'x'       to hold-field.
     perform
       until ws-ptr > +80
       or    hold-field = ' '
         unstring field-in
           delimited by ' '
           into hold-field pointer ws-ptr
         if hold-field not = spaces
             move hold-field to test-field
             inspect test-field
                replacing all ' ' by '0'
             if test-field numeric
               display hold-field
             end-if
         end-if
     end-perform.
Back to top
View user's profile Send private message
rekuth123
Beginner


Joined: 12 Jul 2005
Posts: 7
Topics: 2

PostPosted: Wed Jul 13, 2005 9:11 am    Post subject: Reply with quote

Hi Bithead,

Thanks for your response.
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Jul 13, 2005 9:34 am    Post subject: Reply with quote

I think Bithead deserves thanks, also!

Very Happy
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Wed Jul 13, 2005 9:36 am    Post subject: Reply with quote

That's OK Mervyn. Kolusu deserves more credit for this site than I do.
Back to top
View user's profile Send private message
rekuth123
Beginner


Joined: 12 Jul 2005
Posts: 7
Topics: 2

PostPosted: Thu Jul 14, 2005 3:20 pm    Post subject: Reply with quote

Hi Kolusu/Bithead

Thanks to both of you.The logic you have provided is really good and it's working fine.

But for the below case

Input :
0 to 4.99 Milligrams - In this case it has to retrieve both 0 and 4.99

When I ran this input thru this logic I'm retrieving 0 but I'm not retrieving 4.99 as
IF TEST-FIELD NUMERIC is failing for 4.99 as it has decimal places. Please help me to overcome this problem.

Moreover I want to move 0 to one variable and 4.99 to another variable and both the variables are of s9(4)V9(3) while the hold-field is of X(40). Please help me to include this also in the logic you have provided. Waiting for u r response
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group