cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for Changing File Name

Former Member
0 Kudos

Hi Experts,

I am working on one scenrio, where i am fetching the file name dynamically by adapter module.

Now, the file name needs to be checked for the following conditions:

BOOKING_REF_DELIVERYNO_WB.pdf

BOOKING_REF_DELIVERYNO_BOLCOPY.PDF

DELIVERYNO_AWB.PDF

Depending upon the type of file being picked up by PI from the mail box,following needs to be done:

1.time stamp needs to be added ..

ex..

for file SO10162239_123_458_BOLCOPY.pdf--> the file name must be changed to :

SO10162239_X2100_20101206_123_458_BOLCOPY.pdf.

Please suggest if this can be done by graphical mapping ?

Thanks,

Sushama

Accepted Solutions (0)

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Sushama,

To change the filename, you need to access the Adapter Specific Message Attributes for FTP (make sure this is ticked in ID). Here is a sample code for changing the filename:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm

After getting the filename, you need to concat the output with the Date Function currentDate.

Hope this helps,

Mark

Former Member
0 Kudos

Hi,

it's for mail adapter..

I dont think dynamic configuration should work for mail adapter.

Please suggest.

Thanks,

Sushama

Former Member
0 Kudos

hi,

I am using following UDF..

FileName->ParseFile>getNykFilename>concat--


!

Current date-> concat> Trim> FileName

concat----


|

constatnt[.pdf]--->

UDF for parse file:

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

String[] sarray;

String regex = "\"";

String retstring;

String fname;

int l= raw.length();

try {

sarray = raw.split(regex, 3);

retstring = sarray[1];

fname=sarray[l-1];

if( fname=="WB")

{

raw.concat("_X2100_");

}

else if (fname=="BOLCOPY")

{

raw.concat("_X2101_");

}

else if (fname=="AWB")

{

raw.concat("_X2102_");

}

} catch (Exception e) {

retstring = "no_att_name_found.err";

}

return retstring;

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

UDF for getNykFileName:

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

String[] sarray;

String regex = "[_]";

String retstring;

if(!orgName.endsWith(".err")){

try {

sarray = orgName.split(regex, 3);

retstring = sarray[0];

} catch (Exception e) {

retstring = "nyk_filename.err";

}

return retstring;

}else{

return orgName;

}

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

But, its not working..

Its giving the file name as:

no_att_name_found.err20101206 for the input file : 801243209_81473641_wb.pdf

Display queue result for parsefileName:

"no_att_name_found.err"

Please suggest.

Thanks,

Suahama