Skip to Content
author's profile photo Former Member
Former Member

retreive price from matrix before sales order added

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?

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2007 at 03:27 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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)

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2007 at 08:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2007 at 12:04 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2007 at 03:12 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.