Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
irina_ivanova
Explorer

Let me share with your how to call PaPM function from Analysis for Office step-by-step.

Scenario allows user to update workbook by clicking on the button “Reconcile”. Button triggers remote call PaPM function by Function ID with parameters from workbook. In this case, variable “Planning version” value passed to PaPM function as selection fields.

Planning Form1.png

To carry out into practice this scenario it is necessary proceed next steps:

  1. Create the PaPM environment and functions for processing
  2. Create the functional module additionally processing variables from workbook
  3. Create the set of BW objects to realize the planning function
  4. Create Macros to call the planning function

I describe each of them bellow in details.

1. Creating PaPM environment

My PaPM environment assumes reconciliation between two Model BW, implemented with Join and Writer function. Rules restricted by SELFLD0 and SELFLD1 fields, which are BW info-objects. SELFLD1 “Planning version” has a variable ZV_MSM_SELFLD1_01, which used in workbook. (SAP Help: SAP Profitability and Performance Management )

PaPM env2.png

2. Creating the Functional Module

The functional module creating is carried out in thansaction SE37. Easy ABAP code allows implementing the  necessary rules to construct the parameters string, passed to the standard functional.

 

FUNCTION ZNXI_RUN_BY_SELFLD1_FOX
  IMPORTING
    VALUE(I_ENV_ID) TYPE /NXI/P1_DTE_ENV_ID
    VALUE(I_VER) TYPE /NXI/P1_DTE_VER
    VALUE(I_FID) TYPE /NXI/P1_DTE_FID
    VALUE(I_PROC_ID) TYPE /NXI/P1_DTE_PROC_ID OPTIONAL
    VALUE(I_SELFLD1) TYPE /BIC/OISELFLD1 OPTIONAL
  EXPORTING
    VALUE(E_EXPTN) TYPE I. "Type’s used to easy access in FOX


  TYPES:
    BEGIN OF ls_AUXSTRC,
      /bic/SELFLD0 TYPE /bic/oiSELFLD0, "Dependent selection field
      /bic/SELFLD1 TYPE /bic/oiSELFLD1, "Selection field from Workbook
    END OF ls_AUXSTRC.

  DATA:
    l_selfld1 TYPE /BIC/OISELFLD1 VALUE '',
    l_pckg_sel TYPE /NXI/P1_DTE_PACKAGE_SEL VALUE '',
    l_tab_msg  TYPE BAPIRET2_TAB.

    E_EXPTN = 0. "OK execution by default

    IF I_ENV_ID IS INITIAL OR I_VER IS INITIAL OR I_FID IS INITIAL.
        E_EXPTN = 1. "Must be defined
        RETURN.
    ENDIF.

    IF I_PROC_ID IS INITIAL.
        l_selfld1 = I_SELFLD1. "If proccess wasn’t defined, selection field should be 
    ENDIF.

    IF l_selfld1 IS NOT INITIAL.
     SELECT SINGLE * FROM MYRELTBL INTO @DATA(ls_AUXSTRC)
      WHERE /BIC/SELFLD1 = @I_SELFLD1.

      CONCATENATE 'SELFLD0=( SELFLD0 = ''' ls_AUXSTRC-/bic/SELFLD0
        ''');SELFLD1=( SELFLD1 = ''' ls_AUXSTRC-/bic/SELFLD1 ''')' INTO l_pckg_sel.
    ENDIF.


    CALL FUNCTION '/NXI/P1_FW_RUN_FUNCTION_PC'
    EXPORTING
      i_env_id           = I_ENV_ID
      i_ver              = I_VER
      i_fid              = I_FID
      i_proc_id          = I_PROC_ID
      i_package_sel      = l_pckg_sel
      i_run_type         = 'RUN'
      i_rspc_synchronous = 'X'
      i_execute_post_run = 'X'
    IMPORTING
      e_tab_msg          = l_tab_msg.

IF l_tab_msg IS NOT INITIAL.
    E_EXPTN = 2. "Execution with errors
    RETURN.
ENDIF.

ENDFUNCTION.

 

To allow using the function ZNXI_RUN_BY_SELFLD1_FOX inside the FOX script, it should be declared in table RSPLF_FDIR via transaction SM30.

sm30.png

 3. Creating the set of the BW objects to realize the planning function

The blog post How to Trigger BW Process Chains from Analysis for Office  explains clearly and in detail how to create the set of objects for planning. As a result, set of ADSO ZNXIDZ20, Composit Provider ZNXIVZ20, Aggregation ZNXIAZ20 are created.Planning Objects.png

In my case, ADSO ZNXIDZ20 consists of combination of standard info-objects /NXI* and Info-object SELFLD1, which store the selection filed value. Using SELFLD1 gives easy access to the necessary type within the FOX script, described below.

ADSO.png

The Planning function ZNXAZ20_F001 is a formula type function (0RSPL_FORMULA) with the next configuration:

Planning function1.png

The following FOX script inside the planning function ZNXAZ20_F001 looks like bellow.

 

DATA LV_ENV TYPE /NXI/ENV_ID.
DATA LV_VER TYPE /NXI/VER.
DATA LV_FID TYPE /NXI/FID.
DATA LV_PS_V TYPE SELFLD1.
DATA LV_ERR TYPE I.

LV_FID = VARV( 'ZV_MSM_NXIFID_01' ).
LV_PS_V = VARV( 'ZV_MSM_SELFLD1_01' ).
LV_ENV = VARV( 'ZV_MSM_NXIENV_01' ).
LV_VER = VARV( 'ZV_MSM_NXIVER_01' ).

CALL FUNCTION 'ZNXI_RUN_BY_SELFLD1_FOX'
EXPORTING I_ENV_ID = LV_ENV I_VER = LV_VER I_FID = LV_FID I_SELFLD1 = LV_PS_V
IMPORTING E_EXPTN = LV_ERR.
IF LV_ERR <> 0.
  MESSAGE E000( 0 ) WITH 'Error! Watch Application Monitor for details.'.
ENDIF.

 

4. Creating Macros to call planning function

And the last but not least, Workbook macros for Reconcile button should be defined.

Add Planning function ZNXAZ20_F001 to workbook with alias PF_1. Constant for Function ID and variable Planning version are defined on hidden Tech page:

WB_HiddenList1.png

 

After that, add macros code like bellow:

 

 

Public Sub ReconcileButtonAction()
    Call Application.Run("SAPExecutePlanningFunction", "PF_1")
    Call Application.Run(“SAPExecuteCommand”, "Refresh", "DS_1")
End Sub

 

 

Вesides the Planning function execution, the related data store with alias DS_1 might be refreshed.

How to add the planning function described in blog post Using Planning Objects in Analysis For Microsoft Excel .

Thank you for reading through and I hope you now get a knowledge to apply in your practice.

Irina.

 

 

 

Labels in this area