cancel
Showing results for 
Search instead for 
Did you mean: 

File Content Conversion. Help required

Former Member
0 Kudos

Hi All,

My scenario

I have source text file. I need to do Receiver Determination based on some value.

I need to send again text file at target side.

My source txt file is:

}}}}

Condition:

If :59:/1000001642 comes then send to Receiver A

If :58:/9000001642 comes at that position then send to Receiver B

Can you please tell me how to apply FCC at sender and receiver side as I am not able to

do it.

Regards

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Rick,

Sounds like you are on your way to getting it solved. Thatu2019s great!

One correction for other readers who may come across this thread. The code above is not a user defined function (UDF). Itu2019s a java map to be used in "enhanced receiver determination". The map's only job is to create a u201CReceiversu201D document type which is then used by XI to route the document. In the case of this thread, it will allow routing of a flat file without using FCC in the sender or receiver file adapter and without an interface map for the actual payload. The actual payload is not mapped at all. The flat file will pass through XI unaltered. It does require some java coding though, which is why Sarveshu2019s suggestion is attractive. It just depends on the requirements.

Thanks,

-Russ

Former Member
0 Kudos

Hi Rick,

It will be nice if you can provide some more information about your source text file, I mean what is your endseparator, fieldseparator, or if it is fixedfeild length, is there any key field used, is there any header and item etc..

Based on you input we can suggest the FCC.

Once you will be able to pick the source file after doing FCC, then in RD under conditon editor using x-path you can give your conditions easly.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

My scenario is that:

I have source text file given that needs to be sent as same target text file

at target system. There are 2 Target systems. So I need to do Receiver determination

It means if Receiver determination was not present then it will be dummy (source text -- target text ) Interface.

If u see this text file you can see value :59:/1000001642#

At this position of this text file other value :58:/9000001642 can also come.

Condition:

If :59:/1000001642 comes then I need to send the source file to Receiver A

If :58:/9000001642 comes at that position then I need to send the source file to Receiver B

So only to read this value I am required to do FCC at source side and at target side.

Can there be any way I can avoid FCC and do Rec Determination because I am required to

do complex FCC at both source and target side.

My source txt file is:

}}}}

Pls let me know for source an target FCC.

Regards

Former Member
0 Kudos

Hi,

What I understood is, the source file should be created as it is at receier side, but since there are two receiving systems then file should be sent to these systems based on the content inside it and because of this you need to do FCC right.

The file seems to have address data on it, so this means the structure will be fixed. Can you give me structure of source file.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

This is structure of source file

}}}}

Either :59:/1000001642# will come or :58/9000001642# will come

Same text structure should be present at target side also.

I need to make DT,MT etc. for the above source file.

I do not have any other information.

Regards

Former Member
0 Kudos

Hi Rick,

Can there be any way I can avoid FCC and do Rec Determination because I am required to

do complex FCC at both source and target side.

If you want XI to route a flat file (without FCC in file adapter), then I think you will need to do enhanced

receiver determination. It will have to be a java map since the input is still a flat file.

http://help.sap.com/saphelp_nw04/helpdata/en/43/a5f2066340332de10000000a11466f/content.htm

https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3343

There are many ways to handle this in java, but hereu2019s a simple example that should get you started.



import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;

import com.sap.aii.mapping.api.MappingTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;

public final class AdvancedReceiverJava implements StreamTransformation {

	private Map _param;   

	public void setParameter(Map param) {
		_param = param;
	}

	public void execute(InputStream in, OutputStream out) throws StreamTransformationException {
		//MappingTrace trace =  (MappingTrace)_param.get(StreamTransformationConstants.MAPPING_TRACE);
		
		BufferedReader reader = null;
		
		try {
			reader = new BufferedReader(new InputStreamReader(in));
			StringBuffer sb = new StringBuffer();
			String line = null;

			while ((line = reader.readLine()) != null) {
				sb.append(line).append("\n");
			}
			String fileString = sb.toString();
			
			//replace this with a call to value mapping for more configurable solution
			String receiver = null;
			if (fileString.indexOf("59:/100000164") > -1)
				receiver = "receiverService1";
			else if (fileString.indexOf("58:/9000001642") > -1)
				receiver = "receiverService2";
			else
				throw new Exception("No receiver found in source file.");
				
			StringBuffer xml = new StringBuffer();
			xml.append("<?xml version='1.0' encoding='UTF-8'?>");
			xml.append("<ns0:Receivers xmlns:ns0='http://sap.com/xi/XI/System'>");
			xml.append("<Receiver><Service>").append(receiver).append("</Service></Receiver>");
			xml.append("</ns0:Receivers>");

			out.write(xml.toString().getBytes());
			out.flush();

		} catch (Exception e) {              
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			e.printStackTrace(pw);
			throw new StreamTransformationException(sw.toString());  
		} finally {
			if (reader!= null) try { reader.close(); } catch (Exception e) {} 
		}
	}    
}

