LE Scripts

 

Home
Up

 

declarations instance variables for w_getpsx12
integer Attempts, F, P, L, FieldCount, EditErrors, psX12File 
string Fields[100], CleanFields[100], psX12Line, AChar, Delimiter = "*", EditMessage
string CrLf = char(13) + char(10)
string SubjectLine, NoteText, psX12FileName, psX12FileNames[100], CleanpsX12FileNames[100]
string EmailEnterpriseId, EnterpriseId, EnterpriseName, EmailDate, EmailTime, EmailAddress
long InBoxCount, InBoxLoc, psX12Loc[1000], psX12Count, RecLength

 

Open for w_getpsx12
st_helper.Text = "Checking for 1st email..."
TriggerEvent(Timer!)
st_helper.Text = "Waiting for 2nd email check after " + string(Now(),"hh:mm:ss") + "..."
timer(180)

 

Timer for w_getpsx12
//Declare local variables & objects
boolean TransactionOK
mailSession MS
mailMessage Msg
mailRecipient Recipient
Attempts += 1
//Setup for a new mail check
EditErrors = 0
psX12Count = 0
EditMessage = ""
psX12FileNames = CleanpsX12FileNames
InBoxCount = 0
InBoxLoc = 0
//Create MS as mailsession
MS = create mailsession
//Download mail to MS or display error message
st_helper.Text = "Logging on to the mail session now..."
if MS.mailLogon(MailDownload!) <> mailReturnSuccess! then
	lb_psx12inbound.AddItem("Error downloading into mail session at " + string(Now(),"hh:mm:ss"))
	return
end if
//Get messages, display error message if getmessages fails
st_helper.Text = "Checking for email..."
if MS.mailGetMessages() <> mailReturnSuccess! then
	lb_psx12inbound.AddItem("There was an error retrieving mail at " + string(Now(),"hh:mm:ss"))
	st_helper.Text = "Attempt " + string(Attempts) + " got an error."
	goto MSLogoff
end if
//Display error message if there is no email at all
InBoxCount = UpperBound(MS.MessageID[])
if InBoxCount = 0 then
	st_helper.Text = "There were no emails waiting at all..."
	goto MSLogoff
end if
	
//Check InBox for psX12-formatted email
st_helper.Text = "Checking for psX12s in the InBox now..."
for InBoxLoc = 1 to InBoxCount
	MS.mailReadMessage(MS.MessageID[InBoxLoc], Msg, mailSuppressAttachments!, FALSE)
	SubjectLine = Msg.Subject
	if left(SubjectLine,4) = "*!*!" and Msg.UnRead then 
		psX12Count += 1
		psX12Loc[psX12Count] = InBoxLoc
		lb_psx12inbound.AddItem(string(psX12Count,"000") + " " + SubjectLine)
	end if
next
//If there are not any psX12 transactions just return now
if psX12Count = 0 then
	st_helper.Text = "No psX12s at attempt " + string(Attempts) + ", " + string(Now(),"hh:mm:ss") + ", waiting for next timer click..."
	goto MSLogoff
end if
//Display how many there are
st_helper.Text = "Checking " + string(psX12Count) + " psX12 transacation(s) now..."	
lb_psx12inbound.AddItem(string(psX12Count,"000") + " psX12s received at " + string(Now(),"hh:mm:ss") + "...")
	
//Connect to the database & halt if can't be done
CONNECT USING SQLCA;
if SQLCA.SQLCODE <> 0 AND SQLCA.SQLCODE <> -1 then
	messagebox("Database CONNECT failed","SQLCA.SQLCODE is " + string(SQLCA.SQLCODE))
	halt
end if
		
