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

Question Regarding Pic clause.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Wed Nov 14, 2007 3:12 pm
Reply with quote

Can I move an element (having pic comp5 which is just comp) to another element that is comp-3?
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Nov 14, 2007 3:16 pm
Reply with quote

Did you make a try?What was the result?
Back to top
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Wed Nov 14, 2007 3:19 pm
Reply with quote

Hi,
I did compile the program successfully but i dont know whether it will work during run time that i cannot check because application can be run by client only.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Nov 14, 2007 3:43 pm
Reply with quote

The move from COMP to COMP-3 is valid provided the variables are of same size.
Please provide the piece of code fordeclaration and move so that we could help you more.
Back to top
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Wed Nov 14, 2007 3:51 pm
Reply with quote

01 AT1 PIC S9(00004) COMP.
01 AT2 PIC S9(00012)V9(06) COMP-3 .

Move At1
To At2
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 4:16 pm
Reply with quote

A numeric move works just fine, from four digits to larger works just fine.....
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Nov 14, 2007 7:54 pm
Reply with quote

jackal,
Quote:
Can I move an element (having pic comp5 which is just comp) to another element that is comp-3?

PIC 9(1) COMP-5 can accomodate numeric values from 0 to 65535.
PIC 9(1) COMP-3 can accomodate numeric values from 0 to 9.

suppose if PIC 9(1) COMP-5 contain the value 65535 and is moved to PIC 9(1) COMP-3, the result from PIC 9(1) COMP-3 will be 5 and 6553 will get truncated.

Example code:
Code:
       IDENTIFICATION DIVISION.                             
       PROGRAM-ID. COMP5.                                   
       DATA DIVISION.                                       
       WORKING-STORAGE SECTION.                             
       77 WS-A PIC 9(1) COMP-5 VALUE ZERO.                   
       77 WS-B PIC 9(1) COMP-3 VALUE ZERO.                   
       PROCEDURE DIVISION.                                   
           DISPLAY 'WS-A ' WS-A ' ==> INITIAL  VALUE'       
           DISPLAY 'WS-B ' WS-B '     ==> INITIAL  VALUE'   
           PERFORM 65535 TIMES                               
           COMPUTE WS-A = WS-A + 1                           
           END-PERFORM                                       
           DISPLAY 'WS-A ' WS-A ' ==> COMPUTED VALUE'       
           MOVE WS-A TO WS-B                                 
           DISPLAY 'WS-B ' WS-B '     ==> MOVED    VALUE'   
           GOBACK.                                           

Output:
Code:
WS-A 00000 ==> INITIAL  VALUE
WS-B 0     ==> INITIAL  VALUE
WS-A 65535 ==> COMPUTED VALUE
WS-B 5     ==> MOVED    VALUE

Please post the working-storage declaration for PIC COMP-5 variable. So that it will be easy to suggest you how to declare PIC COMP-3 variable which will get the input value(s) from PIC COMP-5 variable.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Nov 14, 2007 8:56 pm
Reply with quote

jackal,
Quote:
Can I move an element (having pic comp5 which is just comp) to another element that is comp-3?

Quote:
01 AT1 PIC S9(00004) COMP.
01 AT2 PIC S9(00012)V9(06) COMP-3 .

Move At1
To At2


In your first post you mentioned COMP-5 and in the latest post you mentioned as COMP.

Suppose if you are moving COMP-5 to COMP-3, use appropriate PIC 9(x)V9(y) COMP-3.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Nov 14, 2007 10:50 pm
Reply with quote

Hello,

Quote:
I did compile the program successfully but i dont know whether it will work during run time that i cannot check because application can be run by client only.
I suggest you test this (and any other code about which you are unsure) in a test program of your own. This program would have no business-rules logic. It would be only for testing.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Nov 15, 2007 1:29 am
Reply with quote

Jackal,

You said: i cannot check because application can be run by client only.

Ouch... This is not an acceptable situation to be in. Programmers must be able to test their code. This is a basic requirement. I suspect you know this already yet somehow managed to find yourself in a crazy situation that prevents you from testing your code.

Do not stay in this situation. Change the situation so that you can test what you code. If you can't change the situation, then perhaps transfer to an area that does permit their programmers to test their own code...

As well, the question you asked can be answered by making a test program. You don't have to use a production program to test this out. I have hundreds of test programs hanging around that I use to test things out.

But like I said, you need to be able to test your own code.
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 Question for file manager IBM Tools 7
No new posts To search DB2 table based on Conditio... DB2 1
No new posts question for Pedro TSO/ISPF 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
Search our Forums:

Back to Top