Thursday, March 19, 2015

LedgerGeneralJournal through AIF AX 2012 R3

I am going to explain how we could import a Ledger General Journal through AIF in AX 2012 R3.

First of all, we can check in AIF Services Form the standar service called LedgerGeneralJournalService.





We can see the status NoError, that is good.

Now, we need to create a EndPoint, let us check the AIF EndPoint Form




In this case we are going to use a File System Adapter in the field Adapter.


Now, we can choose the service, so we need to click the Service Operations Button.





 And then, we select de data polices button.




 We will mark all the fields that we will need in the schema, and we will show the schema



<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:tns="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal" xmlns:st="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="SharedTypes.xsd" namespace="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes" />
  <xs:element name="LedgerGeneralJournal" type="tns:AxdLedgerGeneralJournal" />
  <xs:complexType name="AxdLedgerGeneralJournal">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="LedgerJournalTable" type="tns:AxdEntity_LedgerJournalTable" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AxdEntity_LedgerJournalTable">
    <xs:sequence>
      <xs:element minOccurs="1" name="JournalName" type="st:AxdExtType_LedgerJournalNameId" />
      <xs:element minOccurs="0" name="Name" nillable="true" type="st:AxdExtType_Name" />
      <xs:element minOccurs="0" maxOccurs="unbounded" name="LedgerJournalTrans" type="tns:AxdEntity_LedgerJournalTrans" />
    </xs:sequence>
    <xs:attribute fixed="entity" name="class" use="required" />
    <xs:attribute name="action" type="st:AxdEnum_AxdEntityAction" />
  </xs:complexType>
  <xs:complexType name="AxdEntity_LedgerJournalTrans">
    <xs:sequence>
      <xs:element minOccurs="0" name="AccountType" nillable="true" type="st:AxdEnum_LedgerJournalACType" />
      <xs:element minOccurs="0" name="AmountCurCredit" nillable="true" type="st:AxdExtType_AmountCurCredit" />
      <xs:element minOccurs="0" name="AmountCurDebit" nillable="true" type="st:AxdExtType_AmountCurDebit" />
      <xs:element minOccurs="0" name="Company" nillable="true" type="st:AxdExtType_SelectableDataArea" />
      <xs:element minOccurs="0" name="DefaultDimension" nillable="true" type="st:AxdType_DimensionAttributeValueSet" />
      <xs:element minOccurs="0" name="LedgerDimension" nillable="true" type="st:AxdType_MultiTypeAccount" />
      <xs:element minOccurs="0" name="OffsetDefaultDimension" nillable="true" type="st:AxdType_DimensionAttributeValueSet" />
      <xs:element minOccurs="0" name="TransDate" nillable="true" type="st:AxdExtType_TransDate" />
      <xs:element minOccurs="0" name="Txt" nillable="true" type="st:AxdExtType_LedgerJournalTransTxt" />
    </xs:sequence>
    <xs:attribute fixed="entity" name="class" use="required" />
    <xs:attribute name="action" type="st:AxdEnum_AxdEntityAction" />
  </xs:complexType>
</xs:schema>



Schema PLZ...

We need to Active the EndPoint








(Some dude is making a bad job and the CIL knows it)

And now, we will build the XML FILE.


<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
    <Header>
        <MessageId>{429AA009-09D4-45A9-BB2B-14DF0DFD3D92}</MessageId>
        <LogonAsUser>NETWORK\jarizmendi</LogonAsUser>
        <Company>ara</Company>
        <Action>http://schemas.microsoft.com/dynamics/2008/01/services/GeneralJournalService/create</Action>
        <RequestMessageId>
        </RequestMessageId>
    </Header>
    <Body>
        <MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
        <LedgerGeneralJournal xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal">     
            <LedgerJournalTable class="entity">                   
              <JournalName>CPFCob</JournalName>
              <Name>COMISION DE COBRANZA                              </Name>
              <LedgerJournalTrans class="entity">           
                <AccountType>Ledger</AccountType>
                <AmountCurCredit>0.00</AmountCurCredit>
                <AmountCurDebit>54779.00</AmountCurDebit>
                <Company>ara</Company>
                <DefaultDimension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />               
                  <LedgerDimension>
                      <DisplayValue xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">20301000-01001-AC0001-1102020801-CATA</DisplayValue>
                      <Account xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">20301000</Account>
                      <Values xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">
                          <Value>
                              <Name>ACentrodeCosto</Name>
                              <Value>01001</Value>
                          </Value>
                          <Value>
                              <Name>BEmCoPoTr</Name>
                              <Value>AC0001</Value>
                          </Value>                       
                          <Value>
                              <Name>DRegion</Name>
                              <Value>1102020801</Value>
                          </Value>
                          <Value>
                              <Name>ECategoria</Name>
                              <Value>CATA</Value>
                          </Value>
                      </Values>
                  </LedgerDimension>               
                <TransDate>2015-03-18</TransDate>
                <Txt>Bonificación a Prteador X Compr. Dep.</Txt>                  
              </LedgerJournalTrans>
            </LedgerJournalTable>
      </LedgerGeneralJournal>   
    </MessageParts>
  </Body>
</Envelope> 



Check the structure, first we have Message header with the follow structure.

<Header>
        <MessageId>{429AA009-09D4-45A9-BB2B-14DF0DFD3D92}</MessageId>
        <LogonAsUser>NETWORK\jarizmendi</LogonAsUser>
        <Company>ara</Company>
        <Action>http://schemas.microsoft.com/dynamics/2008/01/services/GeneralJournalService/create</Action>
        <RequestMessageId>
        </RequestMessageId>
    </Header>


 Check the Action, it is formed by the namespace + external name of the service + the action of the service

The body has the Document tags in the same order of the schema.

The XML now is in the directory and the service is Active, just run the follow code:

void JCJob()
{
    Args    args;
    AifGatewayReceiveService agrs = new AifGatewayReceiveService();
    AifInboundProcessingService aip = new AifInboundProcessingService();
    AifGatewaySendService agss = new AifGatewaySendService();
    AifOutboundProcessingService aop = new AifOutboundProcessingService();
    ;
    agrs.run();
    aip.run();
    agss.run();
    aop.run();
}

 
 And the result is:














 
 
WOW








I know... the Journal is uncompleted.



Friday, March 13, 2015

TypId en Dynamics 2012

Compilando algunos reportes migrados de la versión 2009 a la 2012, me doy cuenta de que la función "TypeId" ya no se encuentra disponible y se ha reemplazado por la función "ExtendedTypeStr"





Como puede verse en la línea 11, "TypeId" no se reconoce, debe sustituirse como en la línea 12

Friday, January 2, 2015

Multiselección de registros en un Grid

En Ax se pueden seleccionar multiples registors dentro de un Grid, lo que ahora vamos a hacer es manipular nuestra selección.



Lo primero que hay que hacer es cambiar la propiedad MultiSelect de nuestro botón a True.

Después vamos a escribir el siguiente código en nuesto método Clicked()

01 void clicked()
02 {
03    TestName    testName;
04    ;
05
06
07    For (testName = TestName_ds.getFirst(True) ? 

08                TestName_ds.getFirst(true) : 
09                           TestName_ds.cursor(); testName ;     testName = TestName_ds.getNext())
10    {
11        TestName_ds.findRecord(testName);
12        info (testName.FirstName);
13     }

14}


Si prefieren hacerlo con un while...


07  testName = TestName_ds.getFirst(True) ? TestName_ds.getFirst(true) : TestName_ds.cursor();
08
09     while (testName)
10     {
11        info(testName.FirstName);
12        testname = TestName_ds.getNext();
13
14     }


La numeración continúa en 07 reemplazando el ciclo For, el resultado es el mismo.

=)