Dynamics AXBR

Blog destinado a usuários do Dynamics AX no Brasil.
Options:

Complex Queries in AX

Visão geral o artigo “Expressions in query ranges”, Axaptapedia.

Construção de uma query simples:

1
2
3
  query = new Query();
  dsInventTable = query.addDataSource(tableNum(InventTable));
  queryBuildRange = dsInventTable.addRange(fieldNum(InventTable, DataAreaId));

Critério simples:
Pesquisar o registro onde o itemID é B-R14.

  queryBuildRange.value(strFmt('(ItemId == "%1")', queryValue("B-R14")));

Pesquisando registros onde o tipo é um serviço:

queryBuildRange.value(strFmt('(ItemType == %1)', any2int(ItemType::Service)));

Pesquisando registros onde o tipo é um serviço ou o itemID é B-R14.

  queryBuildRange.value(strFmt('((ItemType == %1) || (ItemId == "%2"))', any2int(ItemType::Service), queryValue("B-R14")));

Pesquisando registros onde a data da modificação é depois de 01/01/200.

  queryBuildRange.value(strFmt('(ModifiedDate > %1)', Date2StrXpp(01012000)));

Critérios complexos combinando condição OU e E

Pesquisando todos os registros aonde o tipo é um serviço ou item e que o ProjCategoryId for igual a Spares.

  queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3) && (%4 == "%5")))',
    fieldStr(InventTable, ItemType),
    any2int(ItemType::Service),
    any2int(ItemType::Item),
    fieldStr(InventTable, ProjCategoryId),
    queryValue("Spares")));

Condições WHERE referenciando a campos de multiplas tabelas

Para o exemplo abaixo, nós construimos uma query que consiste em um JOIN the dois datasources usando um EXIST JOIN.

  query = new Query();
  dsInventTable = query.addDataSource(tableNum(InventTable), tableStr(InventTable));
  dsInventItemBarCode = dsInventTable.addDataSource(tableNum(InventItemBarCode), tableStr(InventItemBarCode));
  dsInventItemBarCode.relations(true);
  dsInventItemBarCode.joinMode(JoinMode::ExistsJoin);
 
  // Add our two ranges
  queryBuildRange1 = dsInventTable.addRange(fieldNum(InventTable, DataAreaId));
  queryBuildRange2 = dsInventItemBarCode.addRange(fieldNum(InventItemBarCode, DataAreaId));

Procurar todos os registros aonde o código de barras existir para um item e foi modificado depois que o item foi modificado.

  queryBuildRange2.value(strFmt('(ModifiedDate > InventTable.ModifiedDate)'));

Perceba que SE nós tivéssemos adicionado nosso dataSource InventTable usando o seguinte código:

  dsInventTable = query.addDataSource(tableNum(InventTable), "InventTableCustomName"); // Perceba que nós estamos modificando um nome diferente para o DataSource

Então a query deve aparecer como:

  queryBuildRange2.value(strFmt('(ModifiedDate > InventTableCustomName.ModifiedDate)'));

Conditional joins

Nós iremos modificar levemente o exemplo anterior, para remover a adição automatica do relacionamento para o Join.

  query = new Query();
  dsInventTable = query.addDataSource(tableNum(InventTable), "InventTable");
  dsInventItemBarCode = dsInventTable.addDataSource(tableNum(InventItemBarCode), "InventItemBarCode");
  dsInventItemBarCode.joinMode(JoinMode::ExistsJoin);
 
// Add our two ranges
  queryBuildRange1 = dsInventTable.addRange(fieldNum(InventTable, DataAreaId)); 
  queryBuildRange2 = dsInventItemBarCode.addRange(fieldNum(InventItemBarCode, DataAreaId));

Usando as tecnicas acima, é possível criar queries com quase o mesmo tanto de flexibilidade como usando comandos SQL diretamente.

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Rodar job de exportação (FBI) na mão para debugar

Caros,
A um tempo atrás eu precisei debugar processos dos livros fiscais e por rodar em threds, eu não conseguia debugar.

A solução que adotei, foi essa abaixo:

1
2
3
4
5
6
7
8
static void Job1(Args _args)
{
    FBIExport_BR    export;
    int                  jobCode = 5;
    ;
    export = new FBIExport_BR(FBIJOb_BR::construct(jobCode), new FBISqlExecutor_BR(FBIDatabaseConnectionFactory_BR::returnFBIDatabaseConnection()));
    export.run();
}

A única mudança necessária é o código do job, que você deve mudar conforme o job que você quer executar.

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Imprimindo direto em PDF

