Skip to Content
0

IDoc no and Timestamp to be populated in File Name Scheme

Oct 25, 2016 at 07:17 AM

408

avatar image

Dear Team,

This is basically IDOC-FILE(xml) conversion.

Requirement is to populate the IDOC no and timestamp in Filename when the file gets posted into FTP server:

<FILENAME_IDOCNO_timestamp>

Please help on this. Thank you very much in advance. Below is the reference thread

https://archive.sap.com/discussions/thread/3960305

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Rajesh PS Nov 04, 2016 at 11:04 AM
0

Hi Ryan/Raghu/Nitin,

I have used the same UDF but taken the EDIDC segments(DOCNUM,CREDAT,CRETIM) as arguments and passed it to UDF and mapped it to root node and used ASMA in communication channel.

Thanks all for your valuable inputs.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Great Rajesh,Glad that the UDF shared ,worked.:)

1
Nitin Deshpande Oct 25, 2016 at 03:43 PM
1

Hello Rajesh,

The Idoc number is coming from the input. So you need to give the input field name without quotes.

you have written as "DOCNUM_" this will be marked as constant. Please give the input variable name of Idoc number from your UDF.

For ex - Filename (String Idoc_num, ResultList Output)

So in your expression you need to give Idoc_num as the field name, without any quotes. This is actually basic Java.

Regards,

Nitin

Show 10 Share
10 |10000 characters needed characters left characters exceeded

Yes,

Even I have mentioned the same in the Code

filename = "MARA" + IdocNumber+ Timestamp;

change it and post the UDF if you face any errors.

0

Hi Nitin/Raghu,

Please find my below UDF code:

String filename = new String(""); DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName"); filename = "" + idoc_num + CREDAT + CRETIM + ".csv"; conf1.put(key1,filename); return filename;

Actual file name should be SALES_BLR_KEY_Idocnum_CREDAT_CRETIM.csv

For ex - SALES_BLR_KEY_324520_26102016_115623.csv

BLR and KEY will change and SALES is constant. Please need your kind help to close this.

0

That code that you have given won't even compile because CREDAT & CRETIM don't exist based on the arguments you have defined for the method in your UDF. If BLR and KEY will change then you would also need to supply those as inputs to the UDF.

filename = "SALES_BLR_KEY_" + idoc_num + date + time + ".csv";

You would need to replace the BLR & KEY part with the appropriate variable values if they can change however.

Regards,

Ryan Crosby

1

Hi Ryan,

Thanks for the inputs. But file name is populating as "SALES_BLR_KEY_idoc_num_date_time.csv.

I have used same naming convention in communication channel and construction mode is 'append' and used ASMA. Below is the code. Variables are idoc_num, date and time mapped the UDF to a variable.

String filename = new String(""); DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName"); filename = "SALES_BLR_KEY_" + "idoc_num" + "date_" + "time_" + ".csv"; conf1.put(key1,filename); return filename;

0

Hi Rajesh,

You are outputting string literals by surrounding idoc_num, date, and time with double quotes. The line of code to get the variable data you want should be as follows without any modifications based upon your UDF definition.

filename = "SALES_BLR_KEY_" + idoc_num + "_" + Date + "_" + 
           Time + ".csv";

Regards,

Ryan Crosby

capture.png (93.1 kB)
0

Hi Ryan,

So Should we need to use arguments in UDF and map it root node or additional variable? Also let me know whether to use ASMA or Variable substitution?

Also what is the filename scheme to be used in comm channel.

In below filename the BLR and KEY will vary and this is idoc to csv scenarion. I dont require idocnum or timestamp inside csv. Please help on this.

filename = "SALES_BLR_KEY_" + idoc_num + "_" + Date + "_" + 
           Time + ".csv";
0

Mapping is above

udf-date-time.jpg (18.0 kB)
0

Hi Rajesh,

The usage of the variable is fine as that won't get output via FCC to my knowledge and for the naming you can use ASMA based on the UDF. In the communication channel just use the value passfilename in the field for FileName and it will take whatever value is created in the UDF.

If BLR and KEY will also vary then you need to adjust the UDF to have two more additional input variables that will also be used in the above statement to generate the string.

Regards,

Ryan Crosby

0

Mapping is mentioned above for reference

udf-ars.jpg (38.4 kB)
0

Hi Nitin/Raghu,

Please find my below UDF code:

String filename = new String(""); DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName"); filename = "" + idoc_num + CREDAT + CRETIM + ".csv"; conf1.put(key1,filename); return filename;

Actual file name should be SALES_BLR_KEY_Idocnum_CREDAT_CRETIM.csv

For ex - SALES_BLR_KEY_324520_26102016_115623.csv

BLR and KEY will change and SALES is constant. Please need your kind help to close this.

0
Gagandeep Batra Oct 25, 2016 at 07:55 AM
0

You can use dynamic configuration in mapping and generate the file name using that.

Regars

GB

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Gagandeep,

Could you please elucidate briefly. It would be greadtful

0
Praveen Gandepalli Oct 25, 2016 at 08:06 AM
0

Hi Rajesh,

Check example#3 in below my blog.

Reuse FunctionLibrary for DynamicConfiguration and Message Header Attributes

Regards,

Praveen.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Unable to use the link

This site can’t be reached

The webpage at https://blogs.sap.com/2016/09/11/reuse-functionlibrary-for-dynamicconfiguration-and-message-header-attributes/ might be temporarily down or it may have moved permanently to a new web address.

ERR_TUNNEL_CONNECTION_FAILED

0

I can open the link, i am not sure why it is not working for you.

0
Raghuraman S Oct 25, 2016 at 10:58 AM
0

Link is opening as Praveen suggested.

If I remember I gave you the code also Rajesh.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Raghu,

I have replied on that thread https://archive.sap.com/discussions/thread/3960305

Please help on this for a smooth closure. Thanks much.

0
Suhale Shaik Nov 01, 2016 at 04:25 PM
0

Hi Rajesh,

Please go through the below link. You can change your code as per your requirement.

https://blogs.sap.com/2009/03/26/dynamic-configuration-vs-variable-substitution-the-ultimate-battle-for-the-file-name/

Regards,

Suhale Shaik.

Share
10 |10000 characters needed characters left characters exceeded