Scenario

LANSA Composer

Scenario

LIC011 - Email notification service

You are the owner of a notification service. You send e-mail notifications to your mailing list subscribers to inform them of new store sales or special offers as soon as they are published by the stores.  The stores will publish their sales information in xml files, and will place them in a special folder on their FTP servers designed for your access.

The xml file structure is defined by you, and same structure is used by all the stores. The xml file contains information such as store name, items on sale, each item name and price, and offer expiration date.

Objectives

To pull the sales information from each store's FTP server, process each file, and make a list of items on sale in a simple text file or CSV format.
Send an e-mail to the mailing list subscribers with a file containing the list of items on sale attached.

Steps

In order to achieve these objectives you will need to complete the following:

  • Step 1 - Design the XML & DTD file structure
  • Step 2 - Create "local" and "remote" folders
  • Step 3 - Create the transformation map
  • Step 4 - Define each store as a trading partner.
  • Step 5 – Create an FTP configuration for each store
  • Step 6 - Define text response file for the email body
  • Step 7 - Create the processing sequence
  • Step 8 – Run processing sequence and test

Guidance

1.  Use the XML & DTD created in the previous exercise as a guide

  • The XML file will contain details of products on offer for a single store
  • Consider the following structure for the XML:
    Offers
    Store Name
    Offer
     -  Product Number     -  Product Description     -  Price     -  Expiry Date
  • The XML file contains a number of lines for each Store name.
  • The dtd file should define the structure of the XML file and its data elements. See earlier exercise for an example and apply this to your store offers XML file. The XML file should refer to the dtd file.

2.  You will need to create these folders on the server:

  • an "iiiEmailAttch" folder to store your output CSV file
  • an "iiiStore_Local" folder to hold the XML files retrieved via FTP
  • a "remote" folder for each trading partner to hold the XML files which you will retrieve using FTP. For example folders named: iiiStore1_Remote, iiiStore2_Remote.

3.  Define a Transformation Map to merge text with values from the XML Store Offer file into a CSV file. The CSV file design will be done in MapForce

  • The output text file can be created as a CSV file with a single column, where you can concatenate the information into human readable text strings.
  • Each line should be constructed by concatenating text elements and variable values from the input XML file to produce a readable text string.
    For example, each line of your text file could be similar to:
    Store XYZ is offering ABC item on sale for $999.99 for a limited time only, offer valid until DDD.

     where XYZ, ABC and 999.99, DDD are extracted from XML file.

  • Consider the following steps toe define the transformation map in MapForce:

     -  Insert the XML Store Offer file

     -  Insert a text file (CSV) with a single string column

     -  Insert constants containing each piece of text required

     -  Use the CONCAT string function to build each row made up of constants and values from the XML file

     -  Link the output from the CONCAT function to the "row" in the CSV file

     -  Save and prepare your map.

4.  The stores will be defined as trading partners. Create new Trading Partners: iiiStore1, iiiStore2.

     Review Administration and Housekeeping / Code Maintenance / Trading partner installation-defined properties. As shipped, a property "EXAMPLE – Example installation-defined property" is defined. New Trading Partners will have this property, See the Properties tab for each trading partner.

     Put a unique value, such as iiiSTO, into each trading partner's Example property. Use this in your processing sequence to loop through all trading partners and select your trading partners only.

     Do not create default linked folders for the new trading partners.

5.  You will also need an FTP configuration for each store. Link the FTP configurations for each store's FTP server to a corresponding store (trading partner).

6.  MAIL_SEND: Assume the mailing list is handled by the e-mail service com[pany. You only need to send one email for each xml file received. Send each e-mail to a single address which represents the mailing list service.

7.  Define a text file which will be the body text in your sent email

8.  Create a processing sequence to do the following:

  • Loop through all trading partners

           - If trading partner Example property = "iiiSTO"

                - If trading partner FTPIN not equal blanks

                     - Retrieve XML offer file via FTP (saving into Stores_Local folder)

  • Directory List of iiiStores_Local

           - Loop through directory list

                - Use CONCAT to build path/filename for CSV file to be output by transform map

                - Run Transform Map

           - Directory list of iiiEmailAttch folder (contain output CSV files from transform map)

           - MAIL_SEND using text file. Attach CSV files based on directory list

           - Terminate.