View previous topic :: View next topic
|
Author |
Message |
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
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 |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
noorkh
New User
Joined: 06 Mar 2006 Posts: 76 Location: Chennai
|
|
|
|
Yes, I agree with David. Direct move itself should work. Post the source code.
Noor |
|
Back to top |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
isys2006
New User
Joined: 11 Mar 2006 Posts: 13
|
|
|
|
Hi Dave
Gr8 explanation. Thanx a ton!!!!
I will check it over the weekend & let you know how it went.
Thanks
Ram |
|
Back to top |
|
|
|