cancel
Showing results for 
Search instead for 
Did you mean: 

output processing program with internal unique serial number without gaps

elars_krger
Discoverer
0 Kudos

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?

elars_krger
Discoverer
0 Kudos

Nobody who wants to help me?

Accepted Solutions (0)

Answers (2)

Answers (2)

elars_krger
Discoverer
0 Kudos

Thanks 🙂

> Use an enqueue object to make sure that the transmission not performs twice at the same time

... that's my problem. How do i set the _SCOPE parameter in the context of "SAP update processing" correctly?

jrgkraus
Active Contributor
0 Kudos

Try this approach:

- create a table where you create a line whenever you start the sending procedure. Use a GUID as the key for this table. Create also a field for the customer number of the recepient and a serial number that is left empty on creation. Save the invoice number from VBRK-VBELN in this table also.

- create a second table with two fields: customer number (recepient party) and last serial number.

When starting the sending process:

- select all lines with empty serial numbers and matching recepient from the first table. From this table, take the line with the lowest GUID.

- read the second table with the customer number of the recepient.

- add 1 to the number found there and generate the output using this number

- perform the transmission

- update the serial number in both tables

Use an enqueue object to make sure that the transmission not performs twice at the same time