Skip to Content
0
Dec 04, 2018 at 10:37 AM

output processing program with internal unique serial number without gaps

119 Views

I have to create an output processing routine (NAST, RSNAST00, APP "V3").

The message is a special file with an internal serial number.

Requierments:

  1. unique serial number (for customer to identify the message unique)
  2. without gaps (for customer: Did I receive all messages?)

The file shoud be transferred by FTP to customer. For network failures, the conditions must be met!

Theses:

  1. A number range object is not acceptable. A number is used on a network failure. The following message file has a new number with a gap.
  2. The number assignment must be protected. A new number may only be generated after a successful FTP. I need a lock on a database table line.
  3. "Commit" or "Rollback" is forbidden in output processing programs.

My first concept "select single for update"

I create a table with serial number. In the output processing program:

  1. "select single for update" to protect the number.
  2. create message, file, FTP
  3. update the line with the new number.

But it does not work in all cases, not safe in all cases!

Reason: Implicit commit: if the program is extracted from the work process. The database lock is released. A parallel process pulls the same number. The number is NOT unique!

How do i create a unique sequence number without gaps in a output processing program, safely?