cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic configuration not working in Java mapping

Former Member
0 Kudos

Hi All,

I have a scenario where i am using java mapping. In this i am doing following

1)Read file name from input message header

2)set file name in output message Header

3) set Directory name in output message Header

i have used following code .. but iit is not working... when i test end to end... in reciver communication channel it is failing stating " message failed as "Directory is not set in Header. Also i checked in SXMB_MONI "dynamic configuration".It is not showing Directory.

this is code.

public void transform(TransformationInput transformationInput,TransformationOutput transformationOutput)
			throws StreamTransformationException {
		
		
			private Map para;
			String Directory ;
			String  inputFileName;
			String var1 = "ABC";

			para = transformationInput.getInputHeader().getAll();
			

			
			DynamicConfiguration conf = (DynamicConfiguration) para
					.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
			
			DynamicConfigurationKey keyFileName1 = DynamicConfigurationKey
			.create("http://sap.com/xi/XI/System/File", "FileName");
	                inputFileName = conf.get(keyFileName1); 

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

			
			DynamicConfigurationKey keyDirecory = DynamicConfigurationKey
					.create("http://sap.com/xi/XI/System/File", "Directory");
			
					
			
			
			Directory = "tmp/"+var1; 
			
			
			conf.put(keyFilename,inputFileName);
			
			conf.put(keyDirecory, Directory);
                      }

I am in PI 7.1 , and in eclipse its showing warning that Para is not used.

Can anyone show some lights.

Also is there any way to debug this?? like is there any function by which i can write the trace for each step to see those in MONI.

Accepted Solutions (0)

Answers (5)

Answers (5)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Method name: public void createDirectory(Resultlist result, Container container)throws StreamTransformationException

//Use Simple UDF and do the following lines

String Directory ;

String inputFileName;

String var1 = "ABC";

DynamicConfiguration conf = container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keyFileName1 = DynamicConfigurationKey

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

inputFileName = conf.get(keyFileName1);

DynamicConfigurationKey keyFilename = DynamicConfigurationKey

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

DynamicConfigurationKey keyDirecory = DynamicConfigurationKey

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

Directory = "tmp/"+var1;

conf.put(keyFilename,inputFileName);

conf.put(keyDirecory, Directory);

}

and remove these 3 lines

//private Map para;

//para = transformationInput.getInputHeader().getAll();

//DynamicConfiguration conf = (DynamicConfiguration) para.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION

>>I am in PI 7.1 , and in eclipse its showing warning that Para is not used.Can anyone show some lights.

You can simply remove declaring Map Para line... The eclipse gives warning because you dont assign values for it and you are trying to use...

For using the same input file name in output side, you dont need coding ... you need only for the directory...

Enable ASMA attributes in the channel.

Edited by: Baskar Gopal on Feb 24, 2011 10:58 AM

Former Member
0 Kudos

I have used DynamicConfiguration conf= arg0.getDynamicConfiguration().

Param didn't work.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Here is a link from the wiki explaining how to use the PI 7.1 Java Mapping api

http://wiki.sdn.sap.com/wiki/display/XI/UsingPI7.1APIforJavamapping

Here is also a sample code as well,

https://wiki.sdn.sap.com/wiki/display/XI/SampleJAVAMappingcodeusingPI7.1+API

In your case, instead of using


private Map para;
			para = transformationInput.getInputHeader().getAll();			
			DynamicConfiguration conf = (DynamicConfiguration) para
					.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

You could try using


DynamicConfiguration conf = transformationInput.getDynamicConfiguration();

Hope this helps,

Mark

Edited by: Mark Dihiansan on Feb 23, 2011 11:41 AM

RKothari
Contributor
0 Kudos
deepak_shah
Contributor
0 Kudos

Hi,

You can throw the exception explicitly using the following statement in catch block.

throw new StreamTransformationException("", exeption_obj);

1. Implement your mapping program, when ever handling exceptions throw StreamTransformationException in catch block.

2. Create Instance for MappingTrace or AbstactTrace (as shown in above statement).

3. Add your message by using methodu2019s of above classes by category (Info/Warning/Debug).

4. Pass the fields from the program to trace message, in order to check the status in SXMB_MONI.

In addition Please refer following link.

1. http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm

Hope this helps

Regards,

Deepak

Edited by: Deepak Shah on Feb 23, 2011 10:43 AM

Former Member
0 Kudos

i have ticked the AMSA properties in both Sender and receiver.

Former Member
0 Kudos

Hi,

Have you ticked the option of Set Adapter-Specific Mesage Attributes and under that File Name and Directory in the Communication channel?

If you just want the source file name as the target file name you need not write the code. Just ticking the Set ASMA and File Name in communication channel is enough.

Regards,

Aravind