Applies to

SAP BI 7.0.and also to BI 3.5

Author: Yogeshwar Shelar

Date:     13th Dec 2013

Summary

This article gives you an approach for looping of process chain to execute some steps repeatedly with different selections or condition.

Introduction

We come across some scenario where we have to run same process chain for multiple times for multiple selections or conditions. Here we need to loop our process chain with some stopping condition.

Scenario

Loding data from DSO to Cube through DTP Sales Org wise. If there is large volume of Sales data, we can prefer to load it giving sales org selection.

Here we have a process chain which loads sales data from DSO to Cube through DTP. We can run the same process chain multiple times for different Sales org so that it will push data to cube Sales org wise. Here I have not implemented whole scenario. Have shared only approcah by means of which you can implement the scenario.

Steps involved in this scenario:

1)    Create event in SM64  which will trigger this Process chain

2)    Create a variant in table TVARVC which will be used as a counter to run process chain n number of times.

3)    Program at the end of process chain which will trigger the same process chain in the loop.

4)    Finally process chain which will have DTP to load data and a program at the end to trigger same process chain itself.

Step 1: Creating event in SM64

/wp-content/uploads/2013/12/1_342853.png

Step 2: Create a variant LOOP_COUNTER which will be used as a counter to run the process chain in the loop.

/wp-content/uploads/2013/12/2_342854.png

We will update the value of  LOOP_COUNTER in table TVARVC after every run of process chain. It will control how many times we want to run our process chain in the loop.

Step 3: Create a program which will trigger same process chain by triggering event.

/wp-content/uploads/2013/12/3_342855.png

Consider we have in all 5 sales org for which we are going to load data from DSO to cube through DTP in the process chain. In order to load data one by one for each sale org, we will have to run same process chain for 5 times for 5 sales org.

Initialy value in COUNTER will be 1. As soon as data gets load for first sales org, value in COUNTER will be set to 1, likewise will increment COUNTER by 1 till it becomes 5. Once value of COUNTER becomes 5 then will will again set COUNTER to 1 and will terminate the process chain. Above program will take care of setting value of COUNTER and also triggering same process chain again in the loop till data for all sales org get loaded.

Peocess Chain Design:

4.PNG

Above process chain will be based on event we created in above step. In our case it is ZPC_LOOP_TEST

1)    Once event ZPC_LOOP_TEST gets triggered by some way, It will start the process chain.

2)    Data will be loaded for first sales org through DTP. You will have to give selection on sales org through routine at DTP level. To avoid complexity it is not shown in the article.

3)    Program will check the value of COUNTER in the back end, it will trigger or end the process chain based on the value  COUNTER in the backend.

I have just shown you approach to loop a process chain. you can implement the same appropriate to your requirement.

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Matthew Billingham

    I created a new process type “looper” to handle this kind of requirement rather more generically.  I’ll have to make a document explaining it.

    One question – does trigger event wait until the process chain has finished before triggering the next?

    (0) 
    1. Yogeshwar Shelar Post author

      Hi Matthew Billingham

      Would like to see your approach based on prcess type “looper”. Kindly post it.

      trigger event will not wait until the process chain has finished before triggering the next but it will not impact as triggering would be the last step of process chain and it will hardly take seconds to finish. Also there is one more syntax WAIT which can solve this, I should have used it in my program.

      (0) 
      1. Matthew Billingham

        I can’t post my development, unfortunately, as I’ve used a much wider framework that would be too complicated to post.

        Rather than trigger using events, you can function module:

        CALL FUNCTION ‘RSPC_CHAIN_START’

               EXPORTING

                 i_chain = chain

               IMPORTING

                 e_logid = logid.

        This will run synchronously.

        (0) 
        1. Shanthi Bhaskar

          Yes I did use Mathew’s approach in lot of programs…One more advantage is we can trigger The meta chain with this approach. and obviously no need of maintaining the Events.

          (0) 
          1. Matthew Billingham

            I’ve never really understood what the point of event triggered chains was! I’ve always used the function module to start them programmatically. Perhaps someone can enlighten me.

            (0) 
            1. Shanthi Bhaskar

              Hi Mathew,

              For instance I have one BW Process chain which needs to be triggered right after ECC Program. Here I can make use of Event triggering by using an RFC FM which triggers event which was used in the above program…

              (0) 
      1. Matthew Billingham

        According to the variant, a different subclass of the looper is used. The subclass contains the process specific stuff – like handling how many iterations.

        Something like:

        WHILE obj->has_next( ) EQ abap_true.

        obj->execute( ).

        ENDWHILE.

        (0) 

Leave a Reply