SAP Knowledge Base Article - Public

1942970 - Return Value of Planning Function or Planning Sequence in Analysis for Excel

Symptom

When execute Planning Function with API in Analysis for Excel, for example, Application.Run("SAPExecutePlanningFunction", "PF_1"), even the Planning Function is ended with errors(for example, RSPLF-xxx), the return Value is still 1(execution successful).

The symptom is the same when execute Planning Sequence with API in Analysis for Excel.

Environment

SAP Analysis for Microsoft Office

Reproducing the Issue

Executing SAPExecutePlanningFunction or SAPExecutePlanningSequence

Cause

This is an intended behavior of Analysis Edition for Microsoft Office.

Whenever a planning function or Planning Sequence is being execute via SAPExecutePlanningFunction or SAPExecutePlanningSequence there are two possible return codes:
0 = execution failed.
1 = execution successful.

"Execution successful" in this context means that there has been no technical issue with the execution itself which indeed is independent from any other issues the logic might cause or run
into.  So even the Planning Function or Planning Sequence has errors, it has been successful triggered by AO, the Return Value should be set as 1(execution successful).

Resolution

Your requirement in VBA code to figure out about inconsistent state could be handled by using the call to SAPListOfMessages("ERROR";FALSE).
Whenever the returning object contains one or more messages you could skip further processing.

Example VBA Code:

Sub Button1_Click()
  Dim lResult As Long
  Dim lResult1 As Variant

  lResult = Application.Run("SAPExecutePlanningFunction", "PF_1")
  lResult1 = Application.Run("SAPListOfMessages", "ERROR")
  If IsArray(lResult1) Then
    If UBound(lResult1) > 0 Then
      MsgBox ("Planning Function ended with error")
    End If
  End If
End Sub

Keywords

Planning Function, Planning Sequence, SAPExecutePlanningFunction, SAPExecutePlanningSequence, AO, Analysis for Excel, Analysis Edition for Microsoft Office, Return Value, SAPListOfMessages , KBA , BI-RA-AO-XLA , Excel Addin , BW-PLA-IP , Integrated Planning , How To

Product

SAP Analysis for Microsoft Office all versions