View previous topic :: View next topic
|
Author |
Message |
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi all,
I have a table which have a date entry in one of its column. To get a download of the table, a copybook is already created. The copybook defines the date column as
Code: |
ACCESS-DT-OUT PIC S9(8).
|
After we are downloading the table into a flat file which we are creating, the date is displayed as
When we checked the table, the actual date which is present in the table is
Can any one please let me know exactly where am I going wrong?
Should the date clause be defined as 9(8) instead of S9(8)? |
|
Back to top |
|
|
NOWAR
New User
Joined: 20 Feb 2007 Posts: 11 Location: Houthalen, Belgium
|
|
|
|
The picture S9(8) means that you can store an signed-number. If you don't need a signed number the store, it is better to use PIC 9(8) clausule.
A picture S9(8) is displayed as '1989051E', that is correct. Because the last 'E' is your + or - sign. If you want to read this number in edit mode, you must view it in hex-mode. You open your file in EDIT or BROWSE or VIEW and use the command "HEX ON" in the command-line.
Example :
------------
Code: |
Command ===> HEX ON
****** ***************************** Top of Data ****
000001 1989051E
****** **************************** Bottom of Data *** |
What you see is...
Code: |
Command ===>
****** ******************
000001 1989051E
FFFFFFFC4444444444
198905150000000000
-------------------------
****** ****************** |
Now you can read it hexadecimal, and the combination of 'C5' = 'E' = Positive number
If you would use picture 9(8) than the number is displayed like :
Code: |
Command ===>
****** ***********
000001 19890515
****** ***********
|
I hope you can understand this
Rudi |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Thank you...
For your vivid explanation.. |
|
Back to top |
|
|
mnnarayankar
New User
Joined: 21 Jan 2008 Posts: 23 Location: bangalore
|
|
|
|
Hi Swapnadeep,
If u have table with DATE column then for date column the Cpoybook contain unsigned packed decimal degits.
its copybook equivalent is pic x(10) or it may be pic 9(8).
if u r taking S9(8) thats means u r taking date as a Singed digit but it is not.
if u r taking S9(08) then use PIC S9(8) trailing with separate character
so S does not take any space.
internally it takes 4 byte. but 8 unsigned digits. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Good explanation Rudi. |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi,
Can you please explain a bit more on what you wanted to mean by trailing with seperate character?
I used PIC 9(8) instead of PIC S9(8) but to no avail. I am still getting the same display in my file. |
|
Back to top |
|
|
mnnarayankar
New User
Joined: 21 Jan 2008 Posts: 23 Location: bangalore
|
|
|
|
Try for
PIC S9(09) trailing with separate character |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi Narayan,
Can you please be a bit of more descriptive? Can you kindly explain what you mean by trailing with seperate character? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I used PIC 9(8) instead of PIC S9(8) but to no avail. I am still getting the same display in my file. |
Please post the code (data definitions and procedure statements) as well as the output from the display.
Data moved/calculated to a 9(8) field should not generate a "C" sign. . .
If you simply used a redefine and still moved to the S9(8) definition, the sign would still be there. |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi,
I have declared a copybook A, which downloads data from the table into its variable is as under:
Code: |
01 XXXXXXXX-03-PROG-GRP-LIST-OUT.
05 FILLER PIC X(1).
05 XXXXXXXX-03-EFF-DT-ID-OUT PIC S9(8).
05 FILLER PIC X(1).
05 XXXXXXXX-03-ENTRY-DT-ID-OUT PIC S9(8).
05 FILLER PIC X(1).
05 XXXXXXXX-03-SEQ-NBR-ID-OUT PIC S9(3).
05 FILLER PIC X(1).
05 XXXXXXXX-03-ACCESS-DT-OUT PIC S9(8).
|
These variables store the data and we are to write a flat file using these variables. For that purpose we have declared another copybook in the same format. The layout of the 2nd copybook is as under:
Code: |
01 PROGRAM-GROUP-LIST-OUT.
05 FILLER PIC X(1).
05 EFF-DATE-ID-OUT PIC 9(8).
05 FILLER PIC X(1).
05 ENTRY-DATE-ID-OUT PIC 9(8).
05 FILLER PIC X(1).
05 SEQUENCE-NUMBER-ID-OUT PIC S9(3).
05 FILLER PIC X(1).
05 ACCESS-DATE-OUT PIC 9(8).
|
The piece of code in which we are moving the variables for writing is as under:
Code: |
INITIALIZE PROGRAM-GROUP-LIST-OUT.
MOVE XXXXXXXX-03-PROG-GRP-LIST-OUT(WS-SUB-PCD)
TO PROGRAM-GROUP-LIST-OUT
DISPLAY 'EFF DT:' XXXXXXXX-03-EFF-DT-ID-OUT(WS-SUB-PCD).
DISPLAY 'ENT DT:' XXXXXXXX-03-ENTRY-DT-ID-OUT(WS-SUB-PCD).
MOVE PROGRAM-GROUP-LIST-OUT TO PROG-OUT
WRITE PROG-OUT
ADD 1 TO WS-COUNT-PCD.
|
The displayed format of the date variable is as under:
Code: |
****** ***************************** Top of Data ******************************
000001 OTH AA1 2005060A 2004081A 00A 2004081A 0000000{ MANUFACTURERS REPS
000002 OTH AA1 2005060A 2004072F 00A 2004072F 0000000{ MANUFACTURERS REPS
000003 OTH A01 1985100A 1994092G 00A 1994092G 0000000{ PHARMACY PROGRAM-GA¬
000004 OTH A02 1992060A 1994092G 00A 1994092G 0000000{ TEXAS PHARMACY¬ PROGRA
000005 OTH A10 1989051E 1998041G 00A 1998041G 1998040B TRAVEL AGENTS PROG¬
000006 OTH A10 1989051E 1997030F 00A 1997030F 1998040B TRAVEL AGENTS PROG¬
000007 OTH A10 1989051E 1989052F 00A 1989052F 0000000{ TRAVEL AGENTS PROG¬
000008 OTH A12 1991010A 1992080C 00A 1992080C 0000000{ INCIDENTAL EXPOSURE -
|
|
|
Back to top |
|
|
bhaktavatsala.v Warnings : 1 New User
Joined: 23 Mar 2007 Posts: 11 Location: India
|
|
|
|
Hi, please double check that the program is picking the correct copy book(changed version) and from the correct library. |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi,
I have deleted the loadlibrary that was created when the program was using the unchaged copybook. Also I have currently made all changes and the program is picking the correct copybook. |
|
Back to top |
|
|
NOWAR
New User
Joined: 20 Feb 2007 Posts: 11 Location: Houthalen, Belgium
|
|
|
|
But you display the original record ?
Code: |
DISPLAY 'EFF DT:' XXXXXXXX-03-EFF-DT-ID-OUT(WS-SUB-PCD).
DISPLAY 'ENT DT:' XXXXXXXX-03-ENTRY-DT-ID-OUT(WS-SUB-PCD). |
Maybe you must display the elements of record "PROGRAM-GROUP-LIST-OUT" ? (instead of XXXXXXXX-03-PROG-GRP-LIST-OUT)
Try this
Code: |
DISPLAY 'EFF DT:' PROGRAM-GROUP-LIST-OUT.
DISPLAY 'ENT DT:' PROGRAM-GROUP-LIST-OUT.
|
|
|
Back to top |
|
|
NOWAR
New User
Joined: 20 Feb 2007 Posts: 11 Location: Houthalen, Belgium
|
|
|
|
I'm sorry, but I think what you did show is the data of the output-file.
Also try to move the vaules in each element seperated.
For example :
Code: |
01 A
03 B PIC s9(8)
03 C PIC s9(8)
01 A-DISP
03 B-DISP PIC 9(8)
03 FILLER PIC X value ';'
03 C-DISP PIC 9(8)
|
not do this
Code: |
MOVE A TO A-DISP
WRITE RECORD FROM A-DISP |
but try this
Code: |
MOVE B TO B-DISP
MOVE C TO C-DISP
WRITE RECORD FROM A-DISP |
|
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Sorry buddy, ur sugesstion did not work. M still getting the same error. |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Sorry buddy.
Basically I had made a mistake in the copybook for which I was not getting the desired date output.
But when I corrected the copybook and used the method as suggested by you, I got the desired date display.
Thank you all for removing the error. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Code: |
MOVE XXXXXXXX-03-PROG-GRP-LIST-OUT(WS-SUB-PCD)
TO PROGRAM-GROUP-LIST-OUT |
This will not work. When the group is moved, the sign is retained and the sign is what you are trying to get rid of (if i understand correctly). |
|
Back to top |
|
|
mnnarayankar
New User
Joined: 21 Jan 2008 Posts: 23 Location: bangalore
|
|
|
|
Hi Swapnadeep,
plz do find the attachment for your problem.
its supported in cobol.
IDENTIFICATION DIVISION.
PROGRAM-ID. DATESOL.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO DD1.
SELECT OUTFILE ASSIGN TO DD2
FILE STATUS IS WS-STATUS.
DATA DIVISION.
FILE SECTION.
FD INFILE
LABEL RECORDS ARE STANDARD.
01 XXXXXXX-03-PROG-GRP-LIST-OUT.
05 FILLER PIC X(1).
05 XXXXXXXX-03-EFF-DT-ID-OUT PIC S9(8).
05 FILLER PIC X(1).
05 XXXXXXXX-03-ENTRY-DT-ID-OUT PIC S9(8).
05 FILLER PIC X(1).
05 XXXXXXXX-03-SEQ-NBR-ID-OUT PIC S9(3).
05 FILLER PIC X(1).
05 XXXXXXXX-03-ACCESS-DT-OUT PIC S9(8).
05 FILLER PIC X(49).
FD OUTFILE.
01 OUTREC PIC X(80).
WORKING-STORAGE SECTION.
01 PROGRAM-GROUP-LIST-OUT.
05 FILLER PIC X(1).
05 EFF-DATE-ID-OUT PIC 9(8).
05 FILLER PIC X(1).
05 ENTRY-DATE-ID-OUT PIC 9(8).
05 FILLER PIC X(1).
05 SEQUENCE-NUMBER-ID-OUT PIC S9(3).
05 FILLER PIC X(1).
05 ACCESS-DATE-OUT PIC 9(8).
01 WS-AREA.
05 WS-STATUS PIC X(02).
05 ARE-THERE-MORE-RECORDS PIC X VALUE 'Y'.
88 NO-MORE-RECORDS VALUE 'N'.
PROCEDURE DIVISION.
100-MAIN-PARA.
PERFORM 200-OPEN-PARA.
PERFORM 300-READ-PARA.
PERFORM 400-PROCESS-PARA UNTIL NO-MORE-RECORDS.
PERFORM 500-CLOSE-PARA.
STOP RUN.
200-OPEN-PARA.
OPEN INPUT INFILE
OUTPUT OUTFILE.
DISPLAY 'OPEN STATUS: ' WS-STATUS.
300-READ-PARA.
READ INFILE
AT END MOVE 'N' TO ARE-THERE-MORE-RECORDS
END-READ.
DISPLAY 'READ STATUS: ' WS-STATUS.
400-PROCESS-PARA.
MOVE XXXXXXXX-03-EFF-DT-ID-OUT TO EFF-DATE-ID-OUT.
MOVE XXXXXXXX-03-ENTRY-DT-ID-OUT TO ENTRY-DATE-ID-OUT.
MOVE XXXXXXXX-03-SEQ-NBR-ID-OUT TO SEQUENCE-NUMBER-ID-OUT.
MOVE XXXXXXXX-03-ACCESS-DT-OUT TO ACCESS-DATE-OUT.
WRITE OUTREC FROM PROGRAM-GROUP-LIST-OUT.
DISPLAY 'WRITE STATUS: ' WS-STATUS.
PERFORM 300-READ-PARA.
500-CLOSE-PARA.
CLOSE INFILE
OUTFILE.
infile is:
2005060A 2004081A 00A 2004081A
2005060A 2004072F 00A 2004072F
1985100A 1994092G 00A 1994092G
1992060A 1994092G 00A 1994092G
1989051E 1998041G 00A 1998041G
1989051E 1997030F 00A 1997030F
1989051E 1989052F 00A 1989052F
1991010A 1992080C 00A 1992080C
and outfile is:
20050601 20040811 00A 20040811
20050601 20040726 00A 20040726
19851001 19940927 00A 19940927
19920601 19940927 00A 19940927
19890515 19980417 00A 19980417
19890515 19970306 00A 19970306
19890515 19890526 00A 19890526
19910101 19920803 00A 19920803 |
|
Back to top |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Hi Narayanan,
Thank you for your solution.
I have used the method suggested by Nowar and that is the same which you have suggested.
Thanks a lot for posting the full COBOL code.
Dick,
Quote: |
Hello,
Code:
MOVE XXXXXXXX-03-PROG-GRP-LIST-OUT(WS-SUB-PCD)
TO PROGRAM-GROUP-LIST-OUT
This will not work. When the group is moved, the sign is retained and the sign is what you are trying to get rid of (if i understand correctly).
|
Currently what I did was, I moved the entire group in the first instance and then I am moving the variables that should not have any signs in them.[/code] |
|
Back to top |
|
|
|