cancel
Showing results for 
Search instead for 
Did you mean: 

Add counter in Receiver File name

former_member190358
Participant
0 Kudos

Hello Everyone,

I have a Idoc to file scenaraio . The file comes regularly and whenevr the file comes, it should get suffix with datestamp and then the counter.

The name is should be Partner_YYYYMMDDHHMMSSL.xml.

Where L is counter and should be increased everytime.

Regards,

Ravi

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

please chk below code but for this also u have to go for DC....give a try

http://wiki.sdn.sap.com/wiki/display/Snippets/UDFtoReadMessageIDofaPIMessage

former_member184681
Active Contributor
0 Kudos

Hi,

First of all, this requirement can only be fulfilled with NFS transfer protocol - otherwise you will not be able to use the Add Counter option of the receiver CC.

Now, you cannot use just one dynamic filename feature for this purpose. Only File Construction Mode can handle sequence number counter, and you cannot use both: Timestamp and Counter in File Construction Mode. So you will have to use two options in parallel: ASMA+Dynamic Configuration and File Construction Mode = Add Counter.

Please refer to this Wiki for implementation guidelines:

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407

Hope this helps,

Greg

former_member190358
Participant
0 Kudos

Hi All,

Sorry, i forgot to mention that its a AS2 Receiver .

Regards,

Ravi

Former Member
0 Kudos

have a look:

http://wiki.sdn.sap.com/wiki/display/XI/AttribMapper-AssignAS2Filename+Dynamically

try to create file name in mapping itself using a comination of DC along with number range functionality...just give a try and let us know the output

former_member190358
Participant
0 Kudos

Hello AmitSri,

Could you please let me know, if i can add the message id to the file name as an extension.

Regards,

Ravi

Former Member
0 Kudos

try below logic:

partnerconstant(_) concat -> time stamp udf + concatcounter concat+constant(.xml) +concat -> dynamic config udf -> target node.

click on counter standard function and enter Initial value 1 and incremental 1 .

time stamp udf:

String AddTimestamp(String var1, Container container) throws StreamTransformationException{

String DATE_FORMAT_NOW = "yyyyMMddHHmmss";

Calendar cal = Calendar.getInstance();

SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);

return sdf.format(cal.getTime());

}

note :add import instructions(pkg) java.text.SimpleDateFormat

dynamic conf:

String DynamicConfig(String a, Container container) throws StreamTransformationException{

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

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

conf.put(key,a);

return "";

}

in id:

you have to enable ASMA and File Name properties in Receiver File Adapter.

Edited by: bhavanisankar.solasu on Mar 7, 2012 4:13 PM

Shabarish_Nair
Active Contributor
0 Kudos

there are various options available to you.

refer

&

Former Member
0 Kudos

Check this