cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC TO FILE based on condition

Former Member
0 Kudos

Hi,

I am having IDOC to Ftp scenario, where i need to send the IDOC on condition.

1. In IDOC there is a field Location, based on this field the target files has to be created.

ex:-

1. for Location India ---> file has to be created in INDIAN folder

2. for Location USA ---> file has to be created in USA folder

3. 2. for Location Uk ---> file has to be created in UK folder etc.......

Like this there are nearly 20 folders where i need to create at the target side, based on the location field the fied has to be created at the respective folder automatically.

When i trigger the IDOC with the Location INDIA, automatically the file has to get created in INDIAN FOLDER.

Please help me...

cheers

nissi

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I have worked on such scenario.

I will give you brief detail.

Create N number of Service INterface (Number of countries). Create multiple Operation mapping. Then in the Interface Determination put the condition for the filed which carry Country Name and then different channels can route them to different folder using multiple Receiver Agreement and Receiver Channel.

Hope this approach suits you.

Regards....

Former Member
0 Kudos

Hi ,

All your folders are on one FTP machine? or on defferent FTP Machines?

1. IF floders are on different FTP machines then you can use condition in Receiver Determination and use multiple Communication channels to place the files.

2. If folders are on one FTP Machine : You can use the Variable Substituion using location field for Targer Directory .

Former Member
0 Kudos

Hi SKumar,

I use the udf but not files are created dynamically at the respective folders, All folders are at One FTP only. How can we use variable substitution for this. Can you please make it clear.

Regards,

Joshua.

Former Member
0 Kudos

Hi ,

Define a variable for a field for location in Variable Substituion and get the value dynamically which you can use in Target Directory path.

eg: in Variable Substitution var1 = payload: MT_Data, 1, Location, 1

Target Directory : /Output/%var1%

naveen_chichili
Active Contributor
0 Kudos

Hi Nissi,

Check this [Link|http://wiki.sdn.sap.com/wiki/display/NWTech/OneIDOCtoMultipleFilessendingtoMultiplefoldersoftheFTPusingsingleCommunicationChannel(SAPXI-PIProcess+Integration)].

thanks and Regards,

Naveen

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nissi,

Could you please kindly look into this blog

/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping

Hope this helps.

regards

Anupam

Former Member
0 Kudos

Hi Anupam,

I checked the link u have sent, but in my scenario i am not able to compare with your link, i am just confused, because i am new to this xi, but dont get me wrong in suggesting me.

in my case my based on the Field Location, the file has to generate in respective Folder. how can i with this requirement kindly suggest me.

Nissi

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

Write dynamic configuration UDF to pass directory based on input field.

Regards,

Raj

Former Member
0 Kudos

Hi Raj,

could you please send me the udf code which is similar to that, i am new to XI.

rajasekhar_reddy14
Active Contributor
0 Kudos

Anupam already provided link please refer that...

former_member854360
Active Contributor
0 Kudos
public String dynamicDirectoryName(String Location, Container container) throws StreamTransformationException
{ 
        String Directory;
        String  inputFileName;
		


DynamicConfiguration conf = (DynamicConfiguration) container
					.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);


DynamicConfigurationKey key2 =  DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

Directory = conf.get(key2);

If(Location.equals("India")
{
Directory = "/India/";
}
else if(Location.equals("Austrlia"))
{
Directory = "/Austrlia/";
}
conf.put(key2,Directory);

return Directory;
 }

catch(Exception e) 

{ 

     String exception = e.toString(); 

      return exception; 

}
Former Member
0 Kudos

chk this...(this will suits ur req):

/people/madanmohan.agrawal/blog/2009/05/20/combining-three-different-aspects-of-pi-asma-af-module-and-variable-substitution-in-one-shot

in the above blog instead of "File" name parameter using "Directory" and adjust the code accordingly....

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");

Former Member
0 Kudos

Hi Roy,

Thanks for your code, its very useful and suits to my requirement. But i am having folders already in my target file system.

Based upon the location ID . directly the the file should be placed in the respective folder.

please find the below code and suggest me if any changes to be done.

**************************************************************************************************************

public String dynamicDirectoryName(String Location, Container container) throws StreamTransformationException

{

String Directory;

String inputFileName;

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

//DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

//Directory = conf.put(key1,location);

inputFileName = con.put(key2,location);

//Directory = conf.get(key1);

inputFileName = conf.get(key2);

If(inputFileName.equals("INDIA")

{

con.put(key2,"INDIA");

}

else if(inputFileName.equals("AUSTRALIA"))

{

con.put(key2,"AUSTRALIA");

}

else

{

return "";

}

former_member854360
Active Contributor
0 Kudos

Hi,

Ya it will put the files dynamically in those folders which you have already created in target system.

It will not create any new folder.

con.put(key2,"FOLDERPATH");