//write psX12s to file
for InBoxCount = 1 to psX12Count
	//Get Msg from the InBox into SubjectLine and NoteText
	MS.mailReadMessage(MS.MessageID[psX12Loc[InBoxCount]], Msg, mailSuppressAttachments!, FALSE)
	SubjectLine = Msg.Subject
	NoteText = Msg.NoteText
	//Format filename and open file for saving it
	psX12FileName = "D:\!465SU00\!InBoundX12\" + string(Today(),"yyyymmdd") + string(Now(),"hhmmss") + string(InBoxCount,"000") + ".txt"
	psX12File = FileOpen(psX12FileName, StreamMode!, Write!, LockWrite!, Replace!)
	//If there is an error opening display the error message
	if psX12File = -1 then
		lb_psx12inbound.AddItem("  " + "Couldn't open ->" + psX12FileName + " for " + SubjectLine)
		psX12FileNames[InBoxCount] = ""
	else
		//Write out SubjectLine and NoteText
		FileWrite(psX12File,SubjectLine + CrLf + NoteText)
		FileClose(psX12File)
		psX12FileNames[InBoxCount] = psX12FileName
		MS.mailReadMessage(MS.MessageID[psX12Loc[InBoxCount]], Msg, mailSuppressAttachments!, TRUE)
	end if
next
//Open each file, edit, and handle the transaction
for InBoxCount = 1 to psX12Count
	//Read each psX12FileNames, edit for valid enterprise id & email address on file, handle valid transactions
	if psX12FileNames[InBoxCount] <> "" then
		psX12FileName = psX12FileNames[InBoxCount] 
		psX12File = FileOpen(psX12FileName)
		if psX12File = -1 then
			messagebox("File Open Error","File Open returned " + string(psX12File) + " Trying to open >" + psX12FileNames[InBoxCount] + "<")
			halt
		end if
		fileread(psX12File,psX12Line)
		EmailEnterpriseId = mid(psX12Line,5,4)
		SELECT "id", "name", "email"
		INTO :EnterpriseId, :EnterpriseName, :EmailAddress
		FROM "enterprise"
		WHERE "id" = :EmailEnterpriseId;
		if SQLCA.SQLCode <> 0 then EnterpriseId = ""
		if EnterpriseId = "" then
			//Display invalid enterprise id message
			lb_psx12inbound.AddItem(string(InBoxCount,"000") + " **" + EmailEnterpriseId + " is not a valid id ")
		else
			//Check for email address & continue edit if there is one
			if isnull(EmailAddress) or EmailAddress = "" then
				lb_psx12inbound.AddItem(string(InBoxCount,"000") + " **No email address on file")
			else
				lb_psx12inbound.AddItem(string(InBoxCount,"000") + " Email back to " + EmailAddress + string(InBoxCount))
				EmailDate = mid(psX12Line,10,8)
				EmailTime = mid(psX12Line,18,6)
				EditErrors = 0
				if isnull(EnterpriseName) or EnterpriseName = "" then EnterpriseName = "Not Named Yet!!!"
				EditMessage = "Received from Enterprise #" + EnterpriseId + " " + EnterpriseName + CrLf
				EditMessage += "Dated " + EmailDate + " Time " + EmailTime + CrLf + CrLf
				fileread(psX12File,psX12Line)
				EditMessage += psX12Line + CrLf
				FieldCount = ParseLine(psX12Line)
				if FieldCount < 2 or FieldCount > 3 then
					EditErrors += 1
					EditMessage += "!!! " + string(FieldCount) + " fields where 2 or 3 were expected " + CrLf
				end if
				if EditErrors = 0 then
					choose case Fields[1]
						case "JV"
							//handle JV
							TransactionOK = handleJV(psX12File)
						case "CAT"
							//handle CAT
							TransactionOK = handlecat(psX12File)
						case "REQUEST"
							//hande REQUEST
							if Fields[2] <> "CAT" then
								EditErrors += 1
								EditMessage += "!!! REQUEST did not specify CAT "
							else
								TransactionOK = handlerequest(psX12File)
							end if
						case else
							EditMessage += "!!! JV, CAT, or REQUEST expected in first field " + CrLf
					end choose
				end if
				if EditErrors <> 0 then
					EditMessage += "!!! This psX12 transaction was not processed               " + CrLf
					EditMessage += "!!! " + string(EditErrors) + " edit error(s) were counted  " + CrLf
				end if
							
				//Send Email
				Recipient.Name = EmailAddress
				Msg.Recipient[1] = Recipient
				Msg.Subject = "!*!*Response from Ledger Engine"
				Msg.NoteText = EditMessage
				MS.mailSend(Msg)
				
			end if
		end if
		fileclose(psX12File)
	end if
