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
 

 

conversion from numeric data to comp data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Wed Apr 16, 2008 12:25 pm    Post subject: conversion from numeric data to comp data
Reply with quote

Hi,
I am unable to convert numeric data to comp-data using rexx.
If anyone had already worked on it or if anyone have any ideas on it kindly let me know how to do the same.

I need the conversion to write the data back into the datafile after the conversion

with regards,
surya
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Wed Apr 16, 2008 2:48 pm    Post subject: Reply to: conversion from numeric data to comp data
Reply with quote

things in REXX are character strings so whenfrocessing records ( in general )
fields must be parsed and converted accordingly

the representations that might be object of discussion are

hexadecimal fields with no numeric implications ( flags bits for example )
binary numbers
packed numbers

remember also that when converting You must reformat according to the picture ( decimal point issue)

here is snippet with samples of different conversions
Code:
hexad = '1234'x
binry = '0002'x
packd = '002c'x

say "hexad = '1234'x " hexad
say "binry = '0002'x " binry
say "packd = '002c'x " packd

say "c2x(hexad) " c2x(hexad)
say "c2x(binry) " c2x(binry)
say "c2x(packd) " c2x(packd)

say "c2d(hexad) " c2d(hexad)
say "c2d(binry) " c2d(binry)
say "c2d(packd) " c2d(packd)


say "unpack(packd) " unpack(packd)


exit

unpack: procedure
    parse arg packed
    /* Convert packed data to hex and split */
    char = c2x(packed)
    number = left( char, length(char)-1 )
    sign = right( char, 1 )
    /* Check sign and numeric sections */
    if  verify(sign, "ABCDEF" ) > 0 then ,
        return ""
    if  verify( number, "0123456789" ) > 0 then ,
        return ""
    /* Check negative sign */
    if  pos(sign, "BD" ) > 0 then,
        return -number
    else ,
    return  number
exit
Back to top
View user's profile Send private message
surya anem

New User


Joined: 20 Dec 2007
Posts: 54
Location: Hyderabad

PostPosted: Wed Apr 16, 2008 3:49 pm    Post subject: Reply to: conversion from numeric data to comp data
Reply with quote

Hi,
Thanks a lot..My code is working now. I always get confused between the conversions and this code of urs has cleared most of doubts.

with regards,
surya
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts JCL to get submitted once dataset has... vinu78 JCL & VSAM 17 Thu Feb 16, 2017 7:32 am


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