Monday 17 December 2018

Get Approver name from workflow history - ax 2012

Get Approver name from workflow history




public display Name displayApproverName()
{
    WorkflowTrackingTable           workflowTrackingTable;
    WorkflowTrackingStatusTable     workflowTrackingStatusTable;
    WorkflowTrackingCommentTable    workflowTrackingCommentTable;
    WorkflowTrackingWorkItem        workflowTrackingWorkItem;
    WorkflowWorkItemTable           workflowWorkItemTable;

    select ContextCompanyId, ContextTableId, ContextRecId from workflowTrackingStatusTable
        where workflowTrackingStatusTable.ContextCompanyId    == curext()
           && workflowTrackingStatusTable.ContextTableId      == this.TableId
           && workflowTrackingStatusTable.ContextRecId        == this.RecId
        join firstonly TrackingId, CreatedDateTime,user from workflowTrackingTable order by CreatedDateTime desc
            where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
        join workflowTrackingWorkItem where workflowTrackingWorkItem.WorkflowTrackingTable == workflowTrackingTable.RecId
        join workflowWorkItemTable where workflowTrackingWorkItem.WorkItemId == workflowWorkItemTable.Id  ;

    return workflowWorkItemTable.userName();
}

For more information about this error navigate to the report server on the local server machine, or enable remote errors - ssrs report ax 2012

For more information about this error navigate to the report server on the local server machine, or enable remote errors - generating ssrs report - ax 2012.


Go to SQL server management studio (ssms).

connect to Reporting server - Right Click - select properties

Navigate to Advance - change property 'EnableRemoteError' to 'True'.




Tuesday 11 December 2018

use AOT query in code


use AOT query in code
static void Job10(Args _args)
{

    CustInvoiceJour custInvoiceJour;
    Query           query = new Query(queryStr (InventJournalTrans)); // Query name.
    QueryRun        qr;
    QueryBuildRange qbr;
    InventJournalTrans inventJournalTrans;
    MainAccount mA;
    DimensionAttributeValueCombination dimensionAttributeValueCombination;
    HcmWorker hcmWorker;
    JournalError    journalError;
    InventDim   inventDim;
    // Find the InvoiceDate range on AOT Query.
    qbr = query.dataSourceTable( tablenum (InventJournalTrans))
            .findRange( fieldNum (InventJournalTrans, JournalId));

    // We can check if the query range does exist, if not, we can create it.
    if (!qbr)
    {
        qbr = query.dataSourceTable( tableNum (InventJournalTrans))
            .addRange( fieldNum (InventJournalTrans, JournalId));
    }

    // Assigning query range value.
    qbr.value('IJN006806');


    // Executing our query.
    qr = new QueryRun(query);

    // Looping through query results.
    while (qr.next())
    {
        // Assinging query results to table buffer.
        inventJournalTrans = qr.get(tableNum(InventJournalTrans));
        mA = qr.get(tableNum(MainAccount));
        dimensionAttributeValueCombination  = qr.get(tableNum(DimensionAttributeValueCombination));
        inventDim = qr.get(tableNum(InventDim));
        // Showing results.
        info( strFmt ('%1 - %2 - %3' , inventJournalTrans.JournalId,
                                    dimensionAttributeValueCombination.RecId,
                                    inventDim.RecId));
    }

Thursday 22 November 2018

get user name based on user id

workerRecid =  DirPersonUser::findUserWorkerReference('ssgrp021'); // userid

        hcmworker = HcmWorker::find(workerRecid);
        select partyTable where partyTable.RecId == hcmworker.Person;
     
        info(strFmt("%1",partyTable.Name));

Wednesday 21 November 2018

Unable to see the unit price and net amount on the PO Confirmation report

Unable to see the unit price and net amount on the PO Confirmation report


------->>
check box [tik] - 'Purchase order prices/amount' on the Vendor master 'Purchase order defaults' fast tab to display net amount on purchase order confirmation report.

Monday 8 October 2018

look up - restrict duplicates and null values

look up - restrict duplicates and null values 



public static void lookupGroupDimension(FormStringControl _dimensionFocusControl)
{
    Query query = new Query();
    QueryBuildDataSource        queryBuildDataSource;
    QueryBuildRange             queryBuildRange;
    SysTableLookup              sysTableLookup;

    sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionAttributeValue),_dimensionFocusControl);
    sysTableLookup.addLookupfield(fieldNum(DimensionAttributeValue,GroupDimension));

    queryBuildDataSource = query.addDataSource(tableNum(DimensionAttributeValue));
    queryBuildDataSource.orderMode(OrderMode::GroupBy);
    queryBuildDataSource.addGroupByField(fieldNum(DimensionAttributeValue, GroupDimension));
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(DimensionAttributeValue, GroupDimension));
    queryBuildRange.value(SysQuery::valueNotEmptyString());

    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(true);
    sysTableLookup.performFormLookup();
}

debug access

debug access


lease go thorugh this location :
To access the local group policy
  1. From the Start menu, choose Control Panel.
  2. In Control Panel, double-click Administrative Tools.
  3. In the Administrative Tools window, double-click Local Security Policy.
  4. In the Local Security Settings window, expand the Local Policies folder.
  5. Click User Rights Assignment.
  6. In the Policy column, double-click Debug programs to view current local group policy assignments in the Local Security Policy Setting dialog box.
  7. To add new users, click the Add User or Group button.

Sunday 7 October 2018

tts error

tts error

static void TheAxaptaResetTTS(Args _args)
{
    while (appl.ttsLevel() > 0)
    {
        info(strfmt("Level %1 aborted",appl.ttsLevel()));
        ttsAbort;
    }
    info("done");

}

Friday 17 August 2018

SSRS & AX Configuration


Use the below link to config SSRS
https://community.dynamics.com/ax/b/rudrasdynamicsthoughts/archive/2014/04/30/ax2012r3-report-server-step-by-step-installation-and-configuration
In MS Server config Map the DB name.



....................



Thursday 2 August 2018

send mail after submitting PurchRFQ with attachment

Send mail after submitting PurchRFQ with attachment

PurchRFQFormLetter - Main 

pass the table(vendRFQJourLoc) to the custom class to save and send email

_sendEmailRFQ is the custom class

while select
vendRFQJourLoc where
vendRFQJourLoc.RFQCaseId == PurchRFQCaseTable::findRecId(args.record().RecId).RFQCaseId
{ _sendEmailRFQ.runAndSaveSSRSReport(_vendRFQJourLoc); _sendEmailRFQ.RFQEmail(_vendRFQJourLoc); }

..............................................................................................................................................................................................

class K_SendEmailRFQ { }

public void deleteReportFile(str _ReportPath) { str ReportPath = _ReportPath; if(!ReportPath) warning("No file in local to remove"); else WinAPI::deleteFile(@ReportPath); }

./////

