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

write is not using the area from the FROM area


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

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Thu Jan 08, 2015 5:07 am
Reply with quote

i have 2 input records that get reformated and then written to a flat file.
the write command is:

WRITE ECOE-TRAN-RECORD FROM ECOE-CB006-RECORD.

ECOE-CB006-RECORD contains the correct data from input record 1 but when the WRITE is executed a low value record is written, when the next input record is formated, ECOE-CB006-RECORD contains the info from input record 2, but when the write is exected, the data from input record 1 is written.

what can be causing this?

thanks
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 08, 2015 6:05 am
Reply with quote

Program error.

For a more detailed explanation, we'd need to see all the relevant code, including knowledge of where data-definitions are located for each name that you mention.

The simplest problem would be that the WRITE is being executed before the data is put into ECOE-CB006-RECORD.
Back to top
View user's profile Send private message
xsray

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Thu Jan 08, 2015 6:32 am
Reply with quote

this shows the buffer before the first write

Code:
********** AUTOMONITOR **********                           
01 ECOE-TRAN-RECORD      '...................................
                          ...................................
                          ...................................
                          ...................................
                          ...................................
ECOB0015 -1----+----2----+----3----+----4----+----5- LINE: 73
 120420 5300-WRITE-OUTPUT-ECOETRAN.                         
 120420                                                     
 120420     WRITE  ECOE-TRAN-RECORD  FROM  ECOE-CB006-RECORD.
 120420                                                     
 120420     EVALUATE  ECOETRAN-STATUS                       
 120420         WHEN  FSC-SUCCESS                           
-+----1----+----2----+----3----+----4----+----5----+----6 LIN


this is what is in ECOE-tran-record after the write - same a ecoe-cb006-record
Code:
 LIST ECOE-TRAN-RECORD ;
ECOE-TRAN-RECORD =     
'0349622651B18825117739H



the second write is:
Code:
********** AUTOMONITOR **********                           
01 ECOE-TRAN-RECORD      '0349622651B18825117739H           
                          084                  RX3084       
                          0158512200         00 09094845140 
                            0            18716Y    1882511773
                                                             
ECOB0015 -1----+----2----+----3----+----4----+----5- LINE: 73
 120420 5300-WRITE-OUTPUT-ECOETRAN.                         
 120420                                                     
 120420     WRITE  ECOE-TRAN-RECORD  FROM  ECOE-CB006-RECORD.
 120420                           


as you can see the first buffer's value is still there - but after the write the correct data is in the buffer
Code:

 LIST ECOE-TRAN-RECORD ;
ECOE-TRAN-RECORD =       
'0349622652B18917442886H


the difference between the 2 records is the 51B and 52B in ECOE-TRAN-RECORD

now when i look at what was actually written, ir is not the 2 records i expect - but

Code:
BROWSE    QCPJNT.ECOET
 Command ===>         
***********************
.......................
0349622651B18825117739H


a low-value record and the first record, but not the second record.

strange stuff

Code'd
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 08, 2015 8:10 am
Reply with quote

Quote:
this is what is in ECOE-tran-record after the write - same a ecoe-cb006-record
This completely misunderstands buffering. What should be in the FD 01 after a write is LOW-VALUES (at first -- eventually earlier records would be there) as you CANNOT see the contents of the buffer after the WRITE statement is executed.

Buffers are used in reading and writing records but they require additional understanding with them.

You need to provide the SELECT and all the WRITE statements in the code for us to help you more.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 08, 2015 5:51 pm
Reply with quote

Please use the Code tags for information requiring preservation of spacing.

Still guessing as you have not supplied sufficient code.

It looks like you have variable-length records and are using APPLY WRITE ONLY for the file, or compiler option AWO.

Possibly you have no BLOCK CONTAINS on the FD (so defaults to one record per block) and only one buffer defined for the file, but this is unlikely.

Otherwise, as Robert has indicated, the address under the FD would have been "moved on" to the next available part of the buffer, and you would not see the data you expect.

