Hi Ernesto,
Good day to you.
I'm sorry my friend, I was busy this couple of months in preparation of our new project in the company.
But anyways, let me clarify some or few things before showing solution to your scenario.
First of all, I candidly understand your situation. You have an internal problem of double encoding and/or issuance of receipt of a particular customer's PO and you want a control of it right in SBT system. This is fine, if your internal procedure tells you to issue one receipt one PO policy. But what about for customer having several ordered item in just one PO? When this transaction is printed to posting document, sales invoice or delivery receipt to be exact, tendency is that, this is not enough to be printed in just one receipt and you need another page(another SI/DR #series) to print it all, w/c become another number series (other country are using the pre-printed sales invoice). Maybe this is why SBT is thinking in the global demand of SBT system. But in your part, perhaps you're dealing with few item in customer's PO therefore, your need is applicable.
Also, PONumber is coming from your clients, and the possibility is that it can be repeated by other customer, so we'll used the CustNo+PONum to look for if this is recorded already or not.
Below is the source code to answer your need and let us make it simple direct to point and trying to avoid the spaghetti code of SBT (sopost.prg, this is too hard to trace, unless you need). I just put a pop up message to prompt your user that the same PO is already there. Its up to them to continue, or try to rectify my code according to what you really suitable most to you.
Start here. (assume sbt engine is in q:\sbtsys\pro50)
1. Open vfp5 and enter the ff.
1.1 set path to q:\sbtsys\pro50,q:\sbtsys\pro50\so &&tells vfp to look something in the folder.
1.2 set defa to q:\sbtsys\pro50\so &&change default directory
1.3 modi form sopost &&the target form of sbt
(note i know the 3steps is fine but if you have an error try)
set classlib to q:\sbtsys\pro50\sbtlib (and other classlib if needed)
2. In the field that you mentioned above, replace the codes as you see below:
**************************code starts here Ernesto****************
LOCAL ll_return
**new code 2017.03.03
_opntbl=select() &&to save active dbf open at a moment
sele a_somast &&when seek command is executed, your record pointer will change, let us keep it to a variable so you can go back
_order=order() &&to restore current index of somaster
_gorecn=recno() &¤t record pointer
doit=.t. &&doit, a variable if to continue or not
_SoCustNo=left(allt(thisform.txtsomast_custno.value),6) &&custcode
_SoPoNumb=left(allt(this.value)+space(20),20) &&ponumber must be in overall char 20
if seek((_SoPoNumb+_SoCustNo),"a_somast","ponum1") &&if PO exist, prompt user
if MESSAGEBOX("P.O Number for this customer already exist. Do you want to continue...",4+32+256,"PoNum: "+ALLTRIM(a_somast.ponum))=7
doit=.f. &&if you dont want to continue, the do it(doit) is false
endif
endif
if doit &&if do it, execute orignal code
**marking of the original code of SBT
ll_return = .t.
ll_return = g_objevt("GV") OR .t.
= DODEFAULT()
= g_losfcs("L", THIS, ll_return)
**end of original code
else &&if not, disable the line item command button to stop him
thisform.cmblb_line.enabled=.f.
thisform.cmblb_cancel.setfocus()
endif
sele a_somast
go _gorecn &&recall current location before seek command
set order to _order &&return index if any
sele (_opntbl) &&go back if open other database
this.value=_SoPoNumb &&make sure ponumber has no blank space from left
RETURN
********
I did not include the history file soymst to shorten the tread and expected you to do so. But if you can't, don't hesitate to ask.
Best,
JunMagoncia
Manila,
Philippines