Monday, 13 July 2015

Main Account is Displayed  on Purchase Req Form in that Financial Dimension.

Ans: PurchReqLine Table level we can write one method:

 
// Finding the main account from posting profile written


public DimensionDisplayValue MRKPMainAccount(InventTable inventTable)

{

DimensionDisplayValue mainAccount;

DimensionAttributeValueCombination dimensionAttributeValueCombination;

EcoResProduct ecoResProduct;

ItemGroupId itemGroupId;

InventPosting inventPosting;


boolean itemCodeAll,itemCodeGrp,itemCodeCategory,itemCodeTable;

 

ecoResProduct = EcoResProduct::find(inventTable.Product);

itemGroupId = InventItemGroupItem::findByItemIdLegalEntity(inventTable.ItemId, inventTable.DataAreaId).ItemGroupId;


if(ecoResProduct.WW_Category == WW_Category::Stock)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::All

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeAll =

true;

}


if (!itemCodeAll)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::GroupId

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeGrp =

true;

}

}


if (!itemCodeAll && !itemCodeGrp)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Category

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeCategory =

true;

}

}


if (!itemCodeAll && !itemCodeGrp && !itemCodeCategory)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Table

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeTable =

true;

}

}

}


else if(ecoResProduct.WW_Category == WW_Category::NonStock)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::All

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeAll =

true;

}


if (!itemCodeAll)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::GroupId

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeGrp =

true;

}

}


if (!itemCodeAll && !itemCodeGrp)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Category

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeCategory =

true;

}

}


if (!itemCodeAll && !itemCodeGrp && !itemCodeCategory)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Table

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeTable =

true;

}

}

}


return mainAccount;

}
method ::2
// New method written for updating the Main Account written by ramesh




void


MRKPUpdateDefaultFinancialDim(ItemId _itemId)

{

DimensionAttributeValue dimAttrMAValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue;

DimensionAttribute dimAttrMA,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;

DimensionAttributeValueSetStorage davss;

RecId defaultDimension;

InventTable inventTable = InventTable::find(_itemId,

true);

CustTable custTable;

DimensionDisplayValue mainAccount;

davss = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);

mainAccount = this.MRKPMainAccount(inventTable);

dimAttrMA = DimensionAttribute::findByName(

'MainAccount');

dimAttrMAValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrMA,mainAccount,
false, true);


if (dimAttrMAValue)

{

davss.addItem(dimAttrMAValue);

inventTable.DefaultDimension = davss.save();

inventTable.update();

}

}

 
###
Method 3::
/// <summary>

/// Creates the default dimension by using the entity dimension specifiers from the line.

/// </summary>

/// <param name="_currentDefaultDimensionAfterRequisitioner">

/// A <c>boolean</c> for indicating if the current default dimension should be added to the dimension source list

/// after the requisitioner; optional.

/// </param>




public


void setDefaultDimension(boolean _currentDefaultDimensionAfterRequisitioner = false)

{

List dimensionSources =

new List(Types::Class);

ProjTable projTable;

HcmEmployment employee;

VendTable vendor;

InventTable inventTable;


if (!this.isConsumption())

{


return;

}


if (!_currentDefaultDimensionAfterRequisitioner)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(this.DefaultDimension));

}


// Apply defaults from project


if (this.ProjId)

{

projTable = ProjTable::find(this.ProjId);

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(projTable.DefaultDimension));

}


//Employee

employee = HcmEmployment::findByWorkerLegalEntity(this.Requisitioner, this.BuyingLegalEntity);


if (employee)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(employee.DefaultDimension));

}


if (_currentDefaultDimensionAfterRequisitioner)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(this.DefaultDimension));

}


// Vendor


if (this.VendAccount)

{

vendor = VendTable::findByCompany(

this.buyingLegalEntity2DataArea(),

this.VendAccount);

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(vendor.DefaultDimension));

}


// Product


if (this.ItemId)

{

inventTable = InventTable::findInLegalEntity(this.ItemId,

this.ItemIdDataArea

);

this.MRKPUpdateDefaultFinancialDim(inventTable.ItemId);

// added by ramesh for updating the financial dimension for PR Line;
dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(inventTable.DefaultDimension));

}

this.DefaultDimension = DimensionDefaultingEngine::getDefaultDimension(dimensionSources);

}
 

Saturday, 11 July 2015

CustomerPersonsXppImport

