Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Order Entry Import 1

Status
Not open for further replies.

null2222

Programmer
Oct 20, 2011
2
CA
Hi Guys
I'm trying to create a program to automate some of our imports but I'm running into a error I can't figure out.
It keeps giving me a IE_EXECUTE_SCRIPT_FAILED, Failed to insert record when doing the import.

I was hoping one of you guys had some insight that could help me out.

Here's the xml file i'm using
Code:
<?xml version="1.0" encoding="utf-8"?>
<AccpacImpExp Action="16" ComposeStyle="1" ProgramName="OE1100" Type="IMPORT" Version="532" HasTitleRecord="1">
<VIEW ID="OE0520" Type="3" Action="0" SelectedIDs="1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 23 24 25 26 27 28 29 32 38 40 45 46 51 53 54 78 254 255 256 257 "><TABLE>Orders</TABLE></VIEW>
<VIEW ID="OE0500" Type="9" Action="0" Parent="OE0520" SelectedIDs="1 2 3 4 6 15 32 40 "><TABLE>Order_Details</TABLE></VIEW>
<VIEW ID="OE0508" Type="8" Action="0" Parent="OE0500" SelectedIDs="1 2 3 "><TABLE>Order_Detail_Serial_Numbers</TABLE></VIEW>
<VIEW ID="OE0507" Type="8" Action="0" Parent="OE0500" SelectedIDs="1 2 3 "><TABLE>Order_Detail_Lot_Numbers</TABLE></VIEW>
<VIEW ID="OE0740" Type="9" Action="0" Parent="OE0520" SelectedIDs="1 2 "><TABLE>Order_Payment_Schedules</TABLE></VIEW>
<VIEW ID="OE0180" Type="9" Action="0" Parent="OE0520" SelectedIDs="1 2 "><TABLE>Order_Comments_Instructions</TABLE></VIEW>
<VIEW ID="OE0522" Type="8" Action="4096" Parent="OE0520" SelectedIDs="1 2 "><TABLE>Order_Optional_Fields</TABLE></VIEW>
<VIEW ID="OE0501" Type="8" Action="4096" Parent="OE0500" SelectedIDs="1 2 3 "><TABLE>Order_Detail_Optional_Fields</TABLE></VIEW>
<VIEW ID="OE0502" Type="8" Action="4" Parent="OE0500"><TABLE>Order_Kitting_Details</TABLE></VIEW>
<VIEW ID="OE0503" Type="8" Action="4" Parent="OE0500"><TABLE>Order_BOM_Details</TABLE></VIEW>
<VIEW ID="OE0504" Type="8" Action="4" Parent="OE0502"><TABLE>Order_Kitting_Serial_Numbers</TABLE></VIEW>
<VIEW ID="OE0506" Type="8" Action="4" Parent="OE0502"><TABLE>Order_Kitting_Detail_Lot_Numbers</TABLE></VIEW>
<DBNAME>C:\Users\dlabbe\Desktop\Repos\AutomatedRMADayEnds\AutomatedRMADayEnds\bin\Debug\Exports\RMAORD-MPQDAT-20111021093250.csv</DBNAME>
<DBTYPE>Single CSV File</DBTYPE>
</AccpacImpExp>

And the code I use to call it
Code:
//Create Session
            AccpacCOMAPI.AccpacSession session = new AccpacCOMAPI.AccpacSession();
            session.Init("", "XY", "XY1100", "56A");

            //Try connecting to the session
            try { session.Open(ACCOUNT_USERNAME, ACCOUNT_PASSWORD, AUDTORG, System.DateTime.Now, 0, ""); }
            catch (System.Runtime.InteropServices.COMException err)
            {
                ResultText = "\t\t(ERROR): Could not connect to session (" + err.Message + ")";
                return -1;
            }

            //Create Database Links
            AccpacCOMAPI.AccpacDBLink mDBLinkCmpRW = session.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
            AccpacCOMAPI.AccpacDBLink mDBLinkSysRW = session.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);

            AccpacImportExport.ImportExport ImportInterface = new AccpacImportExport.ImportExport();
            ImportInterface.Open(mDBLinkCmpRW);
            ImportInterface.ImportAction = AccpacImportExport.tagImportActionType.IMPORT_INSERT;

            ImportInterface.SetViewEx("OE0520", "", AccpacImportExport.tagViewType.VIEW_SEQUENCED_HEADER, null,AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0500", "OE0520", AccpacImportExport.tagViewType.VIEW_DETAIL_SEQUENCED, null, AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0508", "OE0500", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0507", "OE0500", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0740", "OE0520", AccpacImportExport.tagViewType.VIEW_DETAIL_SEQUENCED, null, AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0180", "OE0520", AccpacImportExport.tagViewType.VIEW_DETAIL_SEQUENCED, null, AccpacImportExport.tagViewActionType.ACTION_ASK);
            ImportInterface.SetViewEx("OE0522", "OE0520", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.OPTIONAL_VIEW);
            ImportInterface.SetViewEx("OE0501", "OE0500", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.OPTIONAL_VIEW);
            ImportInterface.SetViewEx("OE0502", "OE0500", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.COMPOSE_ONLY);
            ImportInterface.SetViewEx("OE0503", "OE0500", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.COMPOSE_ONLY);
            ImportInterface.SetViewEx("OE0504", "OE0502", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.COMPOSE_ONLY);
            ImportInterface.SetViewEx("OE0506", "OE0502", AccpacImportExport.tagViewType.VIEW_DETAIL_ORDERED, null, AccpacImportExport.tagViewActionType.COMPOSE_ONLY);

            //Run Import Job
            ImportInterface.VerifyOnPut = true;
            ImportInterface.ExecuteImportScript(Path.GetDirectoryName(Application.ExecutablePath) + @"\Exports\" + FileName,ref TempBool);

            //Return warnings / errors
            ResultText += "Result:" + ImportInterface.ImpExpStatus;
            for (int i = 0; i < mDBLinkCmpRW.Session.Errors.Count; ++i)
                ResultText += "\t\t" + mDBLinkCmpRW.Session.Errors.Item(i) + "\r\n";
 
My best advice is do not use the Accpac import routines, they are fine for one time imports but suck for a long term solution.
Write a macro to read the data and then generate the invoices in OE using the views. You can do your own data validation and avoid the import errors that bug the import routine.
 
Tried out the method that you guys suggested.
Wow that was a lot easier than playing around with the ImportExport COM.

Just one more question in the recording there are lots of Fetch, Browse and Read calls peppered in the macro. Are those necessary for creating documents or can I strip them out?
 
Strip them out, as well as any line with "temp =" in it. The only ones you usually need to create records are:

.RecordGenerate
.RecordCreate
.Init
.PutWithoutVerification
.Process
.Insert
.Update

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top