Skip to Content
Technical Articles

Zero(0) byte trigger/control file creation for each main file, with name same as main data filename

Problem statement: After successful creation of main file, create a zero(0) byte trigger file with same name as main payload filename at receiver side.

Requirement

Create zero byte(empty file) trigger file at FTP/SFTP receiver side with a same name as main data file name.
Create Trigger file only if main data file is created at receiver side.

In this blog post I will be creating .xml file at receiver end with dynamic filename and after successful creation of this main .xml file, a corresponding 0 byte .trg file will be created at receiver end.

Syntax for Main Filename : (interface-name)+(unique-id)+.(main file-type)

Syntax for Trigger Filename : (interface-name)+(unique-id)+.(trigger file-type)

Sample Main Filename: PARTFAM_0000000000345678.xml

Sample Trigger Filename: PARTFAM_0000000000345678.trg

 

I am using UDF to achieve this requirement.

 

Design of interface will be as follow.

ESR PART

  • Create data type , message type and sender interface for sender(as per requirement)
  • Create data type, message type and receiver interface for main payload (eg. .xml,.csv file)
  • Create message mapping and Operation mapping (actual mapping for main payload)
  • Now create data type, message type and receiver interface for creation of trigger file.
  • Create message mapping and operation mapping for trigger file.

ID PART

  • One sender channel (IDOC/PROXY/REST etc- as per requirement)
  • Two receiver channels
  1. To place main data file
  2. To create 0 byte file with same name as the main file

Use below UDF to generate file name dynamically (you can use any constant or values coming from payload) to generate file name and its extension.

As per my requirement I have used 3 input arguments for constructing file name with its extension (in your case this can be achieved by using only one or two arguments by using concatenation of required values)

Map this UDF to root node of mapping

  1. Main mapping
  2. Please use Write empty file option from Empty-message handling tab so that empty message will get processed.
  3. Please use Write empty file option from Empty-message handling tab so that empty message will get processed.
    1. Trigger file mapping
      In Trigger file’s message mapping, map only root node of receiver side with UDF.Provide same input to UDF as given in main message mapping program.Configure ICO as below.

      • Assign sender channel in Inbound Processing tab
      • Add receiver system at Receiver tab
      • Assign both operation mapping and service interfaces in receiver interface tab.

      Refer below screen shot for the same.


      Please check the maintain order option as highlighted above, this will ensure that the main file will be created FIRST and after that only the TRIGGER file will be created at receiver end as per the SEQUENCE of operation mapping.

      Incase if any main message fails in SAP-PO due to mapping error,  the message for trigger( .trg) file will go in scheduled status in Message Monitor and will not be delivered until actual file is delivered to target system.

      • Now assign both of the communication channels in outbound processing tab.

      Please configure trigger file channel as below.

      • Assign target file path and give any name in file name tab as it will get overwritten by dynamic file name generated in UDF.
      • Please use Write empty file option from Empty-message handling tab so that empty message will get processed.
      • In advance tab use ASMA properties.
      • Below module is used to create empty (0 byte) file.

      Configure module tab as given below (Irrespective of any message type used) it is used to remove default XML tag and root node name from the file.

       

       

      For actual data file channel use the same configuration except module parameter.

      Conclusion – Once above configuration is in place you will be able to create zero byte trigger or control file for each main data file with same name.

      For example – If different ARTMAS Idocs for article master data are triggered from SAP as follows.
      IDOC number  – 1234 , 1235, 1236 etc
      Then at receiver side below files will get created.

      ArtilceMaster_1234.xml (main data file)
      ArtilceMaster_1234.trg (0 byte trigger file)

      ArtilceMaster_1235.xml (main data file)
      ArtilceMaster_1235.trg (0 byte trigger file)

      ArtilceMaster_1236.xml (main data file)
      ArtilceMaster_1236.trg (0 byte trigger file)

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