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

Reading HEX variable in Fixed Dec Variable


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

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 12:51 pm
Reply with quote

Hi

I have a piece of code which looks like this:

Code:

DCL CHAR_10       CHAR(10) INIT('') ;
DCL CHAR_04       CHAR(04) INIT('') ;

DCL DEC_07        FIXED DEC(7,3) BASED ADDR(CHAR_04) ;

DCL PIC_07        PIC'(4)9V.999' INIT(0) ;


IF SUBSTR(CHAR_10,1,4) ^= ' ' THEN
DO;
   CHAR_04    = SUBSTR(CHAR_10,1,4) ;
   PIC_07     = DEC_07 ;
END;


Value in CHAR_10 is coming from a input file which is in HEX format.
If there is any space in the CHAR_04, say '40400544' then I'm getting S0C7 else in other cases like '0144769C' it works fine.

Can you please suggest what I'm doing wrong here?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Jun 02, 2012 1:30 pm
Reply with quote

Use the "VALID" builtin
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Jun 02, 2012 3:26 pm
Reply with quote

All data is in hex format - it is how you interpret that hex format that gives data meaning. You are interpreting char data as numeric - it isn't. If you want leading blanks to be leading '00'x then you need to overlay them.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 7:27 pm
Reply with quote

Hi Nic,

That field is always suppose to have numeric data(of 7 figure with 3 decimal digits) or either spaces. But in some cases the field has partial spaces and partial numeric data. In case of '40400544', the field PIC_07 should get the value 0544.000 after ignoring the two leading spaces.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Jun 02, 2012 7:34 pm
Reply with quote

If it contains partial this, partial that, how do you decide if 40400544 is 0544.000 and not 400.544?

You're working with Shambolic Hopeless Imbecile Trash.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 7:49 pm
Reply with quote

Prino,
I gotta be agree with u !!
thanks for enlightening me
f*** it
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 7:55 pm
Reply with quote

I just realized..they are toying with me.
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: Sat Jun 02, 2012 8:30 pm
Reply with quote

Hello,

Quote:
I just realized..they are toying with me.
Depends on who you consider as "they". . . Different people have different ways to "teach".

Quote:
But in some cases the field has partial spaces and partial numeric data. In case of '40400544', the field PIC_07 should get the value 0544.000 after ignoring the two leading spaces.
The "requirement" you mention is NOT something that is done.

How does it happen that you have a value that may or may not have a sign, and may or may not leading values to ignore (i.e. x'40')? How did such data get created?

Suggest you have much more to do than fix than the 0c7. . .
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 8:46 pm
Reply with quote

well..I guess..first I need to understand the requirements clearly..they means my boss...gave me a file and ask to extract the price (the first four character of the variable in question)...just to teach me a lesson in PL\I.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 9:00 pm
Reply with quote

[rant]I think he did it intentionally...putting some junk values..just to annoy me..(there is only one record in the entire file!!!) that field is either supposed to have numeric values or all spaces..[\rant]

Sorry guys...to put you through this..
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: Sat Jun 02, 2012 11:04 pm
Reply with quote

Hello,

Not a problem icon_smile.gif

Suggest you include a numeric test in the code and when the value is not numeric, print a message saying the record was rejected due to a non-numeric value.

If this is just for learning, i guess you'll need to bite the bullet and deal with it some way.

There is still the problem of knowing when a leading x'40' is to be discarded or part of the value to be retained. My first thought i if the field does not have a valid sign, the entire field is questionable (at best).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sun Jun 03, 2012 11:12 am
Reply with quote

It was only for learning purpose and I think i have learnt a things or two about data movements in Pl/I and I have started to like it :-)

Thanks everyone.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top