Friday, June 15, 2018

Export Legalentity Multiple Address

static void BFIL_LegalEntityMultipleAddress(Args _args)
{
    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    SysExcelCell                    cell;
    SysExcelFont                    font;
    int                             row;
 
    CompanyInfo                     companyInfo;
    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('C:C').numberFormat('@');

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

    cell = cells.item(1, 2);
    cell.value('LegalEntity 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, 5);
    cell.value('Address');
    font = cell.font();
    font.bold(true);
    row = 1;

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

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

   
   /*
// inserting the Multiple record for only one current legalentity ----
   companyInfo      = companyInfo::findDataArea(curext());
   dirPartyTable    = DirPartyTable::findRec(companyInfo.RecId);
 
   while select PartyLocation where PartyLocation.party == dirPartyTable.recid
      join location where location.recid == PartyLocation.Location
       join postalAddress where postalAddress.Location == location.RecId
                          && partyLocation.Location == postalAddress.Location

*/

// insert the all legalEntity multiple address

    while select companyInfo
    {
        dirPartyTable    = DirPartyTable::findRec(companyInfo.RecId);
        while select 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(companyInfo.DataArea);
        cell = cells.item(row, 2);
        cell.value(companyInfo.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