next
lb_psx12inbound.AddItem("Done with this batch.")
MSLogoff:
MS.mailLogoff()
destroy MS
st_helper.Text = string(psX12Count) + " items at attempt " + string(Attempts) + ", "+ string(Now(),"hh:mm:ss") + ".  Waiting to check again..."
	

 

 

w_getpsx12 Function parseline

Fields = CleanFields
F = 1
P = 1
L = len(aline)
for P = 1 to L
	AChar = mid(aline,P,1)
	if AChar = Delimiter then
		F += 1
	else
		Fields[F] += AChar
	end if
next
return (F)

 

w_getpsx12 Function handlecat
//Declare local variables
string Descr, Price, AString
date Dated
time Timed
integer GSId, LineCounter, IdHash, PriceEdit
boolean Deleted
//Finish edit on first line, go no farther if there are any
if Fields[2] <> EnterpriseId then
	EditErrors += 1
	EditMessage += "!!! Enterprise id on first line is not the same as in subject line of email " + CrLf
end if
if len(Fields[3]) <> 14 then
	EditErrors += 1
	EditMessage += "!!! DateTime on the first line must be 14 characters long " + CrLf
else
	Dated = date(left(Fields[3],4) + "-" + mid(Fields[3],5,2) + "-" + mid(Fields[3],7,2))
	Timed = time(mid(Fields[3],9,2) + ":" + mid(Fields[3],11,2) + "-" + right(Fields[3],2))
end if
if EditErrors <> 0 then return false
LineCounter = 1
//Check that next line has 4 fields and 1st is ITEM
RecLength = fileread(filehandle, psX12Line)
if RecLength <= 0 then
	EditMessage += "!!! Zero length record or EOF encountered before ECAT "
	EditErrors += 1
	return false
end if
EditMessage += psX12Line + CrLf
FieldCount = ParseLine(psX12Line)
if Fields[1] <> "ITEM" then
	EditErrors += 1
	EditMessage += "!!! " + Fields[1] + " was found where ITEM was expected " + CrLf
	return false
