Hot Topic (More than 10 Replies) record locked/can't post technique question (Read 1814 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
record locked/can't post technique question
May 24th, 2012 at 9:12pm
Print Post Print Post  
I have a high transaction inventory-based business that involves lots of purchase orders and sales orders (yea!) of lots of item numbers.  My costs on individual items change frequently, and client prices on those items are Sesame-calced and updated whenever the cost of an item changes (as told to Sesame by the cost recorded in the purchase order when the item is ordered from our vendor).

I have many instances in which a transaction entry (a quote, a purchase order, a sales order) results in Sesame wanting to post some results of the transaction entry back to one of the contributing databases (a client record, an inventory record, a vendor record, etc).  An example of my layman's technique for dealing with a situation in which an inventory record cannot be updated with the 'quantites' from a purchase order because the purchase order was being placed/posted while the inventor record was 'locked' by another user:

                            If @XResultSetLocked(vRS1) = 0
                                {
                                       XResultSetValue(vRS1, "QtyOnOrder", @TN(vQtyOnOrder))
                                XResultSetValue(vRS1, "QtyAvailToSell", @TN(vQtyAvailToSell))
                              }
                             else If @XResultSetLocked(vRS1) = 1
                                    {
                                   vEmail = @sendmail("smtp2go.com","Item Record Qty fields Not Updated ALERT!","MyServer@gmail.com","Myemail@gmail.com","","","QtyOnOrder (" + vQtyOnOrder + ") and QtyAvailToSell (" + vQtyAvailToSell + ") amounts were not posted in ItemNum " + vItemNum + "on PONum " + vPONum + " due to locked Inventory record.  Please notify Sesame mgr to post manually.","","")
                                    }


So, my solution is to notify via email myself if a posting didn't execute, and then I can go into that target record and record the updates myself.  Effective, but cludgy - and not acceptable if the frequency grew beyond once in a blue moon.  So my question is this:  what is a better technique for accomodating a situation where the posting of an item to a different database is 'timing critical' but cannot happen because the target record is open by another user?

Or is my query akin to an algebra student wandering into a quantum physics class, raising his hand, and asking "what's up with the Universe?"
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: record locked/can't post technique question
Reply #1 - May 24th, 2012 at 9:42pm
Print Post Print Post  
perhaps the question I should be asking first is "does Sesame (I don't think so) or will Sesame3 have finer 'field locking' capabilities ?

What confused me was:  I have played around with a testing copy of my app, where I have commented out @XResultSetLocked;  I have an inventory record form open on my screen, and then I additionally open a PO and 'place/post' that inventory item number line item in the Purchase order screen.  Then I close the still open Inventory item form/screen.  Then if I go back into that inventory record, the cost has, in fact, been updated (XResultSetValue posted the new cost data to the underlying inventory database fields).   

But if instead of me having both the inventory screen and the purchase order screen open on my computer, a different user/workstation has the inventory record open on their screen, and I duplicate the test by creating a purchase order on my workstation and 'place/post' the inventory item, in that instance XResultSetValue does NOT post the data to the Inventory underlying database fields.

  

Larry
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: record locked/can't post technique question
Reply #2 - May 25th, 2012 at 6:20am
Print Post Print Post  
You say costs change frequently, but do they change greatly? If not, it might be better to switch to an accounting method with unit cost and price based on an average over time.  Among other things, that would offer more price stability to your customers. Unit cost of the specific units sold wouldn't fluctuate so much, so timing of updates wouldn't be critical.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: record locked/can't post technique question
Reply #3 - May 25th, 2012 at 3:00pm
Print Post Print Post  
Hi Rick,

We only keep about a week's worth of inventory (50 turns a years), and might sell 50 different distinct item numbers a day to 50 different customers.  So we're basically purchasing each day what we're selling each day (toner, paper).  Each product item num will have a price record for multiple clients (some item nums we might have 100 clients buying, and some item nums might have 2 or 3).  If a specific item has 50 customers buying it, there will be 50 price records (the price record is identified by a combo of the client id and the product item num) and each price record might be a different price (based upon customer factors like size, qty purchased, timeliness of payment, etc).  Example:  an item costs us $60, and prices for that item might range from $68 to $100.  If we're only selling 3 or 4 of that item a week, I'm only going to stock 4 or 5 of them a week.  So we're quite sensitive to cost changes on that item.  If in the course of a year my cost goes up incrementally from $60 to $73, then the quicker I can adjust our price records for that item, the better I can maintain/increase my profit on that item num.   And that's just one item - we face that scenario dozens of times a day.