-Russ

Former Member
0 Kudos

Hi Rick,

Just do exactly same as mentioned in this blog to pick the flat file. Do not create the UDF as mentioned in this blog just use SplitByValue function in your mapping..

Set the context of ITEMSET to CG_INPUT_MSG and use split by value and map to ITEM.

Once you will pick the file you can use x-path in RD..

This is not full solution, you may need to do some R&D but it is possible..

I hope it helps you.

Regards,

Sarvesh

Former Member
0 Kudos

HI Rick

Solution given by Sarvesh can work for you.

What you need is in mapping. Read the file as single field as shown in blog. Target side you can create a field called. Receiver.

Do use split by value for genrating target node 0..unbounded but for Receiver node you can identify the field from the data and pass it.

Use this field to identify the receiver at RD. And while doing an FCC back again you need not to write this field.

Another method can be using enhanced receiver determination as said above.

<Receivers>

<Receiver>

    <Party agency=u201Chttp://sap.com/xi/XIu201C scheme=u201CXIPartyu201C></Party>

    <Service>ABC_200</Service>

</Receiver>

</Receivers>

http://help.sap.com/saphelp_nw70/helpdata/EN/34/393071e9b998438ddb8ce97cd617a1/frameset.htm

Thanks

Gaurav

Former Member
0 Kudos

Hi,

How will I do FCC back from xml to text format at target side since my file is complex in nature.

Pls suggest.

Regards

Former Member
0 Kudos

Hello Rick,

Here is the complete Solution for your problem. It was a little bit interesting so I developed it for fun..

How to do mapping: http://www.flickr.com/photos/23639237@N02/3040806902/sizes/o/

Receiver Determination: http://www.flickr.com/photos/23639237@N02/3040808536/sizes/o/

Sender FCC: http://www.flickr.com/photos/23639237@N02/3040809452/sizes/o/

Receiverr FCC: http://www.flickr.com/photos/23639237@N02/3039972845/sizes/o/

Output: http://www.flickr.com/photos/23639237@N02/3039973629/sizes/o/

In output file you can see one extra # sign this is just due to AL11 dir , this extra sign will be removed when you save this file on your local machine, or when it will reach to final destinaion.

Let me know if you find any difficulty.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

Firstly I want to thank you for your support. Thanks a lot!!!

I will start the development and will ask you if get any problem.

Please expalin me know about Receiver FCC . I am not able to understand that.

Regards

Former Member
0 Kudos

Hello Rick,

You are most welcome.

Are you talking about : '0x0D''0x0A' , if yes then it is a hexadecimal value of 'nl'. Instead of using endSeparator as 'nl' I have used '0x0D''0x0A' .

ITEMSET is the Recordset Structure. You can also do the Receiver FCC as

ITEMSET.fieldSeparator -


'nl'

ITEMSET.endSeparator -


'nl'

When you will develope the whole scenario then you will come to knwo everything.

Best of Luck!

Regards,

Sarvesh

Former Member
0 Kudos

Hi Rick,

first of all, you need to define XML structure (Data Type, Message Type, Message Interface) for you document and make FCC on sender file adapter (txt->XML):

http://help.sap.com/saphelp_nw70/helpdata/EN/2c/181077dd7d6b4ea6a8029b20bf7e55/frameset.htm

Then you make your routing condition in receiver determination based on the value in this XML.

After that you need to set up receiver file adapter FCC (XML->txt)

http://help.sap.com/saphelp_nw70/helpdata/EN/d2/bab440c97f3716e10000000a155106/frameset.htm

With best regards,

Alexej.