View previous topic :: View next topic
|
Author |
Message |
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
Hi,
Please provide the link directly that contains cobol reference manual |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
If WS-ON-HAND-QTY is completely filled with numerics, you could move.
If not, you could not.
F1F2F3F4F5 --> 12345C |
|
Back to top |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Apologies, I read this wrong. You only have Five-bytes display to contend with.
Slowly wiping egg from face....
Bill |
|
Back to top |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
I thought it was nybble. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Why quybble? |
|
Back to top |
|
|
santy Warnings : 1 New User
Joined: 19 Jul 2007 Posts: 22 Location: mumbai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|