cMessage

The following example will demonstrate the usage of cMessage class and its methods in use.

The steps of a message lifecycle is as follows.

  1. Instantiate a message object from cMessage class.
  2. Reset the internal state of the cMessage object using method Construct.
  3. Set a name to the message using method SetName
  4. Add a new attribute to the message using method AddAttribute
  5. Pack the entire message (all attributes and values) to a SalString using method Pack

Once the message is packed, this can be used at a later stage of an application.

  1. Initialize a cMessage object from a SalString containing a packed IFS message using message Unpack
  2. Get the application object’s name using method GetName
  3. Get the value of a given attribute in a message using method FindAttribute
public partial class frmUpdateCompanyHeader : cFormWindow
{
  #region Window Variables
  public cMessage msgHeadInfo = new cMessage();
  #endregion
public SalNumber UM_GenerateDiff(SalNumber nWhat) { #region Local Variables cMessage msgMaster = new cMessage(); SalString lsMaster = ""; #endregion #region Actions using (new SalContext(this)) { switch (nWhat) { case Ifs.Fnd.ApplicationForms.Const.METHOD_Inquire: <some code> return false; case Ifs.Fnd.ApplicationForms.Const.METHOD_Execute:
//1 resetting the internal state of the cMessage object, msgMaster msgMaster.Construct();
//2 setting the name of a message as "GENERATE". msgMaster.SetName("GENERATE");
//3 adding an attribute named "Dummy" to the message. msgMaster.AddAttribute("DUMMY", "TRUE");
//4 packing the entire message (all attributes and values) to a string,lsMaster lsMaster = msgMaster.Pack(); CallMaster(lsMaster); return true; case Ifs.Fnd.ApplicationForms.Const.METHOD_GetType: return Ifs.Fnd.ApplicationForms.Const.CHILDTYPE_Any; } } return 0; #endregion } public SalNumber CallMaster(SalString lsMaster) { #region Actions using (new SalContext(this)) { if (hWndMaster == SalWindowHandle.Null) { hWndMaster = Sal.ParentWindow(i_hWndFrame); } Sal.SendMsg(hWndMaster, Ifs.Fnd.ApplicationForms.Const.PAM_User, 10, lsMaster.ToHandle()); } return 0; #endregion } public SalNumber OnPamUser(SalNumber wParam, SalNumber lParam) { #region Local Variables SalString sName = ""; #endregion #region Actions using (new SalContext(this)) {
//initializing a cMessage object from a string containing a packed IFS message msgHeadInfo.Unpack(SalString.FromHandle(lParam));
//getting the application object’s name sName = msgHeadInfo.GetName(); if (sName == "UPDATE") {
//getting the value of a given attribute in a message sChildUpdated = msgHeadInfo.FindAttribute("UPDATED", "FALSE"); if (sChildUpdated == "TRUE") { bChildUpdated = true; } else { bChildUpdated = false; } } else { <some code> } RefreshButtonState(); } return 0; #endregion }
}