IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparision logic for Alpha-numeric fields in PL1


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
op

New User


Joined: 31 Oct 2006
Posts: 48
Location: Chennai

PostPosted: Tue Sep 25, 2007 8:11 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Sep 30, 2007 2:59 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sun Sep 30, 2007 3:54 am
Reply with quote

Dick, are you saying the esteemed PL/I does not have a function like the Alphabet clause in COBOL?
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Sun Sep 30, 2007 4:12 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Sep 30, 2007 5:04 am
Reply with quote

Good catch, Pierre icon_smile.gif

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 icon_wink.gif

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 icon_confused.gif
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Sun Sep 30, 2007 8:01 am
Reply with quote

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
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Sun Sep 30, 2007 1:29 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts Find a record count/numeric is multip... COBOL Programming 1
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
Search our Forums:

Back to Top