View previous topic :: View next topic
|
Author |
Message |
op
New User
Joined: 31 Oct 2006 Posts: 48 Location: Chennai
|
|
|
|
Hi,
In the input file, a VB dataset, I do have randomly many records of the same header (position 1 3).
I am supposed to select only 1 record with the highest value in a CHAR field (position 24). But the values in this field are 0-9,A-Z (the values are in EBCDIC format).
But, the ascending order of preference in the program should be 0-9,A-Z (0 being the lowest and Z being the highest).
As we know, A-Z is less compared to 0-9 in EBCDIC format.
Is there any logic to do the comparison as I require?
Thanks in advance
OP |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
As there have been no other suggestions, one thing you might do is a 2-part compare.
First, check to see if the value is greater than Z. If it is, skip that record.
Second, compare the current value against the previous highest saved value. If "this" value is greater that the previoujs "hi", save it.
When EOF is reached, the last value saved is the one youj want. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Dick, are you saying the esteemed PL/I does not have a function like the Alphabet clause in COBOL? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Quote: |
First, check to see if the value is greater than Z. If it is, skip that record.
|
What will happen for a set of records ( I don't know the context ) without any characters A from Z; only digits. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good catch, Pierre
I suppose that if the value is greater than Z (0-9), that "hi" value could be saved in a zero29-hi field. At EOF, if there was no A-Z value, the 0-9 value would be it
Hi Bill,
As i've only helped trouble-shoot pl/i and don't actually speak the language, i don't know. I suspect that even if pl/i supports "alphabetic" it doesn't support an "emulate ascii" collating sequence.
I guess the field might be converted to ascii and then the comparison done |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
OP
If your reqt is just sorting the records in different sequence then you can try in SORT with ALTSEQ.
Create the output file and then run a sort step. |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Note : the piece of tests is obviously valid but here just for information
With the help of PLIASCII
Code: |
DCL ZEBCDIC CHAR(1) INIT(' ');
DCL ZASCII CHAR(1) INIT(' ');
DCL PTRE PTR;
DCL PTRA PTR;
DCL ZL BIN FIXED(31,0) INIT(1);
.....................
ZEBCDIC = 'F1'X;
ZASCII = '00'X;
PTRE = ADDR(ZEBCDIC);
PTRA = ADDR(ZASCII);
CALL PLIASCII(ZASCII,ZEBCDIC,ZL); |
Note : ZEBCDIC may overlap ZASCII( refering to a field of record ).
Cheers
Pierre |
|
Back to top |
|
|
|