end if
//Process ITEM lines until a line is encountered that is not ITEM
do
	if FieldCount < 3 or FieldCount > 4 then
		EditErrors += 1
		EditMessage += "!!! " + string(FieldCount) + " field(s) on ITEM where 3 or 4 are expected " + CrLf
		return false
	end if
	GSId = integer(Fields[2])
	if GSId = 0 then
		EditErrors += 1
		EditMessage += "!!! " + Fields[2] + " was found where a goods & services Id was expected " + CrLf
	else
		IdHash += GSId
	end if
	if Fields[3] = "" then
		EditErrors += 1
		EditMessage += "!!! There was nothing in the third field where Description was expected !!! " + CrLf
	else
		if Fields[3] = "DELETE" then
			SELECT "descr"
			INTO :AString
			FROM  "catalog"
			WHERE "enterpriseid" = :EnterpriseId AND "gsid" = :GSId;
			if SQLCA.SQLCode = 0 then
				//Delete it
				DELETE FROM "catalog"
				WHERE "enterpriseid" = :EnterpriseId AND "gsid" = :GSId;
				Deleted = true
			else
				//Complain about it
				EditErrors += 1
				EditMessage += "!!! Requested DELETE of item " + string(GSId) + " not in catalog " + CrLf
			end if
		else
			Descr = Fields[3]
		end if
	end if
	//Continue on with edit if not DELETE
	if not Deleted then
		PriceEdit = integer(Fields[4])
		if PriceEdit = 0 then
			EditErrors += 1
			EditMessage += "!!! Price of zero, or no price was found in the fourth field !!! " + CrLf
		else
			Price = Fields[4]
		end if
		if EditErrors = 0 then
			//See if this item is already in the catalog
 			SELECT "descr"
			INTO :AString
			FROM  "catalog"
			WHERE "enterpriseid" = :EnterpriseId AND "gsid" = :GSId;
			if SQLCA.SQLCode = 0 then
				//Update existing entry
				UPDATE "catalog"
				SET
					"descr" = :Descr,
					"price" = :Price,
					"lastupdate" = :Dated,
					"lastuptime" = :Timed
				WHERE "enterpriseid" = :EnterpriseId AND "gsid" = :GSId;
			else		
				//Put new item into the database
				INSERT "catalog"
					("enterpriseid", "gsid", "descr", "price", "lastupdate", "lastuptime")
				VALUES
					(:EnterpriseId, :GSId, :Descr, :Price, :Dated, :Timed);
				//If there was an SQL error count it as an edit error
				if SQLCA.SQLCode <> 0 then
					EditErrors += 1
					EditMessage += "!!! Updating database got SQLError '" + SQLCA.SQLErrText
					goto Done
				end if
			end if
		end if
	end if
	
	//Read the next record
	RecLength = fileread(filehandle, psX12Line)
	if RecLength <= 0 then
		EditMessage += "!!! Zero length line or EOF encountered before ECAT "
		goto Done
	end if
	EditMessage += psX12Line + CrLf
	FieldCount = ParseLine(psX12Line)
	LineCounter += 1
loop until Fields[1] <> "ITEM"
//Line after ITEMs must be ECAT
if Fields[1] <> "ECAT" then
	EditErrors += 1
	EditMessage += "!!! " + Fields[1] + " was found where ECAT was expected " + CrLf
//	return false
	goto Done
end if
LineCounter += 1
//Check LineCounter and ID Hash
if integer(Fields[2]) <> LineCounter then
	EditErrors += 1
	EditMessage += "!!! A line count of '" + Fields[2] + "' was found where " + string(LineCounter) + " lines were counted " + CrLf
end if
if integer(Fields[3]) <> IdHash then
	EditErrors += 1
	EditMessage += "!!! A GSId hash of '" + Fields[3] + "' was found where " + string(IdHash) + " was expected " + CrLf
end if
Done:
if EditErrors = 0 then
	COMMIT USING SQLCA;
	return true
else
	ROLLBACK USING SQLCA;
	return false
end if
ws_getpsx12 Function handlejv
//Declare local variables
string AString, NewText, LDetTexts[50], LedgerText
date Dated, ADate
integer LDetId, JournalLDetID, LedgerLDetId, LineCounter, EntCounter, PriceEdit
integer LDetIds[50], LDetCount, LDetP, EditErrorsBeforeENT
real Amount, Amounts[50], Net, LedgerNet
long FillLength
boolean AlreadyThere
//Finish edit on first line, go no farther if there are any
if Fields[2] <> EnterpriseId then
	EditErrors += 1
	EditMessage += "!!! Enterprise id on first line is not the same as in subject line of email " + CrLf
end if
if len(Fields[3]) <> 8 and not isnumber(Fields[3]) then
	EditErrors += 1
	EditMessage += "!!! Date on the JV line must be a number 8 digits long " + CrLf
else
	Dated = date(left(Fields[3],4) + "-" + mid(Fields[3],5,2) + "-" + mid(Fields[3],7,2))
end if
if EditErrors <> 0 then return false
LineCounter = 1
//Check that next line has 3 or 4 fields and 1st is ENT
RecLength = fileread(filehandle, psX12Line)
if RecLength <= 0 then
	EditMessage += "!!! Zero length record or EOF encountered before ECAT "
	EditErrors += 1
	return false
