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

I have an issue in the .Net library AP Sage300 (Version 2019)

Status
Not open for further replies.

johnny9864

Programmer
Sep 27, 2013
35
CA
I have an issue in the .Net library I have no issue creating a vendor using a macro:

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

Dim temp As Boolean
Dim APVENDOR1header As AccpacCOMAPI.AccpacView
Dim APVENDOR1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0015", APVENDOR1header
Set APVENDOR1headerFields = APVENDOR1header.Fields

Dim APVENDOR1detail As AccpacCOMAPI.AccpacView
Dim APVENDOR1detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0407", APVENDOR1detail
Set APVENDOR1detailFields = APVENDOR1detail.Fields

APVENDOR1header.Compose Array(APVENDOR1detail)

APVENDOR1detail.Compose Array(APVENDOR1header)


Dim APVENDSTAT2 As AccpacCOMAPI.AccpacView
Dim APVENDSTAT2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0019", APVENDSTAT2
Set APVENDSTAT2Fields = APVENDSTAT2.Fields


Dim APVENDCMNT3 As AccpacCOMAPI.AccpacView
Dim APVENDCMNT3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0014", APVENDCMNT3
Set APVENDCMNT3Fields = APVENDCMNT3.Fields


APVENDSTAT2Fields("YTDACTIVE").Value = "1" ' Enable YTD Calculations
APVENDOR1header.RecordClear
APVENDSTAT2.RecordClear

APVENDSTAT2Fields("CNTYR").PutWithoutVerification ("2020") ' Year
APVENDOR1headerFields("VENDORID").Value = "TEST1" ' Vendor Number
temp = APVENDOR1header.Exists

APVENDOR1headerFields("VENDNAME").Value = "Test1" ' Vendor Name

APVENDOR1headerFields("IDGRP").Value = "ANFL" ' Group Code

APVENDOR1header.Insert
APVENDSTAT2.RecordClear

APVENDSTAT2Fields("VENDORID").PutWithoutVerification ("TEST1") ' Vendor Number
APVENDSTAT2Fields("CNTYR").PutWithoutVerification ("2020") ' Year


But using .net :

ACCPAC.Advantage.View apVendorHeaderView = dbLink.OpenView("AP0015");
ACCPAC.Advantage.View apVendorDetailView = dbLink.OpenView("AP0407");
ACCPAC.Advantage.View apVendorStatsView = dbLink.OpenView("AP0019");
ACCPAC.Advantage.View apVendorCmntView = dbLink.OpenView("AP0014");

apVendorHeaderView.Compose(new ACCPAC.Advantage.View[] { apVendorDetailView });
apVendorDetailView.Compose(new ACCPAC.Advantage.View[] { apVendorHeaderView });

apVendorStatsView.Fields.FieldByName("YTDACTIVE").SetValue(1, true);
apVendorHeaderView.RecordClear();
apVendorStatsView.RecordClear();
apVendorStatsView.Fields.FieldByName("CNTYR").SetValue(DateTime.Now.Year, false);
apVendorHeaderView.Fields.FieldByName("VENDORID").SetValue(vendors.Tables[0].Rows[0]["ConsultantReference"].ToString(), false);
bool exist = apVendorHeaderView.Exists;
apVendorHeaderView.Fields.FieldByName("VENDNAME").SetValue(vendors.Tables[0].Rows[0]["CompanyName"].ToString(), false);
apVendorHeaderView.Fields.FieldByName("IDGRP").SetValue(vendors.Tables[0].Rows[0]["IDGRP"].ToString(), false);
apVendorHeaderView.Insert();

I get the error "Tax group cannot be blank."

I don't see I am missing anything, since IDGRP is set, the tax group should be deducted as in the macro
 
Run rvSpy and step through your code and see if the vendor group field is indeed being set.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top