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

MOVE X(6) TO S9(5) COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Aug 10, 2010 2:24 pm
Reply with quote


Is this possible to move an alphanumeric X(6)to s9(5)comp-3 value
Code:

05 WS-DATA-DATAL
   10 WS-ON-HAND-QTY-SIGN            PIC X(01).
           88 WS-ON-HAND-QTY-NEG        VALUE '-'.
   10 WS-ON-HAND-QTY                 PIC  X(05).

05 ON-HAND    S9(5) COMP-3

MOVE WS-DATA-DATAL TO ON-HAND     


If we can't then how can i move this 6 byte value to s9(5) comp-3 value
Also i should validate the sign of on-hand
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Aug 10, 2010 3:02 pm
Reply with quote

There is a link to manuals at the top of the page. You need to click on it, find the COBOL manuals for your system, and read them. Start with the REDEFINES statement and internal formats.

Per the COBOL Language Reference manual section 6.2.24.3,
Quote:
A group move is treated as though it were an alphanumeric-to-alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another.
So you can certainly move an X(6) group to an S9(5) COMP-3 variable. However, since there is no conversion occurring, any use of the S9(5) COMP-3 variable for arithmetic (or pretty much anything, actually) will cause a S0C7 abend in your program as the internal formats are completely different.
Back to top
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Aug 10, 2010 3:17 pm
Reply with quote

Hi,
Please provide the link directly that contains cobol reference manual
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Aug 10, 2010 3:27 pm
Reply with quote

Gopalakrishnan V wrote:
Hi,
Please provide the link directly that contains cobol reference manual

please look for yourself
look at your screen and see if you can find the words "IBM Manuals".
Isn't "can work independently" in your job description ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Aug 10, 2010 3:32 pm
Reply with quote

From my earlier post:
Quote:
There is a link to manuals at the top of the page. You need to click on it, find the COBOL manuals for your system, and read them. Start with the REDEFINES statement and internal formats.
You need to click the link yourself -- we cannot click it for you. And since there are three versions of manuals provided (IBM has released a number of COBOL compilers over the years), I cannot tell you which of the three is appropriate for you.

Are you really sure you are ready for a career in iT? Listing yourself as having skill in JCL, COBOL, VSAM, and DB2 while being unable to answer a simple MOVE statement question -- or being able to find manuals when provided the information about getting to them -- is not a good indication of future success in a field where attention to detail is critical.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Aug 10, 2010 3:41 pm
Reply with quote

Hi !

If WS-ON-HAND-QTY is completely filled with numerics, you could move.
If not, you could not.

F1F2F3F4F5 --> 12345C
Back to top
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Aug 10, 2010 3:48 pm
Reply with quote

Sorry Robert

i found it in google....I don't know why I couldn't find that link in my screen. I think May be some settings to my accoount..


I am new to mainframe but i can learn mainframe quickly. So don't discourage me.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Aug 10, 2010 4:01 pm
Reply with quote

From what I've seen, the manuals link is on every screen of this forum. Why you couldn't find it is a good question.

UmeySan: this is a group move, not an elementary move. The conversion will not happen so the COMP-3 data will be X'F1F2F3' in your example. See section 6.2.24.3 of the COBOL Language Reference manual I cited earlier.
Back to top
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Aug 10, 2010 4:27 pm
Reply with quote

Sorry Robert due to some problem in my browser i couldn't found that manual link. But now its fine...

due to lack of space(bytes) in my copybook i have to move these X(6) to S9(5) comp-3. Please let me know if any other ways
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Aug 10, 2010 4:56 pm
Reply with quote

Six-bytes display will not fit (pack) into Three-bytes packed-decimal. You will lose the high-order (leftmost) display byte. This would work only if the COMP-3 (Packed-Decimal) field were PIC S9(07) COMP-3 (Four-bytes).

As far as incorporating the sign-nibble into the COMP-3 field, that should not be too tough to figure out.

You may not have any other choice but to expand the copybook.

However, if (and this is a big IF), the high-order display byte will always be ZERO (confirmation required), then you'd be OK, but this would only be an act of desperation and is not recommended.

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Aug 10, 2010 5:09 pm
Reply with quote

Apologies, I read this wrong. You only have Five-bytes display to contend with. icon_rolleyes.gif

Slowly wiping egg from face.... icon_redface.gif

Bill
Back to top
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Aug 10, 2010 5:15 pm
Reply with quote

hi Bill O'Boyle,

In that Six byte the sign field also included.