Para tal, nós precisamos setar certos valores nos parâmetros de impressão antes de rodar o relatório.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Variables
PrintJobSettings    printJobSettings;
ReportRun           myReportRun;
 
...
 
// Recuperando os parâmetros do relatório
printJobSettings = myReportRun.printJobSettings();
 
// Configurando nossos parâmetros
printJobSettings.setTarget(PrintMedium::File);
printJobSettings.preferredTarget(PrintMedium::File);
 
printJobSettings.format(PrintFormat::PDF);
printJobSettings.preferredFileFormat(PrintFormat::PDF);
 
printJobSettings.fileName("c:\\attachment.pdf");
 
// Salvando os valores
myReportRun.unpackPrintJobSettings(printJobSettings.packPrintJobSettings());
 
// Rodando o relatório
myReportRun.run();

Antes de rodar o relatório, podemos configurar os valores da query:

1
2
3
4
5
6
7
8
query = myReportRun.query();
qbds = query.dataSourceNo(1);
 
qbds.range(1).value(_custTable.CustAccount);
qbds.range(2).value("");
qbds.range(3).value(queryvalue(NoYes::Yes));
 
myReportRun.run();

Nota: Para usar uma impressora PDF como o “PDFCreator”, simplesmente configure o nome do dispositivo como:

1
myReportRun.deviceName("PDFCreator");

Fonte: http://olondono.blogspot.com.

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Usando “Not Like”

Usando o like normal:

1
2
select firstonly purchTable
  where purchTable.purchId like '09*';

Quando você quiser ter todos os outros registros (not like), no X++ você tem 3 possibilidades:

1.!LIKE :

1
2
select firstonly purchTable
  where !(purchTable.purchId like '09*');

2. notExists join :

1
2
3
select firstonly purchTable
    notExists join refPurchTable
    where purchTable.purchId == '09*';

3. Query-object :

1
2
3
4
5
6
7
8
9
10
11
Query query = new Query();
QueryRun queryRun;
; 
query.addDataSource(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchId)).value('!09*');
queryRun = new QueryRun(query);
if(queryRun.next())
{
    purchTable = queryRun.get(tableNum(PurchTable));
    print purchTable.PurchId;
}
pause;

Fonte: http://www.doens.be/

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Dynamics AX6 – O novo editor X++

Pessoal,
Estava navegando e encontrei um post no Vincent’s Blog que fala a respeito do novo editor x++ para o AX6.

Abaixo a tradução do post:

Atualmente estou trabalhando na próxima versão do Dynamics AX – AX6 e como parte da melhoria, meu time esta trabalhando em um novo editor para a linguagem X++. Este editor é baseado no mesmo framework que o Visual Estudio.

Aqui é como ele se parece:

Os números nas linhas e a marcação gradiente são os primeiros sinais da nova Interface do Usuário, baseado no WPF, que da algumas oportunidades a gráficos interessantes.

Um pouco mais:

Alguns pontos que são relativamentes novos ao editor existente são:

  • Suporte para múltiplas fontes e estilos (comentários são em uma fonte diferente em itálico).
  • Cores diferentes para strings e números.
  • Operadores coloridos (em pink aqui, mas não se preocupe que provavelmente eu irei mudar antes de liberar).
  • Mudança no tracking margin.

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Atalhos no AX

Eu estava dando uma garimpada nos meus docs antigos e achei uma tabelinha que é bem útil, segue:

To Press
Open Help on a class F1
Delete the previous word CTRL+BACKSPACE
Open the Find/Replace dialog CTRL+F
Find the next occurrence F3
Jump to next error message F4
Execute the current job F5
Set and delete a breakpoint F9
Close, and save the current tab F8
Close the current tab, discarding all F6
Compile F7
Replace CTRL+R
Save with a new name CTRL+ALT+S
Display field value options ALT+DOWN
Undo the previous action CTRL+Z
Redo the action which was just undone CTRL+Y
Delete DEL
Select all CTRL+A
Columns selection ALT+O
Normal area selection ALT+A
Lines selection ALT+L
Cancel selection ALT+U
Delete current line CTRL+L
Delete from the cursor position to the end of the line   CTRL+SHIFT+L
Save the selected text to a seperate file ALT+S
Insert contents of seperate file at the cursor position   CTRL+ALT+H
Run a script ALT+M
Go to a specified page or line CTRL+G
Go to next page PAGE UP
Go to previous page PAGE DOWN
Go to the top CTRL+HOME
Go to the bottom CTRL+END
Go to the start of the line/page/file HOME
Go to the end of the line/page/file END
Move the cursor one word to the left CTRL+LEFT
Move the cursor one word to the right CTRL+RIGHT
Go to the previous page, and block SHIFT+PAGE UP
Go to the next page, and block SHIFT+PAGE DOWN
Go to the top, and block CTRL+SHIFT+HOME
Go to the bottom, and block CTRL+SHIFT+END
Go to the start of the line/page/file, and block SHIFT+HOME
Go to the end of the line/page/file, and block SHIFT+END
Move the cursor one word to the right, and block CTRL+SHIFT+RIGHT
Move the cursor one word to the left, and block CTRL+SHIFT+LEFT
Delete the word to the left CTRL+BACKSPACE
Remove all breakpoints CTRL+SHIFT+F9
Insert or remove a breakpoint F9
Enable or disable a breakpoint CTRL+F9
To look up… Press
A label CTRL+ALT+SPACE
A Definition CTRL+SHIFT+SPACE
Properties and methods CTRL+SPACE
To list … Press
Tables F2
Breakpoints SHIFT+F9
Classes F12
Types F4
Enums F11
Reserved words SHIFT+F2
Axapta Application Objects SHIFT+F11
Extended Data Types CTRL+T
Built-in functions SHIFT+F4

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Rodar um formulário ‘modal’.

Algumas vezes precisamos rodar formulários do tipo modal, ou seja, um fomulário que fica na frente dos outros enquanto ele não for fechado, ainda mais quando se trata do AX, onde os usuários costumam não ter muito cuidado ao abrir formulários e isso acaba gerando um pouco de confusão.

Para tal, veja o exemplo na classe SysModalFormDisableAllWkspcs, que basicamente faz:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
static void main(Args args)
{
    Args args1;
    FormRun modalForm;
 
;
    args1 = new Args(args.parm());
    modalForm = classfactory.formRunClass(args1);
    modalForm.init();
    modalForm.run();
    // check if the form is closed
    if (!modalForm.closed())
        modalForm.wait(true);
}

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Usar o ‘like’ em uma instrução IF

No ax é possível usar o like em uma instrução IF como podemos ver abaixo:

1
2
3
4
5
6
7
static void ifWithLike(Args _args)
{
    str     myValue = '2009';
    ;
    if(myValue like '*09')
        info("Hello Word!");
}

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Sure Step 2010

Está disponível no partnersource o Sure Step 2010.

Sure Step 2010

[]s
Pichler



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Se você precisa criar um agendamento ou uma requisição de reunião no Outlook usando X++, apenas copie o código abaixo e certifique-se que exista um cliente Outlook instalado na maquina que o código irá rodar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
static void OutlookAppointment(Args _args)
{
  #SysOutLookCOMDEF
  #define.mapi("MAPI")
  #define.outlook("Outlook.Application")
  COM             sysOutlookCollection;
  COM             collection;
  COMVariant      comStartDate = new COMVariant();
  COMVariant      comEndDate   = new COMVariant();
  COM             c;
  COM             sysOutlook;
  COM             sysOutlookNameSpace;
  COM             sysOutlookMAPIFolder;
  ;
 
  sysOutlook                  = new COM(#outlook);
  sysOutlookNameSpace         = sysOutlook.getNamespace(#mapi);
  sysOutlookNameSpace.logon();
  sysOutlookMAPIFolder        = sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderCalendar);
  collection                  = sysOutlookMAPIFolder.items();
  c = collection.add();
  comStartDate.date(today());
  comStartDate.time(str2Time( "12:00:00"));
  comEndDate.date(today());
  comEndDate.time(str2Time( "12:45:00"));
  c.location('Solugenix 4th Floor Conference Room, India');
  c.subject('Meeting regd Microsoft Dynamics AX 2009');
  c.body('Lets discuss on whats new in DAX 2009');
  c.start(comStartDate);
  c.end(comEndDate);
  c.save();
 
  if (c)
  {
    c.display();
    info("The action is created in Microsoft Outlook");
  }
  else
    throw error("@SYS31969");
 
  sysOutlookNameSpace.logoff();
}

[]s
Pichler

Fonte: http://dax-lessons.spaces.live.com/blog/



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Tags

Categorias

Data do post

February 2010
S M T W T F S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28  

Arquivo

Latest Visitor Loactions

São Paulo, Brazil 7
Curitiba, Brazil 3
Santos, Brazil 2
Rio De Janeiro, Brazil 2
Indaiatuba, Brazil 1
Sorocaba, Brazil 1
Caçapava, Brazil 1
Ribeirão Prêto, Brazil 1
Vinhedo, Brazil 1
Recife, Brazil 1