Tag Archives: process chain

SAP BW Master Data Deletion Program

Up to BW 7.3 included program RSDMD_DEL_BACKGROUND could be used to run MD deletions within Process Chains.
However already in 7.3 this program is obsolete and is to be replaced by a new program: RSDMDD_DELETE_BATCH. See note “1705824 – Old master data deletion is obsolete“.

The parameters of the new program are different, and you can find an explanation in the following post: http://scn.sap.com/docs/DOC-33041

ABAP Program to do mass deletion of Process Chains

The following small program allows you to do a mass deletion of process chains.

I tried to remove all popup messages that occur during PC deletion, but there is stil some problem with that and you have to press OK at each process chain.

You can download the code of the programhere in Saplink format.
Download – PROG_ZBW_RSPC_MASS_DELETE.slnk – 3.3 kB – 408   downloads

Process Chain Statistics Extractor – 0TCT_IS21

0TCT_IS21  is a “Technical Content” extractor that will retrieve statistics from the Process Chainws execution logs. These logs are stored in the following SAP Tables:

  • RSPCPROCESSLOG
  • RSPCLOGCHAIN

The 0TCT_IS21 extractor is a FM based extractor calling the function module RSDDK_BIW_GET_DATA.

The FM is a ‘multi purpose’ function that is used by several TCT extractors. Based on the Data Source it will call the appropriate data extraction subroutine; the one for 0TCT_IS21 is  “PERFORM get_fact_ds21”.

Analysing the  extractor in my system ( I am working on SAP BW 7.30 -SAPKW73008), I noticed the following errors in the extractor itself and in the Transfer Rules / Update Rules to cube 0TCT_C21:

  • Inconsistent conversion of start / end timestamps to start / end date and times
  • Calculation of the overall duration of the process chain is incorrect
  • Calculation of the number of steps in is incorrect

 

Inconsistent conversion of start / end timestamps to start / end date and times

The PC Log Tables provide start and end timestamps. The transfer rule from Data Source 0TCT_DS21 to Infocube 0TCT_C21 derives the start and end time via abap conversion routines. The proble is that start time is converted to the local time zone while end time is converted to UTC.

Code of the start time routine:

FORM COMPUTE_TCTSTRTTIM
  USING    RECORD_NO LIKE SY-TABIX
           TRAN_STRUCTURE TYPE TRANSFER_STRUCTURE
           G_S_MINFO TYPE RSSM_S_MINFO
  CHANGING RESULT TYPE /BI0/OITCTSTRTTIM
           G_T_ERRORLOG TYPE rssm_t_errorlog_int
           RETURNCODE LIKE SY-SUBRC
           ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel datapackage
*$*$ begin of routine - insert your code only below this line        *-*
* DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
  DATA: l_start_time TYPE t.

  CONVERT TIME STAMP TRAN_STRUCTURE-starttimestamp TIME ZONE sy-zonlo
          INTO TIME l_start_time.

  RESULT = l_start_time.
* returncode <> 0 means skip this record
  RETURNCODE = 0.
* abort <> 0 means skip whole data package !!!
  ABORT = 0.
*$*$ end of routine - insert your code only before this line         *-*
ENDFORM.

Code of the end time routine:

FORM COMPUTE_TCTENDTIM
  USING    RECORD_NO LIKE SY-TABIX
           TRAN_STRUCTURE TYPE TRANSFER_STRUCTURE
           G_S_MINFO TYPE RSSM_S_MINFO
  CHANGING RESULT TYPE /BI0/OITCTENDTIM
           G_T_ERRORLOG TYPE rssm_t_errorlog_int
           RETURNCODE LIKE SY-SUBRC
           ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel datapackage
*$*$ begin of routine - insert your code only below this line        *-*
* DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
  DATA: l_end_time TYPE t,
        l_tzone TYPE sy-zonlo.

  l_tzone = 'UTC'.  " This needs to be changed to sy-zonlo.
  CONVERT TIME STAMP TRAN_STRUCTURE-endtimestamp TIME ZONE l_tzone
          INTO TIME l_end_time.

  RESULT = l_end_time.
* returncode <> 0 means skip this record
  RETURNCODE = 0.
* abort <> 0 means skip whole data package !!!
  ABORT = 0.
*$*$ end of routine - insert your code only before this line         *-*
ENDFORM.