Assuming the above, are you looking at the correct file when you are checking it? Look at the third file in the spool for the step, and check that there is nothing unexpected for that dataset. Check the dataset name is the one you are looking at.

If, during your initial test, you had the WRITEs out of sync, your file would look like that. If you or the system have failed to delete the original dataset and it is specified as NEW,CATLG, you would not be seeing the latest output from your program.

There can be other reasons, so I'll stop guessing there.
Back to top
View user's profile Send private message
xsray

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Thu Jan 08, 2015 10:17 pm
Reply with quote

new update - after going over the program with the programmer, the problem only happens when after the output file is closed in the program it is opened again for I-O for a rewrite to the first record. when the open I-O is commented out, the writes work just fine, recompile with the i-o in and the low-value record appears during the initial write when open for output only.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 08, 2015 11:32 pm
Reply with quote

Still none of the code that's been requested? Should be even more of it now.

I have no guesses for closing and re-opening a file. I've never done that.

Are you saying that the mere inclusion of the OPEN for input-output somehow causes the original WRITE not to work? Or is the COBOL code after the second OPEN buggy, and is trashing the file and you'd somehow prefer to blame the original WRITE statement?

How did you confirm that the file was OK before if you do do the second OPEN?
Back to top
View user's profile Send private message
xsray

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Thu Jan 08, 2015 11:55 pm
Reply with quote

so the question is, how do i update the first record in file that was just created in the same program?
Back to top
View user's profile Send private message
xsray

New User


Joined: 16 Sep 2008
Posts: 19
Location: illinois

PostPosted: Fri Jan 09, 2015 12:33 am
Reply with quote

Bill, solved the problem. Your thought about the rewrite trashing the file was right. I added a second SELECT and FD for the file in the program. then opened for output to create the file, then close when done. After that i opened the file again for i-o this time using a different SELECT and FD that corresponded to a new DD in the JCL but pointing to the same file just created.

thanks for your help.

new JCL
//*
//ECOETRA2 DD DSN=QCPJNT.ECOETRAN,DISP=OLD
//*
//ECOETRAN DD DSN=QCPJNT.ECOETRAN,DISP=OLD

new select and fd for ECOETRA2 (same file as ECOETRAN)
SELECT ECOE-TRAN-FILE
ASSIGN TO ECOETRAN
FILE STATUS IS ECOETRAN-STATUS
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.

SELECT ECOE-TRAN-FILE2
ASSIGN TO ECOETRA2
FILE STATUS IS ECOETRA2-STATUS
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.

FD ECOE-TRAN-FILE
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 3000 CHARACTERS
LABEL RECORDS ARE STANDARD.

01 ECOE-TRAN-RECORD PIC X(3000).

FD ECOE-TRAN-FILE2
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 3000 CHARACTERS
LABEL RECORDS ARE STANDARD.

01 ECOE-TRAN-RECORD2 PIC X(3000).

new rewrite code
--------------------------------------------------------
UPDATE FIRST RECORD OF FILE WITH THE HIST COPY ON OFF SW
--------------------------------------------------------
OPEN I-O ECOE-TRAN-FILE2
READ ECOE-TRAN-FILE2 INTO WS-X3000
MOVE WS-COPY-HIST-ON-OFF-SW TO WSX-HIST-IND
REWRITE ECOE-TRAN-RECORD2 FROM WS-X3000
CLOSE ECOE-TRAN-FILE2

by splitting the file into 2 DDs and 2 FDs - it works!
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Fri Jan 09, 2015 8:18 am
Reply with quote

Hi,

Do you really need a second DD statement here?

After closeing the file opened in OUTPUT mode, we can open the same file using same DD statement in I-O mode as well.

Correct me if I am missing anything here

Regards,
Chandan
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 Write line by line from two files DFSORT/ICETOOL 7
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts JCL to write the log on to a PDS file JCL & VSAM 10
No new posts COBOL - create and write to output fi... COBOL Programming 0
Search our Forums:

Back to Top