Thursday, July 17, 2014

Cross company in X++

static void crossCompanyUse(Args _args)
{
    AddressCountryRegion addressCountryRegion,_addressCountryRegion;
    Dialog      dialog;
    DialogField dialogField;
    ;
    dialog = new Dialog();
    dialogField=dialog.addField(typeId(DataareaId));
    dialog.run();
    select * from _addressCountryRegion;

    If(!_addressCountryRegion)
    {
         while Select crossCompany CountryRegionId,Name,Type,AddrFormat,ISOcode
         from addressCountryRegion where addressCountryRegion.dataAreaId == dialogField.value()
         {
            _addressCountryRegion.clear();
            _addressCountryRegion.initValue();
            _addressCountryRegion.CountryRegionId = addressCountryRegion.CountryRegionId ;
            _addressCountryRegion.Name = addressCountryRegion.Name ;
            _addressCountryRegion.Type = addressCountryRegion.Type;
            _addressCountryRegion.AddrFormat = addressCountryRegion.AddrFormat;
            _addressCountryRegion.ISOcode = addressCountryRegion.ISOcode;
            _addressCountryRegion.insert();
         }
         info("Records Imported");
         // insert_recordset _addressCountryRegion(CountryRegionId) Select crossCompany  CountryRegionId  from addressCountryRegion where addressCountryRegion.dataAreaId == dialogField.value();
   }
   else
   {
        info("Records alredy exists");
   }

}


static void crossCompanyUseModify(Args _args)
{
    AddressCountryRegion addressCountryRegion,_addressCountryRegion;
    Dialog      dialog;
    DialogField dialogField;
    CompanyId   currentCompany,newCompany;
    ;
    dialog = new Dialog();
    dialogField=dialog.addField(typeId(DataareaId));

    if(dialog.closedOk())
    {
        dialog.run();
        currentCompany = curext();
        newCompany = dialogField.value();
        select * from _addressCountryRegion;
        If(!_addressCountryRegion)
        {
            select * from _addressCountryRegion;
             while Select crossCompany CountryRegionId,Name,Type,AddrFormat,ISOcode
             from addressCountryRegion where addressCountryRegion.dataAreaId == dialogField.value()
             {
                _addressCountryRegion.clear();
                _addressCountryRegion.initValue();
                _addressCountryRegion.CountryRegionId = addressCountryRegion.CountryRegionId ;
                _addressCountryRegion.Name = addressCountryRegion.Name ;
                _addressCountryRegion.Type = addressCountryRegion.Type;
                _addressCountryRegion.AddrFormat = addressCountryRegion.AddrFormat;
                _addressCountryRegion.ISOcode = addressCountryRegion.ISOcode;
                _addressCountryRegion.insert();
             }
             info("Records Imported");
             // insert_recordset _addressCountryRegion(CountryRegionId) Select crossCompany  CountryRegionId  from addressCountryRegion where addressCountryRegion.dataAreaId == dialogField.value();
       }
       else
       {
            info("Records alredy exists");
       }
    }
}

No comments:

Post a Comment