View previous topic :: View next topic
|
Author |
Message |
shyam6385
New User
Joined: 14 Oct 2009 Posts: 6 Location: bangalore
|
|
|
|
Hi
I am trying to write a cobol pgm which reads a sequential file and write to a ksds file.
my program is running successful but i am not able to write the records into ksds
i checked with my program by placing display statements everywhere and found that write statement is not running well
can you please find the error(logical one) in my program...
iam copying my program here
Code: |
*PROGRAM TO READ SEQUENTIAL FILE AND WRITE THE CONTENTS TO KSDS
IDENTIFICATION DIVISION.
PROGRAM-ID. SEQ2KSDS.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SOURCE-FILE ASSIGN TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS WS-SEQ-STAT-CODE.
SELECT DESTINATION-FILE ASSIGN TO DD2
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS DEST-EMP-NO
FILE STATUS IS WS-KSDS-STAT-CODE.
DATA DIVISION.
FILE SECTION.
FD SOURCE-FILE.
01 SOURCE-REC.
05 SOURCE-EMP-NO PIC 9(5).
05 FILLER PIC X(1).
05 SOURCE-EMP-NM PIC X(25).
05 FILLER PIC X(49).
FD DESTINATION-FILE.
01 DESTINATION-REC.
05 DEST-EMP-NO PIC 9(5).
05 FILLER PIC X(1).
05 DEST-EMP-NM PIC X(25).
05 FILLER PIC X(49).
WORKING-STORAGE SECTION.
01 WS-KSDS-STAT-CODE PIC 9(2) VALUE ZERO.
01 WS-SEQ-STAT-CODE PIC 9(2) VALUE ZERO.
01 WS-EOF PIC X(1) VALUE 'N'.
01 WS-CNT-INSERT PIC 9(3) VALUE ZERO.
01 WS-CNT-INV-INS PIC 9(3) VALUE ZERO.
PROCEDURE DIVISION.
000-MAIN-PARA.
DISPLAY 'INSIDE MAIN PARA.'.
PERFORM 001-INITIALIZATION-PARA.
PERFORM UNTIL WS-EOF = 'Y'
READ SOURCE-FILE
AT END
MOVE 'Y' TO WS-EOF
NOT AT END
PERFORM 002-WRITE-REC-TO-DEST-PARA
END-READ
END-PERFORM
PERFORM 003-DISPLAY-STATS-PARA.
PERFORM 004-CLOSE-FILES.
STOP RUN.
001-INITIALIZATION-PARA.
DISPLAY 'OPENING FILES.'.
OPEN INPUT SOURCE-FILE
OUTPUT DESTINATION-FILE.
DISPLAY 'OPENED FILES SUCCESSFULLY.'.
002-WRITE-REC-TO-DEST-PARA.
DISPLAY 'INSIDE WRITE REC PARA.'.
MOVE SOURCE-EMP-NO TO DEST-EMP-NO.
MOVE SOURCE-EMP-NM TO DEST-EMP-NM.
WRITE DESTINATION-REC
* RECORD KEY IS DEST-EMP-NO
INVALID KEY
DISPLAY 'ERROR IN WRITING RECORD :' SOURCE-EMP-NO
ADD 1 TO WS-CNT-INV-INS
NOT INVALID KEY
DISPLAY SOURCE-EMP-NO ' IS INSERTED'
ADD 1 TO WS-CNT-INSERT
END-WRITE.
003-DISPLAY-STATS-PARA.
DISPLAY '--------------------------------------------------'.
DISPLAY '***** TRANSACTION FILE PROCESSING STATISTICS '.
DISPLAY '--------------------------------------------------'.
DISPLAY 'NUMBER OF RECORDS INSERTED :' WS-CNT-INSERT.
DISPLAY 'NUMBER OF INVALID INS RECS :' WS-CNT-INV-INS.
DISPLAY '--------------------------------------------------'.
DISPLAY '******* END OF PROCESSING ********************'.
004-CLOSE-FILES.
CLOSE SOURCE-FILE
DESTINATION-FILE.
|
and the jcl used to run this is
Code: |
//STEP1 EXEC PGM=SEQ2KSDS
//STEPLIB DD DSN=IDCL15.AUG14.LOAD(SEQ2KSDS),DISP=SHR
//DD1 DD DSN=IDCL15.AUG14.DATA,DISP=SHR
//DD2 DD DSN=IDCL15.AUG14.KSDS.V1,DISP=SHR
//SYSOUT DD SYSOUT=*
//
|
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
003710 DISPLAY 'OPENED FILES SUCCESSFULLY.'. |
This is a lie. Since you do not use file status codes, you do not actually know that the files were opened successfully. Change your program to use file status codes and display them to help debug your problem.
Also, what error message(s) are you getting out when running the program? |
|
Back to top |
|
|
shyam6385
New User
Joined: 14 Oct 2009 Posts: 6 Location: bangalore
|
|
|
|
hi,
I checked running my program with file status codes...
ya what you said is right
the ksds file is not opening
file status is showing as 39
that means record length mismatch..
so how to over come this problem..
please help.. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
That's easy -- change your program record length to match the physical file. If you're not sure the size of the records in the physical file, run a LISTCAT to find out.
However, note that a 39 does not always mean the record length doesn't match -- read the manual description of file status 39 for a better idea of the various conditions that can cause it. For example, if the physical file has alternate index(es), you must indicate this in your COBOL program and change the JCL appropriately. Not doing so would also cause a file status 39. |
|
Back to top |
|
|
shyam6385
New User
Joined: 14 Oct 2009 Posts: 6 Location: bangalore
|
|
|
|
Hi,
i tried that also
now the file is opening
but
it is showing this
IGZ0003W A logic error occurred for file DD2 in program SEQ2KSDS at relative location X'08DE'.
what is it? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you post the VSAM DEFINE for this. . . |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
When you compile your program, you either get an offset listing giving the offsets for each COBOL verb in your program, or a pseudo assembler for each statement in your PROCEDURE DIVISION. Whichever one you got, you can use to find the relative location, which tells you which statement has the problem and you can proceed from there.
However, if you displayed the file status value each time you did anything to the file,you could get an early start on debugging the problem. |
|
Back to top |
|
|
Raghu navaikulam
Active User
Joined: 27 Sep 2008 Posts: 193 Location: chennai
|
|
|
|
Hi shyam6385
Look at your program. You are not reading the input file.
So use a read file statement, move the data to the destination and then write.
Before doing this you should solve the OPEN file issues.
Regards
Raghu |
|
Back to top |
|
|
shyam6385
New User
Joined: 14 Oct 2009 Posts: 6 Location: bangalore
|
|
|
|
thank u one and all..
i have done with that program..
and a special thanks to Donald Knuth |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
and a special thanks to Donald Knuth |
at first glance ...
why? the TAOCP does not contain anything related to the content of this topic
after rereading... I got the meaning
Robert Sample made the post
Donald Knuth is the author of the quote, ( which is part of the signature )
P.S.
Hi Robert ...
that' s something to be proud of.. nobody ever called me John ( Von Neumann ) |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Thanks John (enrico) -- I feel honored to be mentioned in such distinguished company, but saddened that an IT "professional" does not recognize the name. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
I wonder why did not he name you "TANSTAAFL"? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
LOL, Anuj -- it's happened (more than once) already. |
|
Back to top |
|
|
|