cancel
Showing results for 
Search instead for 
Did you mean: 

Reference document through D I API for production order

0 Kudos

Good day folks,

We are creating a purchase order that from production order. What we need is to add this purchase order as a reference to this production order (WOR5 table) using DI API, but we couldn't find the service or object in DI API.

Any idea how to acheive this?

View Entire Topic
ManasGhoshal
Explorer
0 Kudos

Hi,

This is how you can manage the documents to add in Reference.

Here I have done this, after adding an adjustment journal entry I have tagged that to respective A/R Invoice's Reference Document i.e. in INV21.
This below workout code is in C# :-

int result = journalEntry.Add();

// Check if the journal entry was successfully added

if (result == 0)

{

// Get the generated JournalEntry number

string generatedJournalEntryNumber = company.GetNewObjectKey().ToString();

Console.WriteLine("Journal entry added successfully. Journal Entry Number: " + generatedJournalEntryNumber);

// Create a new line in INV21 table to establish the relation

Documents invLine = company.GetBusinessObject(BoObjectTypes.oInvoices);

invLine.GetByKey(invoiceEntry);

invLine.DocumentReferences.ReferencedObjectType = ReferencedObjectTypeEnum.rot_JournalEntry;

invLine.DocumentReferences.ReferencedDocEntry = Convert.ToInt32(generatedJournalEntryNumber);

invLine.DocumentReferences.IssueDate = DateTime.Today.AddDays(2);

invLine.DocumentReferences.Add();

int UpdateResult = invLine.Update();

if (UpdateResult == 0)

{

Console.WriteLine("Invoice line updated successfully with Journal Entry.");

}

else

{

int errorCode;

string errorMessage;

company.GetLastError(out errorCode, out errorMessage);

Console.WriteLine("Failed to update invoice line. Error Code: " + errorCode + ", Error Message: " + errorMessage);

}

}

else

{

int errorCode;

string errorMessage;

company.GetLastError(out errorCode, out errorMessage);

Console.WriteLine("Failed to add journal entry. Error Code: " + errorCode + ", Error Message: " + errorMessage);

company.Disconnect();

}