end if
EditMessage += psX12Line + CrLf
FieldCount = ParseLine(psX12Line)
if Fields[1] <> "ENT" then
	EditErrors += 1
	EditMessage += "!!! " + Fields[1] + " was found where ITEM was expected " + CrLf
	return false
end if
//Process ENT lines until a line is encountered that is not ENT
do
	EditErrorsBeforeENT = EditErrors
	if FieldCount < 3 or FieldCount > 4 then
		EditErrors += 1
		EditMessage += "!!! " + string(FieldCount) + " field(s) on ENT where 3 or 4 are expected " + CrLf
		return false
	end if
	LDetId = integer(Fields[2])
	if LDetId = 0 then
		EditErrors += 1
		EditMessage += "!!! " + Fields[2] + " was found where a Ledger Id was expected " + CrLf
	end if
	if Fields[3] = "" then
		EditErrors += 1
		EditMessage += "!!! There was nothing in the third field where an amount was expected  " + CrLf
	else
		if not isnumber(Fields[3]) then
			EditErrors += 1
			EditMessage += "!!! The third field was '" + Fields[3] + "' where a number was expected  " + CrLf
		else
			Amount = real(Fields[3])
			Amount = Amount/100
		end if
	end if
	if not(isnull(Fields[4]) or Fields[4] = "") then
		NewText = Fields[4]
	else
		NewText = ""
	end if
	If EditErrorsBeforeENT = EditErrors then
		//Continue edit on this line
		if LDetCount = 0 then
			LDetCount = 1
			LDetIds[LDetCount] = LDetId
			Amounts[LDetCount] = Amount
			LDetTexts[LDetCount] = NewText
		else
			for LDetP = 1 to LDetCount
				AlreadyThere = LDetIds[LDetP] = LDetId
			next
			if AlreadyThere then
				EditErrors ++
				EditMessage += "!!! This ENT has an LDetId the same as a previous line " + CrLf
			else
				LDetCount ++
				LDetIds[LDetCount] = LDetId
				Amounts[LDetCount] = Amount
				LDetTexts[LDetCount] = NewText
			end if
		end if
	end if
	//Read the next record
	RecLength = fileread(filehandle, psX12Line)
	if RecLength <= 0 then
		EditMessage += "!!! Zero length line or EOF encountered before ECAT "
		goto Done
	end if
	EditMessage += psX12Line + CrLf
	FieldCount = ParseLine(psX12Line)
	LineCounter += 1
loop until Fields[1] <> "ENT"
//Line after ITEMs must be EJV
if Fields[1] <> "EJV" then
	EditErrors += 1
	EditMessage += "!!! " + Fields[1] + " was found where EJV was expected " + CrLf
//	return false
	goto Done
end if
LineCounter += 1
//Check LineCounter and ID Hash
if integer(Fields[2]) <> LineCounter then
	EditErrors += 1
	EditMessage += "!!! A JV line count of '" + Fields[2] + "' was found where " + string(LineCounter) + " lines were counted " + CrLf
end if
//Does it net zero?
Net = 0
for LDetP = 1 to LDetCount
	Net += Amounts[LDetP]
next
if Net <> 0 then
	EditErrors += 1
	EditMessage += "!!! This JV Nets " + string(Net/100,"#0.00;(#0.00)") + " and should Net zero " + CrLf
end if
if EditErrors > 0 then goto Done
DECLARE ExistingJournal CURSOR FOR
  SELECT "journal"."enterpriseid",   
         "journal"."adate",   
         "journal"."ldetid",   
         "journal"."net"  
    FROM "journal"  
   WHERE ( "journal"."enterpriseid" = :EnterpriseId ) AND  
         ( "journal"."adate" = :Dated )
