Optimizer Rule to View Item Master Remarks

artklein

I am trying to provide my SAP B1 user the ability to see comments populated on the Item Master (OITM) any time they enter the Item No. on a form such as the AR Sales Order, AP Purchase Order, etc.  There was a sample rule that came with Coresuite Country Pack to show Business Partner Remarks when you enter a business partner number on forms such as the AR Sales Order, AP Purchase Order, etc (DOC-0002 Show Business Partner Info).  I tried to copy this rule, but the difference is that the Business Partner is in the Header area of the form with a specific ItemUID, whereas the Item Number is in the Line Detail where all field have the same ItemUID.  The attachment shows how the Business Partner Remarks works and I highlighted the Item No. field that I would like to create to show the Item Remarks.  Any help would be greatly appreciated.


Paolo Manfrin

Hi artklein,


you need to react to the valuechange event of the item 38(matrix), column 1  (itemcode), .


See the attached cocu rule as sample.



try
{
string itemCode = Matrix.GetFromUID(pVal.Form, "38").GetValue("1", pVal.Row-1);
SwissAddonFramework.Messaging.StatusBar.WriteSucess("value changed on " + itemCode);

}
catch (Exception ex)
{
StatusBar.WriteError(ex.Message);
}
return true;

hth


paolo


artklein

Hi Paolo Manfrin,


 


Thanks so much for your responding to my question.  Below is a copy of a sample I had for the Business Partner remarks.  I tried substituting your code for the line marked as ///ART*** with no success.  Could you look at the code below and see if you see what the issue is?


 


try

{

 // get Item Number code

 ///ART*** string ItemCode = customize.UI.Components.TextEdit.GetFromUID(pVal.Form, "38").Value;

 string itemCode = Matrix.GetFromUID(pVal.Form, "38").GetValue("1", pVal.Row - 1);


 

 // query to get U_PopUpRemarks and free_text from Item Master

 string query = string.Format("SELECT ISNULL(REPLACE(CAST(U_PopUpRemarks AS VARCHAR(100)),CHAR(13),CHAR(10)),''), ISNULL(REPLACE(CAST(FREE_Text AS VARCHAR(8000)),CHAR(13),CHAR(10)),'') FROM OITM WHERE ItemCode='{0}'", itemcode);

 

 

 System.Text.StringBuilder output = new System.Text.StringBuilder();

 

 using (System.Data.SqlClient.SqlDataReader rdr = SwissAddonFramework.Utils.SQL.ExecuteQuery(query))


 {

  if (rdr.Read())

  {

   string U_PopUpRemarks = rdr[0].ToString();

   

   if (!string.IsNullOrEmpty(U_PopUpRemarks))

   {

    output.Append(U_PopUpRemarks);

   }

  }

 }

 

 if (output.Length > 0)

 {

  if (pVal.Item.UniqueID == "38")

  {

   MessageBox.Show(output.ToString(), "OK");

  }

  else if (pVal.Item.UniqueID == "54")

  {

   // Workaround to avoid focus being set on ItemCode causing rule to fire twice

   new System.Threading.Thread(new System.Threading.ThreadStart(delegate()

   {

    System.Threading.Thread.Sleep(1000);

    MessageBox.Show(output.ToString(), "OK");

   })).Start();

  }

 }

}

catch (Exception ex)

{

 customize.Messaging.StatusBar.WriteError("Error in coresuite customize Rule (ART:7777: Show Business Partner Info): " + ex.ToString());

 customize.Messaging.Debug.WriteMessage("Error in coresuite customize Rule (ART:7777: Show Business Partner Info): " + ex.ToString(), customize.Messaging.Debug.DebugLevel.Exception);

}

return true;


0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post