jueves, 6 de febrero de 2014

Ax 2012 Copiar Cliente

static server void CopiarCliente(CustTable  _CustTable)
{
    CustTable                           newCusttable;
    DirPartyTable                       DirPartyTable;
    DirPartyPostalAddressView           DirPartyPostalAddressView;
    DirPartyPostalAddressView           DirPartyPostalAddressViewNew;
    LogisticsPostalAddressView          LogisticsPostalAddressView;
    #define.F('F')
    #define.R('R')
    DirParty                            DirParty;
    DirParty                            DirPartyOld;
    DirPartyContactInfoView             DirPartyContactInfoView;
    DirPartyContactInfoView             DirPartyContactInfoViewNew;
    LogisticsElectronicAddress          LogisticsElectronicAddress;


    ;
        if(_CustTable)
        {
            try
            {
                ttsBegin;
                newCusttable.clear();
                newCusttable.data(_CustTable);
                newCusttable.Party              =0;
                newCusttable.initFromCustGroup(CustGroup::find(_CustTable.CustGroup));
                newCusttable.AccountNum         =strReplace(_CustTable.AccountNum,#F,#R) ;
                newCusttable.insert();
                ///////
                DirParty        =DirParty::constructFromPartyRecId(newCusttable.Party);
                DirPartyOld     =DirParty::constructFromPartyRecId(_CustTable.Party);
                //////Agregar nombre
                DirPartyTable   =DirPartyTable::findRec(newCusttable.Party,true);
                DirPartyTable.initFromDirParty(DirPartyOld);
                ttsBegin;
                DirPartyTable.update();
                ttsCommit;


                ///agregar direcciones
                while select * from DirPartyPostalAddressView
                where DirPartyPostalAddressView.Party==_CustTable.Party
                {
                    ///inicializar la vista con la direccion
                    LogisticsPostalAddressView.initFromPartyPostalAddressView(DirPartyPostalAddressView);
                    ///inicializar la direccion
                    DirPartyPostalAddressViewNew.initFromPostalAddressView(LogisticsPostalAddressView);
                    //insertar la direccion
                    DirParty.createOrUpdatePostalAddress(DirPartyPostalAddressViewNew);

                }
                DirParty        =DirParty::constructFromPartyRecId(newCusttable.Party);
                 ///agregar Contacto
                while select * from DirPartyContactInfoView
                where DirPartyContactInfoView.Party==_CustTable.Party
                {

                    ///inicializar la vista con la direccion
                    LogisticsElectronicAddress=LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
                    DirPartyContactInfoViewNew.Locator = LogisticsElectronicAddress.Locator;
                    DirPartyContactInfoViewNew.Type = LogisticsElectronicAddress.Type;
                    DirPartyContactInfoViewNew.LocatorExtension = LogisticsElectronicAddress.LocatorExtension;
                    DirPartyContactInfoViewNew.CountryRegionCode = LogisticsElectronicAddress.CountryRegionCode;
                    DirPartyContactInfoViewNew.IsPrimary = LogisticsElectronicAddress.IsPrimary;
                    DirPartyContactInfoViewNew.IsPrivate = LogisticsElectronicAddress.IsPrivate;
                    DirPartyContactInfoViewNew.IsMobilePhone = LogisticsElectronicAddress.IsMobilePhone;
                    DirPartyContactInfoViewNew.IsInstantMessage = LogisticsElectronicAddress.IsInstantMessage;
                    //DirPartyContactInfoViewNew.LocationName = LogisticsElectronicAddress.LocationName;
                    //LogisticsElectronicAddress          =LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
                    //DirPartyContactInfoViewNew.initFromElectronicAddress(LogisticsElectronicAddress);
                    //insertar la direccion
                    DirParty.createOrUpdateContactInfo(DirPartyContactInfoViewNew);

                }

                ttsCommit;
            }
            catch
            {
                throw(error("Error"));
            }
        }


}

lunes, 4 de noviembre de 2013

jueves, 26 de septiembre de 2013

Query en Sql para sacar las dimensiones financeras ax 2012

select * from
(
    select
        GENERALJOURNALENTRY.ACCOUNTINGDATE fecha,--fecha
        MAINACCOUNT.MAINACCOUNTID CuentaContable,--cuenta contable
        GeneralJournalAccountEntry.REPORTINGCURRENCYAMOUNT importe,--importe
        DimensionAttributeLevelValue.DISPLAYVALUE dv,
        DimensionAttribute.NAME Nombre,
        GeneralJournalAccountEntry.RECID reciddelatransaccion       
    from GENERALJOURNALENTRY
        inner join GeneralJournalAccountEntry on GENERALJOURNALENTRY.RECID=GeneralJournalAccountEntry.GENERALJOURNALENTRY
        inner join DIMENSIONATTRIBUTEVALUECOMBINATION on GeneralJournalAccountEntry.LEDGERDIMENSION=DIMENSIONATTRIBUTEVALUECOMBINATION.RECID
        inner join MAINACCOUNT on DIMENSIONATTRIBUTEVALUECOMBINATION.MAINACCOUNT=MAINACCOUNT.RECID
        --inner join ABXEBITDADATOSSOBRESALIENTE on MAINACCOUNT.MAINACCOUNTID=ABXEBITDADATOSSOBRESALIENTE.CUENTACONTABLE
        inner join DimensionAttributeValueGroupCombination on DIMENSIONATTRIBUTEVALUECOMBINATION.RECID=DimensionAttributeValueGroupCombination.DIMENSIONATTRIBUTEVALUECOMBINATION
        inner join DimensionAttributeValueGroup on DimensionAttributeValueGroupCombination.DIMENSIONATTRIBUTEVALUEGROUP=DimensionAttributeValueGroup.RECID
        inner join DimensionAttributeLevelValue on DimensionAttributeValueGroup.RECID=DimensionAttributeLevelValue.DIMENSIONATTRIBUTEVALUEGROUP
        inner join DimensionAttributeValue on  DimensionAttributeValue.RECID=DimensionAttributeLevelValue.DIMENSIONATTRIBUTEVALUE
        inner join DimensionAttribute on DimensionAttribute.RECID=DimensionAttributeValue.DIMENSIONATTRIBUTE
    --where ABXEBITDADATOSSOBRESALIENTE.CONCEPTO in (2,3,4,5)       
     )p
pivot (max(dv) for Nombre in ([MainAccount],[División],[Sucursal])) piv   -- **

viernes, 16 de agosto de 2013

Obtener el valor de un enum con la etiqueta

TableGroupAll  SacarAccountCode( str         label)
    {
     
        EnumId      enumId = enumNum(TableGroupAll);
        str Na;      

        DictEnum    dictEnum = new DictEnum(enumId);
        int         numEnum;
        ;    
        numEnum = 0;

        while(numEnum   < dictEnum.values())
        {

            Na=dictEnum.index2Label(numEnum);
            if(label ==Na)
            {
               return dictEnum.index2Value(numEnum);

            }
            numEnum++;
        }      
       return 1;
    }

sábado, 1 de junio de 2013

Cambiar de status un workflow x++ Dynamics AX 2012

static void Job120(Args _args)
{
    WorkflowWorkItemTable WorkflowWorkItemTable;
    ;
///////aqui es el registro que se quiere cambiar de status
    select firstOnly * from WorkflowWorkItemTable
    where WorkflowWorkItemTable.RefTableId==1704
    && WorkflowWorkItemTable.RefRecId==5637153828
    && WorkflowWorkItemTable.UserId==curUserId();
   
    WorkflowWorkItemActionManager::dispatchWorkItemAction(WorkflowWorkItemTable,"Comentario para el historial",curUserId(),WorkflowWorkItemActionType::Complete,"GsWFApprovalsInvTranApprove",false);

}

lunes, 13 de mayo de 2013

SSRS Debug VendAgingReport


static void TestAntiguedadProve(Args _args)
{
    VendAgingReportDP dp=new  VendAgingReportDP();
    VendAgingReportContract contract=new VendAgingReportContract();
    Query q;
    QueryRun qr;
    VendAgingReportTmp VendAgingReportTmp;
   
    ;
   
    contract.parmStartDate(today()-300);
    contract.parmZeroDate(today()-300);
    contract.parmDateTransactionDuedate(DateTransactionDuedate::DocumentDate);
    contract.parmAgingBuckets("CLASICO");
    contract.parmPrintAgingBucketDescription(NoYesCombo::No);
    contract.parmInterval(0);
    contract.parmPeriod(DayMonth::Day);
    contract.parmDirection(ForwardBackwardPrinting::Forward);
    contract.parmDetailed(NoYes::Yes);
    contract.parmPrintZeroOrNegative(NoYes::Yes);
    dp.parmDataContract(contract);
    q = new Query(querystr(VendAgingReport));
    qr=new QueryRun(q);
 
    if(qr.prompt())
    {
        dp.parmQuery(qr.query());      
        dp.processReport();
        VendAgingReportTmp= dp.getVendAgingReportTmp();
        while select * from VendAgingReportTmp
        {
            info(VendAgingReportTmp.AccountNum);
        }
 
     
    }
   
   
   
   
   
   
   
}

jueves, 7 de marzo de 2013

Ax 2012 LookUp Multi select ssrs

////////////////////Contract

[
DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(GsCobranzaPonderadosUIBuilder))

]
Public class GsCobranzaPonderadosContract
{
    Str1260    Division;
    Str1260    Sucursal;
}


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

 [

    DataMemberAttribute('Division'),

   // AifCollectionTypeAttribute('Division', Types::String),

    SysOperationLabelAttribute("Division")

]
public Str1260 parmDivision(Str1260 _disivion=division)
{
   Division=strReplace(_disivion,";",",");

    return Division;
}

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

