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

Creating ARCUSO fields in VB.NET 1

Status
Not open for further replies.

BallpointPenguin

Programmer
Oct 23, 2007
12
US
I am trying to get information written to the ARCUSO fields as we migrate our system from 5.2 to 5.4. I am trying to store information retrieved elsewhere, and here is what I'm trying to do:

Session.Open(ACCPACuid, ACCPACpwd, ACCPACcomp, Now, 0, "")
dblink = Session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

llngSuccess = dblink.OpenView("AR0400", ovARCUSO)

'... get strCustomerID, strFieldName, strFieldValue...

ovARCUSO.Init()
ovARCUSO.Fields.FieldByName("IDCUST").Value = strCustomerID
ovARCUSO.Fields.FieldByName("OPTFIELD").Value = strFieldName
ovARCUSO.Fields.FieldByName("VALUE").Value = strFieldValue
ovARCUSO.Verify()
ovARCUSO.Process()
ovARCUSO.Insert()

If ovARCUSO.LastReturnCode <> VC_SUCCESS Then
'... Log error
End If


The problem is that, all of this works properly, but I check the database, and nothing gets written there. What am I missing?
 
So, in that case, you recommend:

llngSuccess = dblink.OpenView("AR0024", ovarcustomer)
llngSuccess = dblink.OpenView("AR0400", ovARCUSO)
ovarcustomer.Compose(ARCUSO)
ovARCUSO.Compose(arcustomer)

Would that be what you're suggesting?
 
BTW, Tuba - Thanks for your reply. I pretty much got thrust into this, and greatly appreciate any help I can get on understanding ACCPAC.
 
Indeed, Accpac views often need "Compositions" to ensure the business logic is followed. Your code looks good, but your mileage may vary...
 
I've tried it, but it still isn't working. Here is the revised code:

Code:
Dim ovarcustomer as AccpacView
Dim ovARCUSO as AccpacView
Dim ary5a(0) as AccpacView
Dim ary5b(0) as AccpacView
Dim llngSuccess as Long

llngSuccess = dblink.OpenView("AR0024", ovarcustomer)
ary5a(0) = ovarcustomer
llngSuccess = dblink.OpenView("AR0400", ovARCUSO)
ary5b(0) = ovARCUSO
ovarcustomer.Compose(ary5b)
ovARCUSO.Compose(ary5a)

'... get strCustomerID, strFieldName, strFieldValue...
Code:
ovARCUSO.Init()
ovARCUSO.RecordClear()
ovARCUSO.RecordGenerate(True)
ovARCUSO.Fields.FieldByName("IDCUST").PutWithoutVerification(strCustomerID)
ovARCUSO.Fields.FieldByName("OPTFIELD").PutWithoutVerification(strFieldName)
ovARCUSO.Fields.FieldByName("SWSET").Value = "1"
ovARCUSO.Fields.FieldByName("VALUE").PutWithoutVerification(strFieldValue)
ovARCUSO.Fields.FieldByName("LENGTH").PutWithoutVerification(Trim(CStr(strFieldValue.Length)))
ovARCUSO.Insert()
If ovARCUSO.LastReturnCode <> AccpacCOMAPI.tagViewReturnCode.VC_SUCCESS Then
	...generate error message...
End If

Again, the problem is that no errors are generated... but no records show up in the server, either. So I'm wondering what I'm missing.

And, by the way, I have gone into the Accpac client, started recording a macro, done this by hand, finished the macro, and then viewed the VBA code. That was how I got the "RecordGenerate" function added in.

I think it's probably something fairly simple that I'm overlooking, and it'll have people 3 miles away hearing me when I slap my forehead in exasperation...

Thanks!
 
Did any of you hear that a couple of hours ago? That was the sound of my forehead being slapped.

What I did was add something after the above second section of code...
Code:
If ovARCUSO.LastReturnCode <> AccpacCOMAPI.tagViewReturnCode.VC_SUCCESS Then
    ...generate error message...
End If
[RED]ovarcustomer.update()[/RED]

I guess it probably helps if the view is told to update the database, doesn't it? [blush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top