public void RFQEmail(VendRFQJour _vendRFQJour) { #define.HTML1(" ") #define.HTML2("") SysEmailParameters parameters = SysEmailParameters::find(); SMTPRelayServerName relayServer; SMTPPortNumber portNumber; SMTPUserName userName; SMTPPassword password; Str subject,body; InteropPermission interopPermission; SysMailer mailer; System.Exception e; FilePath attachFileExcel,attachFileInvoice,attachFileCommon; VendTable vendTable; PurchTable purchTableLoc; str email,Rfqid; FilePath invPath; FilenameOpen _InvoicePath; SysEmailMessageTable message; Notes msgbody ; LogisticsElectronicAddress LogisticsElectronicAddress; LogisticsLocation LogisticsLocation; DirPartyLocation dirPartyLocation; PurchRFQVendLink purchRFQVendLink; // VendRFQJour _vendRFQJour; str emailAddress; RecId recId; str Name; SysUserInfo sysUserInfo; //alle 2192018 msk strt SysEmailTable sysEmailTable; Map mappings = new Map(Types::String, Types::String); //alle 2192018 msk end ; _InvoicePath = this.runAndSaveSSRSReport(_vendRFQJour); select Email from sysUserInfo where sysUserInfo.Id == curUserId(); Name = sysUserInfo.Email; Rfqid = _vendRFQJour.RFQId; while select vendTable where vendTable.AccountNum == _vendRFQJour.VendAccount join dirPartyLocation where vendTable.Party == dirPartyLocation.Party join logisticsElectronicAddress where logisticsElectronicAddress.Location == dirPartyLocation.Location && logisticsElectronicAddress.IsPrimary == NoYes::Yes && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email { email = LogisticsElectronicAddress.Locator; if (parameters.SMTPRelayServerName) relayServer = parameters.SMTPRelayServerName; else relayServer = parameters.SMTPServerIPAddress; portNumber = parameters.SMTPPortNumber; userName = parameters.SMTPUserName; password = SysEmailParameters::password(); body += strFmt(' <b> Please find attached our Request for Quote number '+Rfqid+'') + "<br/><br/>"; sysEmailTable = SysEmailTable::find('RFQ'); message = SysEmailMessageTable::find(sysEmailTable.EmailId, sysEmailTable.DefaultLanguage); subject = message.Subject; msgbody = message.Mail; CodeAccessPermission::revertAssert(); try { interopPermission = new InteropPermission(InteropKind::ComInterop); interopPermission.assert(); mailer = new SysMailer(); mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM); mailer.fromAddress("ax@scgroup.global"); //(SysUserInfo::find().Email); mailer.tos().appendAddress(email); //_defEmail); mailer.ccs().appendAddress(Name); mailer.attachments().add(_InvoicePath); mailer.subject(subject); mailer.htmlBody(body+msgbody); // mailer.htmlBody(body); mailer.sendMail(); CodeAccessPermission::revertAssert(); info("Email sent successfully "); } catch (Exception::CLRError) { e = ClrInterop::getLastException(); while (e) { info(e.get_Message()); e = e.get_InnerException(); } CodeAccessPermission::revertAssert(); info ("error"); } //mappings.insert('RFQNumber', _vendRFQJour.RFQId); //sysEmailTable = SysEmailTable::find('RFQ'); //SysEmailTable::sendMail(sysEmailTable.EmailId, //'en-au', // Chosen language //email ,//'sivakumar@x.com', // Who you're sending the email to //mappings, // Your variable mappings //_InvoicePath, // Location of file attachment (server/client matters) or none //"" , // XML if you're using XSLT //false , // Traceable or not? //'admin', // Sending user //false); // Use retries? } WinAPI::deleteFile(_InvoicePath); //WinAPI::deleteFile(_commonPath); //WinAPI::deleteFile(_ExcelPath); WinAPI::deleteFile(attachFileExcel); WinAPI::deleteFile(attachFileInvoice); WinAPI::deleteFile(attachFileCommon); }

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

public str runAndSaveSSRSReport(VendRFQJour _vendRFQJourLoc) { SrsReportRunController ssrsController = new SrsReportRunController(); PurchRFQSendContract Contract = new PurchRFQSendContract(); SRSPrintDestinationSettings printerSettings; //VendRFQJour _vendRFQJourLoc; str ReportPath; /*select firstOnly _vendRFQJourLoc order by _vendRFQJourLoc.createdDateTime DESC where _vendRFQJourLoc.RFQCaseId == _caseTable.RFQCaseId;*/ ReportPath = "C:\\SendRFQReport\\" + _vendRFQJourLoc.RFQId +".pdf"; ssrsController.parmReportName(ssrsReportStr(RFQSend, Report)); ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous); ssrsController.parmShowDialog(false); Contract.parmPurchInternalRFQId(_vendRFQJourLoc.InternalRFQId); Contract.parmDocumentTitle('Request for Quotation'); ssrsController.parmReportContract().parmRdpContract(Contract); printerSettings = ssrsController.parmReportContract().parmPrintSettings(); printerSettings.printMediumType(SRSPrintMediumType::File); printerSettings.fileFormat(SRSReportFileFormat::PDF); printerSettings.overwriteFile(true); printerSettings.fileName(@ReportPath); ssrsController.runReport(); return ReportPath; }

..................................................................................................................................................................

public static void main(Args _args) { PurchRFQCaseTable _vendRFQJourLo; FilenameOpen attachmentFilename; Alle_SendEmailRFQ sendEmailPOConfirmation; sendEmailPOConfirmation = new K_SendEmailRFQ();
}

Wednesday 9 May 2018

update default dimensions in ax 2012

update default dimensions in ax 2012


class ProjDimUpload
{
    

}

..............................................................

public void importProjDim()

{

    RecId               recIdDefaultDimension,Dimension3,itemid;

    //table

    ForecastSales               forecastSales,forecastSalesLoc;

    CustTable                   custTable;

    DefaultDimensionView       defaultDimensionView;

    InventTable               inventTable;

 
    container   financialDimensionFromExcel;

    container   conDimensionName;

    ;

    while select forecastSales

    {

        select forupdate forecastSalesLoc where forecastSalesLoc.CustAccountId == forecastSales.CustAccountId

            && forecastSalesLoc.ItemId == forecastSales.ItemId

            && forecastSalesLoc.RecId == forecastSales.RecId;


        conDimensionName = this.TIDgetDimensionName();

        financialDimensionFromExcel += "";

        financialDimensionFromExcel += "";

        financialDimensionFromExcel += forecastSalesLoc.CustAccountId;

        financialDimensionFromExcel += "";

        financialDimensionFromExcel += "";

        financialDimensionFromExcel += forecastSalesLoc.ItemId;

        financialDimensionFromExcel += "";

        financialDimensionFromExcel += "";


        custTable = CustTable::find(forecastSalesLoc.CustAccountId);

        
        recIdDefaultDimension       = this.TIDcreateDefaultDimension(conDimensionName,financialDimensionFromExcel);


      Dimension3 = DimensionDefaultingService::serviceMergeDefaultDimensions(recIdDefaultDimension, custTable.DefaultDimension);



        Dimension3 = DimensionDefaultingService::serviceMergeDefaultDimensions(itemid, custTable.DefaultDimension);



        forecastSalesLoc.DefaultDimension =Dimension3;



        //forecastSalesLoc.DefaultDimension = recIdDefaultDimension;

        forecastSalesLoc.update();

    }

}
.............................................................................

Public DimensionDefault TIDcreateDefaultDimension(container _attr, container _value, boolean _createIfNotFound = true)
{
    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                    result;
    int                                 i;
    DimensionAttribute                  dimensionAttribute;
    DimensionAttributeValue             dimensionAttributeValue;
    //_attr is dimension name in table DimensionAttribute
    container               conAttr =   _attr;
    container               conValue = _value;
    str                     dimValue;

    for (i = 1; i <= conLen(conAttr); i++)
    {
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

        if (dimensionAttribute.RecId == 0)
        {
            continue;
        }

        dimValue = conPeek(conValue,i);

        if (dimValue != "")
        {
            // _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.
            dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,_createIfNotFound);

            // Add the dimensionAttibuteValue to the default dimension
            valueSetStorage.addItem(dimensionAttributeValue);
        }
    }
    result = valueSetStorage.save();
    return result;
}


..............................

public  container TIDgetDimensionName()
{
    DimensionAttribute              dimAttr;
    DimensionAttributeSetItem       dimAttrSetItem;
    DimensionEnumeration            dimensionSetId;
    DimensionAttributeValue         dimAttributeValue;
    container                       DimensionName;

    dimensionSetId      = DimensionCache::getDimensionAttributeSetForLedger();

    while select dimAttr order by Name
                where dimAttr.Type != DimensionAttributeType::MainAccount
            join RecId from dimAttrSetItem
                where dimAttrSetItem.DimensionAttribute     == dimAttr.RecId &&
                      dimAttrSetItem.DimensionAttributeSet  == dimensionSetId
            {
                dimensionName += dimAttr.Name;

            }

    return DimensionName;
}



/////////////////////////////////////////

public static void main(Args args)
{
   ProjDimUpload projDimUpload = new ProjDimUpload();
    projDimUpload.importProjDim();
}

Wednesday 2 May 2018

create and post invoice journal ax 2012

create and post invoice journal ax 2012

public void createpostInvoiceJournal(ProjInvoiceJour    projInvoiceJour)
{
    LedgerJournalCheckPost  jourCheckPost;
    LedgerJournalTable      jourTable;

    AxLedgerJournalTable    header  = new AxLedgerJournalTable();
    AxLedgerJournalTrans    trans   = new AxLedgerJournalTrans();

    container               offsetDim;

    GeneralJournalAccountEntry  generalJournalAccountEntry;
    GeneralJournalEntry         generalJournalEntry;
    ProjParameters              projParameters;
    ProjJournalTrans            projJournalTrans;
    DimensionAttributeValueSetStorage   dimStorage;
    Str                                 worker;
    Counter                             i;

    // The AP invoice journal name, could vary.
    LedgerJournalNameId     ledgerJournalNameId;

    // This is the entry against the Vendor account.
    // It will have to pre-exist for this script to work.
    // It is probably created the first time such an entry is
    // made on a journal line.
    DimensionAttributeValueCombination  davc;

    LedgerJournalACType         accType, offsetAccType;
    BankAccountTable            bankAccountTable;

    accType         = LedgerJournalACType::Vend;
    offsetAccType   = LedgerJournalACType::Ledger;

    select projParameters;
    ledgerJournalNameId = projParameters.JournalName;
    header.parmJournalName(ledgerJournalNameId);
    header.parmJournalType(LedgerJournalType::VendInvoiceRegister);
    header.save();

    select generalJournalEntry
        join generalJournalAccountEntry where generalJournalEntry.JournalNumber == GeneralJournalEntry::findBySubledgerVoucher(projInvoiceJour.LedgerVoucher,curext()).JournalNumber
            && generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId
            && generalJournalAccountEntry.PostingType == LedgerPostingType::ProjPayrollAllocation;

    trans.parmAccountType(accType);
    trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
    trans.parmInvoice(projInvoiceJour.ProjInvoiceId);

    //First is Display value, followed by Main Account and then dimensions.

    trans.parmAccountType(LedgerJournalACType::Vend);

    // Note: This only works if the DimensionValueAttributeCombindation record
    // exists from before.
    select projJournalTrans where projJournalTrans.ProjId == projInvoiceJour.ProjInvoiceProjId;
    select firstonly RecId from davc
        where davc.DisplayValue == projJournalTrans.ALE_AccountNum;// "202-000300"; //Vendor123 is the vendor account number.

    trans.parmLedgerDimension(davc.RecId);

    //There's a parm method for credit as well. generalJournalAccountEntry.
    trans.parmAmountCurDebit(generalJournalAccountEntry.AccountingCurrencyAmount);
    trans.parmOffsetAccountType(offsetAccType);
//offsetDim   = ["52121-Disp", "52121", 2, "Site", "12345", "Department", "204"];  
//52121-12345-204,"52121",2,"site",12345,'dep',204
//main account and other dim followed by - and no of dim 
    //trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDim));
    trans.clearField(fieldNum(ledgerJournalTrans, offsetLedgerDimension), false);
    trans.parmOffsetLedgerDimension(generalJournalAccountEntry.LedgerDimension);

    dimStorage = DimensionAttributeValueSetStorage::find(generalJournalAccountEntry.LedgerDimension);

    for (i= 1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "worker")
        {
            worker = dimStorage.getDisplayValueByIndex(i);
        }
    }
    trans.parmApprover(str2int(worker));
    trans.parmApproved(NoYes::Yes);

    trans.save();

    jourTable =  header.ledgerJournalTable();

    if (jourTable.RecId > 0)
    {
        jourCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(jourTable,
                                                                NoYes::Yes,
                                                                NoYes::Yes);
        // Post only if there is succesful validation.
        //if (jourCheckPost.validate())
        {
            jourCheckPost.run();
        }
    }
}