So s9(5) comp-3 will have 3 byte and six field position(ie 6 nibble)
so first nibble will have sign and next 5 nibble will have values from WS-ON-HAND-QTY(assume always numeric)

Is this Correct!!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 10, 2010 5:24 pm
Reply with quote

Gopalakrishnan V wrote:
Is this Correct!!


No.

1.3.4.7 Examples: numeric data and internal representation
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Aug 10, 2010 6:36 pm
Reply with quote

How about something like this:
Code:
05 WS-DATA-DATAL
   10 WS-ON-HAND-QTY-SIGN            PIC X(01).
           88 WS-ON-HAND-QTY-NEG        VALUE '-'.
   10 WS-ON-HAND-QTY                 PIC  X(05).

05 ON-HAND    S9(5) COMP-3

05 WS-DATA-WORKX   PIC X(06).
05 WS-DATA-WORKN  REDEFINES WS-DATA-WORKX
       PIC S9(6) SIGN LEADING SEPARATE.

MOVE WS-DATA-DATAL TO WS-DATA-WORKX
EVALUATE WS-ON-HAND-QTY-SIGN
   WHEN '+'
   WHEN '-'
      IF WS-ON-HAND-QTY IS NUMERIC
         MOVE WS-DATA-WORKN TO ON-HAND
      ELSE
         PERFORM NON-NUMERIC-ROUTINE
      END-IF
   WHEN OTHER
      PERFORM INVALID-SIGN-ROUTINE
END-EVALUATE
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Aug 11, 2010 6:33 am
Reply with quote

Hi VGK,

You could try this:

Code:
IF WS-ON-HAND-QTY IS NUMERIC
   MOVE WS-ON-HAND-QTY TO ON-HAND
   IF WS-ON-HAND-QTY-SIGN = '-'
      MULTIPLY ON-HAND BY -1
   END-IF
ELSE
   PERFORM GET-HELP
END-IF


For the purists out there you could also ELSE the 2nd IF and MULTIPLY ON-HAND by +1 to produce a more efficient positive sign.

P.S. The more editing you do the more sleep you'll get.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Aug 11, 2010 8:25 am
Reply with quote

I thought it was nybble.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Aug 14, 2010 5:55 am
Reply with quote

Why quybble?
Back to top
View user's profile Send private message
santy
Warnings : 1

New User


Joined: 19 Jul 2007
Posts: 22
Location: mumbai

PostPosted: Wed Aug 18, 2010 4:26 pm
Reply with quote

hi gopala,

--If we can't then how can i move this 6 byte value to s9(5) comp-3 value

Ans for your question is that, u can move the value of WS-DATA-DATAL into ON-HAND but their are some condition as below.

1. all value contain by WS-DATA-DATAL should be numeric, also some of value will be trancated while moving value into ON-HAND variable, because it is defiend as s9(5) comp-3 which store 3 byts value. so your numeric value of WS-DATA-DATAL variable will be trancated from right side.
2. if the variable WS-DATA-DATAL contain non-numeric then u can't move the value into ON-HAND variable, u will get SOC7 abend.

Hope this will help you to clear your doubt.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 18, 2010 5:34 pm
Reply with quote

with the incorporation of a redefine and the addition of an 88 level,
the following code will meet the expectations of the TS
without any truncation:
Code:

05 WS-DATA-DATAL
   10 WS-ON-HAND-QTY-SIGN            PIC X(01).
      88 WS-ON-HAND-QTY-NEG          VALUE '-'.
      88 WS-ON-HAND-SIGN-VALID       VALUES '+' , '-'.
   10 WS-ON-HAND-QTY                 PIC  X(05).
   10 WS-ON-HAND-QTY-N
      REDEFINES
      WS-ON-HAND-QTY                 PIC 9(5),

05 ON-HAND                           S9(5) COMP-3

IF  WS-ON-HAND-SIGN-VALID
THEN
    CONTINUE
ELSE
    SET WS-ON-HAND-SIGN-VALID    TO TRUE
END-IF
   
IF  WS-ON-HAND-QTY-N NUMERIC
THEN
    COMPUTE ON-HAND = NUMVAL(WS-DATA-DATAL)
ELSE
    PERFORM NON-NUMERIC-ERROR-REPORT
    MOVE ZERO TO ON-HAND
END-IF
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 How to move the first field of each r... DFSORT/ICETOOL 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 How to move DB2 Installation HLQ DB2 4
Search our Forums:

Back to Top