How to post a pickinglist journal using x++ code

Hi all,

I’ve created Pickinglist journal using Prod id, itemid, bom unit, bom consump, inventory dimensions

I’ve some doubts …

Is it necessary to give proposal value?

How could I post my journal through x++?

Thanks in advance

No

Use \Classes\ProdJournalCheckPostBOM

When I try to post using code I’m getting error as

pastedimage1528110382492v1.png

But i when post manually it’s getting posted…

My form is

My coding is

 while select forupdate pjttmp where pjttmp.TransactionStatus  == ProdJournalTableTempStatus::Post
    {
        try
        {
            ttsbegin;
            prodJournalCheckPostbom= ProdJournalCheckPostBOM::newPostJournal(pjttmp.JournalId,true);
            prodJournalCheckPostbom.run();
            pjttmp.TransactionStatus =ProdJournalTableTempStatus::Posted;
            pjttmp.PostedDateTime = datetimeutil::utcNow();
             pjttmp.(fieldnum(ProdJournalTableTemp,ModifiedBy))=pjttmp.createdBy;
                    pjttmp.(fieldnum(ProdJournalTableTemp,ModifiedDateTime))=DateTimeUtil::utcNow();
                    pjttmp.update();
            pjttmp.update();
            ttscommit;
            info(strfmt("Posted"));
        }
        catch(Exception::Error)
        {
            continue;
        }
    }

How is the journal created when posted manually and using code?

Also check, if the \Data Dictionary\Tables\ProdJournalBOM\Fields\InventConsump is updated properly.

No, Kranthi.

InventConsump isn’t filled Kranthi for that prodid…

How can we fill that?

I created the journal by passing necessary field values from temp table to prodjournalbom table

It is equivalent to BomConsump in inventory unit. Convert BomConsump to quantity in inventory unit and assign that value to InventConsump.

For reference see, \Classes\ProdJournalFormTransBOM\fieldModifiedBomUnitIdPost

like that is it any class for InventProposal field value, kranthi?

You can assign InventConsump value to InventProposal and BomConsump value to BomProposal

Example:

prodJournalBOM.BomProposal= prodJournalBOM.BomConsump;
prodJournalBOM.InventProposal = prodJournalBOM.InventConsump;

Is it necessary to update BOM qty and QtyBOMCalc fields in ProdBom table for pickinglist journals?

Not necessary. The insert() on prodJournalBOM will handle it.

But when i check the values in prodbom table for my journal id those fields are empty, kranthi

How was the ProdBOM created? Try creating a new production order and check.

Do you still get the error after updating the InventConsump ?