Hi,
You are saying that the newly generated document number is the primary key of ztable.
But you are trying to use UPDATE command with the same.
UPDATE command is used to update an existing record.
How can you UPDATE a record which isn't there in the table ? Shouldn't it be INSERT command to be used here ? and LS_HEADER structure the primary key field INVOICE_NO is not filled up after document posting so the query will not be able to create a record.
( It will create a record for the first time with INVOICE_NO field with value 0000000000 and will give a dump from second time onwards with message "Record already exists with primary key 000000000" ).
These are some basic fundamentals which are lacking in the code. Please check.
Regards,
Ashish