cancel
Showing results for 
Search instead for 
Did you mean: 

[DI-API] Access a non-saved open document

Former Member
0 Kudos

Hi y'all,

When a user wants to add an invoice (or delivery note) I would like to have access to the document object. Normally, with a saved document, you can access the document by it's document number and so on, because it exists in the database. But the document the user is creating is not saved in the database.

Is it possible to get a reference to this document object, what only exists in the system-memory...

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Using the SP_SBO_TransactionNotification you can get access to the added object, and you can still rollback the transaction just asigning a number to the error variable.

From an addon, I don´t think you could do it using DI API. Access through the UI API is not enough?

Regards,

Ibai Peñ

Former Member
0 Kudos

Hi Ibai,

The SP_SBO_TransactionNitification is the stored procedure? And how do I rollback that transaction then...? Maybe you do have some sample code...?

Through the UI-API should be enough, but the document is a DI-API object...?

Thanks in advance...

Rowdy

Former Member
0 Kudos

Hi Rowdy,

The SP_SBO_TransactionNitification is the famous stored procedure. The only thing you need to do to rollback it is set the error number to something different from 0. This will make SBO know that the transaction was not OK, and it will automatically rollback it.

On the other issue, UI will be enough if you have all the values you need in the form.

Regards,

Ibai Peñ

Former Member
0 Kudos

Hi Ibai,

You've got me a little bit confused... How can I set a value in a stored procedure? I can call it, give some parameters and get a result, but how do I intercept the call from SAP to the stored procedure and change the errorcode it returns...?

Thanks in advance,

Rowdy

Former Member
0 Kudos

I´m sorry, I thought you know about the SBO_SP_TransactionNotification. This stored procedure is placed on every company database. Each time an object (document, master data, whatever) is created/modified/deleted, this stored procedure gets fired. What you need to do is put some code on it, to handle the task you want to do.

Have a look at:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/34f5cd90-0201-0010-939b-abb...

Have a look at this variables:


declare @error  int                -- Result (0 for no error)
declare @error_message nvarchar (200)     -- Error string to be displayed

If you want the process to be rollbacked, just asign a number different from 0 to @error. This error will be displayed in SBO with the @error_message message.

Hope helps,

Ibai Peñ

Former Member
0 Kudos

Hi Ibai,

I'm aware of the SBO_SP_TransactionNotification, however, I misreaded your post. I thought you where saying there was a possibility to capture the stored procedure in code. With TransSQL I have limited options, not enough...

The problem is that we have to acces the data in a document at all times. (Before and after posting) That's no problem when a user is browsing documents and editing them. But when a user is entering a new document, SAP has created a object in memory, and we want to access that one... Do you (or anybody) know if it is possible?

Thanks in advance...

Former Member
0 Kudos

Hi,

I´m sorry to say that I don´t think that is possible. You will not be able to get a DI API object with data that is not stored in the DB from the AddOn.

But I must insist that in the SBO_SP_TransactionNotification the data is added in the DB, but it is still "Before" adding it, becouse you can rollback the adding process. What I haven´t try is creating a COM object with a DI API connection and try to get the object that was just added. Perhaps this is what you need (if it works).

Regards,

Ibai Peñ

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

This can be a path to follow:

If you want to access information in the form before adding it, the user interface, with heavy programming of almost all events, could accomplish this.

If you need to access information of a specific document just after creation (this is the same as the object in memory) in a multi client environment you could create a Unique Identifier for the machine and the form in user defined fields. Then query this information to get the key and reference it. Again, to make your Add-on "aware" of the creation you will need heavy event programming after creation.

I know this is a bit diffuse, but if you could tell me what you need to do with the object in memory may be I could help you.

-M