View previous topic :: View next topic
|
Author |
Message |
Sudhakar9d
New User
Joined: 10 Aug 2005 Posts: 3
|
|
|
|
How to convert Char to BIN fixed and bin fixed to character in pl/i. Please see the below code I have.
I have: DCL VSC FIXED BIN(31) and for online display I need PIC 'ZZZZZ9999' format. also from PIC 'ZZZZZ9999' TO vsc assignment
Will this work
DCL XPIC PIC 'ZZZZZ9999';
DCL VSC FIXED BIN(31) BASED(ADDR(XPIC);
Will automatically convert from VSC to XPIC format??? pls suggest. and vice versa. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
No; VSC will simply overlay the first four bytes of XPIC, giving you garbage, and possibly an 8097 on-code.
If you're programming in Enterprise PL/I, use the DECIMAL function. In MVS PL/I, automatic conversion might give you the results that you want. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Akatsukami wrote: |
No; VSC will simply overlay the first four bytes of XPIC, giving you garbage, and possibly an 8097 on-code.
If you're programming in Enterprise PL/I, use the DECIMAL function. In MVS PL/I, automatic conversion might give you the results that you want. |
In every version of PL/I both
Code: |
XPIC = VSC; /* and */
VSC = XPIC; |
Are perfectly OK. |
|
Back to top |
|
|
Sudhakar9d
New User
Joined: 10 Aug 2005 Posts: 3
|
|
|
|
Thanks for the answer.
I'm new to PL/I, Actually I want is 'REDEFINE' function cobol similary in PL/I.
I have INTEGER column in DB2 Table and DCLGEN generated as FIXED BIN(31). after getting value and calculation I need to display on screen without leading zeros. So REDEFINE in cobol would be best for this but I'm not sure in PL/I.. Pls tell what is the solution for this.
I'm not sure how to use Automatic Conversion. can you explain pls.
I tried DEFINED, BASED functions did not work, Is there anything else to REDEFINE or share memory space b/w variables in PL/I |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Actually I want is 'REDEFINE' function cobol similary in PL/I. |
Why do you believe this?
With no more to go on than the tiny bit posted, this looks like a very bad idea. . .
Maybe if you clarify just what you want to actually do and how these might be candidates for a redefine, someone might have a suggestion. |
|
Back to top |
|
|
Sudhakar9d
New User
Joined: 10 Aug 2005 Posts: 3
|
|
|
|
I use PL/I Language and ISPF Dialog panels for Online screens. I changed my DB2 table to include INTEGER column(VSC) and DCLGEN was generated copybook for this as DCL VSC FIXED BIN(31). so down the line in program I use VSC to compare in IF and other Embedded SQL statements for the same column. After all, I want display VSC field at online screen, and also users will enter the values for this field.
Ex:1. VSC = 00012345 -- I want to display on screen as 12345
Since this field is bin fixed, I can't use for display directly. So I want to map this to a PVSC PIC 'ZZZZZ9999' and use PVSC to display at on line screen for the same value.
So in order to do this I want map both variables(VSC,PVSC) to the same memory location and use any variables at any time. I do not need to move each other to make it same all time, when I use any one of these variables.
Since my screen will display in this program more than 8 times and each time I need to move VSC value to PVSC and display and receiving time move back to PVSC to VSC. This I have to do 8 time in the program if I not using the same memory location for both of the variables.
So this is the reason, I was looking for PIC and BIN variables can share same memory location and when it use, does it automatically convert to their declaration type?. Is there any other mothed to use.
In COBOL, I used 'REDEFINE' clause for this case, not sure in PL/I |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Neither COBOL nor PL/I will do this. The hex value of a PIC S9(09) COMP or FIXED BIN(31) field with value 12345 is x'00003039'. The hex value of the last 5 characters of a display field PIC ZZZZZ9999 would be x'F1F2F3F4F5' -- not at all the same, and a REDEFINES or BASED will not change them from one to the other -- only a move to another variable will do it.
I recommend you spend some time in the manuals learning the internal formats for the various data types so you will know which ones make sense to overlay and which don't. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
With no more to go on than the tiny bit posted, this looks like a very bad idea. . . |
Yup, you have now confirmed this. . .
As Robert mentioned, a redefinition of these fields/values will not perform as you want them to. |
|
Back to top |
|
|
|