[

    DataMemberAttribute('Sucursal'),

  // AifCollectionTypeAttribute('Sucursal', Types::String),

    SysOperationLabelAttribute("Sucursal")

]
public Str1260 parmSucursal(Str1260 _Sucursal=Sucursal)
{
   Sucursal=strReplace(_Sucursal,";",",");

    return Sucursal;
}

/////////////////////////////////UIBuilder

class GsCobranzaPonderadosUIBuilder  extends SysOperationAutomaticUIBuilder
{
    DialogField                   DivisionC;
    DialogField                   SucursalC;

   // DialogField                   AccountNum;

    FormRun fr;
    GsCobranzaPonderadosContract contract;
}

 /////////////////////////////////////////////77

public void Divisionlookup(FormStringControl accountNumLookup)///division

{
  //  Object control = dialog.formRun().controlCallingMethod();

    Query query = new Query(queryStr(GsLookUpDivisionViewQ));

    container   cnt;
    ;
    SysLookupMultiSelectGrid::lookup(query, accountNumLookup, accountNumLookup, cnt);

}


/////////////////////////////////77

public void Sucursallookup(FormStringControl accountNumLookup)///division

{


    Query query = new Query(queryStr(GsLookUpSucursalViewQ));

    container   cnt;
    ;
    SysLookupMultiSelectGrid::lookup(query, accountNumLookup, accountNumLookup, cnt);

}



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

