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

How to convert Numeric to Packed Decimal COMP3 in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 29, 2012 5:50 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Oct 29, 2012 6:00 pm
Reply with quote

everywhere but a COBOL forum it would be wiser to word things according to the S370/s390/zARCH terminology ( POP )
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
ibmmainframes.com/viewtopic.php?t=27921&highlight=rexx+pack+unpack
and here
ibmmainframes.com/viewtopic.php?t=41407&highlight=rexx+pack+unpack
and here
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
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

Senior Member


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

PostPosted: Wed Oct 31, 2012 2:26 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 31, 2012 2:27 pm
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: 39
Location: Brasil

PostPosted: Fri Dec 07, 2012 9:08 pm
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: 1788
Location: Bloomington, IL

PostPosted: Fri Dec 07, 2012 9:32 pm
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

Moderator Emeritus


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

PostPosted: Fri Dec 07, 2012 10:06 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top