1. 程式人生 > >Running a R/3 Job in BW Process Chain(整理SDN)

Running a R/3 Job in BW Process Chain(整理SDN)

使用ABAP非同步排程其他系統的JOB,也許會有用吧。原理類似於在BW端排程R3端的EVENT,

然後該EVENT會返回一個成功或者失敗的狀態給BW的PROCESS CHAIN。

下文中有詳細的過程,源自SDN。

You can create a job in R/3 to be triggered "After Event". Then in your process chain, you create an ABAP process:

Call mode: Asynchronous

Called From: Destination (your R/3 system)

Scheduled Program: (put in R/3 event name)

The trick is that in R/3, you will need to create an ABAP program that executes function module RSPC_ABAP_FINISH (with parm of the name of the ABAP process in the process chain). This signals the process chain, that the ABAP process is complete (for Asynchronous ABAP processes, the process chain will wait for user intervention before going to the next step in the process chain). When you save the ABAP process in the process chain, you will receive a warning saying that you must call the RSPC_ABAP_FINISH function module to tell process chain that the ABAP process finished.

In R/3 create an event (let's call it ZSTARTJOB).  SM62

In BW, in your process chain, create an ABAP process with the following parameters:

Call mode: Asynchronous

Called From: Destination (your R/3 system)

Scheduled Program: ZSTARTJOB

In R/3, create an ABAP program which will signal your process chain in BW, that your ABAP process has finished. Your code can look like this:

REPORT  ZRSPC_ABAP_FINISH.
 
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle: Detination BW
*"  IMPORTING
*"     VALUE(I_VARIANT) TYPE  RSPC_VARIANT
*"  EXCEPTIONS
*"      ALREADY_FINISHED
*"----------------------------------------------------------------------
 
PARAMETER: p_rfc LIKE rfcdes-rfcdest,
           p_var(30) TYPE c.
 
CALL FUNCTION 'RSPC_ABAP_FINISH'
    DESTINATION p_rfc
     EXPORTING
       I_VARIANT              = p_var
     EXCEPTIONS
       ALREADY_FINISHED       = 1
       OTHERS                 = 2
              .
    IF SY-SUBRC  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

This program will prompt for RFC Destination (which will be your BW system) and a variant (which will be the name of the ABAP process variant in your process chain). So create a variant for this ABAP program to save these values (lets call the variant (R3_FINISH). This will allow you to call this program in a background job. So....

Now create your background job in R/3. Schedule it to execute "After Event" ZSTARTJOB. The last step in this job is to call ZRSPC_ABAP_FINISH with the variant R3_FINISH.  SM36

The result will be when you execute your process chain, the ABAP process in BW will trigger the event in R/3 which will start your R/3 job. When your R/3 job finishes and executes the ZRSPC_ABAP_FINISH program, the ABAP process in your process chain will be set to "Green" and your process chain will continue to the next process.

ZRPSC_ABAP_FINISH is an ABAP program (not a function module) which you need to create. The function module is RSPC_ABAP_FINISH and exists in BW. You are executing the function module from R/3 which is why you need to specify an RFC destination in your R/3 program.