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

Moving of data from 9 (7) to9 (7) comp-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vicharapusrinu
Warnings : 1

New User


Joined: 04 Dec 2006
Posts: 63
Location: Hyderabad

PostPosted: Thu Sep 09, 2010 10:34 am
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Sep 09, 2010 11:56 am
Reply with quote

Hi vicharapusrinu,
Quote:
some junk is getting moved.
Why do you think so ?
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Sep 09, 2010 12:06 pm
Reply with quote

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
Code:
090910


Seems to be working fine for me ...
Back to top
View user's profile Send private message
vicharapusrinu
Warnings : 1

New User


Joined: 04 Dec 2006
Posts: 63
Location: Hyderabad

PostPosted: Thu Sep 09, 2010 12:19 pm
Reply with quote

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
View user's profile Send private message
vicharapusrinu
Warnings : 1

New User


Joined: 04 Dec 2006
Posts: 63
Location: Hyderabad

PostPosted: Thu Sep 09, 2010 12:26 pm
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Sep 09, 2010 12:31 pm
Reply with quote

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... icon_wink.gif
Back to top
View user's profile Send private message
BhavaniV

New User


Joined: 23 Aug 2010
Posts: 5
Location: Chennai

PostPosted: Thu Sep 09, 2010 3:12 pm
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Sep 09, 2010 7:06 pm
Reply with quote

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... icon_smile.gif ... But yeah... the reason is because the variable will be considered as AlphaNumeric.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Sep 09, 2010 7:23 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Sep 10, 2010 5:08 am
Reply with quote

Hi,

REDEFINE WS-TODAYS-CYYMMDD-V3 and WS-FILE-DATE as PIC 9(7) and MOVE them to your receiving fields.
Back to top
View user's profile Send private message
Kurt Deininger

New User


Joined: 13 Jul 2010
Posts: 19
Location: Frankfurt/Germany

PostPosted: Fri Sep 10, 2010 2:36 pm
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Sat Sep 11, 2010 1:29 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Sep 11, 2010 4:21 am
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Sep 13, 2010 1:20 pm
Reply with quote

Thanks for clarifying, Robert, the manual states it clearly icon_smile.gif .
Back to top
View user's profile Send private message
BhavaniV

New User


Joined: 23 Aug 2010
Posts: 5
Location: Chennai

PostPosted: Mon Sep 13, 2010 5:32 pm
Reply with quote

Thanks
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top