cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA MAPPING

madanmohan_agrawal
Contributor
0 Kudos

Hi,

I have a requirement to send flat file from one place to another. The only thing that needs to be done is to change the receiver file name as per data in input flat file. I do not have any structure of flat file so I thought of using JAVA Mapping to accompolish this.

Input file (name = ABC.txt)

A123

B456

C789

D123

Now if the first character of a line is C and the 3rd position of that line is 8 then I have to change the receiver file name as "NY_ABC.txt".

Please suggest the java code that can be used in JAVA mapping for the above.

Ragards,

Madan Agrawal

Accepted Solutions (1)

Accepted Solutions (1)

sunilchandra007
Active Contributor
0 Kudos

Hi,

You can simply do this in graphical mapping by writing UDF. Fill a paramerter in target structure using the UDF for the file name. While configuring the file adapter at receiver side, use Adapter-Specific Message Attributes to fill the FileName parameter.

Regards,

Chandra

Answers (3)

Answers (3)

madanmohan_agrawal
Contributor
0 Kudos

Solved.

Thanks for your help.

Shabarish_Nair
Active Contributor
0 Kudos
byte[] buffer = new byte[1024];
			for (int read = in.read(buffer); read > 0; read = in.read(buffer))
				temp.write(buffer, 0, read);

		String payload = temp.toString();

String Sections[];

Sections = payload.split("\\n");


for (i=0;i<Section.length;i++)
{

if((Section<i>.toString.indexOf('c') == 0) && (Section<i>.toString.indexOf('8') == 2)

// SET YOUR LOGIC FOR FILE NAME HERE


}

maybe that is something you are looking for. Might have to do a small tweak on the code yourself

sunilchandra007
Active Contributor
0 Kudos

Go through this link-

Configuring the Receiver File/FTP Adapter

http://help.sap.com/saphelp_nw04s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm

Regards,

Chandra