Wednesday, February 13, 2008

Gentran Application Integration - Import Map Missing line items

After creating and testing several EDI 810 invoice export maps in Gentran Application Integration, we moved most of them into production. The problem occured when we ran these 810 maps in a batch and were importing many documents at the same time. For some reason some of the invoices were missing line items. At first there was no pattern...a five line item invoice might have two lines while a six line item invoice may only have one.

Rather than go into much detail about what I tried (and what Sterling Tech support tried) here is the problem and the solution:

Problem
The EDI 810 IT101 segment was being generated with the Gentran Application Integration provided code in the Standard rules. The standard rule we used is called loop_count and it was counting the loops through the IT1 group. I realized this might be the problem when one of the maps that did not use this feature (as our trading partner did not require this segment) was not failing.

Solution
In plain terms...use your own code. I created a global variable (under file->session rules) loopcount and initialized it to zero. Each time the IT101 segment is reached, I incremented the loopcount by 1 and set the IT101 segement to this value. Pretty simple.

Added Bonus
So before making this change, I had to audit each invocie by looking at each invoice and comparing the number of line items to the CTT01 segement (usually total line count) to figure out if there were any errors. I would then import all of This was quite a chore. So after adding the loopcount code, I also added a bit of error checking in the CTT01 segement. Here is the code:

If #0354 != loopcount then
begin
empty(#0354)
end

The #0354 value is the value loaded into the CTT01 segment. I happen to have a totalLines field in my database that I map to this segment. If the loopcount value does not match the CTT01 segemnt, the CTT01 segment is set to NULL. Since the CTT01 is mandatory when it is activated, a null value will cause the invoice document to fail and be sent to your red outbox? folder where it can be imported individually, but since getting rid of the canned loop_count standard rule I have not had a failure.