Apr 27, 2014

Job to create expense record by using service classes





Here is the sample job to create expense record  by using service class.


static void createExpLine(Args _args)
{


    TrvExpenseService            expService;    //  Service class
    TrvExpense                   trvExpense;      // Expense Document object
    TrvExpense_TrvExpTable       expenseTable;  // Expense Header data object
    TrvExpense_TrvExpTrans       expenseTrans;  // Expense Line data object
    AifEntityKeyList             entityKeyList; // Entity key list


    TrvExpNumber                 expNum;
    ; 


    // Create the service instance
    expService =  TrvExpenseService::construct(); 


    // Create the document object
    trvExpense = new TrvExpense(); 


    //create the Expense header
    trvExpense.createTrvExpTable();
    expenseTable    = trvExpense.parmTrvExpTable().addNew();
    expenseTable.parmCreatingWorker("000131"); 


     // Create the Line
    expenseTrans    = new  TrvExpense_TrvExpTrans();
    expenseTrans.parmCostType("Car Rental");
    expenseTrans.parmExpType(TrvExpType::CarRental);
    expenseTrans.parmPayMethod("CASH");
    expenseTrans.parmTransDate(today());
    expenseTrans.parmAmountCurr(10);
    expenseTrans.parmProjId("10001");  
    expenseTrans.parmAdditionalInformation("Free Text");  
    expenseTable.createTrvExpTrans().add(expenseTrans);
     // Create Customer


    entityKeyList = expService.create(trvExpense);
    expNum = entityKeyList.getEntityKey(1).parmKeyDataMap().lookup(fieldnum(TrvExpTable, ExpNumber));
    info(strfmt("Created Expense: Exp Number: %1.", expNum)); 


}





























1 comment:

Anonymous said...

Thanks for post