cancel
Showing results for 
Search instead for 
Did you mean: 

User function macro to trigger events

denizcetin
Advisor
Advisor
0 Kudos

Hello guys,

I created process chains in Business Warehouse for using in APO Demand Planning. The planer has to run the process chains after he does a manual correction of forecast data. However, the planer should not go to the transaction rspc (process chains) to start the process chain manually, the process chain should be start from interactive planning by a macro button. So I created an event that triggers the process chain. Now I would like to create a macro which triggers this event and consequentially the event should trigger the process chain. I found function module BP_EVENT_RAISE, which triggers events. Now I have to create an own function module calling function BP_EVENT_RAISE, which I can use in a user function macro.

But I am not familiar with ABAP and don' t know how to use the function module in my function module. It should be very easy, but my experiments failed...

my setup:

Importparameter: EVENTID

Export: empty

Changing: F_Argument Type /SAPAPO/MXSOP-V (Value Matrixelement)

F_CALC_ERROR Type C

Tables: VALUE_TAB LIKE /SAPAPO/VALUE_TAB (Table for giving values to functions of advanced macros)

Code:

FUNCTION /TEST/PPK_TRIGGER_EVENT.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(EVENTID)
*"  TABLES
*"      VALUE_TAB STRUCTURE  /SAPAPO/VALUE_TAB
*"  CHANGING
*"     REFERENCE(F_ARGUMENT) TYPE  /SAPAPO/MXSOP-V
*"     REFERENCE(F_CALC_ERROR) TYPE  C
*"  EXCEPTIONS
*"      BAD_EVENTID
*"      EVENTID_DOES_NOT_EXIST
*"      EVENTID_MISSING
*"      RAISE_FAILED
*"      OTHERS
*"----------------------------------------------------------------------

  DATA:

  LV_EVENT                 LIKE /SAPAPO/VALUE_TAB-STRING.
  gc_true                  TYPE c value 'X',
  gc_false                 TYPE c value ' '.



  F_CALC_ERROR = gc_true.
* Read event to be triggered
  READ TABLE VALUE_TAB INDEX 1 TRANSPORTING STRING.
  IF SY-SUBRC = 0.
    LV_EVENT = VALUE_TAB-STRING.
*  else.
    F_CALC_ERROR = gc_true.
  endif.

  CALL FUNCTION 'BP_EVENT_RAISE'
    EXPORTING
      EVENTID                      = LV_EVENT
*     EVENTPARM                    = ' '
*      TARGET_INSTANCE              = ' '
    EXCEPTIONS
      BAD_EVENTID                  = 1
      EVENTID_DOES_NOT_EXIST       = 2
      EVENTID_MISSING              = 3
      RAISE_FAILED                 = 4
      OTHERS                       = 5
            .
  commit work.
  IF SY-SUBRC <> 0.
    F_CALC_ERROR = gc_true.
  ELSE.
    F_CALC_ERROR = gc_false.

  ENDIF.

ENDFUNCTION.

Can anybody help me? What is wrong?

Thanks a lot in advance

Deniz Cetin

View Entire Topic
denizcetin
Advisor
Advisor
0 Kudos

Hello Emmanuel,

it works!!!:) yeah! My colleague had a mistake in the process chain settings. The event was not assigned to the process chain correctly. So it could not work. I tried it also with my coding before and it also worked. So thanks a lot!

Maybe we can help each other also in future with problems and questions in DP.

Best regards,

Deniz