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 Char to Bin and Bin to character in PL/I

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

New User


Joined: 10 Aug 2005
Posts: 3

PostPosted: Sun Oct 18, 2009 9:40 am    Post subject: Conversion from Char to Bin and Bin to character in PL/I
Reply with quote

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
View user's profile Send private message

Akatsukami

Global Moderator


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

PostPosted: Sun Oct 18, 2009 10:19 am    Post subject:
Reply with quote

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
View user's profile Send private message
prino

Active Member


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

PostPosted: Mon Oct 19, 2009 12:28 am    Post subject:
Reply with quote

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
View user's profile Send private message
Sudhakar9d

New User


Joined: 10 Aug 2005
Posts: 3

PostPosted: Mon Oct 19, 2009 12:34 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Oct 19, 2009 1:10 am    Post subject:
Reply with quote

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
View user's profile Send private message
Sudhakar9d

New User


Joined: 10 Aug 2005
Posts: 3

PostPosted: Mon Oct 19, 2009 1:42 am    Post subject: Reply to: Conversion from Char to Bin and Bin to character i
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Mon Oct 19, 2009 2:23 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Oct 19, 2009 2:39 am    Post subject:
Reply with quote

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
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 File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
No new posts EBCDIC to ASCII conversion using OCOPY mistah kurtz All Other Mainframe Topics 5 Tue Sep 06, 2016 2:26 pm


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