Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reading HEX variable in Fixed Dec Variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
mistah kurtz

Active User


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

PostPosted: Sat Jun 02, 2012 12:51 pm    Post subject: Reading HEX variable in Fixed Dec Variable
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Sat Jun 02, 2012 1:30 pm    Post subject:
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: 1712
Location: UK

PostPosted: Sat Jun 02, 2012 3:26 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 7:27 pm    Post subject:
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Sat Jun 02, 2012 7:34 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 7:49 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

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

I just realized..they are toying with me.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Jun 02, 2012 8:30 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 8:46 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Jun 02, 2012 9:00 pm    Post subject:
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

Site Director


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

PostPosted: Sat Jun 02, 2012 11:04 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sun Jun 03, 2012 11:12 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Reading data from PS file and send it... rajatbagga All Other Mainframe Topics 18 Fri Sep 23, 2016 12:51 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Reading selected volumes of a multi-v... RickBig JCL & VSAM 6 Wed Jul 13, 2016 7:26 pm
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us