I have tested that having a '_bus' entry in the Data Dictionary (DD) maintenance 'Business Object' field doesn't mean the table is writable.
For example: 'AP_InvoiceHistoryHeader' has 'AP_InvoiceHistory_bus' shown in the DD as its Business Object, but after successful nSetKeyValue (using InvoiceNo & HeaderSeqNo), nSetKey and nSetValue using that BO - causes an nWrite returns a zero! (i.e. read only - see sample program below).
How do I tell (preferably programmatically) which business objects are writable and what their UI object names are for use with nSetProgram and nLookupTask respectively?
Dim oSS: Dim oScript: Dim oBusDim retVal : retVal = 0Dim sCommentWas : sCommentWas = ""Set oScript = CreateObject("ProvideX.Script")oScript.Init ("C:\Sage\Sage 100 Standard ERP\MAS90\Home")Set oSS = oScript.NewObject("SY_Session")retVal = oSS.nLogon()retVal = oSS.nSetUser("user", "password")retVal = oSS.nSetCompany("ABC")retVal = oSS.nSetProgram(oSS.NlookupTask("AP_InvoiceHistory_ui"))Set oBus = oScript.NewObject("AP_InvoiceHistory_bus", oSS)retVal = oBus.nSetKeyValue("InvoiceNo$", "1050190") 'retVal = 1retVal = oBus.nSetKeyValue("HeaderSeqNo$", "000000") 'retVal = 1retVal = oBus.nSetKey() 'retVal = 1sCommentWas = ""retVal = oBus.nGetValue("Comment$", sCommentWas) 'retVal = 1retVal = oBus.nSetValue("Comment$", "Testing") 'retVal = 1retVal = oBus.nWrite() 'retVal = 0
I am also using VBA, but I am not looking for a method, I am looking for the UI parameter to the NLookupTask method and the BO parameter to the NewObject method that provides possible write ability to a given table. There seems to be no way to predict it. For a particular table, I can lookup the BO given in the data dictionary, but that is sometimes read-only when I have, by chance, found a read-write BO. There must be a method to lookup a related read-write BO.
Elliott, I've picked up this project again and NO it is not to modify history (my poor choice of sample code). I would really like to be able to determine the BO for writing to any non-history table via BOI! Any hints would be much appreciated!
While this may not be an absolute perfect statement, usually the business object follows the name of the file.
I usually look in Visual Integrator. If the table is not available for import or the field is not available in the table for import, then it is not writable via BOI either. Or at least that has been my experience.
For example: AP_CUSTOMER -> AP_CUSTOMER_BUS AP_VENDOR ->AP_VENDOR_BUS
I assume you are familiar with Web Content | Resources | File Layouts and Program Information? I get the impression you are but I'm just covering all bases.
Hey Dan - Well this info is in the dictionary and if using File Layouts, after you find your table then in the top left look for "Bus Obj:" then can see the different _Bus and _Upd classes. Some are obvious such as SO_InvoiceHeader belonging to SO_Invoice_bus. But if your table is say SO_InvoiceTierDistribution it correctly says SO_InvoiceTierDistribution_bus but in your BOI code most likely you will not have instantiated it directly. It's more likely you started at the Header (oInvc let's say), then referenced the Lines (oLines), then referenced the Distribution object as a child of oLines :
rVal = oInvc.oLines.oDistribution.nSetKeyValue("InvoiceNo$", sInvoiceNo) 'etc etc
The point is between dictionary, File Layouts, and Windows Explorer you can get the immediate _Bus but depending on the table it may not be the way you reference it.
Great information Alnoor! Thank you!!!