Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
carrfamily Absent Member.
Absent Member.
324 views

Help with deleting a record

I have an application where I read a record, perform some calculations, and then decide whether I want to delete the record or save (“rewrite”) it.  The compiler gives me an error, apparently inconsistent with the MicroFocus documentation.   Please advise how I can achieve my purpose.

 

In Micro Focus Online Documentation the rules for Deleting a record state:

  1. The associated file must be open in the I-O mode at the time of execution of this statement. (See the topic The OPEN Statement.)
  2. For files in sequential access mode, the last input-output statement executed for file-name-1 prior to the execution of the DELETE statement must have been a successfully executed READ statement. The operating system logically removes from the file the record that was accessed by that READ statement.

Here is my code:

         SELECT CLEANDATA

             ASSIGN TO "CLEANDATA"

             ORGANIZATION IS SEQUENTIAL

             ACCESS IS SEQUENTIAL.

 

. . .

       FD  CLEANDATA

           LABEL RECORDS ARE STANDARD.

       01  CLEANDATA-REC.

           05  CLEANDATA-FIELD  OCCURS 4000 PIC S9(12).

 

. . .

 

           open I-O    CLEANDATA.

 

. . .

           read CLEANDATA next

               at end go to 1000-EXIT.

           MOVE 'N' TO W-DELETE-CLEANDATA-FLAG.

           perform 2000-SCAN-FOR-ERRORS.

           if W-DELETE-CLEANDATA-FLAG = 'Y'

                DELETE CLEANDATA RECORD      ==>  Compiler barfs “Not allowed with SEQUENTIAL files”

           else rewrite CLEANDATA-REC.

           go to 1000-ENTRY.

 

I will be most grateful for your advice.

Tags (2)
0 Likes
1 Reply
Highlighted
DanielP1 Absent Member.
Absent Member.

RE: Help with deleting a record

The DELETE statement can only be specified for files with relative or indexed organization.
See https://www.microfocus.com/documentation/enterprise-developer/ed40/ED-Eclipse/HRLHLHPDF80B.html

If you want to stick with the Line sequential file type/organization, read your input file and for each record, write it or not to a second output file.

Daniel

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.