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
 

 

deleting a particular record.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: deleting a particular record.
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

Moderator Team Head


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

PostPosted: Sat Jul 11, 2009 8:10 pm    Post subject: Reply to: deleting a particular record.
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    Post subject: Reply to: deleting a particular record.
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: 7932
Location: Bellevue, IA

PostPosted: Sat Jul 11, 2009 8:59 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Jul 13, 2009 12:57 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Jul 18, 2009 12:00 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Jul 18, 2009 12:22 am    Post subject:
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    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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


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