Skip to Content

This blog post explains about how to Monitor a Local or a Shared Folder for a file and process the contents of the File using SAP PCo and SAP MII. It uses an SAP PCo Agent called File Monitor Agent which is available in PCo 2.2 and above. It Works in both Notification and Query Mode

In PCo you define which folder is to be monitored. If the agent finds a file that meets the configuration criteria that you specified in the PCo, then it generates, for example, a notification message and sends it to the connected destination system. In this way you can transfer file contents to the destination system. You can also define specific actions to be done like Moving, Copying, Renaming the files.


Let us see step by step procedure using an example.

Creation of Source System

  • Go to SAP PCo Management Console
  • Click on Add New Source System.

/wp-content/uploads/2016/04/1_935378.png

  • Choose the Source System type as FileMonitorAgent and create one

/wp-content/uploads/2016/04/2_935379.png

  • After the Source System has been created, in the Settings Tab of the new Source System, Browse the folder you need to Monitor and enter the File Mask as needed, (in our case I am giving it as ‘*.csv’ to monitor csv files). default is “*.*”

/wp-content/uploads/2016/04/3_935380.jpg

  • And choose one of the File Handling Actions from the below Dropdown, (Default is DoNothing). In Case of Move, Copy or Rename, you must choose a Destination Folder using the Folder Browse button
    • You cannot choose a System Folder for Monitor and Destination,
    • You can obviously monitor a Network Folder which is shared from another system or server as well. In that case you can give the shared folder path in the Folder to monitor like (\\Servername\SharedFolderPath)
    • Check the Ignore unavailability of UNCFolders if you are using a network shared folder as, the network folder might be disconnected often which will stop the agent
  • In case if Authentication is needed to access the Folder if it is a Shared Folder, you can give the credentials in the Authentication Tab. Click to Test the Connection

/wp-content/uploads/2016/04/4_935387.png

  • Save the Changes

Creation of Destination System

  • Add the MII System as a New Destination System

/wp-content/uploads/2016/04/6_935391.png

  • Give SAP MII Server Details and Credentials and Save the Destination System

/wp-content/uploads/2016/04/7_935392.jpg

Creation of Agent Instance


  • Create an Agent Instance and choose the Source System as the “MonitorFolder”.

/wp-content/uploads/2016/04/81_935397.jpg

/wp-content/uploads/2016/04/82_935398.jpg

  • Once the Agent instance has been created, Go to Subscription Tab and add the tags to be monitored by following below steps
    • Click on Browse and a Tag Browser opens

              /wp-content/uploads/2016/04/9a_935399.jpg

    • Click on Browse again in the Browse Pop up so as to see the available Tags
    • Select them and Click “Add Selected Items” and Click OK

                  /wp-content/uploads/2016/04/9c_935401.jpg

    • Now the Subscription items have been added

               /wp-content/uploads/2016/04/9d_935412.jpg

  • Click on the Query ports Tab and Choose SAP MII as the Port Type and type an unused port of SAP MII Server from where the File Monitor Agent can be queried

/wp-content/uploads/2016/04/10_935413.jpg

  • Save the Agent Instance

Creation of Notification

  • Right Click on the Agent instance and Click on “Add Notification” and create a New Notification

     /wp-content/uploads/2016/04/12a_935417.jpg

     /wp-content/uploads/2016/04/12b_935418.jpg

  • In the trigger tab, Keep the Trigger Type as Always and check the Enabled checkbox.

         /wp-content/uploads/2016/04/13_935422.jpg

  • In the Output Tab, click the Generate Expressions to generate all the subscription items of the Agent.

     /wp-content/uploads/2016/04/14_935429.jpg

  • Meanwhile in SAP MII, Destination System, Create a Simple Transaction with XML Saver which can save the XML input from PCo Notification

          /wp-content/uploads/2016/04/15_935430.jpg

  • In the Destinations Tab, Add the Already configured SAP MII Destination System

     /wp-content/uploads/2016/04/16_935431.jpg

  • In the Destination Tab, Browse the already created transaction in SAP MII and map the Input Parameter Name

     /wp-content/uploads/2016/04/17_935438.jpg

  • Save the Changes.

Testing the Notification

  • Start the Agent

     /wp-content/uploads/2016/04/19_935440.jpg

  • Paste a CSV File in the folder which PCo is monitoring. As we are Moving the files, in few seconds we can see that the file is disappearing

     /wp-content/uploads/2016/04/20_935447.jpg

  • Now the Notification should have run automatically.
  • Now we can go and check the Workbench for a newly saved XML file which we received from PCo Notification

     /wp-content/uploads/2016/04/22_935448.jpg

  • Now MII has received the File Content through PCo File Monitor Notification, Which an MII expert can parse and use it as necessary

/wp-content/uploads/2016/04/23_935449.jpg

Query Mode

  • Create a PCo Dataserver in SAP MII.
  • Choose the Connector type as PCo Connector and Click Next
  • Enter PCo wsdl and Click Next and give credentials.
  • All the PCo Agents will appear, Choose the appropriate Agent

     /wp-content/uploads/2016/04/27_935460.jpg

  • Click Finish, Enable and Save the Data server.
  • Make sure that you have few files in the Folder which is being monitored by SAP PCo. Which means that it should not be in Move File Handling Action mode in the Source System

     /wp-content/uploads/2016/04/29_935451.jpg

  • Go to the SAP MII Workbench and create a PCo Query and choose the new Data Server
  • Choose “Tag Retrieve Query” mode and go to Tag Retrieve Query tab. The available Files in the Monitored folder will appear and you can select the files as needed.

     /wp-content/uploads/2016/04/31_935452.jpg

  • Execute the Query and check the result, as the different file contents will appear in different Rowsets.

     /wp-content/uploads/2016/04/32_935459.jpg

We can use other file types as also such as .txt, .log etc using File Monitor Agent

Regards,

Austin

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Shikhil Vyas

    Hey Austin,

    Great post and thanks for sharing your experience.

    Just a small query came to my mind when I was exploring File monitoring agent. Is there a way that we can read a file from a shared folder on Pco ( using Pco expression) and based on validation move the file to another archive / another folder.
    As only notification has trigger expression , the file is moved to another location and then message is sent to MII.

    Is there any alternative or work around where we should move the files from a shared folder location to a different archive folder location, only if the file and content is valid ?

    Regards

    Shikhil

    (0) 
    1. Austin Jacob Post author

      Hi,

      Shikhil, Thanks for your response. File Handling based on the File Content validation is not possible. But, as you said notification can be controlled based on file content in Notification Expression.

      Regards,

      Austin

      (0) 

Leave a Reply