on 2016 Sep 27 8:33 PM
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.
Hi Kamil,
The key is included in the event arguments. The BusinessObjectInfo.ObjectKey contains the xml representation of the key of the created document.
Pedro Magueija
If this answer was helpful or correct consider marking it as such.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't find any solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
If this answer was helpful or correct consider marking it as such.
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
If this answer was helpful or correct consider marking it as such.
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
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
If this answer was helpful or correct consider marking it as such.
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
If this answer was helpful or correct consider marking it as such.
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
Hi again. Thank you for your replies.
But it works when Outgoing Payment adds without approve.
Firstly I need draft DocEntry.
When I activate Approval template for Outgoing Payment and when user adds, SAP B1 adds draft for payment. So BusinessObjectInfo.ObjectKey is null.
In DataEvent I wrote if BusinessObjectInfo.FormTypeEx == "426" (it is Outgoing Payment form)
What is wrong?
Regards, Kamil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kamil,
Please post the entire code, otherwise it is very hard to know what might be the issue.
Also note that, even when saving a draft the BusinessObjectInfo still contains the key for the draft.
The object type of the BusinessObjectInfo will be 112 (Draft).
Pedro Magueija
If this answer was helpful or correct consider marking it as such.
As I mentioned above, I just wrote this:
if (BusinessObjectInfo.FormTypeEx == "426" && BusinessObjectInfo.EvenType==SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
{
string objectKey=BusinessObjectInfo.ObjectKey;
}
So objectKey is always empty when Approval Template activated for Outgoing Payment.
Otherwise it is not null.
I don't need oDrafts (which type is 112, table is ODRF),
I need oPaymentsDrafts (type is 140, Table is OPDF)
It is how Pedro said, just adding an example how to get the XML
System.Xml.XmlDocument oXml = new System.Xml.XmlDocument();
oXml.LoadXml(businessObjectInfo.ObjectKey);
int docEntry = int.Parse(oXml.SelectSingleNode("//DocEntry").InnerText);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
9 | |
8 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.