7. Manage a Mail Export Action

A mail export action sends the data of a table or view by mail as soon as an application reaches a certain status (action type export_mail).

Make sure that the application and the export definitions exist:

The mail subject and body are taken from a mail template in REDADM.ADM_MAIL_PARAMS. Templates for all trigger types are delivered with RED (e.g. app_notify_final); own templates are created with API_REDADM.SET_MAIL_PARAM.

7.1. Add a Mail Export Action to an Application

Use API_REDADM.ADD_APP_ACT_EXP_MAIL. Besides application, action name, export, mail template, and recipients, the following parameters control when the action runs (see Triggering Actions):

p_finished_type

The status that triggers the action: LOADED, PRELIM, PRELIM_DQ, FINAL, FINAL_DQ, or MAT. The DQ-aware types only start the action if the data quality status is OK and are recommended for exports.

p_valid_from_bdate

The first business date for which the action runs.

p_active

Activates or deactivates the action.

p_run_once

If true, the action runs only once per business date; if false, it runs again when the data of the application changes later.

p_run_delay

Delay in seconds after the last data change before the action is queued.

p_bdate_retention and p_bdate_retention_future

Trigger window in days backwards and forwards from today; business dates outside the window are not triggered. Negative values mean unlimited.

p_cal_name and p_cal_key

Optional calendar that restricts the action, e.g. to business days.

The following example sends the export ‘test_exp’ with the template app_notify_final to testuser@test.at, 60 seconds after the final status of a business date has been reached. It runs only once per business date, from 2024-08-01, and not for business dates older than 3 days. The action is created inactive.

Example: Add the Mail Export Action ‘tst_act’

 1EXECUTE SCRIPT API_REDADM.ADD_APP_ACT_EXP_MAIL(
 2    'TEST_APP'            -- p_app_name
 3   ,'tst_act'             -- p_action_name
 4   ,'test action'         -- p_description
 5   ,'FINAL'               -- p_finished_type
 6   ,'test_exp'            -- p_exp_name
 7   ,'app_notify_final'    -- p_mail_template
 8   ,'testuser@test.at'    -- p_recipients
 9   ,'2024-08-01'          -- p_valid_from_bdate
10   ,false                 -- p_active
11   ,true                  -- p_run_once
12   ,60                    -- p_run_delay
13   ,3                     -- p_bdate_retention
14   ,null                  -- p_cal_name
15   ,null                  -- p_cal_key
16   ,0                     -- p_bdate_retention_future
17);

The action is stored in REDADM.RED_APP_ACTIONS:

APP_NAME

ACTION_NAME

FINISHED_TYPE

ACTION_TYPE

ACTION_PAR1

ACTION_PAR2

ACTION_PAR3

VALID_FROM_BDATE

ACTIVE

RUN_ONCE

RUN_DELAY

BDATE_RETENTION

BDATE_RETENTION_FUTURE

TEST_APP

tst_act

FINAL

export_mail

test_exp

app_notify_final

testuser@test.at

2024-08-01

false

true

60

3

0

7.2. Modify a Mail Export Action

To modify the action, use API_REDADM.MODIFY_APP_ACT_EXP_MAIL. NULL leaves a parameter unchanged, while a blank (’ ‘) restores its default value.

In the following example the action is activated and the DQ-aware trigger type FINAL_DQ is used.

Example: Activate the Action and Wait for the Data Quality Check

 1EXECUTE SCRIPT API_REDADM.MODIFY_APP_ACT_EXP_MAIL(
 2    'TEST_APP'            -- p_app_name
 3   ,'tst_act'             -- p_action_name
 4   ,null                  -- p_description
 5   ,'FINAL_DQ'            -- p_finished_type
 6   ,null                  -- p_exp_name
 7   ,null                  -- p_mail_template
 8   ,null                  -- p_recipients
 9   ,null                  -- p_valid_from_bdate
10   ,true                  -- p_active
11   ,null                  -- p_run_once
12   ,null                  -- p_run_delay
13   ,null                  -- p_bdate_retention
14   ,null                  -- p_cal_name
15   ,null                  -- p_cal_key
16   ,null                  -- p_bdate_retention_future
17);

The entry in REDADM.RED_APP_ACTIONS has changed:

APP_NAME

ACTION_NAME

FINISHED_TYPE

ACTION_TYPE

ACTION_PAR1

ACTION_PAR2

ACTION_PAR3

VALID_FROM_BDATE

ACTIVE

RUN_ONCE

RUN_DELAY

BDATE_RETENTION

BDATE_RETENTION_FUTURE

TEST_APP

tst_act

FINAL_DQ

export_mail

test_exp

app_notify_final

testuser@test.at

2024-08-01

true

true

60

3

0

To switch an action on or off without changing other settings, use API_REDADM.TOGGLE_APP_ACTION. The runs of an action can be monitored in REDADM.STA_APP_ACTION_STATUS and REDADM.STA_APP_ACTION_DETAIL.

7.3. Remove a Mail Export Action

Remove an application action with API_REDADM.REMOVE_APP_ACTION.

Example: Remove the Action ‘tst_act’

1EXECUTE SCRIPT API_REDADM.REMOVE_APP_ACTION(
2    'TEST_APP'            -- p_app_name
3   ,'tst_act'             -- p_action_name
4);

The action is removed from REDADM.RED_APP_ACTIONS.