cancel
Showing results for 
Search instead for 
Did you mean: 

alert message via jco

Former Member
0 Kudos

hi guys,

i am retrieving,updating the data via jco in sap r/3 tables....

ok fine, but i want alert message from sap , if any updation happens in sap table

how can i get but i am using jco.. is it possible? yes means

plz send me steps ....

thanks

tony

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tony



import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.ParameterList;
import com.sap.mw.jco.JCO.Table;

/**
 * @author Techedge
 * 
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class AlertDispatcher
{

	private JCO.Repository jcoRepository;

	public boolean dispatch_alert(String strClient, String strLogin, String strPassword, String strLanguage, String strHostName, String strSysNo, String strMessage, String strAlrtCategory) throws Exception
	{
		try
		{
			JCO.Client jcoConnection = JCO.createClient(strClient, strLogin, strPassword, strLanguage, strHostName, strSysNo);
			if (jcoConnection == null)
				return false;
			jcoConnection.connect();

			jcoRepository = new JCO.Repository("ARAsoft", jcoConnection);
			if (jcoRepository == null)
				return false;

			JCO.Function function;
			try
			{
				function = createFunction("SALERT_CREATE");
				if (function == null)
					return false;
			}
			catch (Exception e)
			{
				
			}

			ParameterList impParameters = function.getImportParameterList();
			ParameterList tblParameters = function.getTableParameterList();

			Table tblContainer = tblParameters.getTable("IT_CONTAINER");
			if (tblContainer == null)
				return false;

			tblContainer.insertRow(1);
			tblContainer.setValue("ERROR_DESCRIPTION", "ELEMENT");
			tblContainer.setValue(strMessage.length(), "ELEMLENGTH");
			tblContainer.setValue("C", "TYPE");
			tblContainer.setValue(strMessage, "VALUE");
			tblContainer.appendRow();

			impParameters.setValue(strAlrtCategory, "IP_CAT");
			function.setExportParameterList(impParameters);
			function.setTableParameterList(tblParameters);

			jcoConnection.execute(function);
			jcoConnection.disconnect();

			return true;

		}
		catch (Exception e)
		{
			
		}

	}// end dispatch_alert

	public JCO.Function createFunction(String name)
	{
		IFunctionTemplate ft = jcoRepository.getFunctionTemplate(name.toUpperCase());
		return (ft == null) ? null : ft.getFunction();
	}// end createFunction

}// end class

Hope it help

Francesco

Former Member
0 Kudos

hi,

ok , but here you sending message to the function ,which stores the alert

message into sap table ...but my requirement is how to get alert

message in my console when any updation happens in sap table

thanks