cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to create Maintenance Notification using SAP .NET Connector 3.0

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Answers (0)