cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a PCR inside another PCR

Former Member
0 Kudos

Hi Experts

I have a requirement where I should call a PCR in another PCR. Suppose ZWTM is a pcr which has T/F as return value.

It is used in another rule say ZKTM say by using PCYGZWTM. If ZWTM returns T then remaining branches of ZKTM has

to get executed. How can I capture the return value T/F of ZWTM inside rule ZKTM without IF and ENDIF.

Thanks in advance

Accepted Solutions (0)

Answers (3)

Answers (3)

jagan_gunja
Active Contributor
0 Kudos

This can be achieved as below:

1. Payroll pcr with a condition checking pcr ZWTM

1.1  lines in the initiating PCR

         P   PCY ZWTM *

      1      NUM=& ZTRU*            OBTAIN CONDITION FROM VAR. ZTRU

      2 D   NUM?0                       CONDITION FALSE?

*        Z    GCY ZWTT                  - NO, TRUE; GO TO PCR FOR TRUE

=       Z    GCY ZWTF                  -YES, FALSE, GO TO PCR FOR FALSE

1.2 PCR ZWTM   check condition and set true/false

               ZERO=&ZTRU*            SET VAR ZTRU TO 0, INDICATING FALSE CONDITION

....                                             Check condition - e.g., PSA, pay scale, etc.

....                                             If ok, set condition as true (NUM=1)

               NUM=1   ADDWT&ZTRU

2.  Time eval pcrs: You can use a utility time type, say ZTRU with zero or 1 to indicate true/false

2.1 calling pcr   

        P   PCY ZWTM *

        D   HRS=DZTRU  HRS?0        Cond.false?

*       Z   GCY ZWTT

=      Z    GCY ZWTF   

2.2 pcr ZWTM

               HRS=0    ADDDBZTRUZ              SET T/T ZTRU TO ZERO

....                                         Check condition - e.g., PSA, pay scale, etc.

               HRS=1    ADDWBZTRU

Note the char Z at the end of ADDDB op'n sets the current value of the t/t to the current value of HRS.

3. Alternatively,  following can be used in the calling pcr:

3.1 In the calling pcr, check conditions instead of in ZWTM pcr.

    e.g., check PA, PSA, contract type, P/T or F/T (as found in IT 7 or with emp.%.

     If condition is true, go to pcr ZWTT, else to ZWTF.

Please note:

a. If the first character in the column for an operation = '*' (asterisk), it is equivalent to using NEXTR, i.e., go to next line.  This can be used if you have a full PCR line with operations and you want to go to next line; in this case NEXTR can't be used.              

b. Remi's suggestion is correct but the lines can be used in a schema or sub-schema.  IF is a schema function but not an operation.

former_member193210
Active Contributor
0 Kudos

Hello Mani,

In Jagan's example, you would not have to create 2 other pcrs since ZWTM would be called by a Function other than IF, such as PIT.

In this scenario, instead of using Operation GCY, you could use Operation PAYTP, as in PAYTP F or PAYTP T, where F and T are the branches for False and True.

former_member193210
Active Contributor
0 Kudos

What Operation are you using to get those return values?

Note that if you are using Operation SCOND (Set Condition) in your pcr, then all the return values to your Queries (other Operations) must also use Operation SCOND and the pcr must be called by Function IF.

To answer your requirement, try copying the True and False parts of ZWTM into ZWTT and ZWTF, then modify your schema with the following

IF          ZWTM

ACTIO   ZWTT           (if ZWTM's condition is True)

ELSE

ACTIO   ZWTF           (if ZWTM's condition is False)

ENDIF

Former Member
0 Kudos

Hi,

Can you pls share ZWTM PCR?

You can use same PCR like this

ZWTM

     *

          ****

               Condition

                   True

                         PCY ZWTMT

                    False

                         PCY ZWTMF

     T

          ****

               True Logic

     F

          ****

               False Logic

Thanks,

Ketul