Hello! I've been having trouble with my queries in the Accounts Payable Case Study Training. Specificaclly, in the section 'Transform - Add an Activity: Set or Remove Payment Block'. I've been able to insert all the other activities without any problems, but I'm stuck at this one.
Here are the instructions:
Here is the codes I've tried at first:
```
INSERT INTO _CEL_AP_ACTIVITIES
(
_CASE_KEY
, _ACTIVITY_EN
, _EVENTTIME
, _SORTING
)
SELECT
BSEG.MANDT||BSEG.BUKRS||BSEG.BELNR||BSEG.GJAHR||BSEG.BUZEI AS _CASE_KEY
, CASE
WHEN CDPOS.VALUE_NEW IS NULL THEN 'Remove payment block'
WHEN CDPOS.VALUE_OLD IS NULL THEN 'Set payment block'
END AS _ACTIVITY_EN
, CAST(CDHDR.UDATE || CDHDR.UTIME AS TIMESTAMP) AS _EVENTTIME
, CASE
WHEN CDPOS.VALUE_OLD IS NULL THEN 20
WHEN CDPOS.VALUE_NEW IS NULL THEN 30
END AS _SORTING
FROM BSEG AS BSEG
JOIN BKPF AS BKPF ON 1=1
AND BSEG.MANDT=BKPF.MANDT
AND BSEG.BUKRS=BKPF.BUKRS
AND BSEG.BELNR=BKPF.BELNR
AND BSEG.GJAHR=BKPF.GJAHR
AND BSEG.BSCHL = '31'
JOIN CDPOS AS CDPOS ON 1=1
AND BSEG.MANDT=CDPOS.MANDANT
AND CDPOS.VALUE_NEW IS NULL OR CDPOS.VALUE_OLD IS NULL
AND CDPOS.FNAME = 'ZLSPR'
JOIN CDHDR AS CDHDR ON 1=1
AND BSEG.MANDT=CDHDR.MANDANT
;
```
Than I asked a friend for help and we came up with this new code:
```
INSERT INTO _CEL_AP_ACTIVITIES(_CASE_KEY, _ACTIVITY_EN, _EVENTTIME, _SORTING)
SELECT
TAB_0._ACTIVITY_EN,
TAB_0._CASE_KEY,
CAST(CDHDR.UDATE || CDHDR.UTIME AS TIMESTAMP) AS _EVENTTIME,
CASE
WHEN TAB_0._ACTIVITY_EN = 'Set payment block' THEN 20
WHEN TAB_0._ACTIVITY_EN = 'Remove payment block' THEN 30
END AS _SORTING
FROM (SELECT
(BSEG.MANDT||BSEG.BUKRS||BSEG.BELNR||BSEG.GJAHR||BSEG.BUZEI) AS _CASE_KEY,
CASE
WHEN CDPOS.VALUE_NEW IS NULL THEN 'Remove payment block'
WHEN CDPOS.VALUE_OLD IS NULL THEN 'Set payment block'
END AS _ACTIVITY_EN,
BSEG.MANDT AS MANDT
FROM BSEG
JOIN CDPOS ON BSEG.MANDT = CDPOS.MANDANT
AND (CDPOS.VALUE_NEW IS NULL OR CDPOS.VALUE_OLD IS NULL)
AND CDPOS.FNAME = 'ZLSPR'
AND BSEG.BSCHL = '31') AS TAB_0
JOIN CDHDR ON TAB_0.MANDT=CDHDR.MANDANT;
```
For some reason, I keep getting the following error:
`Execution error: ERROR: Execution time exceeded run time cap of 00:20`
I don't know what's going on. Can anybody help me understand what I should do to make the query work?