So before Sesame (we were using Q&A) when we placed the PO to replenish a few days' quantity of that item, and the cost changed from $60 to $63, then we had to manually go into the Q&A price records and figure new pricing for those 50 different customers - based upon each customer's unique margin for that product.  Multiple that problem by a couple dozen each day.   Very tedious.  You may perhaps guess that in many many instances those price records were not being changed/updated to reflect the new cost reality, and you'd be correct.  So a year and a half later, my cost might be $69 instead of $60, but many of those price records have not be changed upwards, and thus the ever increasing downward pressure on margins.

But with Sesame, that cost increase on a PO triggers automatically an immediate update of all price records for that item num, calculated upon each price record's unique margin.  No human has to 'keep track of cost changes and then edit price records', so I get the instant price changes I need, and it doesn't cost me expensive human labor that I can't afford.  In the 2.5 years since I built this application suite (on Sesame - yea!) of Sales Order, Invoicing, Purchase Order, Quote, PricingRecords, Client, Vendor, Delivery/Shipping Logistics, Sales Analysis, we have increased our margins 7.5 full points, which is huge, and is the reason in this lousy economy why we haven't had to lay anyone off.  And Sesame has reduced our data entry keystrokes by 60% at the same time.

So, to answer your question, the costs rarely change greatly, but they change frequently, and there are so many products that the collective impact of not adapting a sale to that individual instance of a, say, 4% increase in cost is, over time, a big deal.   As to the customer mindset, if they order a particular item 8 times in a year, the price might be different by a little bit 5 of those times.  But if they're ordering 25 different products from us in that year, some percentage of those items will have a decreasing cost (and therefore a decreasing price), so it's a constant flux of prices going up and down (like the stock market).  the changes upward are usually small, and Sesame always points out to the customer when a price has gone down from 3 months ago, so the customers are happy to know that Sesame is reflecting the cost trends of the industry both up and down.

In my experience, traditional accounting systems work fine in models where you buy a 6 week supply of something, sell it off, then buy another 6 week supply of something, then sell it off, and you know for those 6 weeks what your cost is on that item.  But we're only carrying a few days (or on some items, one sale's worth of inventory; or on some items we're not carrying ANY inventory, but only ordering the product when we've got a sale for it) and we generate invoices automatically every day from the previous day's sales orders (yea!), which increases our cash flow by about 3 days worth (yea!), and accounting systems that must wait for vendor invoices, and completed delivery tickets to be turned into invoices, for the accounting system to calculate/communicate profitability are too slow afoot.

Couldn't think of how to make that a shorter explanation - apologies!   But the short of it is - Sesame has allowed us to dig holes using a backhoe instead of a shovel, so we can dig, with no increase in personnel, more holes per day that are bigger and deeper.

I'm just interested in programming technique that would allow the 'can't execute this event at this time' to be accomplished, later, programmatically instead of manually (the phrase that is in my head - though not exactly on point - is 'rollback transaction', or 'third normal'). 
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: record locked/can't post technique question
Reply #4 - May 25th, 2012 at 3:05pm
Print Post Print Post  
My apologies for the VOLUME of words in my response to Rick.  I considered sending him a pm, but I thought it might be encouraging to some new Sesame users on here, to see how big an impact this wonderful tool can have on their business or organization.  And it's an opportunity for me to say thank you thank you thank you to the designers/Lanticans for providing us with such a wonderful enabling tool, and the great responsive customer service and technical help that they provide on this forum.  I suspect that you don't fully realize what a tremendous help you have been to a lot of people - a lot of companies and the various employees that are dependent on those companies for their livelihood.  Kudos to you all.
  

Larry
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: record locked/can't post technique question
Reply #5 - May 25th, 2012 at 3:48pm
Print Post Print Post  
Can the price updates wait one day? Maybe you shouldn't be posting changes live, but at the end of the day, after everyone else is out of Sesame.