static void CustomerPersonsXppImport(Args _args)
{
    #define.Name("Alex Anikiev")
    #define.FirstName("Alex")
    #define.LastName("Anikiev")
    #define.PostalAddressName("Postal address")
    #define.City("Alpharetta")
    #define.County("FULTON")
    #define.Country("USA")
    #define.Street("1125 Sanctuary Pkwy #300")
    #define.State("GA")
    #define.ZipCode("30009")
    #define.ElectronicAddressName("Electronic address")
    #define.Locator("alexani@microsoft.com")
    #define.LocatorExt("")
    #define.CustAccount("Alex")
    #define.CustGroup("10")
    #define.Currency("USD")
    #define.CostCenter("OU_4803")
    #define.Department("OU_2311")  
    #define.ExpensePurpose("Training")

    DirPerson                   dirPerson;
    DirPersonName               dirPersonName;
    LogisticsLocation           logisticsLocation;
    LogisticsPostalAddress      logisticsPostalAddress;
    LogisticsElectronicAddress  logisticsElectronicAddress;
    CustTable                   custTable;

    try
    {
        ttsbegin;

        //Person
        dirPerson.clear();
        dirPerson.initValue();
        dirPerson.Name = #Name;

        if (dirPerson.validateWrite())
        {
            dirPerson.insert();

            if (dirPerson)
            {
                //Person name
                dirPersonName.clear();
                dirPersonName.initValue();
                dirPersonName.FirstName = #FirstName;
                dirPersonName.LastName = #LastName;
                dirPersonName.Person = dirPerson.RecId;
                dirPersonName.ValidFrom = DateTimeUtil::utcNow();
               dirPersonName.ValidTo = DateTimeUtil::maxValue();

                if (dirPersonName.validateWrite())
                {
                    dirPersonName.insert();
                }
                else
                    throw error("Person name");

                //Location
                logisticsLocation = LogisticsLocation::create(#PostalAddressName, NoYes::Yes);

                //Party location
                DirParty::addLocation(dirPerson.RecId, logisticsLocation.RecId, true, true, false, [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId]);

                //Postal address
                logisticsPostalAddress.clear();
                logisticsPostalAddress.initValue();
                logisticsPostalAddress.City = #City;
                logisticsPostalAddress.County = #County;
                logisticsPostalAddress.CountryRegionId = #Country;
                logisticsPostalAddress.Street = #Street;
                logisticsPostalAddress.State = #State;
                logisticsPostalAddress.ZipCode = #ZipCode;
                logisticsPostalAddress.Address = LogisticsPostalAddress::formatAddress(
                #Street, #ZipCode, #City, #Country, #State, #County);              
                logisticsPostalAddress.Location = logisticsLocation.RecId;
                logisticsPostalAddress.ValidFrom = DateTimeUtil::utcNow();
                logisticsPostalAddress.ValidTo = DateTimeUtil::maxValue();

                if (logisticsPostalAddress.validateWrite())
                {
                    logisticsPostalAddress.insert();
                }
                else
                    throw error("Postal address");

                //Location
                logisticsLocation = LogisticsLocation::create(#ElectronicAddressName, NoYes::No);

                //Party location
                DirParty::addLocation(dirPerson.RecId, logisticsLocation.RecId, false, true, false);

                //Electronic address
                logisticsElectronicAddress.clear();
                logisticsElectronicAddress.initValue();
                logisticsElectronicAddress.Location = logisticsLocation.RecId;
                logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Email;
                logisticsElectronicAddress.Locator = #Locator;
                logisticsElectronicAddress.LocatorExtension = #LocatorExt;
                logisticsElectronicAddress.ValidFrom = DateTimeUtil::utcNow();
                logisticsElectronicAddress.ValidTo = DateTimeUtil::maxValue();

                if (logisticsElectronicAddress.validateWrite())
                {
                    logisticsElectronicAddress.insert();
                }
                else
                    throw error("Electronic address");

                //Customer
                custTable.clear();
                custTable.initValue();
                //CustTable.Currency = "";//initValue

                custTable.AccountNum = #CustAccount;
                //custTable.AccountNum = NumberSeq::newGetNum(CustParameters::numRefCustAccount()).num();
                custTable.Party = dirPerson.RecId;

                custTable.CustGroup = #CustGroup;
                custTable.initFromCustGroup(CustGroup::find(#CustGroup));

                custTable.Currency = #Currency;
                custTable.DefaultDimension = AxdDimensionUtil::getDimensionAttributeValueSetId(
                [3, "CostCenter", #CostCenter, "Department", #Department, "ExpensePurpose", #ExpensePurpose]);

                if (custTable.validateWrite())
                {
                    custTable.insert();
                }
                else
                    throw error("Customer");
            }
        }
        else
            throw error("Person");

        ttscommit;
    }
    catch
    {
        error("Error!");
        return;
    }

    info("Done!");
}

AX2012 Import HCMWorker or Employee from CSV This is the sample code for creating the Employee and if employee exists then updating the employee.

AX2012 Import HCMWorker or Employee from CSV
This is the sample code for creating the Employee and if employee exists then updating the employee.
First build the class to read from CSV file and call this methods for creating/updateing the worker.
Please change the container column number values from your csv positions.

we can use HCMWorkerImportService for create, but this service did'nt provide the update functionality.
I will update the the next post using service to create/update the employee.

private void run()
{

 if (!HcmWorker::findByPersonnelNumber(conPeek(_c, #EmployeeNumber)).RecId)
        {//Update employee
            this.employeeCreate(_c);
        }
        else
        {//Insert employee
            this.employeeUpdate(_c);
        }

}


static public Description createDescription(DirPersonName _dirPersonName)
{
    #Define.Space(" ")
    return _dirPersonName.FirstName
        + (_dirPersonName.MiddleName ? #Space + _dirPersonName.MiddleName : "")
        + (_dirPersonName.LastName   ? #Space + _dirPersonName.LastName   : "");
}


public Static HcmPersonGender convGender(str _gender)
{
    HcmPersonGender ret;
    #Define.Female("Kvinde")
    #Define.Male("Mand")
    ;
    switch (_gender)
    {
        case #Female:
            ret = HcmPersonGender::Female;
            break;

        case #Male:
            ret = HcmPersonGender::Male;
            break;

        default:
            ret = HcmPersonGender::None;
    }

    return ret;
}


public Static str defaultCountryRegionId()
{
    str ret;
    LogisticsPostalAddress  logisticsPostalAddress_Default;
    ;

    logisticsPostalAddress_Default.initValue();

    ret = logisticsPostalAddress_Default.CountryRegionId;

    return ret;
}





public static date convDate(str _date)
{
    Date ret;
    ;

    ret = str2Date(_date, 123);

    return ret;
}


This method is used to create the employee.
Create
private void employeeCreate(container _c)
{
    boolean                                 ret = true;
    CompanyInfo                             companyInfo;
    HcmEmploymentRecId                      newEmploymentRecId;
    ValidFromDateTime                       employmentStartDateTime;
    ValidToDateTime                         employmentEndDateTime;
    HcmWorker                               newHcmWorker;
    DirPerson                               dirPerson;
    DirPersonName                           dirPersonName;
    HcmEmploymentType                       hcmEmploymentType = HcmEmploymentType::Employee;
    NumberSeq                               numberSeqPersonnelNum;
    HcmPersonPrivateDetails                 HcmPersonPrivateDetails;
    AxLogisticsPostalAddress                axLogisticsPostalAddress = new AxLogisticsPostalAddress();
    AxLogisticsLocation                     axLogisticsLocation;
    ;

    companyInfo = companyInfo::find();

    employmentStartDateTime = datetobeginUtcDateTime(HrmImportEmployeeMasterdata::convDate(conpeek(_c, #DateOfHiring)), DateTimeUtil::getUserPreferredTimeZone());
    employmentEndDateTime   = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());

    dirPersonName.FirstName     = conpeek(_c, #FirstName);
    dirPersonName.MiddleName    = conpeek(_c, #MiddleName);
    dirPersonName.LastName      = conpeek(_c, #LastName);
    newHcmWorker = HcmWorker::find(HcmWorkerTransition::newCreateHcmWorker(dirPersonName
                                                                           , conpeek(_c, #EmployeeNumber)
                                                                           , companyInfo.RecId
                                                                           , hcmEmploymentType
                                                                           , employmentStartDateTime
                                                                           , employmentEndDateTime));

    if (newHcmWorker.RecId == 0)
    {
        ret = false;
    }

    if (newHcmWorker.RecId == 0)
    {
        // Updating an existing worker

        // If there is no active employment for the worker
        newEmploymentRecId = HcmWorkerTransition::newCreateHcmEmployment(newHcmWorker.RecId, companyInfo.RecId,
                hcmEmploymentType, employmentStartDateTime, employmentEndDateTime);


        if (newEmploymentRecId == 0)
        {
            ret = false;
        }
    }

    if (ret)
    {
        if(numberSeqPersonnelNum)
        {
            // mark number sequence based ID consumed
            numberSeqPersonnelNum.used();
        }
    }
    else
    {
        if(numberSeqPersonnelNum)
        {
            numberSeqPersonnelNum.abort();
        }

        dirPerson.clear();
        dirPersonName.Person = 0;
    }

    hcmPersonPrivateDetails.initValue();
    hcmPersonPrivateDetails.Person      = dirPersonName.Person;
    hcmPersonPrivateDetails.BirthDate   = HrmImportEmployeeMasterdata::convDate(conpeek(_c, #BirthDate));
    hcmPersonPrivateDetails.Gender      = HrmImportEmployeeMasterdata::convGender(conpeek(_c, #Gender));
    hcmPersonPrivateDetails.insert();

    dirPerson                   = dirPerson::find(dirPersonName.Person, true);
    dirPerson.Initials          = conpeek(_c, #Initials);
    dirPerson.ProfessionalTitle = conpeek(_c, #Position);
    dirPerson.update();

    //Create address
    axLogisticsLocation = new AxLogisticsLocation();
    axLogisticsLocation.validateInput(true);
    axLogisticsLocation.parmIsPostalAddress(NoYes::Yes);
    axLogisticsLocation.parmDescription(HrmImportEmployeeMasterdata::createDescription(dirPersonName));
    axLogisticsLocation.save();

    axLogisticsPostalAddress    = new AxLogisticsPostalAddress();
    axLogisticsPostalAddress.parmLocation(axLogisticsLocation.parmRecId());
    axLogisticsPostalAddress.validateInput(true);
    axLogisticsPostalAddress.parmCountryRegionId(HrmImportEmployeeMasterdata::defaultCountryRegionId());
    axLogisticsPostalAddress.parmZipCode(conpeek(_c, #PostalCode));
    axLogisticsPostalAddress.parmZipCodeRecId(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).RecId);
    axLogisticsPostalAddress.parmStreet(conpeek(_c, #Address));
    axLogisticsPostalAddress.parmCity(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).City);
    axLogisticsPostalAddress.parmCityRecId(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).CityRecId);
    axLogisticsPostalAddress.save();

    DirParty::addLocation(dirPersonName.Person, axLogisticsLocation.parmRecId(), true, true, true);
}


This method is used to update the employee

Update
private void employeeUpdate(container _c)
{
    boolean                                 ret = true;
    CompanyInfo                             companyInfo;
    ValidFromDateTime                       employmentStartDateTime;
    ValidToDateTime                         employmentEndDateTime;
    HcmWorker                               hcmWorker;
    DirPerson                               dirPerson;
    DirPersonName                           dirPersonName;
    HcmEmploymentType                       hcmEmploymentType = HcmEmploymentType::Employee;
    HcmPersonPrivateDetails                 HcmPersonPrivateDetails;
    AxLogisticsPostalAddress                axLogisticsPostalAddress = new AxLogisticsPostalAddress();
    AxLogisticsLocation                     axLogisticsLocation;
    Description                             description_Old;
    HcmEmployment                           hcmEmployment;
    LogisticsLocation                       logisticsLocation;
    LogisticsPostalAddress                  logisticsPostalAddress;
    DirPartyLocation                        dirPartyLocation;
    ;

    companyInfo = companyInfo::find();
    hcmWorker   = hcmWorker::findByPersonnelNumber(conpeek(_c, #EmployeeNumber));

    //Update dirPersonName
    dirPersonName   = dirPersonName::find(hcmWorker.Person, true);
    description_Old = HrmImportEmployeeMasterdata::createDescription(dirPersonName);
    if (   dirPersonName.FirstName  != conpeek(_c, #FirstName)
        || dirPersonName.MiddleName != conpeek(_c, #MiddleName)
        || dirPersonName.LastName   != conpeek(_c, #LastName))
    {
        dirPersonName.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
        dirPersonName.FirstName     = conpeek(_c, #FirstName);
        dirPersonName.MiddleName    = conpeek(_c, #MiddleName);
        dirPersonName.LastName      = conpeek(_c, #LastName);
        dirPersonName.update();
    }

    //Update hiring
    employmentStartDateTime = datetobeginUtcDateTime(HrmImportEmployeeMasterdata::convDate(conpeek(_c, #DateOfHiring)), DateTimeUtil::getUserPreferredTimeZone());
    employmentEndDateTime   = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());

    hcmWorker       = HcmWorker::findByPersonnelNumber(conpeek(_c, #EmployeeNumber));
    hcmEmployment   = hcmEmployment::getActiveEmploymentsByWorker(hcmWorker.RecId, employmentStartDateTime, employmentEndDateTime, true);
    if (hcmEmployment.RecId)
    {
        HcmWorkerTransition::newUpdateHcmEmployment(hcmEmployment, employmentStartDateTime, employmentEndDateTime);
    }
    else
    {
        hcmWorker = HcmWorker::find(HcmWorkerTransition::newCreateHcmWorker(dirPersonName
                                                                           , conpeek(_c, #EmployeeNumber)
                                                                           , companyInfo.RecId
                                                                           , hcmEmploymentType
                                                                           , employmentStartDateTime
                                                                           , employmentEndDateTime));
    }

    hcmPersonPrivateDetails = HcmPersonPrivateDetails::findByPerson(hcmWorker.Person, true);
    if (hcmPersonPrivateDetails)
    {
        if (   hcmPersonPrivateDetails.BirthDate    != HrmImportEmployeeMasterdata::convDate(conpeek(_c, #BirthDate))
            || hcmPersonPrivateDetails.Gender       != HrmImportEmployeeMasterdata::convGender(conpeek(_c, #Gender)))
        {
            hcmPersonPrivateDetails.BirthDate   = HrmImportEmployeeMasterdata::convDate(conpeek(_c, #BirthDate));
            hcmPersonPrivateDetails.Gender      = HrmImportEmployeeMasterdata::convGender(conpeek(_c, #Gender));
            hcmPersonPrivateDetails.update();
        }
    }
    else
    {
        hcmPersonPrivateDetails.initValue();
        hcmPersonPrivateDetails.Person      = dirPersonName.Person;
        hcmPersonPrivateDetails.BirthDate   = HrmImportEmployeeMasterdata::convDate(conpeek(_c, #BirthDate));
        hcmPersonPrivateDetails.Gender      = HrmImportEmployeeMasterdata::convGender(conpeek(_c, #Gender));
        hcmPersonPrivateDetails.insert();
    }

    dirPerson                   = dirPerson::find(dirPersonName.Person, true);
    if (   dirPerson.Initials               != conpeek(_c, #Initials)
        || dirPerson.ProfessionalTitle      != conpeek(_c, #Position))
    {
        dirPerson.Initials          = conpeek(_c, #Initials);
        dirPerson.ProfessionalTitle = conpeek(_c, #Position);
        dirPerson.update();
    }

    //Update or Create address
    select firstOnly forUpdate logisticsLocation
        where logisticsLocation.Description == description_Old
        join dirPartyLocation
            where dirPartyLocation.Location == logisticsLocation.RecId
               && dirPartyLocation.Party    == dirPerson.RecId;

    if (logisticsLocation)
    {
        axLogisticsLocation = AxInternalBase::construct(logisticsLocation);
    }
    else
    {
        axLogisticsLocation = new AxLogisticsLocation();
    }

    axLogisticsLocation.validateInput(true);
    axLogisticsLocation.parmIsPostalAddress(NoYes::Yes);
    axLogisticsLocation.parmDescription(HrmImportEmployeeMasterdata::createDescription(dirPersonName));
    axLogisticsLocation.save();


    //Update or Create postaladdress
    select firstOnly forUpdate logisticsPostalAddress
        where logisticsPostalAddress.Location == axLogisticsLocation.parmRecId();

    if (logisticsPostalAddress)
    {
        axLogisticsPostalAddress = AxInternalBase::construct(logisticsPostalAddress);
    }
    else
    {
        axLogisticsPostalAddress = new AxLogisticsPostalAddress();
    }

    axLogisticsPostalAddress.parmLocation(axLogisticsLocation.parmRecId());
    axLogisticsPostalAddress.validateInput(true);
    axLogisticsPostalAddress.parmCountryRegionId(HrmImportEmployeeMasterdata::defaultCountryRegionId());
    axLogisticsPostalAddress.parmZipCode(conpeek(_c, #PostalCode));
    axLogisticsPostalAddress.parmZipCodeRecId(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).RecId);
    axLogisticsPostalAddress.parmStreet(conpeek(_c, #Address));
    axLogisticsPostalAddress.parmCity(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).City);
    axLogisticsPostalAddress.parmCityRecId(LogisticsAddressZipCode::find(conpeek(_c, #PostalCode)).CityRecId);
    axLogisticsPostalAddress.save();

    DirParty::addLocation(dirPersonName.Person, axLogisticsLocation.parmRecId(), true, true, true);
}