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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Wed May 16, 2007 3:16 pm
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
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed May 16, 2007 4:09 pm
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed May 16, 2007 5:20 pm
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

Moderator Emeritus


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

PostPosted: Wed May 16, 2007 8:06 pm
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
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

Moderator Emeritus


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

PostPosted: Fri May 18, 2007 7:41 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top