I have 2 sets of GetResultSets that produce different results. Could some please explain to me why these 2 examples of GetResultSet methods return different result sets? I've read some examples, including Advanced GetResultSets() by a Sage developoer Bret Richion, dlech's example here, and SY_SERVICE section of object references but i'm stuck in understanding it.
Below are 2 versions of the same codes, one mimics Bret and others mimic dlech. The script tries to get a list of SalesOrderNo for CustomerNo TEMP from SO_SalesOrder, just as the aforementioned 2 guys showed in their examples. Basically, I'm confused because Bret clarifies in his post that that's how it should be done to get a list of sales order numbers for a particular CustomerNo but his way produces an incorrect result set, while dlech's way correctly produces an expected result set.
Could someone please help me understand the differences? Thank you!
Parameter setting based on Bret's example:
Set oBoObj = oBoObj =oSession.AsObject(oSession.GetObject("SO_SalesOrder_bus"))
strCustomerNo = "TEMP"
orderFilter = "OrderType$ = """ & "whatever it is" & """"
intColLenCustomerNo = oFileObj.GetColumnLength("AR_Customer", "CustomerNo$")
Pad = String (intColLenCustomerNo - Len(strCustomerNo), NUL) ' NUL = Chr(0) = NULL
CustNoPadded = strCustomerNo & Pad
retVal = oBoObj.GetResultSets("SalesOrderNo$", "Nothing$", retOrderList, retJUNK, orderFilter, "00" + strCustomerNo, CustNoPadded + HexFE, "kCUSTOMER")
- Source key = "nothing$"
- Begin$ = "00TEMP"
- End$ = "TEMP" + 16 CHR(0) + Chr(254)
- Alt Index "KCUSTOMER" (Div+CustNo+SoNo)
- Filter = Non-key columns
- With this method, the it returns a list of SalesOrderNo that have CustomerNo equal to or larger than the value "TEMP" (e.g. TEMQ, TFMP, and all CustomerNo starting with U, V,W, X, Y, and Z ).
Parameter setting based on dlech's example:
orderFilter = "CustomerNo$ = """ & "TEPM" & """ AND OrderType$ = """ & "whatever it is" & """""
retVal = oBoObj.GetResultSets("SalesOrderNo$", "Nothing$", retOrderList, retJUNK, orderFilter, "", "", "")
- Source key = "SalesOrderNo$"
- Begin$ = ""
- End$ = ""
- Alt Index = ""
- Filter = CustomerNo$ (surrounded by double quotes)
- With this method, it returns only the SalesOrderNos for TEMP, nobody else.
EDIT-5/6/2019----------- I found out that the oddities also was caused by how CustomerNo was retrieved from the record. I noticed that I had GetValue"s" instead of GetValue, thereby padding CustomerNo with Chr(138). Don't be like me and check the methods, variable name/type agreement, and any other typos everyone!