Monday 26 February 2018

vendor import ref pepper


vendor import ref pepper


static void VendorImport(Args _args)
{
    Dialog                      dialog;
    Filename                    filename;
    DialogField                 dialogFileName;

    InboundMerchantTable            vendTable;
    InboundMerchantCommunication    vendAddress;
    EcomMerchantContact             vendContact;

    COMVariantType              type;
    SysExcelCells               cells;
    SysExcelWorkbook            workbook;
    SysExcelWorkbooks           workbooks;
    SysExcelWorksheet           worksheet;
    SysExcelWorksheets          worksheets;
    SysExcelApplication         application;

    VendAccount                 vendAccount;
    Name                        vendName;
    CurrencyCode                currency;
    VendGroupId                 vendGroupId;
    DlvTermId                   dlvTermId;
    PaymTermId                  paymTermId;
    PaymMode                    paymMode;
    EcomBusinessModel           ecomBusinessModel;
    Email                       stockIntimationEmail;
    str                         vendBankAccountId;
    VendBank                    vendBank;
    Name                        bankName;
    SWIFTNo                     SWIFTNo;
    BankIBAN                    bankIBAN;
    str                         routingNum;
    str                         ifsc, beneficiaryName;

    str                         purpose;
    Addressing                  street;
    LogisticsAddressCity        city;
    LogisticsAddressStateId     state;
    LogisticsAddressZipCodeId   zipCode;

    LogisticsAddressCountryRegionId      county;

    TaxRegistrationNumber_IN    vatRegistration;
    TaxRegistrationNumber_IN    cstRegistration;
    TaxRegistrationNumber_IN    serviceTaxRegistration;
    TaxRegistrationNumber_IN    tanRegistration;
    TaxGroup                    salesTaxGroup;
    TaxGroup                    whtTaxGroup;
    PANNumber_IN                PANNumber;

    ContactPersonName           contactPersonName;
    ContactPersonName           addContactPersonName;
    Phone                       contactPhone, contactPhone2;
    Email                       contactEmail;
    Email                       POEmail;
    Email                       PREmail;

    int                         processed, failed, totalRecords = 1000, row = 1;
    SysOperationProgress        simpleProgress;
    #AviFiles
    ;

    dialog = new Dialog("Import payment");
    dialogFileName = dialog.addField(extendedTypeStr(Filenameopen), "File path");

    dialog.run();

    if (dialog.run())
    {
        filename = dialogFileName.value();
    }

    simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing payment lines.', totalRecords);

    application = SysExcelApplication::construct();
    workbooks = application.workbooks();

    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File not found");
    }

    workbook    = workbooks.item(1);
    worksheets  = workbook.worksheets();
    worksheet   = worksheets.itemFromNum(1);
    cells       = worksheet.cells();

    //Iterate through cells and get the values
    ttsBegin;
    do
    {
        //Incrementing the row line to next Row
        row++;
        vendAccount              = COMVariant2Str(cells.item(row, 1).value());
        vendName                 = COMVariant2Str(cells.item(row, 2).value());
        currency                 = COMVariant2Str(cells.item(row, 3).value());
        vendGroupId              = COMVariant2Str(cells.item(row, 4).value());
        dlvTermId                = COMVariant2Str(cells.item(row, 5).value());
        paymTermId               = COMVariant2Str(cells.item(row, 6).value());
        paymMode                 = COMVariant2Str(cells.item(row, 7).value());
        ecomBusinessModel        = str2enum(ecomBusinessModel, COMVariant2Str(cells.item(row, 8).value()));
        stockIntimationEmail     = COMVariant2Str(cells.item(row, 9).value());

        vendBankAccountId        = COMVariant2Str(cells.item(row, 10).value());
        vendBank                 = COMVariant2Str(cells.item(row, 11).value());
        bankName                 = COMVariant2Str(cells.item(row, 12).value());
        SWIFTNo                  = COMVariant2Str(cells.item(row, 13).value());
        bankIBAN                 = COMVariant2Str(cells.item(row, 14).value());
        routingNum               = COMVariant2Str(cells.item(row, 15).value());
        ifsc                     = COMVariant2Str(cells.item(row, 16).value());

        purpose                  = COMVariant2Str(cells.item(row, 17).value());
        street                   = COMVariant2Str(cells.item(row, 18).value());
        city                     = COMVariant2Str(cells.item(row, 19).value());
        state                    = COMVariant2Str(cells.item(row, 20).value());
        zipCode                  = COMVariant2Str(cells.item(row, 21).value());
        county                   = COMVariant2Str(cells.item(row, 22).value());

        vatRegistration          = COMVariant2Str(cells.item(row, 23).value());
        cstRegistration          = COMVariant2Str(cells.item(row, 24).value());
        serviceTaxRegistration   = COMVariant2Str(cells.item(row, 25).value());
        tanRegistration          = COMVariant2Str(cells.item(row, 26).value());
        salesTaxGroup            = COMVariant2Str(cells.item(row, 27).value());
        whtTaxGroup              = COMVariant2Str(cells.item(row, 28).value());
        PANNumber                = COMVariant2Str(cells.item(row, 29).value());

        contactPersonName        = COMVariant2Str(cells.item(row, 30).value());
        addContactPersonName     = COMVariant2Str(cells.item(row, 31).value());
        contactPhone             = COMVariant2Str(cells.item(row, 32).value());
        contactPhone2            = COMVariant2Str(cells.item(row, 33).value());
        contactEmail             = COMVariant2Str(cells.item(row, 34).value());
        POEmail                  = COMVariant2Str(cells.item(row, 35).value());
        PREmail                  = COMVariant2Str(cells.item(row, 36).value());

        beneficiaryName          = COMVariant2Str(cells.item(row, 37).value());


        vendTable.clear();
        vendTable.initValue();

        vendTable.MerchantId            = vendAccount;
        vendTable.Name                  = vendName;
        vendTable.Currency              = currency;
        vendTable.TermsOfPayment        = paymTermId;
        vendTable.MethodOfPayment       = paymMode;
        vendTable.EcomBusinessModel     = ecomBusinessModel;

        vendTable.VendBankAccountNum    = vendBankAccountId;
        vendTable.VendBankAccountId     = vendBank;
        vendTable.VendBankName          = bankName;
        vendTable.SWIFTNo               = SWIFTNo;
        vendTable.IFSCCode              = ifsc;
        vendTable.IBAN                  = bankIBAN;
        vendTable.BankRegistrationNum   = routingNum;
        vendTable.PANNumber             = PANNumber;
        vendTable.TDSGroup              = whtTaxGroup;
        vendTable.isVendorOnly          = true;

        vendTable.BeneficiaryName       = beneficiaryName;

        vendTable.ContactFirstName      = contactPersonName;
        vendTable.Email                 = contactEmail;
        vendTable.Phone                 = contactPhone;
        vendTable.Phone2                = contactPhone2;
        vendTable.StockIntimationEmail  = stockIntimationEmail;
        vendTable.PurchaseIntimationEmail= POEmail;

        vendTable.insert();

        vendAddress.clear();
        vendAddress.initValue();

        vendAddress.InboundMerchantTable= vendTable.RecId;

        vendAddress.AddressId           = vendTable.MerchantId + "_1";
        vendAddress.Address             = street;
        vendAddress.City                = city;
        vendAddress.StateId             = state;
        vendAddress.ZipCode             = zipCode;
        vendAddress.CountryRegionId     = county;

        vendAddress.SalesTaxRegistrationNumber     = cstRegistration;
        vendAddress.TIN                            = vatRegistration;
        vendAddress.ServiceTaxRegistrationNumber   = serviceTaxRegistration;
        vendAddress.TANRegistrationNumber          = tanRegistration;
        vendAddress.Email                          = contactEmail;
        vendAddress.Phone                          = contactPhone;

        vendAddress.insert();


        vendContact.clear();
        vendContact.initValue();

        vendContact.InboundMerchantTable    = vendTable.RecId;
        vendContact.FirstName               = addContactPersonName;
        vendContact.Email                   = contactEmail;
        vendContact.Phone                   = contactPhone;
        vendContact.Phone1                  = contactPhone2;

        vendContact.insert();

        simpleProgress.incCount();
        simpleprogress.setText(strfmt("Vendor no.: %1 Rows: %2", vendAccount, row));
        simpleprogress.update(true);

        type = cells.item(row+1, 1).value().variantType();
    }
    while (type != COMVariantType::VT_EMPTY);

    ttsCommit;

    // quits the application
    application.quit();

    info(strFmt("Total: %1 Processed: %2 Failed: %3", row, processed, failed));
}

