Monday, June 9, 2008

Quick Altova Mapforce Tutorial, Convert EIF to outgoing 880

Started working on converting an .eif file into an X12 880 using mapforce. One thing I learned was that when using the TransformTool.jar you can just specify a * (asterisk) for the new file name and it will use the original file name with .xml for the transformed file. Very Useful.

So my work flow goes something like this. Create a 880 svn repository. Get an .eif invoice and convert it to .xml using the TransformTool.jar (Manually for now)

Transform Explanation Doc is here http://mellerbeck.googlepages.com/sv_diary_5305664_ERPTEEBarcodingInst.doc

Open up Mapforce and use the provided .dtd from Adage (Invoice_Outbound.dtd) and then provide it the converted .xml file (from above) to use as a reference for the mapping. (clicking the add schema/xml)

Then click the EDI button and add the 880 (under x12 tab)

Next I start studying the vendors EDI specs. I first start with ISA line, and set mapforce to match the requested Data Element Separator, Composite Separator, Repetition Separator, and Segment Terminator. I get to this by right clicking the EDI portion and then select properties. I also click the Extended button to change the Interchange Control Version Number (If needed).

Next I started creating constants and connecting them to the appropriate parts of the ISA. I just learned that Segment Terminator 85 (hex 85) equals a newline. I connect the ID qualifier and the sender/receiver ID.

Next work down to the GS. Connect a constant of GP.

Next I create my lame’o Control number generator. Basically read in two numbers, add one to it, and write out the new numbers to the same file. This is for the GS and ST segment.

I add a ‘now’ from the datetime functions and connect it to the invoice date, and then connect the document number to the invoice number (F76).

Then connect the CustomerPurchaseOrderNumber to the Purchase Order Number and PurhcaseOrderSalesOrderNumber connect to Vendor Order Number.

I connected constants for the Terms of Sale.

I met kindof a nasty snag with the date format of the InvoiceDueDate. From Adage it is output like

26-jun-2008 00:00:00

This isn’t a format that Mapforce Recognizes as a date :( so I had to parse out the day, month, year using a substring-before and replace combo, and then value map the jun into a 6 then connect it all to a datetime-from-parts. There might be an easier way so I posted the question on the Mapforce forum.

Next, started working on the N segments. This was interesting because I had never looked up a bill to name before in Adage. It is stored in the en_bill_tbl so did a select en_bill_name where en_bill_key = ‘whatever’

On further review all that was needed was to send the Remit to which made everything much easier. I connected a RE to the F98_1 and the rest of the name, address info etc…

Next I wanted to get looping information So I connect the Detail01 of my xml to the Loop0300 of the edi spec. Then I connected the price, quantity etc.. to the G17 etc…

To get the total invoice quantity use a sum and connect the InvoiceLineQuantity to it inside of a looping area of code.

I ran into the most annoying problem of not being able to import the generated EDI into TrustedLink. After a lot of work, thinking that it was a problem with the segment it turned out to be a slight bug in Mapforce. Inside of mapforce when I connected a now to the F337 it would truncate the time to 6 chars, but the code it was generating was truncating at 12 chars. Since that is invalid for the F337 the import was not happening successfully. To fix it you connect the now to a time-from-datetime and then to the F337 Time and the generated code truncates correctly.

Saturday, February 23, 2008

Exploring the Aggregate - count function

count




This returns the number of nodes/rows within the scope of the 'in-context'

Basically counts how many repeating elements have gone by it.

To illustrate it, lets create a text file count.txt and add it with simple csv processing, then add a count function then connect the Field1 to the nodes/rows. Then create an out text with simple csv processing and connect the result to the Field1 of the out text.

count.txt contains (9 1's on separate lines)

1
1
1
1
1
1
1
1
1

Which will look something like this.




As you might imagine, if you hit the output tab you will get 9 (the number of repeating rows that came through the 'counter' box)



Friday, February 22, 2008

Exploring the Aggregate - avg function

avg


result = avg(set)



Lets say you have a text file named avg.txt which contains
1
2
3
4
5

So add that selecting 'use simple processing for standard CSV'
Add an avg function
And connect your Field1 to the nodes/rows of the avg function
Then create an output text component with 'simple processing'





Now if you click the Output tab you should get 3

Now, I don't know why you don't connect the Rows to the in-context it sort of seems like you should, but if you do it will give you a 5 (the last item in your list of numbers) maybe someone out there can explain this to me?

Lets do
1.1234
2.3
4.6
5.678
7.0000008

Which gets us 4.14028016

Well I didn't figure out where the rounding point of this happens but I think its around the 26th decimal point. I'll leave that to someone else to pursue.

Converting raw 850 X12 EDI into an Adage ATF Purchase Order (.eif) file format using some Custom Code, Mapforce, and TransformTool.jar

I created a new tutorial on how to take some raw X12 edi and convert it into XML and then into an Adage .eif (ATF) file. I will eventually post the text but for now here is the PDF.

Converting raw X12 EDI into Adage ATF.pdf using Mapforce