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

Date with S9(8) Clause.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Jan 24, 2008 11:25 am
Reply with quote

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
Code:
1989051E


When we checked the table, the actual date which is present in the table is
Code:
19890515


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

New User


Joined: 20 Feb 2007
Posts: 11
Location: Houthalen, Belgium

PostPosted: Thu Jan 24, 2008 12:51 pm
Reply with quote

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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Jan 24, 2008 2:14 pm
Reply with quote

Thank you...

For your vivid explanation..
Back to top
View user's profile Send private message
mnnarayankar

New User


Joined: 21 Jan 2008
Posts: 23
Location: bangalore

PostPosted: Thu Jan 24, 2008 4:01 pm
Reply with quote

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

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Thu Jan 24, 2008 4:29 pm
Reply with quote

Good explanation Rudi.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jan 25, 2008 10:07 am
Reply with quote

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

New User


Joined: 21 Jan 2008
Posts: 23
Location: bangalore

PostPosted: Fri Jan 25, 2008 2:20 pm
Reply with quote

Try for

PIC S9(09) trailing with separate character
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jan 25, 2008 3:13 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Fri Jan 25, 2008 9:41 pm
Reply with quote

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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Mon Jan 28, 2008 9:40 am
Reply with quote

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

New User


Joined: 23 Mar 2007
Posts: 11
Location: India

PostPosted: Mon Jan 28, 2008 10:15 am
Reply with quote

Hi, please double check that the program is picking the correct copy book(changed version) and from the correct library.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Mon Jan 28, 2008 11:32 am
Reply with quote

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

New User


Joined: 20 Feb 2007
Posts: 11
Location: Houthalen, Belgium

PostPosted: Mon Jan 28, 2008 4:01 pm
Reply with quote

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

New User


Joined: 20 Feb 2007
Posts: 11
Location: Houthalen, Belgium

PostPosted: Mon Jan 28, 2008 4:13 pm
Reply with quote

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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Mon Jan 28, 2008 5:02 pm
Reply with quote

Sorry buddy, ur sugesstion did not work. M still getting the same error.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Mon Jan 28, 2008 5:33 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jan 28, 2008 8:46 pm
Reply with 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).
Back to top
View user's profile Send private message
mnnarayankar

New User


Joined: 21 Jan 2008
Posts: 23
Location: bangalore

PostPosted: Sun Feb 03, 2008 3:35 pm
Reply with quote

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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Mon Feb 04, 2008 9:36 am
Reply with quote

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
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 Help with SORT - I need to validate d... DFSORT/ICETOOL 5
No new posts Date format correction using dfsort DFSORT/ICETOOL 3
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts CONVERT a given date from UTC TO BST CICS 0
No new posts Pull data using date difference betwe... DB2 6
Search our Forums:

Back to Top