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.

Leave a Reply