ORDER BY "journal"."ldetid" ASC;   
//Is this date already in the Journal?
OPEN ExistingJournal;
FETCH ExistingJournal INTO :AString, :ADate, :JournalLDetId, :Net;
if SQLCA.SQLCode = 0 then
	//Get existing journal amounts out of Ledger
	do while SQLCA.SQLCode = 0
		SELECT "enterprise", "ldetid", "text", "net"
		INTO :AString, :LedgerLDetID, :LedgerText, :LedgerNet
		FROM "ledger"
		WHERE ("enterprise" = :EnterpriseId) AND ("ldetid" = :JournalLDetId);
		if SQLCA.SQLCode = 0 then
			//Back out this day's amount
			LedgerNet -= Net
			UPDATE "ledger"
			SET "net" = :LedgerNet
			WHERE ("enterprise" = :EnterpriseId) AND ("ldetid" = :JournalLDetId);	
		else
			EditErrors += 1
			EditMessage += "!!! Please advise Saunders that your Ledger is corrupt" + CrLf
			goto Done
		end if
		FETCH ExistingJournal INTO :AString, :ADate, :JournalLDetId, :Net;
	loop
	DELETE FROM "journal" WHERE ("enterpriseid" = :EnterpriseId) AND ("adate" = :Dated);
	EditMessage += "Previous Journal for this date has been backed out of the Ledger" + CrLf
end if
for LDetP = 1 to LDetCount
	//Put new entries into the journal
	INSERT "journal"
		("enterpriseid", "ldetid", "adate", "net")
	VALUES
		(:EnterpriseId, :LDetIds[LDetP], :Dated, :Amounts[LDetP]);
	//Accumlate in Ledger
	SELECT "enterprise", "ldetid", "text", "net"
	INTO :AString, :LedgerLDetID, :LedgerText, :LedgerNet
	FROM "ledger"
	WHERE ("enterprise" = :EnterpriseId) AND ("ldetid" = :LDetIds[LDetP]);
	if SQLCA.SQLCode = 0 then
		//It's already there, accumlate into it
		LedgerNet += Amounts[LDetP]
		UPDATE "ledger"
		SET "net" = :LedgerNet
		WHERE ("enterprise" = :EnterpriseId) AND ("ldetid" = :LDetIds[LDetP]);
	else
		//Setup New ledger account for this enterprise, expecting text
		if LDetTexts[LDetP] = "" then
			SELECT "text" INTO :LedgerText FROM "ledger_details" WHERE "ldetid" = :LDetIds[LDetP];
			if SQLCA.SQLCode <> 0 then
				EditErrors += 1
				EditMessage = "!!! New Ledger Detail Code '" + string(LDetIds[LDetP]) + "' has no text" + CrLf
				goto Done
			end if
		else
			LedgerText = LDetTexts[LDetP]
		end if
		INSERT "ledger"
			("enterprise", "ldetid", "text", "net")
		VALUES
			(:EnterpriseId, :LDetIds[LDetP], :LedgerText, :Amounts[LDetP]);
	end if
		
	//If there was an SQL error count it as an edit error
	if SQLCA.SQLCode <> 0 then
		EditErrors += 1
		EditMessage += "!!! Please advise Saunders that updating database got SQLError '" + SQLCA.SQLErrText + CrLf
		goto Done
	end if
