Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to avoidOverwrite the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Sun Oct 16, 2011 7:28 am    Post subject: How to avoidOverwrite the file
Reply with quote

SELECT A,B,C FROM XXX.EMP;
For Example:
values in the table
1 2 3
4 5 6
First I've retrieved all the rows in the table using cursor.
Logic:


Code:

PERFORM UNTIL SQLCODE = 100
IF A NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
IF B NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
IF C NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
FETCH CURS01 INTO :A,:B,:C
END-PERFORM

Excepted Output:
in the Output File:
1 2 3
4 5 6
---------------
I'm getting only
3
6
----------------
It's overwriting the file. How to change the logic.
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Sun Oct 16, 2011 8:41 am    Post subject:
Reply with quote

Hello,

What you have posted shows nothing we can use to help. . .

The code posted shows IFs and WRITEs before the cursor iseven fetched. . .

How is the file defined? How many times is it opened and closed?

If you are doing multiple writes between fetches, how could there ever be more than one value in an output record?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sun Oct 16, 2011 1:55 pm    Post subject: Reply to: How to avoidOverwrite the file
Reply with quote

The code you have posted is obviously "pseudo-code".

If that were working, your output would be:

1
2
3
4
5
6

Since you do a write for each field (you can do that in pseudo-code, but not in real code without some more statements).

There is not much point in us de-bugging pseudo-code, because that is not where your problem is.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Oct 16, 2011 8:08 pm    Post subject: Re: How to avoidOverwrite the file
Reply with quote

senthilnathanj wrote:
Code:


IF A NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
IF B NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
IF C NOT= SPACE THEN
    WRITE FOUTFILE
END-IF
FETCH CURS01 INTO :A,:B,:C
END-PERFORM

Excepted Output:
in the Output File:
1 2 3
4 5 6
---------------
I'm getting only
3
6
----------------
It's overwriting the file. How to change the logic.



With what little you have given us i would suggest:
Code:
PERFORM UNTIL SQLCODE = 100
IF A NOT = SPACES
 OR B NOT = SPACES
 OR C NOT = SPACES
   WRITE FOUTFILE
END-IF
FETCH CURS01 INTO :A,:B,:C
END-PERFORM

[/code]
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sun Oct 16, 2011 9:20 pm    Post subject: Re: How to avoidOverwrite the file
Reply with quote

Code:
01  FOUTFILE-RECORD.
    05  A PIC X.
    05  B REDEFINES A PIC X.
    05  C REDEFINES B PIC X.


Assuming that A, B and C receive data, and that the are all defined in the output record, then something like the above would generate the output you are getting, except for the number of records...

Or:

Code:
01  A PIC X.
01  B PIC X.
01  C PIC X.


underneath the FD. This would cause an "implicit redefines" so A B and C all occupy the same storage space, A would get a value, B would get a value overwriting A, C would get a value overwriting B (and A).

In your output you show nothing in place of the expected A and B values and only what we can assume is the C value appearing.

However, you only get two output records from six writes, implying that A and B are always space on what you have shown so far.

You have to show us more. Dick has pointed out that you have writes before the FETCH - is that why you put the IFs in? You need the/a FETCH before you try to use the data from the FETCH.

You will have to show your FD (for FOUTFILE) and definitions associated with it and all the relevant code in the PROCEDURE DIVISION.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sun Oct 16, 2011 9:48 pm    Post subject: Reply to: How to avoidOverwrite the file
Reply with quote

why keep speculating ?
let' s wait for the TS to come back with some more details ...
or disappear forever icon_wink.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Oct 17, 2011 5:11 am    Post subject:
Reply with quote

Hello,

When the TS started the duplicate (now locked) topic nothing additional to help us help TS was posted. . . icon_sad.gif

We still need to see how the output file is defined and when it is opened and closed.

I'm sure ALL of the problem is in the file definition or processing code, but so far, TS has not been able/willing to provide these.

Suggest the code be modified to do a DISPLAY every time a WRITE is executed to help determine if something is lost or never written. . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Oct 17, 2011 5:27 am    Post subject:
Reply with quote

The field names in the new posting "NO,NAME,COURSE" make it look like a class assignment, or there are a lot of companies trying to track their employees class attendance and assigning very junior programmers to handle the programming.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Mon Oct 17, 2011 12:19 pm    Post subject: Reply to: How to avoidOverwrite the file
Reply with quote

just for reference here is the link to the locked topic
http://www.ibmmainframes.com/viewtopic.php?t=56463&highlight=
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us