Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
pic 9(6) to pic s9(9) comp

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
isys2006

New User


Joined: 11 Mar 2006
Posts: 13

PostPosted: Tue Oct 03, 2006 9:51 pm    Post subject: pic 9(6) to pic s9(9) comp
Reply with quote

Hi
I have a variable from an input file defined as pic 9(6).I need to write this into an output file as pic s9(9) comp variable (4 bytes) after performing some validations.
how do i achieve this conversion and wat is the value of the variable in the output file?
sample input say 200603

I tried the following method. I moved the 9(6) into a S9(9) variable and moved that into the comp variable.But when i opened the output file i could see only 2006.

TIA

ram
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Oct 03, 2006 10:17 pm    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

ram,

Can you please post the actual variable definitions with levels, and the actual code you use to move the variables.

My suspicion is that you moving a higher level group variable to the 'pic s9(9) comp' field, not the s9(9) variable.

Your should be able to move the 9(6) directly to the S9(9) comp variable.

Dave
Back to top
View user's profile Send private message
isys2006

New User


Joined: 11 Mar 2006
Posts: 13

PostPosted: Wed Oct 04, 2006 8:15 am    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Hi Dave
The 9(6) variable is a level 05 variable. The s9(9) and the comp variable has also been defined as a level 05 variable.
Let me try the 'move' again & I will let you know.


Thanks
ram
Back to top
View user's profile Send private message
isys2006

New User


Joined: 11 Mar 2006
Posts: 13

PostPosted: Wed Oct 04, 2006 8:47 am    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Hi Dave
I tried moving the 9(6) variable (value : 200603 & level 05 variable) to the S9(9) Comp variable (level 05 variable ). In the output file the value written was 2006
Obviously that value in the output file is incorrect.
Also could you let me know if there are any Compiler Options that can be used.


Thanks
Ram
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Oct 04, 2006 10:23 pm    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Ram,

Please post the source code for the working storage and move statement. I don't see why the move wouldn't work.

I'll copy and compile and run it on my machine

Dave
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Thu Oct 05, 2006 6:11 pm    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Yes, I agree with David. Direct move itself should work. Post the source code.

Noor
Back to top
View user's profile Send private message
isys2006

New User


Joined: 11 Mar 2006
Posts: 13

PostPosted: Fri Oct 06, 2006 8:19 am    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Hi Dave
Here's the code snippet.

01 WS-PERFORMANCE-RECORD.
05 FUNDNAME PIC X(30) VALUE SPACES.
05 LOAD-YEAR-MONTH PIC S9(9) COMP VALUE ZEROS.
05 YEAR-MONTH PIC S9(9) COMP VALUE ZEROS.
***********************************************************
01 FUNDNAME-O-1.
05 FUNDNAME-O PIC X(30)
OCCURS 40 TIMES.
01 LOAD-YEAR-MONTH-O-1.
05 LOAD-YEAR-MONTH-O OCCURS 40 TIMES.
10 LOAD-YEAR PIC 9(4).
10 LOAD-MONTH PIC 9(2).
01 YEAR-MONTH-O-1.
05 YEAR-MONTH-O OCCURS 40 TIMES.
10 YEAR-O PIC 9(4).
10 MONTH-O PIC 9(2).

******************************************************************
5000-WRITE-RECORD.
******************************************************************

MOVE ZEROS TO WS-COUNT2,WS-TEMPORARY
MOVE 1 TO WS-COUNT3
PERFORM UNTIL WS-COUNT3 > 40
IF KEYS(WS-COUNT3) = 0
MOVE FUNDNAME-O(WS-COUNT3) TO FUNDNAME
MOVE LOAD-YEAR-MONTH-O(WS-COUNT3) TO LOAD-YEAR-MONTH
MOVE YEAR-MONTH-O(WS-COUNT3) TO YEAR-MONTH


Thanks
Ram
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Oct 06, 2006 7:51 pm    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Ram,

The problem you are having comes from the move of
YEAR-MONTH-O(WS-COUNT3) TO YEAR-MONTH.

Although YEAR-O and MONTH-O are defined as PIC 9(), YEAR-MONTH-O is defines by default as PIC X(). When you move the PIC X() field to the PIC 9() COMP field no conversion takes place and is moved byte by byte and is truncated after the 4th character. That?s why you see ?2006? in the COMP field.

There are a couple of ways to correct this.

05 YEAR-MONTH-O OCCURS 40 TIMES.
10 YEAR-MONTH-9 PIC 9(6).
10 FILLER REDEFINES YEAR-MONTH-O.
15 YEAR-O PIC 9(4).
15 MONTH-O PIC 9(2).

MOVE YEAR-MONTH-9(WS-COUNT-3) TO YEAR-MONTH.

Or

01 YEAR-MONTH-9 PIC 9(6).

MOVE YEAR-MONTH-O(WS-COUNT3) TO YEAR-MONTH-9.
MOVE YEAR-MONTH-9 TO YEAR-MONTH.

Dave
Back to top
View user's profile Send private message
isys2006

New User


Joined: 11 Mar 2006
Posts: 13

PostPosted: Fri Oct 06, 2006 9:16 pm    Post subject: Re: pic 9(6) to pic s9(9) comp
Reply with quote

Hi Dave
Gr8 explanation. Thanx a ton!!!! icon_biggrin.gif
I will check it over the weekend & let you know how it went.

Thanks
Ram
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us