cancel
Showing results for 
Search instead for 
Did you mean: 

Get last Payment Draft DocEntry added by user

0 Kudos

Hi all. I have a problem with Payment Draft Document.

We set an approval procedure to Outgoing Payment. So when a user add Outgoing Payment Document it firstly add Payment Draft Document.

So in the Form Data Event I wrote that

if EventType==Add and BeforeAction==False Then

string objectCode=oCompany.GetNewObjectKey();

string objectType=oCompany.GetNewObjectType();

But these two methods always return an empty string. I noticed that if I will add document by code (calling Add() method) then after calling these above two methods does not return an empty string.

The problem is that these methods don't work when user adds document normally.

I don't think that writing query is a good idea. Like SELECT MAX(DocEntry) FROM OPDF.

Because you cannot be sure that DocEntry always increases by adding +1 unit.

For example we have A/P Invoice document with DocEntry 1, 2 ,6, -8, -10 and etc.

So what is the best way to get DocEntry when user add?

1.With help of SBO_SP_TransactionNotification(calling method in it)

OR

2. With help of DI Event Service.

P.S. I never used none of them.

Please, help me to resolve my problem.

Thanks in advance.

Regards, Kamil.

View Entire Topic
0 Kudos

I can't find any solution

pedro_magueija
Active Contributor
0 Kudos

Hi Kamil,

In that case, can you not query the draft table (include a filter to take only drafts of your document type and order them desc)?

E.g.: SELECT TOP 1 DocEntry FROM ODRF WHERE ObjType = '<the_type>' ORDER BY DocEntry DESC


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

0 Kudos

Hi Pedro,

But how can I be sure that DocEntry will not be negative value?

if there is negative value which I need then this query will return another result

For example, in A/P Invoice there is negative DocEntry (like -9, -10 etc.)

pedro_magueija
Active Contributor
0 Kudos

Hi Kamil,

In the ODRF there are no negative DocEntry entries that I can see. Where are you finding your negative DocEntry? Is it on the ODRF table?


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

0 Kudos

I don't need ODRF, Not oDrafts. Just forget about this)

I am working with OPDF, oPaymentsDraft.

For your question, there is not negative DocEntry values in OPDF table.

But FOR EXAMPLE in OVPM (Outgoing Payment) table there are negative DocEntry values.

So, I think that in OPDF table there also will be negative DocEntry values in future.

You never be sure that DocEntry in the OPDF will not negative.

P.S. In above I wrote A/P Invoice insted of Outgoing Payment

pedro_magueija
Active Contributor
0 Kudos

Hi Kamil,

I've just created a couple of outgoing payments (with an approval) and I still don't get negative DocEntry.

Checked both tables OPDF and OVPM.

Are you doing something else during the creation of the Payment that I'm missing?


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

0 Kudos

I also created Outgoing Payments (with or without approval) and I have negative DocEntry.

And here, for example DocEntry -20 and 20 are absolutely different documents.

I don't know how it was happend   And in which situation.

P.S. Internal Number is DocEntry

pedro_magueija
Active Contributor
0 Kudos

Hi Kamil,

I'm afraid I've never seen this kind of situation, and I can't offer any insight.

In this case I'd try to figure out if this is a normal behavior in B1 by opening a ticket with SAP.

Please let us know if you do find a solution or get a reply from SAP.


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

0 Kudos

Hi Pedro,

I have problem with draft document now.

So when I add Outgoing Payment document, SAP B1 add draft document. So with SDK I cannot catch if draft document added or when added, or which draft document added.

I used Event Logger but it also cannot catch.

I can only catch DataAddBefore (before action is true) Event for Outgoing Payment document, and it was trigger TWO TIMES. But it does not give me any useful information. Because approval procedure enabled for this document.

Regards, Kamil