Step 4 Define iiiTUTSEQ06 Processing Sequence

LANSA Composer

Step 4. Define iiiTUTSEQ06 Processing Sequence

LIC008 - Processing via Email

In this step you will create a processing sequence to do the following:

  • Assign – assign variable = OK
  • While – loop while variable = OK
  • Activity – Get single email from server via POP3
  • If &FROMADDRESS * NE ''

          -   Transform – Extract Employee file to CSV

          -   Assign &TONAME = 'Personnel Dept LANSA'

          -   Activity – text substitute – build email body

          -   Activity – Send email response via SMTP

  • Else
  • Terminate

First you will create a text skeleton which will later be used by a text substitute action to create the response email body text.

1.  Open Notepad and create the response text skeleton shown below:

2.  Save this to the IBM i IFS as:

Notes:
  • Notepad will automatically add a txt filename extension
  • This tutorial path can be found under Administration & Housekeeping / System settings / Tutorial files
  • The value %%PARM.TONAME%% and %%PARM.DEPARTMENT%% will be replaced by the Text Substitute action you will include in the processing sequence.

3.  On the Navigator panel select  Definitions / Processing sequences. Click the button to create a new Processing Sequence. The Processing sequence editor will open immediately.

4.  Start defining the processing sequence by selecting the Palette tab (top left) and dragging and dropping the Assign processing directive on to the Details tab. Assign the value 'OK' to a variable &FLAG_WHILE. This will be used to control the While loop.

5.  Next drop a While loop into the processing sequence following the Assign activity. Set the condition to &FLAG_WHILE = 'OK'. The loop will later be terminated by an If condition.

     The While will be highlighted as an error since there is nothing inside the loop at the moment.

6.  Select the Activities tab (top left) and drop the MAIL_RECEIVE activity into the processing sequence. Locate MAIL_RECEIVE in the Email group.

     This must be within the While loop. You can adjust it to the correct level if necessary, using the buttons.

7.  Select the Configurations tab (top left)

a.  Drop the iiiTUT_POP3 – Tutorial POP3 configuration into the Inbound POP3 Mail configuration ID.  You defined this in Step 2.

b.  Set the Subject of email to a value of &DEPARTMENT. The email subject line will contain a department code such as "ADM" which will be used to select employees from the file and output to the CSV file.

c.  In the FROMADDRESS parameter, type &RCVFROM.

See below:

8.   your processing sequence.

     Ignore the error and warning messages. You will complete the processing sequence definition in the following steps.

9.  Once again select the Palette tab (top left) and drop an If directive after the EMAIL_RECEIVE activity. Set the condition to &RCVFROM *NE ''. (i.e. RCVFROM is not equal blank) RCVFROM is returned by MAIL_RECEIVE. It will be blank if no email is found.

     Your processing sequence should now look like the following:

 

10. Select the Transformations tab (top left)

a.  Drop the iiiTUTMAP02 which you created earlier at the end of the processing sequence. Make sure it is positioned within the If loop and adjust if necessary using the promote/demote buttons.

b.  Select the Configurations tab (top left). Drop the Database configuration  iiiTUTDEMO which you created earlier into the EARTHSourceConnection parameter.

c.  Select the Variables tab (top left) and drop the DEPARTMENT variable into the Department_InSourceParameter. We used this variable for the Subject line on the MAIL_RECEIVE activity.

d.  Set the TextfileTargetFilename to

     /LANSA_Composer_licpgmlib/lic/Tutorial/_SentEmail/iii_EmployeeInfo.csv

     Your processing sequence should now look like the following:

11. Save your processing sequence.

12. Select the Palette tab (top left) and drop an Assign directive at the end of the  processing sequence. This will be used to set a value to a variable TONAME which will be merged into the response email text. Complete the expression:

     &TONAME = 'Personnel Administrator'

     Your processing sequence should now look like the following:

 

13. Select the Activities tab (top left) and drop the TEXT_SUBSTITUTE activity at the end of the processing sequence, as shown below:

a.  Complete the Path & filename of skeleton as:

'/LANSA_Composer_licpgmlib/lic/Tutorial/iii_EmployeeInfo.txt'

b.  Complete the Path & filename for expanded text as:

'/LANSA_Composer_licpgmlib/lic/Tutorial/_SentEmail/iii_EmployeeInfo.txt'

14.Select the Activities tab (top left) and drop the MAIL_SEND activity at the end of the processing sequence.

a.  Select the Configurations tab (top left) and drop your iii_INQ_EMP SMTP email details configuration into the SMTP Mail details configuration ID  parameter

b.  Drop the iiiSMTPID Tutorial SMTP configuration into the SMTP mail server configuration parameter.

c.  Set the Body text path and filename to:

   /LANSA_Composer_licpgmlib/lic/Tutorial/_SentEmail/iii_EmployeeInfo.txt

d.  Set the Path and filename for email attachments to:

   /LANSA_Composer_licpgmlib/lic/Tutorial/_SentEmail/iii_EmployeeInfo.csv

eIn the TOADDRESS parameter, type &RCVFROM

f.In the SMTPSUBJECT parameter, type Employee List Request

     Your processing sequence should now look like the following:

 

15. Save your processing sequence.

16. Select the Palette tab (top left) and drop an Else processing directive into the processing sequence. Then drop a Terminate below the Else. Use the Promote / Demote buttons if necessary to position these correctly. Your Processing sequence should now look like the following:

17. Use the button to save your processing sequence.

 

18. Review the Version History tab for the Processing Sequence iiiTUTSEQ06. This will contain the versions saved during this exercise. Note: you can View any of these versions. Restore would make the selected version the current version.

19. Use your email account to send an email request. In the subject line, enter a department code (for example ADM, AUD or FLT ). Send it to the second email account which you specified as the FROMADDRESS in theEMAIL_RECEIVE activity.

20. Use the button to open the run dialogue and then click the Run button to run it. If your processing sequence is correct, your log will look like the following:

 

21. Check the inbox for your email account which you specified in your iii_INQ_EMP SMTP Email Configuration. You should have a response email with the file iii_EmployeeInfo.csv attached. Open this in Excel and check that it contains the expected list of employees.

22. Send a number of email requests for different departments (for example, ADM, FLT, AUD) and run your processing sequence again. Check your email account inbox, which should contain a response for each request, with a CSV file attachment containing employees for the requested department.

     You have now completed this exercise.