AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.03.2015, 18:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
palleagermark: Transform AIF output to a CSV file
Источник: http://www.agermark.com/2015/03/tran...-csv-file.html
==============

Start out by reading Shashi Sadasivans article series on import of CSV files with AIF: https://shashidotnet.wordpress.com/2...me-web-service/. Much of the stuff you need to do for the outbound transformation is the same.

In this example I'm going to show how a Purchase Order Confirmation document can be transformed to a comma (actually semi colon in my example) separated file.

First thing you should do is to create classes to wrap to the XML schemas, so you don't have to work directly with the XML nodes. The class creation is described in Part 3 of Shashi's article series. You'll need classes for the Envelope, the Shared Types and the document in question.
You don't absolutely need to create these classes, but I prefer to work with these classes rather than working directly with the XML nodes.

With the classes in place you can create an instance of the document class (PurchRequistition.AxdPurchaseRequisition). But first you need to isolate the message part of the XML to be able to de-serialize this part of the XML into the document instance.

Here is a method I made for that:


That was the hard part to figure out. I have a gut feeling that you can do this smarter. Please comment if you know how.

I call this method in the beginning of my Transform method, and I then begin to loop over the journal, purchase headers and purchase lines. I use a StringBuilder for the output records.


I have created a method to add each field to the output string, check allowed length, remove unwanted characters and add the field separator. It's called AppendField and that's what I call in the following:


That is it. Remember to close the outgoing stream writer when done:


Here is the AppendField method:


And the GetSafeString method:


You can get the entire class, but not the XSD wrappers, here. You'll have to create the XSD wrappers yourself.

On the outbound port you could use the standard file adapter with this transformation. It will however create the output file with an XML extension. If you need an CSV extension you can't write a a new file adapter extending the standard file adapter. You'll have to override a single method to control the output file name.

Thank you Jacob Broberg for valuable input from your prototype to this solution.

Источник: http://www.agermark.com/2015/03/tran...-csv-file.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axmfg: Output location for the last operation in the production route Blog bot DAX Blogs 0 22.09.2014 18:11
palleagermark: Import CSV files using AIF Blog bot DAX Blogs 0 16.12.2011 18:11
axinthefield: AIF File Adapter for AX 2009 - Security Authorization Blog bot DAX Blogs 0 23.06.2011 21:11
Microsoft Dynamics CRM Team Blog: Importing two or more entities from a Single File Blog bot Dynamics CRM: Blogs 0 09.11.2010 19:05
axStart: InfoPath with default AIF file inbound offline Blog bot DAX Blogs 0 20.05.2008 19:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:35.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.