Get GST rates ref pepper

Get GST rates ref pepper

static void aks_GetGSTRate(Args _args)
{
    TaxRuntimeLookupCondition               taxRuntimeLookupCondition;
    TaxRuntimeLookupMeasureResult           taxRuntimeLookupMeasureResult;
    TaxRuntimeLookupMeasureResultDetail     taxRuntimeLookupMeasureResultDetail;
    TaxRuntimeLookup                        taxRuntimeLookup;
    TaxRuntimeLookupVersion                 taxRuntimeLookupVersion;
    TaxRuntimeDocComponentMeasure           taxRuntimeDocComponentMeasure;
    TaxRuntimeDocComponentMeasureVersion    taxRuntimeDocComponentMeasureVersion;
    TaxRuntimeDocComponent                  taxRuntimeDocComponent;
    TaxRuntimeDocComponentVersion           taxRuntimeDocComponentVersion;
    TaxRuntimeDocTaxType                    taxRuntimeDocTaxType;
    TaxRuntimeDocTaxTypeVersion             taxRuntimeDocTaxTypeVersion;


    while select taxRuntimeLookupCondition
        where taxRuntimeLookupCondition.DimValue1 == 'KA' &&
        taxRuntimeLookupCondition.DimValue2 == '73239200' &&
        taxRuntimeLookupCondition.Ledger == CompanyInfo::find().RecId
    {
        taxRuntimeLookupVersion = TaxRuntimeLookupVersion::find(taxRuntimeLookupCondition.LookupVersion);
        taxRuntimeLookup = TaxRuntimeLookup::find(taxRuntimeLookupVersion.Lookup);

        switch(taxRuntimeLookup.LookupOwnerTableId)
        {
            case tableNum(TaxRuntimeDocComponentMeasure):
                taxRuntimeDocComponentMeasure   =   TaxRuntimeDocComponentMeasure::find(taxRuntimeLookup.LookupOwnerRecId);

                select taxRuntimeDocComponentMeasureVersion order by taxRuntimeDocComponentMeasureVersion.RecId desc
                        where taxRuntimeDocComponentMeasureVersion.TaxRuntimeDocComponentMeasure == taxRuntimeDocComponentMeasure.RecId;

                select firstOnly taxRuntimeLookupMeasureResult
                        join forUpdate taxRuntimeLookupMeasureResultDetail
                    where taxRuntimeLookupMeasureResult.LookupCondition == taxRuntimeLookupCondition.RecId
                        && taxRuntimeLookupMeasureResultDetail.LookupMeasureResult == taxRuntimeLookupMeasureResult.RecId;
                break;

            case tableNum(TaxRuntimeDocComponent):
                taxRuntimeDocComponent  =   TaxRuntimeDocComponent::find(taxRuntimeLookup.LookupOwnerRecId);

                select taxRuntimeDocComponentVersion order by taxRuntimeDocComponentVersion.RecId desc
                        where taxRuntimeDocComponentVersion.TaxRuntimeDocComponent ==  taxRuntimeDocComponent.RecId;
                break;

            case tableNum(TaxRuntimeDocTaxType):
                taxRuntimeDocTaxType    =   TaxRuntimeDocTaxType::find(taxRuntimeLookup.LookupOwnerRecId);

                select taxRuntimeDocTaxTypeVersion order by taxRuntimeDocTaxTypeVersion.RecId
                        where taxRuntimeDocTaxTypeVersion.TaxRuntimeDocTaxType ==  taxRuntimeDocTaxType.RecId;
                break;
        }

        info(strFmt("Path: %1,Value:%2",taxRuntimeDocComponentMeasure.Path,taxRuntimeLookupMeasureResultDetail.Value));
    }
}

Remove reserved item

Remove reserved item Ref pepper

static void A_RemoveReserveItem(Args _args)
{
    InventTrans             inventTrans;
    InventTransOrigin       inventTransOrigin;
    InventMovement          inventMovement;
    InventUpd_Reservation   inventUpd_Reservation ;

    while select inventTrans
    where  inventTrans.ItemId                      == -P-WH4688'
    &&  inventTrans.StatusReceipt               == StatusReceipt::None
    && (inventTrans.StatusIssue                 == StatusIssue::ReservPhysical
    ||  inventTrans.StatusIssue                 == StatusIssue::ReservOrdered)
    exists join inventTransOrigin
    where   inventTransOrigin.RecId            == inventTrans.InventTransOrigin
    {

    if (inventTrans.MarkingRefInventTransOrigin)
    {
    InventTransOrigin::deleteMarking(inventTrans.MarkingRefInventTransOrigin, inventTrans.InventTransOrigin, -inventTrans.Qty, true);
    InventTransOrigin::deleteMarking(inventTrans.InventTransOrigin, inventTrans.MarkingRefInventTransOrigin, inventTrans.Qty, true);
    }

    if (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered)
    {
    Inventmovement = inventTrans.inventmovement(true);
    inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTrans.inventDim(), -1 * inventTrans.Qty, false);
    inventUpd_Reservation.updatenow();
    }
    }
    info('Done');
}

on hand qty

on hand qty

static void OnHandQty(Args _args)
{
    InventDim       inventDim;
    InventSum       inventSum;
    InventOnhand    inventOnHand;
    InventDimParm   inventDimParm;
    ItemId          itemId;
    InventQty       availQty;
    InventQty       inventQty;

    while select sum(postedQty), sum(received), sum(deducted), sum(registered),
    sum(picked), sum(reservPhysical)
    from InventSum group by itemId
    join InventDim
    where inventSum.inventDimId == inventDim.inventDimId &&
    inventSum.itemId == 'B' &&
    inventDim.inventLocationId == 'Mumbai'
    {
    inventQty = inventSum.PostedQty+inventSum.Received+inventSum.Deducted-
    inventSum.Picked-inventSum.ReservPhysical;
    }
    info(strfmt('%1', inventQty));

    itemId = 'BA1502926-P-WH15766-01';
    inventDim.InventLocationId = 'Mumbai';
    inventDimParm.initFromInventDim(inventDim);
    inventOnHand = inventOnHand::newParameters(itemId,inventDim,inventDimParm);
    availQty = inventOnHand.availPhysical();
    info(strfmt('%1', availQty));
}

Wednesday 21 February 2018

get numerical from the string


Get numerical from the string

gstStr  = subStr(this.RegistrationNumber,1,2);

    if(strlen(gstStr) != strlen(strkeep(gstStr,'1234567890')))
    {
        ret = checkFailed("First two digists should be numericals");
    }

Monday 19 February 2018

Run SQL queries in Sql Server

Run SQL queries

select SL.SALESID, SL.CREATEDDATETIME, sl.ECOMSALESID, SL.ORDERSKUID, sl.ITEMID, sl.SALESQTY, SL.LINEAMOUNT, SL.SALESSTATUS, id.INVENTSITEID, id.INVENTLOCATIONID from SALESLINE as SL
 Join INVENTDIM as ID
 ON ID.INVENTDIMID = SL.INVENTDIMID
 And ID.DATAAREAID = sl.DATAAREAID
where SL.SALESQTY < 0
And sl.DATAAREAID = 'tsc'
And SL.CREATEDDATETIME >= '2017-04-01'
And SL.CREATEDDATETIME <= '2018-01-31'


........................................................................

select ECOMT.ORDERSKUID,ECOMT.SOPOSTERRORMSG,ECOMT.COURIERPICKDATETIME,SLIN.HSNCODETABLE, SL.ORDERSKUID,SL.SALESID,SL.TAXGROUP,SL.SALESSTATUS from SALESLINE as SL
join INBOUNDWEBORDERLINE as IWL on IWL.SALESID = SL.SALESID
and  IWL.ITEMID = SL.ITEMID
join ECOMMANIFESTTABLE as ECOMT on ECOMT.ORDERSKUID = IWL.ORDERSKUID
join INBOUNDWEBORDERHEADER as IWH on IWH.EcomSalesId = IWL.ECOMSALESID
join ALLE_MANIFESTSTATUS as AMS on AMS.ECOMMANIFESTTABLE = ECOMT.RECID
join SALESLINE_IN as SLIN on SLIN.SALESLINE = SL.RECID
where SLIN.HSNCODETABLE = 0
AND ECOMT.POSTED = 0
AND IWL.ONHOLD = 0
AND IWL.ISRENTALORDER = 0
AND IWH.ONHOLD = 0
AND SL.DATAAREAID = 'tsc'
AND SLIN.DATAAREAID = SL.DATAAREAID
AND IWH.ORDERCONFIRMATIONDATE >= '2017-01-01'
And ECOMT.COURIERPICKDATETIME >= '2017-04-01'
And ECOMT.COURIERPICKDATETIME <= '2017-06-30'

Friday 16 February 2018

SSRS report save and trigger mail




passing string255 value from Form to the class as

PaymentAdviceSettlementEmail.parmSpecTransRecIdRange(orgRange);
   PaymentAdviceSettlementEmail.run();


.................................................................................................................................


class PaymentAdviceSettlementEmail extends RunBaseBatch
{
    String255       recIdRange;
}

............

public void deleteReportFile(str _reportPath)
{
    if(!_reportPath)
        warning('No file in local to remove');
    else
        System.IO.File::Delete(@_reportPath);
}

..................

private Integer fileSizeInByte(FilePath _filePath)
{
    return WinAPI::filesize(_filePath);
}

.........................

Public void parmSpecTransRecIdRange(String255   _range)
{
    recIdRange =  _range;
}

.............

public NoYesBlank PaymentAdviceEmail(String255 _specTrans)
{
    str                         ccsMailAddr,specRecId;
    int64                       specRecIdInt;
    SpecTrans                   specTrans;
    VendTable                   vendTable;
    VendTrans                   vendTrans;
    Map                         parameterMap = new Map(Types::String, Types::String);
    Email                       requester;

    FilenameOpen                attachmentFilename;
    LogisticsElectronicAddress  logisticsElectronicAddress;
    DirPartyLocation            dirPartyLocation;
    VendPurchOrderJour          vendPurchOrderJour;
    ;

    attachmentFilename = this.runAndSaveSSRSReport(_specTrans);

    specRecId = subStr(_specTrans,1,10);
    specRecIdInt = str2int64(specRecId);

    select specTrans where specTrans.RecId == specRecIdInt;
    select vendTable where vendTable.dataAreaId == specTrans.SpecCompany && vendTable.TableId == specTrans.SpecTableId && vendTable.RecId == specTrans.SpecRecId;

    select RecId from dirPartyLocation
        where dirPartyLocation.Party == VendTable::find(vendTable.AccountNum).Party
    join logisticsElectronicAddress
        where logisticsElectronicAddress.Location   == dirPartyLocation.Location &&
        logisticsElectronicAddress.Type             == LogisticsElectronicAddressMethodType::Email &&
        logisticsElectronicAddress.EcomEmailType    == EcomEmailType::PaymentAdvice;

    if (logisticsElectronicAddress.Locator)
    {
        requester   = logisticsElectronicAddress.Locator;
    }
    else
    {
        requester   = LogisticsElectronicAddress::findRecId(DirPartyTable::findRec(
            VendTable::find(vendTable.AccountNum).Party).PrimaryContactEmail).Locator;
    }

    select vendTrans where vendTrans.AccountNum == vendTable.AccountNum;

    parameterMap.insert('VendorName', VendTable::find(vendTable.AccountNum).name());
    parameterMap.insert('VendorCode', vendTable.AccountNum);
    //parameterMap.insert('InvoiceDate', date2str(vendTrans.TransDate, 123, 2, DateSeparator::Slash, 2, DateSeparator::Slash, 4,DateFlags::None));

    ccsMailAddr = SysEmailTable::find(VendParameters::find().EcomPayAdviceEmailId).EcomReceiverCCs;

    try
    {
        SysEmailTable::sendMail(VendParameters::find().EcomPayAdviceEmailId, SysEmailTable::find(VendParameters::find().EcomPayAdviceEmailId).DefaultLanguage,
                                  requester, parameterMap, attachmentFilename, '', true, curUserId(), true,  strLTrim(strRTrim(ccsMailAddr)),
                                  BaseEmailDocument::PaymentAdvice,"");

        this.deleteReportFile(attachmentFilename);
    }
    catch
    {
        throw Error('Unable to send the E-mail.');
    }

    return NoYesBlank::Yes;
}

////////////////////////////////////////////////////////////////

public void run(Args _args = null)
{
    this.PaymentAdviceEmail(recIdRange);
}


......................................


public str runAndSaveSSRSReport(String255 _specTrans)
{
    str reportPath, attachmentFolder;
    SrsReportRunController           ssrsController = new SrsReportRunController();
    Alle_PaymentAdviceVendContract  contract = new Alle_PaymentAdviceVendContract();


    SRSPrintDestinationSettings     printerSettings;
    ;

    attachmentFolder = SysEmailParameters::find().AttachmentsPath;

    reportPath = attachmentFolder + "\\" + "PaymentAdvice" +'.pdf';

    ssrsController.parmReportName(ssrsReportStr(Alle_PaymentAdviceVendReport, PaymentAdviceVendReport));
    ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    ssrsController.parmShowDialog(false);
    contract.parmString(_specTrans);
    ssrsController.parmReportContract().parmRdpContract(contract);

    //link the printer settings to the controller
    printerSettings = ssrsController.parmReportContract().parmPrintSettings();

    //print to pdf and always overwrite if the file exists
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);
    printerSettings.fileName(@ReportPath);

    //run & save the report
    ssrsController.runReport();

    if ((SysEmailParameters::find().EcomCheckPDFMinSize == NoYes::Yes) && (this.fileSizeInByte(@ReportPath) < SysEmailParameters::find().EcomMinPDFSize))
        throw error('Please check the report manually.');

    return reportPath;
}


..................................................

server static ALE_PaymentAdviceSettlementEmail construct()
{
    return new ALE_PaymentAdviceSettlementEmail();
}


..................................

static void main(Args _args)
{
    ALE_PaymentAdviceSettlementEmail   paymentAdviceSettlementEmail =   new ALE_PaymentAdviceSettlementEmail();

    if (paymentAdviceSettlementEmail.prompt())
    {
        paymentAdviceSettlementEmail.run(_args);
    }

}

.............................................



now report classess

[DataContractAttribute]
class PaymentAdviceVendContract
{
    String255   settleRecId;

}

....................


public String255 parmString(String255 _settleRecId = settleRecId)
{
    settleRecId = _settleRecId;
    return settleRecId;
}


.......................

[
 
    SRSReportParameterAttribute(classStr(PaymentAdviceVendContract))
]
class Alle_PaymentAdviceVendDP extends SrsReportDataProviderPreProcessTempDB
{
    TransDate                           fromDate,toDate;
    VendAccount                         vendorAccount;
    PaymentAdviceVendTmp           PaymentAdviceVendTmp;2018
}


/..............................

[
    SRSReportDataSetAttribute(tableStr(PaymentAdviceVendTmp))
]
public aymentAdviceVendTmp getPurchaseRegisterTmp()
{
    select PaymentAdviceVendTmp;
    return PaymentAdviceVendTmp;
}

...............


/
[
    SysEntryPointAttribute(false)
]
public void processReport()
{
    SpecTrans                       specTrans;
    container                       convertStr2Int64;
    String255                       settledRedIdLoc;
    int64                           settleRecIdLoc,settleRecIdRange;
    int                             i;

    PaymentAdviceVendContract paymentAdviceVendContract;

    paymentAdviceVendContract   = this.parmDataContract() as PaymentAdviceVendContract;
    settledRedIdLoc             = paymentAdviceVendContract.parmString();
    convertStr2Int64            = str2con(settledRedIdLoc,",",true);

    for(i=1;i <= conlen(convertStr2Int64); i++)
    {
        settleRecIdRange = conpeek(convertStr2Int64, i);

        if(settleRecIdRange)
        {
            while select specTrans where specTrans.RecId == settleRecIdRange
            {
                this.insertTmpTable(specTrans);
            }
        }
    }
}



.............................

private void insertTmpTable(SpecTrans   _spectrans)
{
    VendTransOpen       vendtransopen;
    VendTrans           vendTrans;
 
    BankAccountTrans    bankAccountTrans;


    select firstOnly RefRecId, AccountNum, AmountCur, TDSAmount_IN from vendtransopen
        where vendtransopen.TableId == _spectrans.RefTableId && vendtransopen.RecId ==  _spectrans.RefRecId;

    select firstOnly Voucher, AccountNum, Invoice, CurrencyCode from vendTrans
        where vendTrans.RecId == vendtransopen.RefRecId && vendTrans.AccountNum == vendtransopen.AccountNum;


    select firstOnly AccountId from  bankAccountTrans
        where bankAccountTrans.Voucher == vendTrans.Voucher;
 

    PaymentAdviceVendTmp.Voucher       =   vendTrans.Voucher;
 
 
    PaymentAdviceVendTmp.insert();

}

...............................................................................................................

Controller class


public class PaymentAdviceVendController extends SrsReportRunController
{
    Map             SpecTransRecId;
    String255       recIdRange;
    MapEnumerator   mapEnumerator;
    #define.ReportName('PaymentAdviceVendReport.PaymentAdviceVendReport')
}

......................

Public void parmSpecTransRecIdRange(String255   _range)
{
    recIdRange =  _range;
}

....
...

protected void prePromptModifyContract()
{
    //this.setRanges(this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey()));
    this.setRanges(this.getFirstQuery());
}

.......

protected void preRunModifyContract()
{
    #ISOCountryRegionCodes
    SrsReportDataContract  contract;

    contract = this.parmReportContract() as SrsReportDataContract;
}


...

public void ReportRun(String255 _rangeLoc)
{
    Alle_PaymentAdviceVendController controller = new Alle_PaymentAdviceVendController();
    controller.parmReportName('Alle_PaymentAdviceVendReport.PaymentAdviceVendReport');
    recIdRange = _rangeLoc;
    controller.parmSpecTransRecIdRange(recIdRange);
    controller.parmShowDialog(false);
    controller.startOperation();
}

....

public void setRanges(Query _query)
{
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;

    qbds = _query.dataSourceTable(tableNum(SpecTrans));
    qbds.clearRanges();

    qbr = qbds.addRange(fieldNum(SpecTrans, RecId));
    qbr.value(recIdRange);
}

...

/// <summary>
/// Sets the report query ranges based on the caller.
/// </summary>
/// <param name="_query">
/// The hold the <c>Query</c> object of the report.
/// </param>
public void setRangesNew(Query _query)
{
    QueryBuildDataSource        qbds;
    VendTrans                   vendTrans;
    FormDataSource              fds;
    Set                         s;
    ;

    qbds = _query.dataSourceTable(tablenum(VendTrans));

    while (qbds.findRange(fieldNum(VendTrans, RecId)))
    {
        qbds.clearRange(fieldNum(VendTrans, RecId));
    }

    if (this.parmArgs())
    {
        vendTrans = this.parmArgs().record();
        if (vendTrans.isFormDataSource() && vendTrans.dataSource())
        {
            s = new Set(Types::Int64);
            fds = vendTrans.dataSource();  // guaranteed to exist
            for (vendTrans = fds.getFirst(fds.anyMarked()); vendTrans; vendTrans = fds.getNext())
            {
                if (!s.in(vendTrans.RecId))  // check if ProdId already exists in set
                {
                    qbds.addRange(fieldNum(vendTrans, RecId)).value(int642str(vendTrans.RecId));
                    s.add(vendTrans.RecId);
                }
            }
        }
        else
        {
            qbds.addRange(fieldNum(VendTrans, RecId)).value(int642str(vendTrans.RecId));
        }
    }
}
.................................................................

public static void main(Args _args)
{
    Alle_PaymentAdviceVendController controller = new Alle_PaymentAdviceVendController();
    controller.parmReportName('Alle_PaymentAdviceVendReport.PaymentAdviceVendReport');
    controller.parmArgs(_args);
    controller.parmShowDialog(false);
    controller.startOperation();
}
....................................................

Delete duplicatw GST rates - Ref pepper

static void DeleteDuplicateGSTRate(Args _args)
{
    TaxRuntimeLookupCondition               taxRuntimeLookupCondition, taxRuntimeLookupConditionGroup, taxRuntimeLookupConditionSelect;
    TaxRuntimeLookupMeasureResult           taxRuntimeLookupMeasureResult;
    TaxRuntimeLookupMeasureResultDetail     taxRuntimeLookupMeasureResultDetail;
    TaxRuntimeLookup                        taxRuntimeLookup;
    TaxRuntimeLookupVersion                 taxRuntimeLookupVersion;
    TaxRuntimeDocComponentMeasure           taxRuntimeDocComponentMeasure;
    TaxRuntimeDocComponentMeasureVersion    taxRuntimeDocComponentMeasureVersion;
    TaxRuntimeDocComponent                  taxRuntimeDocComponent;
    TaxRuntimeDocComponentVersion           taxRuntimeDocComponentVersion;
    TaxRuntimeDocTaxType                    taxRuntimeDocTaxType;
    TaxRuntimeDocTaxTypeVersion             taxRuntimeDocTaxTypeVersion;
    TaxRuntimeTaxMeasureValue               taxRuntimeTaxMeasureValue;
    container                               gstType;
    Query                                   query;
    QueryBuildDataSource                    qbds;
    QueryHavingFilter                       havingFilter;
    QueryRun                                queryRun;
    int                                     counter;
    container                               gstRate;

    query = new Query();
    qbds = query.addDataSource(tableNum(TaxRuntimeLookupCondition));
    qbds.addSelectionField(fieldNum(TaxRuntimeLookupCondition, RecId), SelectionField::Sum);
    qbds.addRange(fieldNum(TaxRuntimeLookupCondition, DimValue1)).value(SysQuery::valueNotEmptyString());
    qbds.addRange(fieldNum(TaxRuntimeLookupCondition, Ledger)).value(SysQuery::value(CompanyInfo::find().RecId));
    //qbds.addRange(fieldNum(TaxRuntimeLookupCondition, DimValue2)).value(SysQuery::value('34013019'));
    qbds.orderMode(OrderMode::GroupBy);
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, DimValue1));
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, DimValue2));
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, DimValue3));
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, Ledger));
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, DateRangeFrom1));
    qbds.addGroupByField(fieldNum(TaxRuntimeLookupCondition, DateRangeTo1));

    havingFilter = query.addHavingFilter(qbds, fieldStr(TaxRuntimeLookupCondition, RecId), AggregateFunction::Count);
    havingFilter.value('>3');
    queryRun = new QueryRun(query);
    while (queryRun.next())
    {
        taxRuntimeLookupConditionGroup = queryRun.getNo(1);
        gstType = conNull();
        gstRate = conNull();
        while select forUpdate taxRuntimeLookupCondition
            where taxRuntimeLookupCondition.DimValue1 == taxRuntimeLookupConditionGroup.DimValue1 &&
            taxRuntimeLookupCondition.DimValue2 == taxRuntimeLookupConditionGroup.DimValue2 &&
            taxRuntimeLookupCondition.DimValue3 == taxRuntimeLookupConditionGroup.DimValue3 &&
            taxRuntimeLookupCondition.Ledger == taxRuntimeLookupConditionGroup.Ledger &&
            taxRuntimeLookupCondition.DateRangeFrom1 == taxRuntimeLookupConditionGroup.DateRangeFrom1 &&
            taxRuntimeLookupCondition.DateRangeTo1 == taxRuntimeLookupConditionGroup.DateRangeTo1
        {
            taxRuntimeLookupVersion = TaxRuntimeLookupVersion::find(taxRuntimeLookupCondition.LookupVersion);
            taxRuntimeLookup = TaxRuntimeLookup::find(taxRuntimeLookupVersion.Lookup);

            select firstOnly taxRuntimeDocComponentMeasure
                where taxRuntimeDocComponentMeasure.RecId == taxruntimelookup.LookupOwnerRecId;

            select firstOnly taxRuntimeDocComponent
                where taxRuntimeDocComponent.Name == 'IGST';

            if (taxRuntimeDocComponentMeasure.TaxRuntimeDocComponent == taxRuntimeDocComponent.RecId)
            {
                select firstOnly taxRuntimeLookupMeasureResult
                        join forUpdate taxRuntimeLookupMeasureResultDetail
                    where taxRuntimeLookupMeasureResult.LookupCondition == taxRuntimeLookupCondition.RecId
                        && taxRuntimeLookupMeasureResultDetail.LookupMeasureResult == taxRuntimeLookupMeasureResult.RecId;

                if (taxRuntimeLookupMeasureResult.RecId)
                {
                    //taxRuntimeTaxMeasureValue = taxRuntimeLookupMeasureResultDetail.Value;
                    if (gstType == conNull())   // for the 1st record
                    {
                        gstType = ['IGST'];
                        gstRate = [taxRuntimeLookupMeasureResultDetail.Value];
                    }
                    else if (conPeek(gstRate, 1) == taxRuntimeLookupMeasureResultDetail.Value)  // for duplicate based on value
                    {
                        ttsBegin;
                        taxRuntimeLookupCondition.delete();
                        ttsCommit;
                        counter++;
                    }
                }
                //if (gstType == 'CGST' || gstType == 'SGST')
                //{
                    //gstCompFoundNo++;
                //}
                //else if (gstType == 'IGST')
                //{
                    //gstCompFoundNo++;
                //}
            }
        }
    }
    info(strFmt('Total => %1', counter));
}