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
 

 

Want to unpack an 01 A S9(3) comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mpriya_r

New User


Joined: 25 Jul 2006
Posts: 6
Location: bangalore

PostPosted: Wed May 16, 2007 2:05 pm    Post subject: Want to unpack an 01 A S9(3) comp-3
Reply with quote

I want to unpack an 01 A S9(3) comp-3
For ex. A holds 01j,after unpacking I must get only-11 and it must apply for 3 digit also(ex.-161).

I tried the following options :

Trail 1 : If I use -99,it works fine for 2 digit numbers hence I get proper value i.e., -11.But this does not work well for 9(3) cases.

Trail 2 : When I use -Z99,result is - 11(ie., - followed by a space and then 11

Trail 3 : When I use --99,result is -11(i.e, a space folowed by -11).Is there a way to pad leading spaces(b4 - sign)?

Guyz, can you tell me if you have other suggestions?
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed May 16, 2007 3:16 pm    Post subject: Re: Unpacking COMP-3
Reply with quote

mpriya_r wrote:
Is there a way to pad leading spaces(b4 - sign)?
Is this the question? #3 gave it to you, what else are you looking for?
Have you tried to digest the section on PICTURE clause editing?
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Wed May 16, 2007 3:42 pm    Post subject: Re: Unpacking COMP-3
Reply with quote

Hi,
Can u try giving Like this
Example:

declare as -999 for s9(3) result would be -011

declare as -z99 for s9(3) result would be -11
Since Z(-) would supress zero.
Back to top
View user's profile Send private message
mpriya_r

New User


Joined: 25 Jul 2006
Posts: 6
Location: bangalore

PostPosted: Wed May 16, 2007 4:01 pm    Post subject:
Reply with quote

Its true that -z99 gives u -11,but if u notice the result will -(space)11.i.e., a space gets inserted between - and 11.The problem is I need to overcome that space and get it as a whole number i.,e. -11(I can get it fine with pic -99, but I face the problem for 3 digits,say -161)
Back to top
View user's profile Send private message
mpriya_r

New User


Joined: 25 Jul 2006
Posts: 6
Location: bangalore

PostPosted: Wed May 16, 2007 4:04 pm    Post subject: Re: Unpacking COMP-3
Reply with quote

William Thompson wrote:
mpriya_r wrote:
Is there a way to pad leading spaces(b4 - sign)?
Is this the question? #3 gave it to you, what else are you looking for?
Have you tried to digest the section on PICTURE clause editing?


I need to get similar results for 3 digits , say, -161
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed May 16, 2007 4:09 pm    Post subject:
Reply with quote

How is #3 not giving you that?
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Wed May 16, 2007 4:21 pm    Post subject: Re: Unpacking COMP-3
Reply with quote

I can't understand ur question,

If u defined as s9(3), Then 3 bytes is allocated. So u can get the output as
-(Space)11 , I think there is no way to supress space, Instead of Zero we make it as Space using Edit character, If u supress the space then ur record lenght will vary . It would be better if u give me ur requriment .

Thanks.
Ram
Back to top
View user's profile Send private message
mpriya_r

New User


Joined: 25 Jul 2006
Posts: 6
Location: bangalore

PostPosted: Wed May 16, 2007 4:50 pm    Post subject:
Reply with quote

Ok, see I have a variable: A S9(3) comp-3 and now I have to unpack it and get a whole number which does not have any spaces in beween or leading spaces because I need to use it for further processing.
So the pic clause I use must give me -11(if actual digits are 2) or -111(if actual digits are 3)
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed May 16, 2007 5:20 pm    Post subject:
Reply with quote

Again, your #3,
Code:
--99
will produce '-111' and 'b-11' where b is a space. The edit picture is four bytes, something has to occupy the leading byte.
If this isn't what you want, you will have to explain it more clearly.
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: Wed May 16, 2007 8:06 pm    Post subject:
Reply with quote

Hello,

What you want is not a standard edited output.

Is there some real reason the output must be left-aligned with one minus sign and no blanks?

If you really have to present the result in this fashion, redefine the output field and move the meaningful data to the left one position and move a space to right-most byte.
Back to top
View user's profile Send private message
mpriya_r

New User


Joined: 25 Jul 2006
Posts: 6
Location: bangalore

PostPosted: Fri May 18, 2007 2:19 pm    Post subject:
Reply with quote

Hello dick,

Thanx for the suggestion.This is the one I was looking for.Thanks a lot.
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 May 18, 2007 7:41 pm    Post subject:
Reply with quote

You're welcome 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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


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