IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

How can we compress char length in PL1?

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> PL/I & ASSEMBLER
View previous topic :: View next topic  
Author Message
surendra_mainframe



Joined: 18 Oct 2005
Posts: 5

Posted: Wed Nov 23, 2005 6:49 pm    Post subject: How can we compress char length in PL1?  

Hi,

Can anyone convert char(3) into char(2) in PL1 just like Comp3 in Cobol?


Surendra
Back to top  
karthik srinivasan



Joined: 07 Oct 2005
Posts: 6
Location: chennai

Posted: Wed Nov 23, 2005 7:32 pm    Post subject: Re: How can we compress char length in PL1?  

HI Surendra,

I am not sure of compressing technique in PL1 , but for the situtation which u are facing you can declare the variable as

DCL ABC CHAR(2) VARYING

when a variable is declared as varying, the srorage allocation for the variable is 2 + 2 bytes ( in extra).

I hope this helps

Thanks
Karthik Srinivasan
Back to top  
surendra_mainframe



Joined: 18 Oct 2005
Posts: 5

Posted: Wed Nov 23, 2005 8:02 pm    Post subject: Thanx Karthik  

But still when i am doing char(2) = char(3) , result of char(2) variable is truncating the data.
Back to top  
k_vikram07



Joined: 23 Nov 2005
Posts: 34

Posted: Wed Nov 23, 2005 8:17 pm    Post subject:  

I don't think we can do this in any language either in Cobol or PL1.

The cobol comp-3 is not for char. it is for numeric.

We do have such a thing for numeric items in Pl1. But not for Char.

You may however raise a condition to stop this truncation if it ever happens.


Thanks
Vik.
Back to top  
nutakkimurali



Joined: 15 Nov 2005
Posts: 22

Posted: Fri Nov 25, 2005 11:55 am    Post subject: Re: How can we compress char length in PL1?  

Hi karthi,

Why it allocates 2+2 when u dec the 2 bytes variable with varying option

Please let me know

DCL ABC CHAR(2) VARYING

when a variable is declared as varying, the srorage allocation for the variable is 2 + 2 bytes ( in extra).
Muralee
Back to top  
karthik srinivasan



Joined: 07 Oct 2005
Posts: 6
Location: chennai

Posted: Fri Nov 25, 2005 2:20 pm    Post subject: Re: How can we compress char length in PL1?  

HI Murali...

The two bytes which is being added is for storing the length of the string.
THE LEFT MOST 2 BYTES CONTAIN THE LENGTH OF THE STRING

ie) 2 bytes ( this is for char(2) ) + 2 bytes ( this is for storing the length )

Hope this helps.....

Thanks & Regards
Karthik Srinivasan
Back to top  
nutakkimurali



Joined: 15 Nov 2005
Posts: 22

Posted: Fri Nov 25, 2005 3:47 pm    Post subject: Re: How can we compress char length in PL1?  

Karthik Thank you for your input

Muralee
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> PL/I & ASSEMBLER
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM