cancel
Showing results for 
Search instead for 
Did you mean: 

Filename with checksum

Former Member
0 Kudos

Hi Experts,

I am working on  file scenario below the pattern of file I need to generate with the details. How can we know the file is checksum or not. Uniquecode has to be generate with date milliseconds with random number.

File pattern is QPS.COMPANYCODE.CY/CN.CURRENCYCODE.UNIQUECODE

Ex: QPS.0111.CN.USD.0911242847812

QPS is identifying the file

0111 is company code

CY/CN if the file is checksum then CY or CN

USD is currency code

UniqueCode  have to generate  using DDHHMMSSNNNRR (DD - Day, HH - Hour, MM- Minute, SS-Second, NNN - Milisecond, RR - Random Number)

Any help would be appreciated.

Regards,

Mohammad

Accepted Solutions (1)

Accepted Solutions (1)

xavisanse
Active Participant
0 Kudos
Former Member
0 Kudos

Hi Xavier,

I tried using dynamic file name but not able to get the time stamp with random number. Can you please help how to achieve.

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

Use below UDF. I just wrote locally in the eclipse you can convert to ESR UDF and add the dynamic configuration logic as well.

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Thanks very much for your help its really great.I am having target structure like

Header

  -- Customer

  ---Customer name

  ---customerAge

Details

--- CompanyAcount

----EmployeeSalary

----EmployeeAge

Where can i add the field to get the file name.I am bit confused pls help i will mark this as answer if i get the field information.

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

You can create variable called fileName under Header node like below and set the file name using dynamic configuration UDF.

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

I converted the java code in ESR but getting function is not declared properly and some 5-6 error. I am poor in writing java code.pls can you help how to write the code in ESR.

Starting i have written the same public static as below.

public static void main(string[] args) throws StreamTransformationException{

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

Use below UDF.


public String setFileName(String companyCode, String currencyCode, String checkSum, Container container)

  throws StreamTransformationException {

  StringBuilder sb = new StringBuilder("QPS.");

  sb.append(companyCode).append(".");

  sb.append(checkSum).append(".");

  sb.append(currencyCode).append(".");

  sb.append(new SimpleDateFormat("ddhhMMssSSS").format(new Date()));

  sb.append(new Random().nextInt(100));

  Map<String, Object> mapParameters = container.getInputHeader().getAll();

  DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

  if (conf != null)

  conf.put(KEY_FILENAME, sb.toString());

  return sb.toString();

  }

Regards,

Praveen.

Former Member
0 Kudos

Hi Paraveen,

Thanks for the help.I have added the same code in UDF but getting below error.

pls help

Regards,

Mohammad

manoj_khavatkopp
Active Contributor
0 Kudos

Mohammad,

Declare your inputs i.e inputs-arguments -companyCode, currencyCode and checkSum individually not all in one line.

Br,

Manoj

Former Member
0 Kudos

Hi Manoj,

Thanks for the reply. I have added the same but when am mapping am not getting any source value can I map it to constant.

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

  • Is company code is not coming from source payload? if yes map it to first argument companyCode
  • If currencyCode is coming from source payload then map the source field otherwise map constant USD to second argument.
  • I don't know the logic for checkSum if it is constant map constant CN to third argument checkSum

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

your UDF code is working very fine but am getting like

QPS.0111.CY.USD.20160615-090417-247.1509061716158

after the date i don't want the -090417-247.

Need to get the value as      QPS.0111.CY.USD.201606150904172471509061716158

How to achieve withput hypens.

Please help

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

Your initial post you want to generate unique code like below.


File pattern is QPS.COMPANYCODE.CY/CN.CURRENCYCODE.UNIQUECODE

Ex: QPS.0111.CN.USD.0911242847812

UniqueCode  have to generate  using DDHHMMSSNNNRR (DD - Day, HH - Hour, MM- Minute, SS-Second, NNN - Milisecond, RR - Random Number)

And i have written the UDF only for that, where did you get the extra time stamp??

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Thanks very much for the reply.

WHen I added the UDF for the field (variable) the file name is creating with timestamp and miliseconds.

Like am getting the filename  QPS.0111.CN.USD.20160615-090417-247.1509061716158

Bold letters am getting extra timestamp.

please how to avoid it when am triggering a file it is coming.

Regards,

Mohammad

Former Member
0 Kudos

Sorry I haven't seen in receiver channel it is taking timestamp.

Regards,

Mohammad

former_member182412
Active Contributor
0 Kudos

Hi Mohammad,

  • Enable FileName attribute in Adapter-Specific Message Attributes

  • Mention file name scheme like below, actually you can mention anything as it is ignored by the adapter when you enable above step.

  • File construction mode should be create.

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Thanks very much for your help.

Now the filename is coming correct but the business is changed  client requested to remove the random numbers in the file. As am using RFClookup counter value in the file. Now the client need the value to be replaced instead of random number. As of now I removed the random number code in the UDF.

Now how can I add the counter value please help.

SIPC062016100054 Value should come at the end of file instead of random number, please help its urgent.

Regards,

Mohammad

Answers (0)