cancel
Showing results for 
Search instead for 
Did you mean: 

issue in mailing

allamudi_loordh
Active Participant
0 Kudos

hi experts,,

i have a scenario, like follows,..i have to pick the files from ECC directory and need to send multiple files to multiple customers through PI.suppose file 1,2,3 ,4..these are my files in Some directory of ECC or suppose in PI .i need to send file 1 to customer 1,2, and cc as customer 3.file 2 only to customer 2 and 3. and file 3 and 4 need to send only customer 1,file 4 to all customers.

what i have a requirement is i need to chek the first four characters of a file so that i can send it to different customers whom ever it may concerns.

Advance thanks,

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Loordh,

Please check in sxmb_moni under dynamic configuration what filename you are getting. Also I hope you have checked the file name in ASMA in sender communication channel so that it picks the sender file name.

allamudi_loordh
Active Participant
0 Kudos

hi sathish,

i checked in sxmb_moni ,,under Dynamic Configuration there i am getiing file name correctly as loordh.txt but if i see under Error it is showing condition is failing to determine reciever ..as i have given condtion in previous post.i tested '=' and '~' operators but of no use ..same error i am getting .

allamudi_loordh
Active Participant
0 Kudos

hi,

thnks for your inputs...i am using UDF for this to get file name based on file name i need to send it diffrent customers which i am assigning it in Reciever rule, same i am using it in Reciever Determination...can you please look into this udf i am getting some expceptional errors.

try

{

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

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

String FileName = conf.get(key);

conf.put(key, FileName);

key = null;

return FileName;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

i am geting "java.lang.NullPointerException

when i tested in operational mapping

former_member854360
Active Contributor
0 Kudos

Hi ,

You cant test dynamic configuration in Message mapping or operation mapping test tab.

it will work only in runtime in a end to end scenrio.

you need to place the file in source folder and test the mapping in runtime.

Also dont forget to check the Adapter specific message attribute and filename in sender adapter

Your UDF is correct.

allamudi_loordh
Active Participant
0 Kudos

hi,

everything is working fine except only in receiver determination..there i used Reciever rule in that i have chcked my file name by using conext objects like as follows .

(File_Name u2248 loordh.txt) for this CC is loordh_bc

(File_Name u2248 allamudi.txt) for this CC is allamudi_bc

Here i am getting error.

can you help me out in this situation

former_member854360
Active Contributor
0 Kudos

Are you getting NO RECEIVER FOUND Error.

Then your condition is not working .

Remenber FileName is case sensitive means Abc and abc is not same.

Check file Name .

also try to use equal (=) operator instead of Contains pattern( u2248

allamudi_loordh
Active Participant
0 Kudos

hi roy,still i am getting same problem..saying at receiver determine condition is stopped process.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

This is pretty simple requirement. Do file to mail scenario. File as sender and mail as receiver.

If you get mail address information in the payload of the file , then use equals function of text (just use some standard functions) to achieve this. Map the address to 'to' mail data structure. Basically you need mail receiver structure and configuration.

if you are not able to handle using standard funtion due to requirements then use UDF.

Refer this [link|http://www.riyaz.net/blog/xipi-sending-emails-using-xi-mail-adapter/technology/sap/83/]

Hope that helps.

allamudi_loordh
Active Participant
0 Kudos

thanks for inputs,,,but in my scenario they will give file name and common folder path then by using that file name i need to route to different receivers in receiver determination. so i am using one sender communication channle and suppose 6 receiver communication channel ,6 Rec.Agreements. one sender agreement.6 interface determination.i need to go with udf.i am new to udf ..there i am getting problem.

can you please help me in this case.

former_member854360
Active Contributor
0 Kudos

Hi,

This scenarion can be done with only one receiver.

You are creating 6 receiver because of 6 different mailing system? Or only Email address(To address) differs ?

If only difference is to address then you can use only receiver and create Mail TO address dynamically in UDF based on input file ame.

You can use the below UDF to read the sourcefile name in mapping and determine the Mail TO address and map it to target mail package structure TO field.

public String G_GetFileName(Container container) throws StreamTransformationException{

Sring mailTO="";

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

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

String ourSourceFileName = conf.get(key);

if(ourSourceFileName.equals("File1.txt")
{
mailTO="cust1emailaddress";
}
else if(ourSourceFileName.equals("File2.txt")
{
mailTO="cust2emailaddress";
}
else If(ourSourceFileName.equals("File4.txt")
{
mailTO="cust1emailaddress;cust2emailaddress";
}

return mailTO; 
}

Also refer this blogs.

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/11287

http://www.riyaz.net/blog/xipi-sending-emails-using-xi-mail-adapter/technology/sap/83/

Former Member
0 Kudos

Hi,

If i am not mistaken u want to send messages to different receiver mail adapter based upon the file name....and u are going to use different mappings...

If yes...then u dont need to go for UDF's ..just CHK ASMA in file sender adapter...and in the Receiver Determination (under receiver sections) choose "context object" as File name and based upon the file name define ur receivers...

Thanks

Amit

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Use Dynamic configuration in udf to achieve this. Basically you need to read the file name

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

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

String SourceFileName = conf.get(key);

return SourceFileName;

Hope this helps.

Also search sdn for the above coding.. You will see plenty..

allamudi_loordh
Active Participant
0 Kudos

hi Roy,

If i am using the mail package ..i am not able to get the content. i am reading the filename but same name should come to mail attachment also,,,when i am doing like this i am getting mail attachment as some "untitled.bin"..when i open with notepad in that nothing is there.i am using only target mapping with udf,bcoz source nothing giving..everything i am reading by udf.kindly help on this.

Thanks,

Loordh

Former Member
0 Kudos

Hi

For populating all the fields of mail adapter dynamically please refer to my wiki

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/603a7bd8-a6a0-2e10-388b-fc9cb9dae6c4

I think you can refer to this.

Regards

Sandeep

allamudi_loordh
Active Participant
0 Kudos

Hi sandeep,

thanks for your reply.when i am using the udf ..i am getting some syntax errors.

allamudi_loordh
Active Participant
0 Kudos

hi ,

it is working now well.but only first line only coming in the attachment ..i am not getting the ramining rows...with this the problem can be resolved fully.

thank you.

allamudi_loordh
Active Participant
0 Kudos

Thank you one and all ..

resolved by writing UDF ..

1.udf for reading filename

2.udf for routing based on filename

3.udf for file reading and passing it to content in mail package.

Regards,

Allamudi Loordh.

former_member854360
Active Contributor
0 Kudos

Hi,

You need to create a File to mail scenario.

Here in Mapping you need to dynamically genarate the Mail TO address .

You can Use Dynamic configuration to read the filename .

Or TO address if maintained in File content itself ten You can use Substring function or UDF to read it.

Create a file to Mail scenarion using mail package structure in receiver side.

Use this blog to create mail attachment in UDF in target mail package structure.

XI Mail Adapter : Dynamically building attachment and message body content using a simple UDF

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/11287

http://www.riyaz.net/blog/xipi-sending-emails-using-xi-mail-adapter/technology/sap/83/