cancel
Showing results for 
Search instead for 
Did you mean: 

retreive price from matrix before sales order added

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

rasmuswulff_jensen
Active Contributor
0 Kudos

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)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

WOW!!

Isn't there some way to just get a price value on the matrix lines? I cannot believe you had to do all of that just to get the price.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hey,

Thanks I will try that. I was using the userdatasource before. Is there a way to also retreive the display settings independent string with the UDS?

Former Member
0 Kudos

In the matrix lines this edittext seems to have the same issues. It is always 300.00 USD for example.

Is there any other way to get that field>

Former Member
0 Kudos

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

Former Member
0 Kudos

Ok thats what I figured.

Which screen field can I grab for a price in the system currency at the line level? If I try to grab the price field I see on the screen it has USD and the number in the string.