on 02-12-2015 4:38 AM
Hi,
I am working on a .NET Console application to create maintenance notification. I am using SAP .NET Connector 3.0 to connect to SAP system from my console application.
As per the requirement to create a notification I am using following BAPI calls in given order:
1. BAPI_ALM_NOTIF_CREATE
IRfcFunction funcCreateNotification = this.SAPRfcDestination.Repository.CreateFunction("BAPI_ALM_NOTIF_CREATE");
funcCreateNotification.SetValue("NOTIF_TYPE", notif_Type);
funcCreateNotification.SetValue("NOTIFHEADER", notifheader);
funcCreateNotification.SetValue("ORDERID", orderid);
funcCreateNotification.SetValue("SENDER", sender);
funcCreateNotification.SetValue("TASK_DETERMINATION", task_Determination);
funcCreateNotification.SetValue("NOTIFHEADER_EXPORT", notifheader_Export);
funcCreateNotification.SetValue("KEY_RELATIONSHIPS", key_Relationships);
funcCreateNotification.SetValue("LONGTEXTS", longtexts);
funcCreateNotification.SetValue("NOTIFACTV", notifactv);
funcCreateNotification.SetValue("NOTIFCAUS", notifcaus);
funcCreateNotification.SetValue("NOTIFPARTNR", notifpartnr);
funcCreateNotification.SetValue("NOTIFTASK", notiftask);
funcCreateNotification.SetValue("NOTITEM", notitem);
funcCreateNotification.SetValue("RETURN", return0);
funcCreateNotification.Invoke(this.SAPRfcDestination);
Above BAPI call gives me notification number in notifheader_Export object. I pass this notification number "%00000000001" to BAPI_ALM_NOTIF_SAVE function as shown below.
2. BAPI_ALM_NOTIF_SAVE
RfcSessionManager.BeginContext(this.SAPRfcDestination);
IRfcFunction funcSaveNotification = this.SAPRfcDestination.Repository.CreateFunction("BAPI_ALM_NOTIF_SAVE");
IRfcStructure structNotifExp = funcSaveNotification.GetStructure("NOTIFHEADER");
funcSaveNotification.SetValue("NUMBER", notifheader_Export.GetValue("NOTIF_NO"));
funcSaveNotification.SetValue("NOTIFHEADER", structNotifExp);
IRfcFunction funcCommit = this.SAPRfcDestination.Repository.CreateFunction("BAPI_TRANSACTION_COMMIT");
funcSaveNotification.Invoke(this.SAPRfcDestination);
funcCommit.Invoke(this.SAPRfcDestination);
RfcSessionManager.EndContext(this.SAPRfcDestination);
After save I commit changes by calling BAPI_TRANSACTION_COMMIT.
At the end of this function call I expect structure 'structNotifExp' to retun valid notification number but it only return empty string.
Could you please suggest me why I am not able to create notification?
I found some posts similar to my problem but suggested solution didn't help me:
Could you please suggest me why I am not able to create notification?
Thanks,
Nirav
Hi Nirav,
I'm not familiar with these ALM BAPIs, but my first guess would be that you need to include the CREATE BAPI within your stateful context! E.g. like this:
1. RfcSessionManager.BeginContext()
2. Invoke CREATE BAPI
3. Invoke SAVE BAPI
4. Invoke BAPI_TRANSACTION_COMMIT
5. RfcSessionManager.EndContext()
Otherwise the Create step and the Save step might run in different user sessions, and then what is the Save step supposed to save...
Best Regards, Ulrich
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.