Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

partial PO posting (line wise)

(0) ShareShare
ReportReport
Posted on by 425

Hi all,

I have a requirement     I have  one PO with 2 PO lines

PO : 00002541  and PO lines

line 1  itemA   qty(2)

line 2 itemB qty(3)

We have packed all the lines in the PO but want to invoice specific line say line number 1  

I tried this code but not working any other help will be appreciated.

my code "

static void partial_Invoice(Args _args)
{
PurchFormLetter PurchFormLetter;

PurchTable PurchTable;

date _ReceivedDate = systemDateGet();

PurchId _purchId = "00002541";

PurchLine purchLine;

;

PurchTable = PurchTable::find(_purchId,true);

ttsBegin;

select forUpdate * from purchLine where purchLine.PurchId == PurchTable.PurchId;
{

purchLine.PurchReceivedNow = 2;

purchLine.update();

}

ttsCommit;

purchFormLetter = purchFormLetter::construct(DocumentStatus::PackingSlip);

//Enum name is recorded, label is registered

//change enum on purchUpdate to change what value(s) are posted

PurchFormLetter.update(PurchTable,"test233",systemDateGet(), PurchUpdate::ReceiveNow,AccountOrder::None,NoYes::No,NoYes::No);


}

Thanks,

Rohit

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: partial PO posting (line wise)

    Did you try to debug?

  • rohit1900 Profile Picture
    rohit1900 425 on at
    RE: partial PO posting (line wise)

    Hi

    I have modified my job as  given in the thread

       PurchFormLetter PurchFormLetter;

       PurchTable purchaseTable;

       date _ReceivedDate = systemDateGet();

       PurchId _purchId = "00002545";

       PurchLine purchLine;

       Query query;

       SysQueryRun chooseLinesQuery;

      ;

      purchaseTable = PurchTable::find(_purchId,true);

       select purchLine

           where   purchLine.PurchId == purchaseTable.PurchId              

           &&      purchLine.PurchStatus != PurchStatus::Canceled;

           {

               purchLine.selectForUpdate(true);

               purchLine.InventReceivedNow = purchLine.PurchQty;

               purchLine.PurchReceivedNow = purchLine.PurchQty;

               purchLine.update();

           }

       query = new Query(queryStr(PurchUpdate));//Query for the filter criteria

       query.dataSourceTable(tableNum(PurchTable)).addRange(fieldnum(PurchTable,PurchId)).value(queryValue(purchaseTable.PurchId));                

       query.dataSourceTable(tableNum(PurchLine)).addRange(fieldNum(PurchLine,PurchStatus)).value(queryValue(PurchStatus::Backorder));

       chooseLinesQuery = new SysQueryRun(query);      

       purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);

       ttsbegin;

       purchFormLetter.chooseLinesQuery(chooseLinesQuery);

       purchFormLetter.update( purchaseTable,'test',systemDateGet(),PurchUpdate::ReceiveNow,AccountOrder::None,false,false);

       ttscommit;    

    it gives error

    QueryBuildRange object not initialized.

    Stack trace

    (S)\Classes\PurchFormletterParmDataInvoice\adjustLinesQuery - line 85

    (S)\Classes\PurchFormletterParmDataInvoice\selectChooseLines - line 26

    (S)\Classes\formletterParmData\createData - line 47

    (S)\Classes\PurchFormletterParmDataInvoice\createData - line 3

    (S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServerIL - line 32

    (S)\Classes\DictClass\callStatic

    (S)\Classes\SysDictClass\invokeStaticMethod - line 26

    (S)\Classes\SysDictClass\invokeStaticMethodIL - line 39

    (S)\Classes\Global\runClassMethodIL - line 30

    (S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServer - line 21

    (C)\Classes\PurchFormLetter_Invoice\chooseLinesServer - line 3

    (C)\Classes\PurchFormLetter\chooseLines - line 26

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

    (C)\Classes\PurchFormLetter\update - line 46

    (C)\Jobs\_partialPOInvoice - line 32

    in my case all lines are packed and invoice only select line.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: partial PO posting(line wise) in AX 2012

    Hi rohit1900,

    Please refer to this thread discussing similar issue community.dynamics.com/.../264262

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans