Normal Topic Errors reported with import file (Read 934 times)
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Errors reported with import file
Nov 9th, 2017 at 12:53am
Print Post Print Post  
I have set up code to record A, then go to Add Mode, add a new record B, and import the exported record.  I can do the steps manually, no problem, works good. 

But when using program, the import process displays the following message:
Import reports errors in file pgmImportRentalInvoiceAndLines. Check the administrative log for details.
The log shows the following:
server_warning / S_ENG510810 / Error: Cannot access ASCII file pgmImportRentalInvoiceAndLines.

The name of the export spec is "pgmImportRentalInvoiceAndLines"  The name is saved as a Global Variable while in Record A, before the export.  Record A is saved, and Add mode is entered.
After adding the new record B, the import spec gets the spec name from the Global variables.  WriteLn shows that global variable routine is working OK.

I have renamed the ImportSpec, loaded the new named spec and renamed it to the original name. Same problem. 
I used a totally different Import spec with the same result.

Working in stand alone mode, no server/client connections.  Using version 2.6

I could not find this topic in the forum Searches.  Could really use some suggestions here.  Don't need for customer until tomorrow, aargh!
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Errors reported with import file
Reply #1 - Nov 9th, 2017 at 2:30pm
Print Post Print Post  
What filename are you exporting the data to? You said the spec is named "pgmImportRentalInvoiceAndLines" but what file is it exporting out to?
What does your code look like?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Errors reported with import file
Reply #2 - Nov 9th, 2017 at 4:17pm
Print Post Print Post  
Thanks, Ray.

The exported file is a variable in the code.  On this test record, the file name is "Rental Invoice_34970_171108_1948.txt".  (I have attached the file).  I have about ten different types of exports/imports that I want to do with this one routine.

Here is the code in the command button:
Code
Select All
======================= "cmdCOPY TO NEW FORM" ON ELEMENT ENTRY CODE =========================
var vDest as String			// Destination Order Type
var vRun as Int
var vPath as String = "C:\Sesame2\SesameExports\"
var vFileName as String = OrderType +"_" + OrderNumber + "_" + vDate + "_" + vTime + ".txt"
var vFullName as String = vPath + vFileName
var vExportSpec as String = "pgmExportFullOrderAndLines"	//Use same Export Spec for all nine exports (177 fields)
var vImportSpec as String

If OrderType = "Rental Invoice" then {
		vDest = "Rental Invoice"
		vImportSpec = "pgmImportRentalInvoiceAndLines" 	// 177 fields
		}

// Set  8 Global Variables to copy from Exported record to use in Imported record.
	GlobalValue("gsImportSpec",vImportSpec)		// Name of import spec to be used in Add Mode
	GlobalValue("gsFullName",vFullName)		// Name of exported file to be imported in Add Mode
	// Six others here

vRun = @LoadExportSpec(vExportSpec)
If vRun = 1 Then {
	RunExportSpec(vFullName,"|","",0,0,0,0,0,0,0,0)  		// NO Hdr, NO Pipe

	// Set CopyForm Mode, Save Form, Go to Add Mode to import and update fields.
	GlobalValue("gsCopyForm",1)				// Set flag that CopyForm process is active.
	FormCommit("")
	vMenu = @SelectTreeItem("dudgeon!Forms!add data!ORDERS!ORDERS")
	}

//============== END OF CODE ===============================
 



Here is the code On Form Entry that only runs in Add Mode if a flag is set from the export process:
Code
Select All
//=============== ON FORM ENTRY CODE ===============

var vRun as Int					// Validator state
var vImportSpec as String 			// Name of import spec to use
var vFullName as String 			// Name of file to import


// IMPORT COPIED RECORD HERE
IF @Mode() = 0 Then {						// Only do in Add Mode
	If @GlobalValue("gsCopyForm") = 1 Then {		// Only do if CopyForm flag is set
		FormCommit("")					// Save this record before import
		// Perform Import Process
		vFullName = @GlobalValue("gsFullName")
		If FileExists(vFullName) Then {
			vImportSpec = @GlobalValue("gsImportSpec")
			vRun = @LoadImportSpec(vImportSpec)
			If vRun = 1 Then {
				RunImportSpec(vImportSpec)
				} Else { @Msg("Could not find the Export file named " + vFullName)
				}
			// End of Import Process

			FormCommit("")				// Save record with imports

			GlobalValue("gsCopyForm",0)
			// Clear 7 other GlobalValues here

			// UPDATE OTHER FIELDS AS NEEDED USING SOME GLOBAL VARIABLES FROM EXPORTED RECORD
			// UPDATE LINE ITEMS IN COPIED ORDER WITH NEW VALUES FROM THIS ORDER
			}			// END OF FILE EXISTS
		}			// END OF COPYFORM MODE
	}			// END OF ADD MODE


// ================== END OF CODE ====================== 


I have stripped out a lot of other code to just show the relevant parts.  Hopefully I got all my {braces} correct.

The user is on a server-client connection, but the exports are temp only and go to local system.  My testing is on a stand alone, not client-server.  The export/import specs change depending on the type of source records.  Exporting forms like orders with subform line items. After making a new record copy, I then modify key fields like Order Number, dates, contacts, etc. (I have excluded most of that code).
  

Rental_Invoice_34970_171108_1948.txt ( 12 KB | 54 Downloads )



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Errors reported with import file
Reply #3 - Nov 9th, 2017 at 4:26pm
Print Post Print Post  
Unless I am mistaken
Code
Select All
RunImportSpec(vImportSpec) 


should be
Code
Select All
RunImportSpec(vFullName) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Errors reported with import file
Reply #4 - Nov 9th, 2017 at 4:47pm
Print Post Print Post  
Ray the GOAT !

That's it Ray.  Again, you made it look so simple.

Thanks, will meet today's deadline.




For those who don't understand, we Patriots fans know Tom Brady as the GOAT (Greatest Of All Time)
« Last Edit: Nov 10th, 2017 at 2:50am by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged