View previous topic :: View next topic |
Author |
Message |
rekuth123 Beginner
Joined: 12 Jul 2005 Posts: 7 Topics: 2
|
Posted: Tue Jul 12, 2005 1:30 pm Post subject: Question on Parsing - Urgent |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jul 12, 2005 2:01 pm Post subject: |
|
|
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 |
|
 |
rekuth123 Beginner
Joined: 12 Jul 2005 Posts: 7 Topics: 2
|
Posted: Tue Jul 12, 2005 3:01 pm Post subject: |
|
|
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 |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Tue Jul 12, 2005 3:35 pm Post subject: |
|
|
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 |
|
 |
rekuth123 Beginner
Joined: 12 Jul 2005 Posts: 7 Topics: 2
|
Posted: Wed Jul 13, 2005 9:11 am Post subject: |
|
|
Hi Bithead,
Thanks for your response. |
|
Back to top |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Jul 13, 2005 9:34 am Post subject: |
|
|
I think Bithead deserves thanks, also!
 _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed Jul 13, 2005 9:36 am Post subject: |
|
|
That's OK Mervyn. Kolusu deserves more credit for this site than I do. |
|
Back to top |
|
 |
rekuth123 Beginner
Joined: 12 Jul 2005 Posts: 7 Topics: 2
|
Posted: Thu Jul 14, 2005 3:20 pm Post subject: |
|
|
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 |
|
 |
|
|