The transfer rule routines converts the timestamps in similar ways for Start Time (0TCTSTRTTIM) , End Time (0TCTENDTIM), Start Time as Key Figure (0TCTSTIMEK) and Time (0TIME) and also for the dates 0CALDAY, 0TCTSTRTDAT, 0TCTENDDAT.

So if you want to have consistency between all times and dates, you should check all the routines for the conversions of the following elements and replace ‘UTC’ by sy-zonlo on each of them (7 routines in total).

Calculation of the number of steps in is incorrect

The characteristic 0TCTSTAUIK (“Frequency”) counts the number of occurrences of steps in process chains. For individual records inthe 0TCT_C21 cube it should always be 1. For the record summarizing the PC execution (the one with 0TCTPRCSTYP = “#’), it should be the sum of the steps in the process chain. However the 0TCT_DS21 extractor performs the calculation incorrectly and returns a negative number equal to 1 minus the number of steps.

There could be several ways to correct this (apart from asking SAP to do the correction…) One way is by creating an user exit that recalculates the field in the extractor, or by correcting the value in the start routine of the update rule.

Calculation of the overall duration of the process chain is incorrect

Same as above. Characteristic 0TCTDURATION is incorrect for the record summarizing the whole PC execution.  Same solutions as above.

RSDMD_DEL_BACKGROUND and Transactional Infocubes

Program RSDMD_DEL_BACKGROUND is used to delete MD in BW. This program can be included in a PC to regularly clean up the “unused” master data entries of a characteristic. By unused we mean those entries whose SID is not referenced in any InfoProvider.

If you schedule such deletions on a characteristic that is used in a Transactional Infocube you might experience errors when there is an open (tellow) request in the Transactional Infocube.

Note “Note 1258548 – Master data cannot be deleted” expalis this.

One solution to this is probably to switch to load mode before running the deletion.

 

Find which parent Process Chains call a given local child Process Chain

ParentChild

During the course of BW daily load maintenance I often need to figure out which Process Chains are calling a given Process Chain.

One way to locate all the parent Process Chains that contain a Process Step of type “Local Process Chain” that start a given ‘child”  Process Chain is to look up the information in table RSPCCHAIN. (Please let me know if there is a standard RSA1 approach to do the same that I missed out). 

First identify the  name of the start process variant in PC you want to locate. This is the technical name of the topmost step (start chain) in your child process chain.

Once you have found the name of the start process variant, do a SE16 search on table RSPCCHAIN with the following field selections
TYPE = CHAIN
VARIANTE = Start process variant technical name
OBJVERS  = ‘A’

All the resulting CHAIN_ID values correspond to the names of the parent process chains

The following very simple program does just what is described above.
Download – NUGG_ZBI_PROCESS_CHAINS_PARENTS.nugg –   6.3 kB – Invalid download ID.   downloads

Source code (1 program + 2 FM):

.
*&---------------------------------------------------------------------*
*& Report  ZBI_PROCESS_CHAINS_PARENTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  zbi_process_chains_parents.

data:
      lt_chains type bapiret2_t,
      ls_chain type bapiret2,
      ls_rspcchain type rspcchain,
      lt_rspcchain type standard table of rspcchain.

select-options s_pc for ls_rspcchain-chain_id.
select * from rspcchain into table lt_rspcchain
  where objvers = 'A'
    and type = 'TRIGGER'
    and chain_id in s_pc.

loop at lt_rspcchain into ls_rspcchain.
  ls_chain-message_v1 = ls_rspcchain-chain_id.
  append ls_chain to lt_chains.
endloop.

call function 'ZBW_PC_ANCESTORS_GET'
  changing
    ct_chains = lt_chains.

loop at lt_chains into ls_chain.
  if ls_chain-row = '0'.
    new-line.skip.
  endif.
    write: / '  '.
  do ls_chain-row times.
    write: '  '.
  enddo.
  if ls_chain-row > 0.
    write: '<=='.
  endif.
  write: ls_chain-message_v1. "', '|'.
*    WRITE: ls_chain-row, '|'.
endloop.
.

.

function zbw_pc_ancestors_get.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  CHANGING
*"     REFERENCE(CT_CHAINS) TYPE  BAPIRET2_T
*"----------------------------------------------------------------------

  data:
        ls_parent type rspc_chain,
        ls_child type rspc_chain,
        lt_parents type rsb_t_pcchain,
        l_recurse type flag,
        ls_chain type bapiret2,
        ls_maxlvl type bapiret2,
        ls_newlvl type bapiret2,
        lt_chains_new type bapiret2_t,
        lt_chains_oldest type bapiret2_t.

  lt_chains_oldest = ct_chains.
  sort lt_chains_oldest by row descending.
  read table lt_chains_oldest into ls_maxlvl index 1.
  ls_newlvl-row = ls_maxlvl-row + 1.
  loop at ct_chains into ls_chain.
    append ls_chain to lt_chains_new.
    if ls_chain-row = ls_maxlvl-row.
      ls_child = ls_chain-message_v1.
      call function 'ZBW_PC_PARENTS_GET'
        exporting
          i_chain_id = ls_child
        importing
          et_parents = lt_parents.
      loop at lt_parents into ls_parent.
        ls_chain-message_v1 = ls_parent.
        ls_chain-row = ls_newlvl-row.
        append ls_chain to lt_chains_new.
        l_recurse = 'X'.
      endloop.
    endif.
  endloop.

  if l_recurse = 'X'.
    call function 'ZBW_PC_ANCESTORS_GET'
      changing
        ct_chains = lt_chains_new.
  endif.
    ct_chains = lt_chains_new.
endfunction.

.

function zbw_pc_parents_get.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_CHAIN_ID) TYPE  RSPC_CHAIN
*"  EXPORTING
*"     REFERENCE(ET_PARENTS) TYPE  RSB_T_PCCHAIN
*"----------------------------------------------------------------------