next	
Done:
CLOSE ExistingJournal;
if EditErrors = 0 then
//Send Trial Balance as of this entry	
	DECLARE TrailBalance CURSOR FOR	
	SELECT "ledger"."ldetid",   
  	       "ledger"."text",   
  	       "ledger"."net"  
  	  FROM "ledger"  
  	 WHERE ("ledger"."enterprise" = :EnterpriseId)
	ORDER BY "ledger"."ldetid" ASC;   
	OPEN TrailBalance;
	FETCH TrailBalance INTO :LDetId, :LedgerText, :LedgerNet;
	if SQLCA.SQLCode <> 0 then
		EditErrors += 1
		EditMessage += "!!! Please advise Saunders that this transaction failed as Trail Balance was being prepared" + CrLf
		goto Done
	end if
	EditMessage += CrLf + "Ledger Trial Balance as of this JV Transaction:" + CrLf + CrLf
	Amount = 0
	do while SQLCA.SQLCode = 0
		Amount += LedgerNet
		LedgerText = left(LedgerText,24)
		AString = string(LedgerNet,"#0.00;(#0.00)")
		FillLength = 12 - len(AString)
    	if LedgerNet >= 0 then FillLength -= 1
   	EditMessage += string(LDetId) + "  " + LedgerText + fill(" ", 25 - len(LedgerText)) + fill(" ", FillLength) + AString + CrLf 
		FETCH TrailBalance INTO :LDetId, :LedgerText, :LedgerNet;
	loop
	EditMessage += fill(" ",31) + "------------" + CrLf
	AString = string(Amount,"#0.00;(#0.00)")
	FillLength = 12 - len(AString)
	if Amount >= 0 then FillLength -= 1
	EditMessage += fill(" ",31 + FillLength) + AString + CrLf + CrLf
	CLOSE TrailBalance;
end if
if EditErrors = 0 then
	COMMIT USING SQLCA;
	return true
else
	ROLLBACK USING SQLCA;
	return false
end if
 
w_getpsx12 Function handlerequest
//Declare local variables
string CatEnterpriseId, CatEnterpriseName, CatEmail, CatGSId, CatDescr, CatPrice, CatDateTime, CurrentEnterpriseId
integer GSId
date LastUpDate
time LastUpTime
EditMessage = ""
EditErrors = 0
CONNECT USING SQLCA;
if SQLCA.SQLCode <> 0 and SQLCA.SQLCode <> -1 then
	MessageBox("SQL Error in handlerequest", SQLCA.SQLErrText)
	halt
end if
//Define CURSOR
DECLARE CatEntries CURSOR FOR
  SELECT "catalog"."enterpriseid",   
         "enterprise"."name",   
         "enterprise"."email",   
         "catalog"."gsid",   
         "catalog"."descr",   
         "catalog"."price",   
         "catalog"."lastupdate",   
         "catalog"."lastuptime"  
    FROM "catalog",   
         "enterprise"  
   WHERE ( "enterprise"."id" = "catalog"."enterpriseid" )   
ORDER BY "enterprise"."name" ASC,   
         "catalog"."descr" ASC;   
//Handle empty CURSOR
OPEN CatEntries;
FETCH CatEntries INTO 
	:CatEnterpriseId, :CatEnterpriseName, :CatEmail, :GSId, :CatDescr, :CatPrice, :LastUpDate, :LastUpTime;
if SQLCA.SQLCode <> 0 then
	EditMessage += "There are no Catalog entries at this time"
	return true
end if
//Setup current Enterprise for control break
CurrentEnterpriseId = CatEnterpriseId
EditMessage = "EID*" + CurrentEnterpriseId + "*" + CatEnterpriseName + "*" + CatEmail + CrLf
do while SQLCA.SQLCode = 0
	if CatEnterpriseId <> CurrentEnterpriseId then
		CurrentEnterpriseId = CatEnterpriseId
		EditMessage += "EID*" + CurrentEnterpriseId + "*" + CatEnterpriseName + "*" + CatEmail + CrLf
	end if
	CatGSId = string(GSId)
	CatDateTime = string(LastUpDate,"yyyymmdd") + string(LastUpTime,"hhmmss")
	EditMessage += "CAT*" + CatEnterpriseId + "*" + CatGSId + "*" + CatDescr + "*" + CatPrice + "*" + CatDateTime + CrLf
	FETCH CatEntries INTO 
	  :CatEnterpriseId, :CatEnterpriseName, :CatEmail, :GSId, :CatDescr, :CatPrice, :LastUpDate, :LastUpTime;
loop
CLOSE CatEntries;
return true


 
Home ] Up ]
Last modified: Friday August 25, 2000.