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
 

 

How to convert Numeric to Packed Decimal COMP3 in REXX

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

New User


Joined: 26 Oct 2012
Posts: 2
Location: India

PostPosted: Mon Oct 29, 2012 5:37 pm    Post subject: How to convert Numeric to Packed Decimal COMP3 in REXX
Reply with quote

I am Writing a REXX program to accept value from user, then i will change it in to comp3 and will store it in a file.

Difficulties:

1)the input from user is x(1)9(7) bytes, Ex: A1234567.
2)Convert the above data to COMP-3
3)And storing in the File in the following layout PIC S9(04) COMP-3.

I searched hard but i got only conversion of Packed Decimal to Numeric. So can someone help me to address the above problem.


Thanks,
Jay
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Oct 29, 2012 5:50 pm    Post subject: Reply to: How to convert Numeric to Packed Decimal COMP3 in
Reply with quote

If you found it one way, can't you just "run it backwards"?

What do you intend to do with the alpha-numeric?

What do you intend doing with the digits other than the four which you are able to store in the definition you have shown?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Mon Oct 29, 2012 6:00 pm    Post subject: Reply to: How to convert Numeric to Packed Decimal COMP3 in
Reply with quote

everywhere but a COBOL forum it would be wiser to word things according to the S370/s390/zARCH terminology ( POP )
http://www-01.ibm.com/support/docview.wss?uid=isg2b9de5f05a9d57819852571c500428f9a

not all the people answering here speak COBOLESE ,
using COBOL terminology will just reduce then number of people willing to help

if You search my posts with PACK UNPACK
You will find snippets for both tasks

here for example
http://ibmmainframes.com/viewtopic.php?t=27921&highlight=rexx+pack+unpack
and here
http://ibmmainframes.com/viewtopic.php?t=41407&highlight=rexx+pack+unpack
and here
http://ibmmainframes.com/viewtopic.php?t=31547&postdays=0&postorder=asc&start=15
Back to top
View user's profile Send private message
jackie.jay

New User


Joined: 26 Oct 2012
Posts: 2
Location: India

PostPosted: Wed Oct 31, 2012 2:08 pm    Post subject:
Reply with quote

Hi Enrico,

Command X2C(number) is not working. I am getting the following message,

BEFORE 1234567
BEF LN 8
89 +++ PACK = X2C(TEMP)
Error running SORTRAN, line 89: Incorrect call to routine
***

My Code :

PNS2 will have value 1234567

SIGN = LEFT(PNS2,1)
IF SIGN = "-" THEN DO
SIGN = "D"
PNS2 = SUBSTR(PNS2,2)
END
ELSE ,
IF SIGN = "+" THEN DO
SIGN = "C"
PNS2 = SUBSTR(PNS2,2)
END
ELSE
SIGN = "C"
SIZE = LENG * 2 - 1
TEMP = RIGHT(PNS2,SIZE,"0") || SIGN
PACK = X2C(TEMP)
LEN = LENGTH(PACK)


Can you kindly look into this ?

Thanks,
Jay
Back to top
View user's profile Send private message
prino

Active Member


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

PostPosted: Wed Oct 31, 2012 2:26 pm    Post subject:
Reply with quote

Your code as included it total crap and already bombs out before the statement containing X2C().

SIASD: Use trace ?r or trace ?i to find the error yourself.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Oct 31, 2012 2:27 pm    Post subject: Reply to: How to convert Numeric to Packed Decimal COMP3 in
Reply with quote

the code I posted was tested and worked...

Your code is different...

just telling that Your code does not work and providing misleading info
is just a waste of time for all

no reason for anybody to download Your broken code to do the testing !

but ...
post using the code tags,it is a due courtesy to people helping,

post ALL the code ,

You diagnosis is wrong, Your code should fail on
SIZE = LENG *2 -1

because as everybody can see LENG was nowhere initialized
Back to top
View user's profile Send private message
Ricardo Viegas

New User


Joined: 18 Oct 2012
Posts: 33
Location: Brasil

PostPosted: Fri Dec 07, 2012 9:08 pm    Post subject: Reply to: How to convert Numeric to Packed Decimal COMP3 in
Reply with quote

Hello Enrico!

What is "code tags" ??

Thanks, Ricardo
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Fri Dec 07, 2012 9:32 pm    Post subject: Re: Reply to: How to convert Numeric to Packed Decimal COMP3
Reply with quote

Ricardo Viegas wrote:
Hello Enrico!

What is "code tags" ??

Thanks, Ricardo

On the reply (both quick and full) screens there is a "Code" button; clicking inserts a code tag at the cursor position. Clicking the "Close Tags" link will then inserts a closing code tag.
Code:
Coded text  looks   like    this.

Note that a fixed-pitch font is used and that multiple spaces are preserved instead of being "squeezed out". This preserves alignment, which can be critical in many cases, and helpfull in many more.
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: Fri Dec 07, 2012 10:06 pm    Post subject:
Reply with quote

Hello,

There is also a Preview function (to the left of the Submit).

Start a new topic or a reply to one. Then apply the code tag to some pgm code, jcl and data. Click Preview to see how your post will appear to the forum rather than how it looks in the Reply editor windor.

Then close the window rather than Submit (unless you are posting anyway icon_smile.gif ).
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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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