July 18, 2013

Inventory Transfer Journal through X++ code

Inventory Transfer Journal through X++ code

Hi All
Here is a small code for Invent Transfer journal Posting


static void CreateTransferJournal(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalCheckPost inventJournalCheckPost;
NumberSeq num;
boolean _throwserror=true;
boolean _showinforesult=true;
InventDim frominventDim,ToinventDim;
;
ttsbegin;

inventJournalTable.clear();
num = new NumberSeq();
num = NumberSeq::newGetNum
(InventParameters::numRefTransferId());
inventJournalTable.initFromInventJournalName(InventJournalName::find
(InventParameters::find().TransferJournalNameId));
inventJournalTable.Description = “Inventory Transfer Journal”;
inventJournalTable.SystemBlocked = true;
inventJournalTable.insert();

inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.ItemId = “xxxxxx”;
frominventDim.InventLocationId=”xx”;
frominventDim.inventSiteId =”xx”;
ToinventDim.InventLocationId = “xxxx”;
ToinventDim.InventSiteId = “xx”;
ToinventDim = InventDim::findOrCreate(ToinventDim);

frominventDim = InventDim::findOrCreate(frominventDim);
inventJournalTrans.InventDimId = frominventDim.inventDimId;
inventJournalTrans.initFromInventTable(InventTable::find(“1101″));
inventJournalTrans.Qty = 10;
inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;
inventJournalTrans.TransDate = SystemDateget();
inventJournalTrans.insert();

inventJournalCheckPost =
InventJournalCheckPost::newJournalCheckPost
(JournalCheckpostType::Post,inventJournalTable);
inventJournalCheckPost.parmThrowCheckFailed(_throwserror);
inventJournalCheckPost.parmShowInfoResult(_showinforesult);
inventJournalCheckPost.run();

inventJournalTable.SystemBlocked = false;
inventJournalTable.update();

ttscommit;
}


-Harry






July 06, 2013

Creating Vendors through X++ in AX 2012- PART VI

Creating Vendors through X++ in AX 2012- PART VI


--Create communication details--

public void createCommAddress(VendorRequestCreate          _vendorRequestCreate)
{
    VendorRequestCommunication       vendorRequestCommunication;
    ;
select Phone1, Phone2, Email, Fax from vendorRequestCommunication 
where vendorRequestCommunication.WI_VendorRequestCreate == _vendorRequestCreate.RecId;
//Phone 1
if(vendorRequestCommunication.Phone1 != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Phone 1';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Phone1;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Phone;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Phone 2
if(vendorRequestCommunication.Phone2 != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Phone 2';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Phone2;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Phone;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::No;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Email
if(vendorRequestCommunication.Email != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Email';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Email;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Email;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
//Fax
if(vendorRequestCommunication.Fax != '' && vendTable.Party != 0)
    {
        logisticsLocation.clear();
        logisticsLocation   = LogisticsLocation::create('Phone', NoYes::No);
        dirPartyContactInfoView.LocationName                = 'Primay Fax';
        dirPartyContactInfoView.Locator                     = vendorRequestCommunication.Fax;
        dirPartyContactInfoView.Type                        = LogisticsElectronicAddressMethodType::Fax;
        dirPartyContactInfoView.Party                       = vendTable.Party;
        dirPartyContactInfoView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
    }
}


Check below posts for more details....




-Harry