cancel
Showing results for 
Search instead for 
Did you mean: 

Idoc to file with file name as ABCD timestamp and count

Former Member
0 Kudos

Hi,

Greetings!

I have an requirement like iDoc to File and the output file name should be ABCDYYMMDDXX (e.g ABCD14091701) in PI 7.1

where,

Default = ABCD

YY = year

MM = month

DD = date

XX = sequence no. on the same day; e.g. first batch on same day = 01, second batch on the dame day = 02

I tried checking many blogs but its not meeting this requirement.

Kindly please help me out in completing this interface.

Regards,

Vinoth

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

You can set filename in UDF using DynamicConfiguration class.

For below requirement, you can use NRO(part of B2B add-on).


vinoth g wrote:

XX = sequence no. on the same day; e.g. first batch on same day = 01, second batch on the dame day = 02

You can set XX from NRO counter

Please check the following guide:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/505eceda-fa91-2f10-4a9b-e5e99285e...

Note: B2B Add-on SP1.0 is available from PI 711 SP08 onwards. Refere Note: 1695522

former_member191435
Contributor
0 Kudos

Hi,

Can you please check below 2 links

http://wiki.scn.sap.com/wiki/display/XI/More+with+the+File+Adapter

Thanks,

Sreenivas

former_member189420
Active Participant
0 Kudos

Hi Vinoth,

Have you checked this blog? Dynamic file name and directory in Receiver File Adapter - summary of possibilities - Process Integr...

Also, is there a value that is coming in your Idoc that specifies the batch no?

Regards,

Anand Patil

Former Member
0 Kudos

Hi Anand,

Thanks for your reply..

I have checked this link.. no value is coming from the iDoc that specifies batch number

This count has to be happen when the output file is generated.. i have used default value and time stamp as of now. its working fine but file count is not happening..

Please help.

Regards,

Vinoth

former_member189420
Active Participant
0 Kudos

Hi Vinoth,

Looking at the options. Even having the standard counter wouldn't help in your scenario.

I would suggest this:

Create a UDF:

List the files from the target directory with " ABCDYYMMDD* " using I/O Library. Add 1 to the result and concatenate to the filename i.e. ABCDYYMMDD(result) using dynamic configuration.

Hope it helps!

Best Regards,

Anand Patil

Former Member
0 Kudos

Hi Anand,

i have tried with below code, but getting error.

Kindly please check the above code is correct and will it meet this requiremet.

And also, from the idoc no value is specifying the batch number.. in this case what will be source field to map with the root node of the target.

Please give your valuable inputs.

Regards,

Vinoth

former_member201264
Active Contributor
0 Kudos

Hi,

If Seeburger installed on your machine, then you can use AttibMapper module parameters to get the required functionality very easily.

Regards,

Sreeni.

former_member189420
Active Participant
0 Kudos

Hi Vinoth,

Below is the code. Use it in-conjunction with your dynamic config code.


String inputFile = "D:\\Receiver"; //This is your target receiver folder

  String dateStr = DateFormat.getDateInstance().format(new Date());

  dateStr = dateStr.substring(0, 2)+ dateStr.substring(3, 5)+ dateStr.substring(8,10);

  final String fileNamePattern = "DEFAULT"+dateStr;

  File file = new File(inputFile);

  File[] listFiles = file.listFiles(new FilenameFilter() {

  @Override

  public boolean accept(File dir, String name) {

  if(name.contains(fileNamePattern))

  return true;

  return false;

  }

  });

  //System.out.println("Number of files in the directory "+inputFile+" : Next Counter"+ (listFiles.length+1));

  int counter = listFiles.length+1;

  String fileName = "";

  if(counter < 10)

  fileName = fileNamePattern+0+counter;

  else

  fileName = fileNamePattern+counter;

  System.out.println("Name of the file will be:"+fileName);

  }

Hope it helps!

Best Regards,

Anand Patil

Former Member
0 Kudos

Hi,

you can do this by a simple UDF..which you can find in many blogs...

for XX - Batch code, you need to add a reference in idoc..so you can check this reference to populate a field in PI...then use the UDF to concatenate...

Thanks,

Ashok