Currently I have built an application (using Visual Studio .Net MVC Web Application in C#) which opens up specific views in Sage 300, which I then use to pull specific table information. I am currently trying to get Quantity on Hand data (the number) from Sage 300's IC0290 ROTO ID View. The code I have will only bring back "0". It does bring back other information from the same table as long as the values for that information are strings. The value type for QTYONHAND is BCD*10.4 . I am trying to use Decimal in C# but it brings back a 0. I have the code listed below. If anyone has any ideas on how I can get the actual data to come through, I would greatly appreciate it.
private void OpenSessionDBandView()
// Create, initialize and open a session.
session = new Session();
session.Init("", "XY", "XY1000", "62A");
session.Open("ADMIN", "ADMIN", "SAMINC", DateTime.Today, 0);
// Open a database link.
mDBLinkOpen = session.OpenDBLink(DBLinkType.Company, DBLinkFlags.ReadWrite);
// Open the I/C Items View - "IC0310"
icItemView = mDBLinkOpen.OpenView("IC0310");
// Open the I/C Items View (Quantities on Hand) - "IC0290"
icLocationDetailsView = mDBLinkOpen.OpenView("IC0290");
public string DoIt()
// "itemNumber" is a value derived from a form created. User submits the item number.
itemQoH = (decimal)icLocationDetailsView.Fields.FieldByName("QTYONHAND").Value;
returnHTML = returnHTML + "Quantity on Hand = " + itemQoH;
The HTML then reads: "Quantity on Hand = 0.0000"
To test the connection and the table accuracy I used this code which worked correctly.
returnHTML = returnHTML + "Item Account Set Code = " + itemAccountSetCode;
The HTML then reads: "Item Account Set Code = FIFO "
This is correct. Strings seem to work correctly but the numbers do not.
The API documentation lists the following:
Field = QTYONHAND Index = 7 Type = BCD*10.4 (This is where I believe the problem is)
This is the data for the value that worked:
Field = CNTLACCT Index = 63 Type = String*6
Hopefully this is enough information that someone might be able to assist me. I should also add I have attempted to convert the BCD into Decimal but I have had no success. Visual Studio also finds an exception if I try to label the variable as a string with the following error:
"unable to cast object of type 'system.decimal' to type 'system.string'."
Thank you again for you help in advance!