on 09-07-2007 7:27 PM
hey All.
I have the following code to retreive the PriceAFVat col from a matrix before a sales order is added into the system:
See simplify version of code below.
oDBDataSource = oSapSalesOrderForm.DataSources.DBDataSources.Item("RDR1");
f
or (int i = 1; i <= counter - 1; i++)
{
docLineMtx.GetLineData(i);
locTaxDetail.GrossAmount = Convert.ToDecimal(oDBDataSource.GetValue("PriceAFVat", oDBDataSource.Offset));
}
can anyone tell me why that field and many others are empty strings when the form is in add mode? Fields such as itemcode are available. How do i get the price for the matrix line if this is the case?
This is how I am doing it and I think it is the only way, because db datasources don't work since the data is not yet in the database, and userdatasources don't work on system forms.
If you find another way please let me know.
I am doing this to get 30 fields per line for a customer, and as the number of lines are increasing the performance drops significally because of the number of COM calls to the UI-API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the hack... It's not pretty (for the user to look at), but it works and no nast surprises or conversion of strings...
OK.. Problem is that the DBDS is not updated with data while typing in the lines, but there is a way to get the dbds update with the current data.
For some reason, if you open and closes the Volumne and Weight Calculations, the data the dbds will be updated with current values... Here is a small sample of how to do it...
SAPbouiCOM.Application app;
SAPbouiCOM.Form eventForm;
Matrix m = (Matrix)eventForm.Items.Item("38").Specific;
for (int i = 1; i <= m.RowCount; i++)
{
m.GetLineData(i);
}
//Open Volumen and Weight Calculations and close it again
app.ActivateMenuItem("5893");
app.Forms.ActiveForm.Items.Item("1").Click(BoCellClickType.ct_Regular);
DBDataSource dbds = eventForm.DataSources.DBDataSources.Item("RDR1");
for (int i = 0; i < dbds.Size; i++)
{
double price = Convert.ToDouble(dbds.GetValue("Price", i).Trim(), System.Globalization.CultureInfo.InvariantCulture);
}
(Problem with this method is that the window that is opened and closed will be shown to the user)
With this query
SELECT [DecSep], [ThousSep], [DateSep], [DateFormat], [SumDec] FROM [OADM] WHERE [CompnyName] = 'myCompany'
you can get the separators from sap
Then I split the cellvalue on spaces
string s1 = ((SAPbouiCOM.EditText)matrix.Columns.Item(columnID).Cells.Item(row).Specific).String;
string[] ss = s1.Split(' ');
You can loop the string array and find occurence which does not contain alfa characters. (because the USD can be in front or at the end of the price depending on the settings)
Then remove the thousand seperator from the found number and then replace the decimal separator with the decimal separator of windows (in case they are not the same).
Then you can use System.Convert.ToDouble() to get the value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed the value you get depends on the display settings.
That is why there is a ".Value" method on EditText object, this method returns a "display settings" independant string.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Curtis,
It is not possible to read most of the fields in "add mode" with a datasource. Even in "update mode" you will not get the right value if you have updated the field.
You have to read the contents of the fields with the UI-API like this:
for edit fields:
((SAPbouiCOM.EditText)matrix.Columns.Item(columnID).Cells.Item(row).Specific).String
or
((SAPbouiCOM.EditText)matrix.Columns.Item(columnID).Cells.Item(row).Specific).Value
for a combo:
((SAPbouiCOM.ComboBox)matrix.Columns.Item(columnID).Cells.Item(row).Specific).Selected
for a checkbox:
((SAPbouiCOM.CheckBox)matrix.Columns.Item(columnID).Cells.Item(row).Specific).Checked
Good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.