The following are the possible values for this input field
1. 3 Grams
2. 30 to 200 Milligrams
3. SPF 50
I have two output fields output-1 and output-2, both declared as PIC S9(4)V9(3) COMP-3.
For the input '3 Grams' I need to move 3 to both output-1 and output-2 as 3 is the only one number available in the input string.
For the input '30 to 200 Milligrams' I need to move 30 to output-1 and 200 to output-2.
For the input 'SPF 50' I need to move 50 to both output-1 and output-2.
Can you please let me know how can I achieve this in cobol.
I can do this using UNSTRING but when I tried to move the value to COMP-3 I'm getting SOC7. Could you please provide me the logic to achieve this? Thanks in advance.
Test the 2nd field to determine which of the 3 cases you described this one is. E.g., if fld 2 begins w/"G" it's case 1; if "t" it's case 2. If fld 1 is SPF it's case 3. Granted, I may be over simplifying but that's the general idea. Again you didn't indicate how many variations you're dealing with. I assumed 3.
From that you can determine where the numeric fields are are.
Take a look at NUMVAL or NUMVAL-C to convert the dec pts and spaces in the fields that contain the numerics.