View previous topic :: View next topic
|
Author |
Message |
vicharapusrinu Warnings : 1 New User
Joined: 04 Dec 2006 Posts: 63 Location: Hyderabad
|
|
|
|
Hi,
Could you please help me out here?
I am trying to move Moving of data from 9 (7) to9 (7) comp-3 with below code
Code: |
01 WS-TODAYS-CYYMMDD-V3.
05 WS-TODAY-C-V3 PIC 9(1).
05 WS-TODAY-YYMMDD-V3 PIC 9(6).
01 WS-FILE-DATE.
05 WS-FILE-C PIC 9(1).
05 WS-FILE-YY PIC 9(2).
05 WS-FILE-MM PIC 9(2).
05 WS-FILE-DD PIC 9(2).
10 WS-AAAAAAAA-DATE1 COMP-3 PIC 9(007) VALUE ZERO.
10 WS-AAAAAAAA-DATE2 COMP-3 PIC 9(007) VALUE ZERO.
MOVE WS-TODAYS-CYYMMDD-V3 TO WS-AAAAAAAA-DATE1
MOVE WS-FILE-DATE TO WS-AAAAAAAA-DATE2 |
But data is not received to below fields, some junk is getting moved.
WS-AAAAAAAA-DATE1
WS-AAAAAAAA-DATE2 |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi vicharapusrinu,
Quote: |
some junk is getting moved. |
Why do you think so ? |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Code: |
05 WS-WORK23 PIC 9(06).
05 WS-WORK24 PIC 9(06) USAGE IS COMP-3.
*
PROCEDURE DIVISION.
*
MAIN-LINE-PARA.
*
MOVE 090910 TO WS-WORK23.
MOVE WS-WORK23 TO WS-WORK24.
DISPLAY WS-WORK24.
STOP RUN.
* |
Output
Seems to be working fine for me ... |
|
Back to top |
|
|
vicharapusrinu Warnings : 1 New User
Joined: 04 Dec 2006 Posts: 63 Location: Hyderabad
|
|
|
|
Binop B,
Thanks for your quick response.
My piece of code is like this
Code: |
DISPLAY 'WS-TODAYS-CYYMMDD-V3' WS-TODAYS-CYYMMDD-V3
DISPLAY 'WS-FILE-DATE' WS-FILE-DATE
MOVE WS-C3-V3L2 TO WS-S9ZK1531-DATE1
MOVE WS-FILE-DATE TO WS-S9ZK1531-DATE2
DISPLAY 'WS-S9ZK1531-DATE1 'WS-S9ZK1531-DATE1
DISPLAY 'WS-S9ZK1531-DATE2 'WS-S9ZK1531-DATE2 |
Before move statement the variable consists of
WS-TODAYS-CYYMMDD-V3:: 2100909
WS-FILE-DATE:: 2100514
After move statement
WS-S9ZK1531-DATE1:: 2 1 0
WS-S9ZK1531-DATE2:: 2 1 0
But I am expecting
WS-S9ZK1531-DATE1::2100909
WS-S9ZK1531-DATE2::2100514 |
|
Back to top |
|
|
vicharapusrinu Warnings : 1 New User
Joined: 04 Dec 2006 Posts: 63 Location: Hyderabad
|
|
|
|
Sorry
My piece of code is like this
Code: |
DISPLAY 'WS-TODAYS-CYYMMDD-V3' WS-TODAYS-CYYMMDD-V3
DISPLAY 'WS-FILE-DATE' WS-FILE-DATE
MOVE WS-TODAYS-CYYMMDD-V3 TO WS-S9ZK1531-DATE1 ------change
MOVE WS-FILE-DATE TO WS-S9ZK1531-DATE2
DISPLAY 'WS-S9ZK1531-DATE1 'WS-S9ZK1531-DATE1
DISPLAY 'WS-S9ZK1531-DATE2 'WS-S9ZK1531-DATE2 |
|
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Code: |
01 WS-FILE-DATE.
05 WS-FILE-C PIC 9(1).
05 WS-FILE-YY PIC 9(2).
05 WS-FILE-MM PIC 9(2).
05 WS-FILE-DD PIC 9(2).
01 WS-FILE-DATE-R REDEFINES WS-FILE-DATE
PIC 9(7). |
and use WS-FILE-DATE-R instead of WS-FILE-DATE.
Am leaving reasoning behind this to be found out by you... |
|
Back to top |
|
|
BhavaniV
New User
Joined: 23 Aug 2010 Posts: 5 Location: Chennai
|
|
|
|
I think the reason is as follows:
The group variable declared would be considered as X(07).
So while moving, it would not be possible to move it to a COMP-3 variable. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi BhavaniV,
Quote: |
So while moving, it would not be possible to move it to a COMP-3 variable. |
I wouldn't necessarily term it as "not possible" as the OP's post clearly depicts that the MOVE statement will work though not as expected... ... But yeah... the reason is because the variable will be considered as AlphaNumeric. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
You can move to a comp-3 variable but you can not do a group move like you are trying. In COBOL there is a big difference between group moves and elementary item moves. You need to read the cobol language reference. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
REDEFINE WS-TODAYS-CYYMMDD-V3 and WS-FILE-DATE as PIC 9(7) and MOVE them to your receiving fields. |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
For example like that:
Code: |
01 WS-TODAYS-CYYMMDD-V3.
05 WS-TODAY-C-V3 PIC 9(1).
05 WS-TODAY-YYMMDD-V3 PIC 9(6).
01 WS-TODAYS-CYYMMDD-V3-RED REDEFINES
WS-TODAYS-CYYMMDD-V3 PIC 9(7).
01 WS-FILE-DATE.
05 WS-FILE-C PIC 9(1).
05 WS-FILE-YY PIC 9(2).
05 WS-FILE-MM PIC 9(2).
05 WS-FILE-DD PIC 9(2).
01 WS-FILE-DATE-RED REDEFINES
WS-FILE-DATE PIC 9(7).
10 WS-AAAAAAAA-DATE1 COMP-3 PIC 9(007) VALUE ZERO.
10 WS-AAAAAAAA-DATE2 COMP-3 PIC 9(007) VALUE ZERO.
MOVE WS-TODAYS-CYYMMDD-V3-RED TO WS-AAAAAAAA-DATE1
MOVE WS-FILE-DATE-RED TO WS-AAAAAAAA-DATE2
|
Cheers. Kurt |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
BhavaniV wrote: |
I think the reason is as follows:
The group variable declared would be considered as X(07).
So while moving, it would not be possible to move it to a COMP-3 variable. |
The group variable will not be considered as some specific type. Cobol simply does no type conversions when doing a group move, that's why! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Kjeld, from 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. In a group move, the receiving area is filled without consideration for the individual elementary items contained within either the sending area or the receiving area, except as noted in the OCCURS clause. |
|
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Thanks for clarifying, Robert, the manual states it clearly . |
|
Back to top |
|
|
BhavaniV
New User
Joined: 23 Aug 2010 Posts: 5 Location: Chennai
|
|
|
|
Thanks |
|
Back to top |
|
|
|