data:
      lt_rspcchain type standard table of rspcchain,
      ls_rspcchain_trigger type rspcchain,
      ls_rspcchain type rspcchain.

refresh et_parents.

" 1st get the corresponding Start Process variants

select * from rspcchain into table lt_rspcchain
  where objvers = 'A'
    and type = 'TRIGGER'
    and chain_id = i_chain_id.

loop at lt_rspcchain into ls_rspcchain_trigger.

  select * from rspcchain into ls_rspcchain
    where objvers = 'A'
      and type = 'CHAIN'
      and variante = ls_rspcchain_trigger-variante.

    append ls_rspcchain-chain_id to et_parents.
  endselect.
endloop.

endfunction.

Process Chain FM API

RSPC_API_GET_CHAINS (Popup to select Process Chain)

RSPC_CHAIN_START (To start Process Chain of type API)

Sample program with PC selection and scheduling

REPORT ZBW_PC_MANAGER.

data: l_t_chains type standard table of RSPCCHAINT.
data: l_s_chains type RSPCCHAINT.
data: l_logid type rspc_logid.

CALL FUNCTION ‘RSPC_API_GET_CHAINS’
EXPORTING
I_WITH_DIALOG = ‘X’
* I_SEL_CHAIN =
* I_SEL_TXTLG =
TABLES
E_T_CHAINS = l_t_chains
EXCEPTIONS
FAILED = 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.

loop at l_t_chains into l_s_chains.
CALL FUNCTION ‘RSPC_CHAIN_START’
EXPORTING
I_CHAIN = l_s_chains-chain_id
* I_T_VARIABLES =
* I_SYNCHRONOUS =
* I_SIMULATE =
I_NOPLAN = ‘W’
* I_DONT_WAIT =
IMPORTING
E_LOGID = l_logid

Program to check the start conditions of your Process Chains

The programs below list the start conditions of the selected Process Chains, and provide a list of the Process Chains scheduled as background jobs.

List the start conditions of the Process Chains: Download – NUGG_ZBI_PROCESS_CHAINS_STARTCOND.nugg –  3.1 kB – 359   downloads

List the scheduled Process Chains: Download – NUGG_ZBI_SCH_PROCESS_CHAINS.nugg –  2.8 kB – 348   downloads

Process Chains

Must read docs:

Tips, Tricks and Techniques for Optimal Use of Process Chains (pdf)
Process Chain Tips

Selective deletion of InfoCube in Process chain – http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/603a9558-0af1-2b10-86a3-c685c60071bc?overridelayout=true

! Generated Program is a SAP object. You need an object key to transport.

Access ABAP + Decisions

http://scn.sap.com/docs/DOC-31355 – ABAP Process Type (call ABAP Program)

http://scn.sap.com/docs/DOC-27399 – Multiple Decsision Type (possibliity of creating custom func in abap)

Setting to avoid that  Process Chains with Immediate Scheduling start after being transported in target system
Note 1233327 – Correction: Scheduling of immediate start for transport
Insert the following into the RSADMIN table with ABAP program – SAP_RSADMIN_MAINTAIN:  Object = NO_TP_SCHEDULE_IMMEDIATE  Value = X