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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

micros SIM help - void event

Status
Not open for further replies.

jd11111

Programmer
Apr 29, 2010
160
US
I am working on a sim and need to script a database update when a specific discount is voided.

The sim is currently querying the database to confirm that a number hasn't been used, posts a discount on the check and then updates the database to mark that record as used.

Now I need the sim to update the record back to unused if the discount is voided from the check. How to script this event in ISL?

 
Why is it necessary to have a used unused flag in a db. Can't you just scan the check and look for its presence and then do what you need to do. Is there data you are looking at beyond the existence of the discount?



 
It's a one-time use coupon. The sim is looking to see if the coupon has been redeemed yet. If not, it posts the discount and updates the database as redeemed. It works well, but I need to allow for voiding of that discount.

thanks
 
This event is called after a discount is voided from the guest check via either direct void or touch void. The event is executed for each configured SIM interface.

Syntax
Event dsc_void

Example:

event dsc_void
errorMessage "Discount was voided from the check."
endevent
 
I got that from the manual also - but I'm trying to figure how to catch a specific discount being voided.
 
event dsc_void



exitwitherror"",@DTL_OBJECT[@NUMDTLT]," - ",@DTL_NAME[@NUMDTLT]


endevent


//You know that the discount will be the last detail entry on the check do you can look at the number or the name of the detail entry(or any available variables for that matter) You may want to use @DTL_TYPE to be sure the line is, in deed, a discount. I can't think of an instance where it wouldn't be, but that not to say it cant happen.
 
Thanks - I have it working pretty well now.

The last problem I'm having is getting the obj_num from the micros.rest_def table. I keep getting an error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'micros.rest_def'

any thoughts?
 
actually - can you post a complete example of querying the micros database to get the field obj_num from the table micros.rest_def, returning the result and assigning the value to a variable?

Thanks again for your help!
 
I am a little confused. There is an obj_num in rest_def, but it is the store number. Is that what you want? If you are looking for a discount number you need to grab the obj_num from micros.dsvc_def.
 
yes - I need the restaurant number. The discount is working correctly (a remote database). I just need to get the restaurant number from the micros database to update the discount # with the restaurant that used it.
 
//////////////////////////////////////////////////////////////////////
var sql_cmd : A500
var sql_error : A500
var h_sql : N12 = 0
var disc_obj : n4 = 1 ///SET THIS TO THE NUMBER OF THE DISCOUNT YOU WANT TO LOOK FOR, IF YOU HAVE MULTIPLE, YOU CAN LOOP THROUGH AN ARRAY
var store_num : n4

///////////////////////////////////////////////////////////////////////////////////////
event dsc_void

if @DTL_OBJECT[@NUMDTLT-1] = disc_obj

format sql_cmd as "select obj_num from micros.rest_def"

call load_sql
call connect_sql
call sql_select (sql_cmd)

store_num=sql_cmd

exitwitherror "",store_num

endif


endevent

//////////////////////////////////////////////////////////////////////


sub load_sql

if h_sql = 0
DLLLoad h_sql, "MDSSysUtilsProxy.dll"
endif

if h_sql = 0
exitwitherror "Unable to Load MDSSysUtilsProxy.dll"
endif

endsub

//-------------------------------------------------------------------------------------//

sub connect_sql

var constatus : N9
// Connect to micros 3700 database
DLLCALL_CDECL h_sql, sqlIsConnectionOpen(ref constatus)

if constatus = 0
DLLCALL_CDECL h_sql, sqlInitConnection("micros","ODBC;UID=custom;PWD=custom", "")
endif

endsub

//-------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------//

sub sql_select( ref sql_cmd )

// intended for single selects from the db where one row is expected
// of course you could always do a sqlGetNext and keep going

var fn : N12 = 0

DLLCALL_CDECL h_sql, sqlGetRecordSet(sql_cmd)

DLLCALL_CDECL h_sql, sqlGetLastErrorString(ref sql_cmd)

if (sql_cmd <> "")
//call show_error(sql_cmd)
errormessage "SQL:",sql_cmd
//fopen fn, "c:\temp\sqlerror.txt", append
//fwrite fn, sql_cmd
//fclose fn
endif

DLLCALL_CDECL h_sql, sqlGetNext(ref sql_cmd)

endsub
 
thanks for the sample script - I already had the discount working, but I get the same error with your script as I got with my own when trying to query the ret_def table:

"[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'micros.rest_def'."

What's strange is that I KNOW this is the name of the table - I just can't figure out why I can't query it. If I do the same query in dbisql I get the result - the restaurant number.

Any thoughts on why this is happening?

Again, thanks for you help!
 
thanks - as it turns out I have a training session with Micros tomorrow so I'll bring it up with them. Hopefully I can get it resolved then.

thanks again for your help.
 
I just noticed something to. If you are doing the query during a SIM, you should get a Sybase error. You have a Microsoft error. Are you trying to do a remote query?
 
i actually just copied the script you uploaded, which is opening the micros database. In the sim I've been working on I'm connecting to a microsoft Sql database, and it works. In this script, though, it only calls the micros database. Is there a need to close a database connection before starting another one?

If so, what is the command for that?
 
I would be really curious to see the code you are using to connect to a sql database in sim, this could be very usefull for me.

Thanks in advance
Robert
 
see the script above from MikeRose

the only difference is that when loading the dll you call the sql server connection instead of micros:

DLLCALL_CDECL h_sql, sqlInitConnection("sqldbName","ODBC;UID=xxx;PWD=xxx", "")

the connection must be set up in ODBC on the server like Micros.
 
thanks.....
I have been looking for something like this for years.....
not sure what I am going to do with it yet but I can think of lots of uses......
 
I got the dll connecting to the micros database fine
I set up an ODBC that tests succesfully to my
sql server database but when I make the changes to
connect to it I get the error message ISL error line 586
format too long

it looks like it is dropping into
if (sql_cmd <> "") //call show_error(sql_cmd) errormessage "SQL:",sql_cmd //fopen fn, "c:\temp\sqlerror.txt", append //fwrite fn, sql_cmd //fclose fn endif



does anyone have a document on the dll ?

that could be really handy

Thanks in advance
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top