how to create item in batch class

Hai Everyone, Good Morning

I want to create Batch class and for that i want to create a item … it was set it to run for every 5 min … what i want to do for this to create item in batch class and how to set it for run every 5 min

Hi Kavin,

Please create the batch class and schedule your batch job and set the recurrence.

Please refer the below links

http://msdn.microsoft.com/en-in/library/cc636647.aspx

http://dynamicsaxforum.blogspot.in/2013/08/create-and-execute-batch-job-ax-2012.html

Click the recurrence button in the dialog box batch tab and click recurrence button, then you can enter the 5 minutes recurrence in this section.

Thanks,

Hari

Hi Hariharan,

like this only i did in batch job form … In recurrence button i mention minutes but it was automatically change the minutes what ever i given means …

Hi Kavin,

Sorry, no idea. In my side AX 2012, recurrence is working fine. I can able to change the settings. Please try to recreate a batch job and try with new recurrence if it is possible.

Please refer this link for recurrence form http://technet.microsoft.com/en-us/library/aa616143.aspx

Thanks,

Hari

Hai hariharan ,

batch process working correctly after i enter the batch group and captions in recurrence i give no end date and give time for execute …

now in this continues i want to create number sequences for group item details … i write code for create number sequences in class run method … class executing but number sequence not creating … can you give some ideas for this

hi every one for creating an item in runbase batch class … i use this following code for create an item in batch class …

class Batch4DemoClass1 extends RunBaseBatch

{

InventTable inventTable;

InventTableModule inventTableModule;

InventItemLocation inventItemLocation;

NumberSeq numberSeq;

Description recipientEmail;

Notes emailBody;

Description subjectText;

Filename fileName;

Log log;

container con;

SysInfologEnumerator enum ;

}


public container pack()

{

return conNull();

}


public void run()
{
;
// The purpose of your job.

try
{
ttsbegin;
try
{
numberSeq = numberSeq::newGetNum(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(ItemId))));
// numberSeq.num();
inventTable.ItemId = numberSeq.num();
inventTable.ItemId = “”;
inventTable.ItemName = “Onida”;
inventTable.ItemGroupId = “Television”;
inventTable.ModelGroupId = “FRP_PICK”;
inventTable.DimGroupId = “CF-W”;

inventTable.ItemType = ItemType::Item;
inventTable.ItemIdCompany = “”;
inventTable.insert();
inventItemLocation.ItemId = inventTable.ItemId;
inventItemLocation.InventDimId = InventDim::inventDimIdBlank();
inventItemLocation.insert();

inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.Price = 1.00;
inventTableModule.UnitId= “Pcs”;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();

inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.Price = 1.00;
inventTableModule.UnitId= “Pcs”;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();

inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.Price = 1.00;
inventTableModule.UnitId= “Pcs”;
inventTableModule.OverDeliveryPct= 0;
inventTableModule.UnderDeliveryPct= 100;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();
}
catch(Exception::Error)
{
this.sendMail();
}
catch(Exception::Info)
{
this.sendMail();
}
ttscommit;
}
catch
{
this.sendMail();
}

}

public boolean runsImpersonated()
{
// false means that the batch must run on a client.
return false;
}

//
//This is the method for sending en email for Error or exception in adding new Records
//
//Passing the Value of Error from insertToFreeTextInvocie method
//
//
public void sendMail()
{
SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();
;

recipientEmail = “@PER195”;
subjectText = “@PER196”;
// info( " hello world");
// error(‘Syntax Error’);
// error(‘Invalid Code’);
//info(error);
log = Info::infoCon2Str( infolog.copy(1,infolog.num()));
con = infolog.copy(1,infolog.num());
enum = SysInfologEnumerator::newData(con );
emailBody = “@PER194”;
while (enum.moveNext())
{
emailBody +=strfmt(’%1’, enum.currentMessage());
}

if (smmOutlookEmail.createMailItem())
{
smmOutlookEmail.addEMailRecipient(recipientEmail);
smmOutlookEmail.addSubject(subjectText);
// smmOutlookEmail.addFileAsAttachment(fileName);
smmOutlookEmail.addBodyText(emailBody);
smmOutlookEmail.sendEMail(smmSaveCopyOfEMail::No);

}
else
{
error("@PER197");
}

}

public boolean unpack(container packedClass)
{
return true;
}

public static void main(Args args)
{
Batch4DemoClass1 batch;
;

batch = new Batch4DemoClass1();
if (!batch.prompt())
batch.run();
}

use this code for create an ITEM in runbase batch class with Email info log for if number seq not creating … in run() if we comment means in form not creating a number seq so it send an info log to outlook attachment for what error showing and where it is like i mention this run() … i get solution for this and working sucessfully

numberSeq = numberSeq::newGetNum(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(ItemId))));

// numberSeq.num();
// inventTable.ItemId = numberSeq.num();
// inventTable.ItemId = “”;

Hi hari haran thanks for your information … i get solution for creating a item in runbase batch class with error info log to email …