Chained FINDSTRs

Now that I learnt that FINDSTR is more flexible than I thought, a quick post on how to apply chained FINDSTR calls.

For instance, if you need to search all XPOs that have the words “holiday” and “GBR” (Brazilian localization tag). You could use the “/f” switch which accepts a file containing the files to look into. First example to make it clearer:

findstr /i /m /s "holiday" *.xpo > holiday_files.txt
findstr /i /m /f:holiday_files.txt "gbr"

Which will first create a file with the list of files with “holiday” (“/m” switch) and then look in the files from this list (“/f:file”) for the “GBR” occurrence.

A special case would be using the “/f:/” switch which accepts the file list from the console (stdin). So a more direct call would be:

findstr /i /m /s "holiday" *.xpo | findstr /i /m /f:/ "gbr"

Finally, use UniqueOcc to make it beautiful!

findstr /i /m /s "holiday" *.xpo | findstr /i /f:/ "gbr" | UniqueOcc

Of course this will not search “holiday” inside GBR tags. This is another task for a future post.

Posted in Dynamics AX, English, Uncategorized | Leave a comment

UniqueOcc: a FINDSTR formatter

The UniqueOcc (from unique occurrence) is a command-line tool that parses the output of the FINDSTR tool that we normally use to search XPO files contents (specially files in the Dynamics AX version control repositories, such as Source Depot). 

The FINDSTR is really usefull for searching an entire directory and its subdirectories for XPO files containing specific words. For example, if you want to know which classes, forms, tables, etc. use the Legal Text feature, you would get a fair estimated by running: 

C:\Depot\AX\Source\Application\GLS>findstr /i /s "legaltxt" *.xpo

This command will search all XPO files (*.xpo) for the “legaltxt” string, starting in the GLS directory, including all subdirectories (/s) and using an insensitive case (/i) comparison. 

The classical FINDSTR output would be: 

Classes\NFFiscalDoc_BR.xpo:        #    FiscalDocJourLegalTxt_BR          ...
Classes\NFFiscalDoc_BR.xpo:        #    FiscalDocTransLegalTxt_BR         ...
Classes\NFFiscalDoc_BR.xpo:      SOURCE #postLegalTxt
Classes\NFFiscalDoc_BR.xpo:        #protected void postLegalTxt()
Classes\NFFiscalDoc_BR.xpo:        #    this.postFiscalDocJourLegalTxt();
Classes\NFFiscalDoc_BR.xpo:        #            this.postFiscalDocTransLeg...
Classes\NFFiscalDoc_BR.xpo:        #        nfFiscalDoc.postLegalTxt();
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:      SOURCE #getCFOPLegalTxt
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #protected LegalTxt_BR ins...
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #    LegalTxt_BR     local...
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #        localLegalTxts = ...
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #        localLegalTxts = ...
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #        localLegalTxts = ...
Classes\NFFiscalDoc_DeliverySlip_BR.xpo:        #    return localLegalTxts
(...many, many, many more lines...)

But you’ll have to scroll and filter it a lot to find which artefacts do have the string you are looking for. A more useful output for our purpose would be: 

Classes\NFFiscalDoc_BR.xpo
Classes\NFFiscalDoc_DeliverySlip_BR.xpo
Classes\PurchCopying.xpo
Classes\PurchFormLetter.xpo
Classes\PurchFormLetter_Invoice.xpo
Classes\SalesCopying.xpo
Classes\SalesFormLetter.xpo
Classes\SalesFormLetter_Invoice.xpo
Data Dictionary\Base Enums\LegalTxtSection_BR.xpo
Data Dictionary\Extended Data Types\LegalTxtDescription_BR.xpo
Data Dictionary\Extended Data Types\LegalTxtId_BR.xpo
(...)

Update: 30 seconds after publishing my post, my colleague Djalma pointed me the “/m” switch in FINDSTR which does exactly this. Well, paying for not reading “FINDSTR /?”… But the extra features below are a plus.

The C++ code below does the job by reading from stdin and writing to stdout

Continue reading

Posted in Dynamics AX, English | Leave a comment

Apresentação RU-5 do Dynamics AX 2009

Adicionei no blog o arquivo PowerPoint com a apresentação das features de RU-5 do Dynamics AX 2009, conforme mostrado no encontro de parceiros realizado no dia 09/agosto/2010. Lembrando que os tópicos foram:

  • Transferência de Crédito de ICMS (Fábio Vazquez)
  • Melhorias na área contábil – Book Numbers & Transaction Text (Djalma Franco)
  • Nota Fiscal Eletrônica (Rodrigo Matiazo)
  • Importação (Rodrigo Matiazo)

Coloquei o arquivo em dois formatos:

[]s

Posted in Dynamics AX, Português, Uncategorized | Leave a comment

The Monty Hall problem

O problema de Monty Hall é famoso por mostrar como a probabilidade não é intuitiva.

O cenário é simples. No show de Monty Hall, ele apresenta três portas (A, B e C). Uma delas possui um prêmio (um carro) e as outras duas não. Bem, as outras duas contêm um bode (goat) em cada uma, mas o participante não pode levar o bode para casa…

O participante escolhe uma das portas (e.g. porta A). Monty Hall então abre uma das outras duas portas (e.g. porta B), mostrando ao participante que ela contém um bode. Feito isso, o participante pode optar entre ficar com a porta que ele escolheu (porta A) ou mudar para a outra porta (porta C). A pergunta é: a melhor estratégia é mudar ou ficar com a porta original?

A maioria das pessoas argumenta que simplesmente não faz diferença. Depois que Monty Hall abriu a porta com o bode, a segunda escolha é a que vale. Logo, qualquer escolha tem 50% de chances de ganhar o carro. Além disso, a primeira escolha só faria diferença se o participante ganhasse logo de primeira o prêmio, aí sim a segunda escolha seria uma soma de probabilidades.

Afinal, faz diferença mudar ou não? Faz diferença. A melhor estratégia é sempre trocar, o que aumenta a chance de ganhar para 67% (2/3).

Continue reading

Posted in Math, Português | 2 Comments

Mais dicas do Configurador CNAB

Adicionei mais dicas para Grupo de Layouts do Configurador usado para gerar arquivos CNAB e NFe de serviços. Elas têm aparecido em blogs e fóruns. Espero que sejam úteis.

Veja em http://www.daniellandi.com/?page_id=99.

Posted in Dynamics AX, Pagamento Eletrônico, Português | Leave a comment

Extrair consulta T-SQL (SQL Server) de um objeto Query

Depurar um objeto QueryRun, Query, QueryBuildDataSource ou FormBuildDataSource no Dynamics AX 2009 pode ser enganoso. Visualizar dados no Dynamics AX Debugger é confuso e usar a opção SQL Trace às vezes não é suficiente.

O método QueryBuildDataSource::toString() é ótimo para visualizar a consulta SQL em texto:


query.dataSourceNo(1).toString()

Mas, como todos já devem ter tentado, o resultado não é uma consulta T-SQL e assim não é compatível com SQL Server.

Desenvolvi um método para extrair uma consulta T-SQL de um objeto Query que é usado na minha ferramenta Configurator Debug. Ele é simples e longe de estar otimizado, mas atende ao escopo da ferramenta (consultas criadas pelo assistente do Configurador usadas no Pagamento Eletrônico). Veja exemplos aqui de consultas em DAX-SQL e T-SQL.

Continue reading

Posted in Dynamics AX, Português, X++ | 2 Comments

Extract T-SQL (SQL Server) statement from Query object

Debugging a faulty QueryRun, Query, QueryBuildDataSource or FormBuildDataSource can be tricky in Dynamics AX 2009. Visualizing data on the Dynamics AX Debugger is cumbersome and using the SQL Trace option is sometimes not enough.

The QueryBuildDataSource::toString() method is great to visualize the SQL statement as text:


query.dataSourceNo(1).toString()

But, as everybody has probably tried, it is not a T-SQL statement and thus not compatible with SQL Server.

I developed a method to extract a T-SQL statement from a Query object which I use in my Configurator Debug tool. It is quite simple and far from optimized, but it handles the scope of that tool (queries created by the Configurator wizard used in Electronic Payments). See examples here of DAX-SQL and T-SQL.

Continue reading

Posted in Dynamics AX, English, X++ | 1 Comment

Dicas de Pagamento Eletrônico

Coloquei algumas dicas sobre Pagamento Eletrônico aqui no site. Separei as dicas em Grupos de Definições e Grupos de Layouts.

Posted in Dynamics AX, Pagamento Eletrônico, Português | Leave a comment

Configurator Debug

Meu primeiro post neste blog é sobre a ferramenta ConfDebug (Configurator Debug) que auxilia a depuração de queries criadas pelo Grupo de Definição do Configurador no Dynamics AX 2009.

Veja os seguintes links:

Posted in Dynamics AX, Pagamento Eletrônico, Português | Leave a comment