Or, maybe you shouldn't email yourself the ItemNumber of the locked records; but instead, store those ItemNumbers in a specially purposed database (or Global Value, Text file, etc). Then, you could run through them as a batch at a later time. Again, checking for locked records, and keeping failed updates in this list for another attempt the next time you run this batch update.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: record locked/can't post technique question
Reply #6 - May 25th, 2012 at 4:01pm
Print Post Print Post  
Instead of sending yourself an email when a transaction can't complete, you might try writing a log file to a central location, or creating a record in a PendingTRX database that contains all the info you need to compete the transaction. You can then trigger a routine on application open (or button click or record save or whatever is the right level of aggression for your application) which checks for pending transactions and attempt to complete them. Successful attempts are removed from the list. Unsuccessful attempts are left in place to be tried again on the next trigger. 

[ninja'd by Carl!]
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: record locked/can't post technique question
Reply #7 - May 25th, 2012 at 4:35pm
Print Post Print Post  
Oh, that's some good food for thought - thank you.  I'll think through how we're doing stuff and what the ramifications/tradeoffs might be (time spent to redesign/re-code versus benefits anticipated).   The 'thwarted because of a locked record' is a rare occurrence, I think (I actually just recently included the 'email myself a note when a lockout occurs). 

The '55 year old business owner with lots of hats to wear' part of me thinks that for the infrequency of the occurrence, the extra programming/brain drain might not be worth the gain.     BUT, the anal-retentive (is there supposed to be a hyphen in there?) part of me lusts to program it the right way - 'the way Hammer would do it!'

"Can the price updates wait one day?"
         Well, we place most of our PO's around 4pm (though there are exceptions).  In the instances where there is a cost change, one of the things that Sesame will do is search through all sales orders created previously that day (and since 4pm the day before) to find any instances of that item number being sold.  Sesame will then calculate what the new price for that customer should be, based upon the new cost, and then email one of us that info so we can intercept and edit that printed sales order and reprint it before we deliver the product (some goodly portion of our orders that are created in the afternoon will be delivered the following day, and many times in the a.m.).  This ends up gaining us an extra few hundred$$ a month in realized profit.  If we wait a day to update pricing, some of those orders might already be delivered, and the lower pricing on that order cemented.   And several other clients might order that product after the purchase order is executed, meaning that their pricing (if the updates wait a day) won't be updated to reflect the new cost reality.  After so many years of manual updating drudgery and tardiness and missed revenues, I really love the 'live update' feature - it's a Marlboro moment for me everything I think about it (although I'm not a smoker, it is an image that communicates, eh?).

Generating a batch or a database that would accumulate these 'lockout instances' and then run them through when Sesame was idle .... that's certainly a good idea to consider.  I'm a little boggled thinking about the complexity (or at least the richness/depth of data required to be captured) in order to recreate the foiled part of the transaction posting.   But that's certainly something for me to percolate on, while I'm watching over the next few whenevers (days, weeks, months) to get a feel for how often these foiled attempts are actually happening.
  

Larry
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: record locked/can't post technique question
Reply #8 - May 25th, 2012 at 5:08pm
Print Post Print Post  
lksseven wrote on May 25th, 2012 at 4:35pm:
part of me lusts to program it the right way - 'the way Hammer would do it!'


Hammer would say, "Meh, it only happens once a month or so. Not worth the amount of programming time it would take to implement a full catch/retry system."
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: record locked/can't post technique question
Reply #9 - May 25th, 2012 at 6:03pm
Print Post Print Post  
I don't see a problem with the length of the reply.  A 5% change in cost over a fairly short period ($60 => 63) is certainly a legitimate reason to not use "average".

I just wanted to point out that sometimes a programming approach is most appropriate and sometimes a change in business process is better.  In many businesses our thought processes become so compartmentalized that we only think in terms of "how can I get the technology to do what this person is asking?" when it might be more effective to change the process--which might require getting some other department involved.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: record locked/can't post technique question
Reply #10 - May 25th, 2012 at 6:44pm
Print Post Print Post  
Rick,

You are so right.  Surgeons usually see 'cutting' as the answer, etc.  It's always prudent advice to step back and evaluate/assess from a wider and more open minded viewpoint.   Thank you!

Hammer,

If the frequency is rare, of course you're right.  It'll be interesting to get a 'read' on that frequency over the near term future.
       Of course, 'not economically justifiable' hasn't always been persuasive to a 'thick head like me'. 

  

Larry
Back to top
IP Logged