public void postRun()
{
    str nombre;
    FormDesign fd;
     DialogField dialogField;
    DialogField dialogFieldS;
    ;
     contract = this.dataContractObject();

    super();

     dialog.dialogForm().formRun().controlMethodOverload(false);

     dialogField = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(GsCobranzaPonderadosContract, parmDivision));
     dialogField.lookupButton(2);
     dialogField.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(GsCobranzaPonderadosUIBuilder,  Divisionlookup), this);


     dialogFieldS = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(GsCobranzaPonderadosContract, parmSucursal));
     dialogFieldS.lookupButton(2);
     dialogFieldS.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(GsCobranzaPonderadosUIBuilder,  Sucursallookup), this);

    //AccountNum.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(GsCobranzaPonderadosUIBuilder,  Divisionlookup), this);
    // dialog.dialogForm().formRun().controlMethodOverloadObject(this);



}
////////////////////////////////////////////

public void getFromDialog()

{
     contract = this.dataContractObject();


    super();

   // contract.parmDivision();
    //contract.parmSucursal();


}
/////////////////////////////////////////////7

public void initializeFields()

{

 contract = this.dataContractObject();

}



//////////////////////////////////DP
 [
  SRSReportQueryAttribute('GsCobranzaPonCustTransCustSettlement'),
   SRSReportParameterAttribute(classStr(GsCobranzaPonderadosContract))
  ]
class GsCobranzaPonderadosDP  extends SRSReportDataProviderBase
{

    GsCobranzaPonderadosTMP GsCobranzaPonderadosTMP;
}

Ya lo demas es lo mismo de un reporte normal processReport,etc..........