web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

One Purchase Invoice against multiple Product receipts through Code X++

(0) ShareShare
ReportReport
Posted on by 85

Is any one know the code or a job to create one Purchase invoice against multiple Product receipts in X++ Dynamics AX 2012.

An urgent feedback will be highly appreciated.

Thanks.

*This post is locked for comments

I have the same question (0)
  • AamirKhan Profile Picture
    85 on at

    Hi Sukrut,

    I am getting below error while using the above refer link,

    Error executing the code:  The field with Id 0 does not exists in table 'Common'

    Stack trace

    (S)\Classes\PurchFormletterParmData\newChooseLines - line 112

    (C)\Classes\PurchFormLetter_Invoice\selectFromJournalLines - line 10

    (C)\Jobs\invoicePurchaseOrder_Packingslip - line 42

    My code,

    static void invoicePurchaseOrder_Packingslip(Args _args)

    {

       Purchformletter_invoice Purchformletter;

       Purchtable purchtable;

       vendPackingSlipJour vendPackingSlipJour;

       vendPackingSlipTrans vendPackingSlipTrans;

       TmpFrmVirtual tmpFrmVirtual;

       List selectedList = new List(Types::Record);

       purchParmUpdate purchParmUpdate;

       purchParmtable purchParmtable;

       ParmId parmId;

       VendInvoiceInfoTable vendinvoiceinfoTable;

       try

       {

           ttsbegin;

           tmpFrmVirtual.setTmp();

           // Add the packing slips into tmpFrmVirtual

           while select vendpackingslipjour

               where (vendpackingslipjour.packingslipid == 'Aamir-1'

               || vendpackingslipjour.packingslipid == 'Aamir-2'

               || vendpackingslipjour.PackingSlipId == 'Aamir-3')

               && vendPackingSlipJour.PurchId       == 'PO-00082'

           {

               tmpFrmVirtual.clear();

               tmpFrmVirtual.TableNum = vendpackingslipjour.TableId;

               tmpFrmVirtual.RecordNo = vendpackingslipjour.RecId;

               tmpFrmVirtual.NoYes = NoYes::Yes;

               tmpFrmVirtual.Id = vendpackingslipjour.PurchId;

               tmpFrmVirtual.insert();

           }

           while select tmpFrmVirtual

           {

               selectedList.addEnd(tmpFrmVirtual);

           }

           // Construct form letter

           purchformletter = Purchformletter::construct(DocumentStatus::Invoice);

           // Add the packing slips to the purch form letter

           purchformletter.selectFromJournalLines(selectedList.pack());

           purchformletter.sumBy(AccountOrder::None);

           purchformletter.reArrangeNow(true);

           purchformletter.reArrange();

           purchformletter.specQty(purchupdate::PackingSlip);

           parmId = purchformletter.parmId();

           // Execute

           ttscommit;

           purchformletter.startOperation();

           if (purchFormLetter.parmJournalRecord().recid)

           {

               info('Invoice completed sucessfully');

           }

           }

           catch

           {

           throw error(strFmt('Invoice failed'));

           }

    }

    Any urgent feedback must be highly appreciated.

    Thanks.

  • AamirKhan Profile Picture
    85 on at

    Hi Sukrut,

    I have debug the code and find that in

    method newChooseLine at line 112  below condition fails

    parmTable = purchFormLetterContract.parmParmTable();

           if (isConfigurationkeyEnabled(configurationKeyNum(PublicSector)))

           {

               vendInvoiceInfoTable.data(parmTable);

               if ((parmTable.ParmId!= '' || vendInvoiceInfoTable.isDirectInvoice()) && parmTable.ParmId == purchFormLetterContract.parmParmId())

               {    

    b/c purchFormLetterContract.parmParmTable(); return 0 record and

    when assign this buffer to vendInvoiceInfoTable.data(parmTable) the last if condition throws error

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans