Friday, June 15, 2018

Export customer Multiple address Using X++

static void BFIL_CustomerMultipleAddressExport(Args _args)
{
    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    SysExcelCell                    cell;
    SysExcelFont                    font;
    int                             row;
    CustTable                       custTable;
    DirPartyTable                   dirPartyTable;
    LogisticsPostalAddress          postalAddress;
    LogisticsLocation               location;
    DirPartyLocation                PartyLocation;


    // intializing classes to export excel
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    workbook = workbooks.add();
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    cells.range('A:A').numberFormat('@');

    // Setting Header values
    cell = cells.item(1, 1);
    cell.value('Customer Account');
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 2);
    cell.value('Customer Name');
    font = cell.font();
    font.bold(true);
    row = 1;
     cell = cells.item(1, 3);
    cell.value('Location Id');
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 4);
    cell.value('Location Name');
    font = cell.font();
    font.bold(true);
    row = 1;

    cell = cells.item(1, 6);
    cell.value('Address');
    font = cell.font();
    font.bold(true);
    row = 1;

    cell = cells.item(1, 7);
    cell.value('State');
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 8);
    cell.value('City');
    font = cell.font();
    font.bold(true);
    row = 1;



     // inserting data row wise selecting Multiple record----
     while select custTable
        where custTable.AccountNum
      join dirPartyTable
        where custTable.Party == dirPartyTable.RecId
      join PartyLocation
        where PartyLocation.party == dirPartyTable.recid
      join location
        where location.recid == PartyLocation.Location
      join postalAddress
        where postalAddress.Location == location.RecId
           && partyLocation.Location == postalAddress.Location
    {
        row++;
        cell = cells.item(row, 1);
        cell.value(custTable.AccountNum);
        cell = cells.item(row, 2);
        cell.value(dirPartyTable.Name);
        cell = cells.item(row, 3);
        cell.value(location.LocationId);
        cell = cells.item(row, 4);
        cell.value(location.Description);
        cell = cells.item(row, 5);
        cell.value(postalAddress.Address);
        cell = cells.item(row, 6);
        cell.value(postalAddress.State);
        cell = cells.item(row, 7);
        cell.value(postalAddress.City);
    }

    application.visible(true);
}

No comments:

Post a Comment

TFS Work space configuration

Refer below link:  https://d365byjp.blogspot.com/2018/10/steps-to-configure-tfsvsts-workspace-in.html