Skip to main content

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



I do not know of any issues in this area.

What does the read statement look like that is triggering the invalid key condition and what is the condition that you are expecting?

An invalid key condition exists when the first byte of file status = "2", nothing else.
The second byte determines the type of invalid key condition.

If you want to check for conditions other than invalid key or at end then you need to explicitly test the file status item with "if file-status not = "00", etc, or define a declaratives section in your program.

The file status should be updated after all I-O operations including successful ones, where file status should contain "00". Is this occurring?

If you do not see the file status being updated as you animate the program then you should check to ensure that you are looking at the correct data item in working-storage that is defined as the file status in the select statement.

If you are still having problems and you have a small sample that you can zip up, please e-mail it to me at:
chris.glazier@microfocus.com

Thanks.

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



Chris Glazier originally wrote:
I do not know of any issues in this area.

What does the read statement look like that is triggering the invalid key condition and what is the condition that you are expecting?


modify-artist.                         
    read artist-file                   
      invalid key                       <<<<<<<<
        perform invalid-key-process     
      not invalid key                   
       ......
    end-read.       


I'm knowingly entering an invalid key to test the error handling. What I'm expecting is that the error message shown previously ("Error processing file : ") displays together with the statuses returned. The error message is being displayed but without the statuses:

01 file-error-message.                       
   05 filler                   pic x(24)     
      value "Error processing file : ".           
   05 status-key-1-display     pic x.       
   05 filler                   pic x(3).     
   05 status-key-2-display     pic 9(3).     


I'd originally had 01 ws-artist-status pic xx as my file status data, and

01 file-error-message.                     
   05 filler                   pic x(24)   
      value "Error processing file : ".     
   05 file-error-status        pic xx.     


but, as nothing was being displayed after the text string I thought I needed to expand the file status according to the MF examples.


The file status should be updated after all I-O operations including successful ones, where file status should contain "00". Is this occurring?


I'm not actually checking this in my code, however, examining ws-artist-file-status, nothing appears in status-key-1 or status-key-2 (as previously described) but binary-status shows '032' for both valid and invalid key conditions.

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



Can you please zip up a small sample project along with a test file to read and e-mail it to me at:
chris.glazier@microfocus.com?

I'll take a look and see if I can reproduce the issue.

Thanks.

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



Chris Glazier originally wrote:
Can you please zip up a small sample project along with a test file to read and e-mail it to me at:
chris.glazier@microfocus.com?

I'll take a look and see if I can reproduce the issue.

Thanks.


Chris: I've emailed 'test.zip' with code and data. Thanks.

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



I have found the problem.

In your program's select clause you specify:


select artist-file                             
  assign "artistdb.dat"                       
  file-status ws-artist-file-status           
  organization indexed                         
  access dynamic                               
  record key ArtistRef                         
  alternate key ArtistSurname with duplicates.


where "file-status" should be "file status" without the hyphen.

By adding the hyphen "file-status" in being interpreted by the compiler as a filename in the ASSIGN clause as the syntax for multiple filename assignment is allowed.

The same goes for ws-artist-file-status.
It is also being treated as part of the ASSIGN clause.

So as far as the compiler is concerned your select has 3 filename assignments and NO file status clause.

Remove the hyphen from "file-status" and it works OK.

[Migrated content. Thread originally posted on 18 October 2011]

Net Express 5.1/Windows XP Pro SP3

File status codes do not appear to be being returned.

I'm using standard code lifted straight from MF examples:

file-control.
         select artist-file
        ....
           file-status ws-artist-file-status
        ....

working-storage section.
01 ws-artist-file-status.
   03 status-key-1             pic x.
   03 status-key-2             pic x.
   03 binary-status redefines status-key-2
                               pic 99 comp-x.
...
01 file-error-message.
   03 filler                   pic x(24)
      value "Error processing file : ".
   03 status-key-1-display     pic x.
   03 filler                   pic x(3).
   03 status-key-2-display     pic 9(3).

procedure division.

....
invalid-key-process.
   move status-key-1 to status-key-1-display
     if status-key-1 not equal 9
        move status-key-2 to status-key-2-display
     else
        move binary-status to status-key-2-display
     end-if
   move file-error-message to message-line
   perform display-message.


On an 'invalid key' condition status-key-1 and status-key-2 contain nothing.
Since status-key-1 contains nothing ('spaces') and is, therefore, not = 9 then the program errors out with '163 illegal character in numeric field' on the next sentence.

I'm puzzled ;-) (of course, I may be missing something also.)



Chris Glazier originally wrote:
I have found the problem.

... "file-status" should be "file status" without the hyphen.

By adding the hyphen "file-status" in being interpreted by the compiler as a filename in the ASSIGN clause as the syntax for multiple filename assignment is allowed.

The same goes for ws-artist-file-status.
It is also being treated as part of the ASSIGN clause.

So as far as the compiler is concerned your select has 3 filename assignments and NO file status clause.

Remove the hyphen from "file-status" and it works OK.


Well, what a stupid mistake on my part. Many thanks for spotting the error. As you say, correcting it means file status codes are now being returned correctly. No excuses but this is the first COBOL programming I've done for longer than I care to remember so the rust has obviously taken hold ;-)