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

deleting a particular record.


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

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Sat Jul 11, 2009 7:42 pm
Reply with quote

Hi All,

I don't know if this is the right forum to discuss this, because the answer can be through JCL as well. Apologies if it is so.

I have a sequential file, and I need to delete the n the record (n will be any number depending on situation). I need to do all the operations on this file itself. I cannot copy it into a new file and again take a copy into this file. The scenario is same as if I opened the file in edit mode and deleting the nth record.
How can this be done?Please can we discuss about all the possibilities.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sat Jul 11, 2009 8:10 pm
Reply with quote

It can't be done the way you've described. Editing the dataset is the only real option.
Back to top
View user's profile Send private message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Sat Jul 11, 2009 8:21 pm
Reply with quote

IF this cannot be done at all like that then what are the other options available.
But, my interviewer told me that it can be done. I am confused!!!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Jul 11, 2009 8:59 pm
Reply with quote

TSO edit will allow you to make such a change. However, batch programs must copy the file and remove the record that way. The COBOL DELETE statement in the COBOL Language Reference manual says this:
Quote:

The DELETE statement removes a record from an indexed or relative file
Note that sequential files are not included.

Interviewers can be wrong, by the way.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jul 11, 2009 9:16 pm
Reply with quote

Hi Arin,

This most probably isn't what he had in mind, but some PS files are designed to "logically" delete records.

A field in the rec is designated as the delete indicator. If it's set the program ignores it and goes on to the next rec.

At some point in the system the file is copied and the indicated recs are dropped.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Jul 13, 2009 12:57 am
Reply with quote

Hello,

Quote:
because the answer can be through JCL as well.
Sorry, but JCL does not delete records - in sequential files or any other. . .

I suspect that there has been a certain lack of communication between you and the interviewer. That or the interviewer does not know that there is no "delete" for a sequential record.

An interviewing technique that is sometimes (unfortunately) used is a "trick" question that is not looking for any technical answer, but rather to see how the applicant handles the trick question.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jul 14, 2009 3:21 am
Reply with quote

I remember that we were able to specify the same file name for SORTIN and SORTOUT when sorting a file (I know - it s/b saved 1st). So it's possible to "delete" recs by OMITting them; don't know if a rec can be "deleted" by identifying its position in the file.

In either case, the file is being re-written. But it lOOks like the rec was deleted. icon_eek.gif

That's a long way to go to trick an interviewee.
Back to top
View user's profile Send private message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Fri Jul 17, 2009 11:41 pm
Reply with quote

Actually I was also looking into this, and I came out with a solution. Can you please suggest if this is correct.
Open the file in I/O mode.
Put a counter.
If the counter <>n it will rewrite the record
else it will not.
will it work with the help of COBOL program with this logic?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Jul 18, 2009 12:00 am
Reply with quote

Hello,

Code like that can be written and executed, but it will not delete anything.
Back to top
View user's profile Send private message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Sat Jul 18, 2009 12:09 am
Reply with quote

Won't it skip that record? I mean when the counter is satisfied it will not rewrite. For the next read again the counter will not be satisfied and it will continue rewriting. Won't it work this way?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Jul 18, 2009 12:22 am
Reply with quote

Hello,

Quote:
I mean when the counter is satisfied it will not rewrite
Correct. . . However, bypassing the re-write does not delete the record from the file.

It is still in the file - because there is no way to physically delete a record from a sequential file. . .
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top