#include "sap_moni.h"
#include "sap_moni_ccm.h"

/*=======================================================================
  (C) Copyright SAP AG, 2002

         
 Author  : Dostert/SAP
 Project : Get data from R/3 using XMB
 Using   : RFCSDK 
 ========================================================================*/
void usage(char *progname) {
        #define BL printf(



         BL"Agent \n\n");
         BL"Syntax: %s Alsysid Msegname Aluniqnum Alindex Alertdate Alerttime <RFC-Template>\n\n",  progname     );


         BL"       <RFC-Template> defined in %s\n", AGENT_LOGIN_FILE  );
}

int main(int argc, char **argv) {
	RFC_HANDLE rfc_handle;

	BAPIAID aid;
	char *ptr;	

	if (argc < 8) {
		usage(argv[0]);
		return AG_INVALID_ARGUMENTS;
	}



	if( sapmon_connect(argv[7], &rfc_handle) >=  AG_FIRST_ERROR) {
		printf("Could not log on\n");
		return AG_CALL_INVALID;
	}


         memset(&aid, ' ', sizeof(aid));

         strncpy(aid.Alsysid, argv[1], strlen(argv[1]));
         strncpy(aid.Msegname,  argv[2], strlen(argv[2]));
         strncpy(aid.Aluniqnum, argv[3], strlen(argv[3]));
         strncpy(aid.Alindex,  argv[4], strlen(argv[4]));
         strncpy(aid.Alertdate,  argv[5], strlen(argv[5]));
         strncpy(aid.Alerttime,  argv[6], strlen(argv[6]) );
	

	bapi_system_alert_acknowledge(	&rfc_handle, 
				 	&aid);


	//Log off
	sapmon_disconnect(&rfc_handle);	
	
	return SAP_OK;
}
