Skip to Content

UDF for filename generation problem

Hi experts,

in my scenario I have a receiver communication channel which sends multiple files to an FTP server.

I have created an UDF to dynamically create filename based on three fields, PLANT, FILE TYPE (this fields are in record set segment) and ID_ORDER_HEADER (this field is on header segment).

The number of the files to generate is: 1 file for each header.

My problem is that each file has the name of the first ID_ORDER_HEADER.

For example if I have 3 headers (so 3 files to generate):

.

ID_ORDER_HEADER 1= 99001

ID_ORDER_HEADER 2= 99002

ID_ORDER_HEADER 3= 99003

Each file has name: 99001.

Here's the structure of input message:

http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:MT_PurchaseOrder_myFirm xmlns:ns1="urn:myFirm-XXXX:PurchaseOrder">

<RecordSet1>

<Plant/>

<File Type/>

<Header1>

<id_order_header_/>

<LineItems1>

<id_order_line_/>

</LineItems1>

<LineItems2>

<id_order_line_/>

</LineItems2>

</Header1>

</RecordSet1>

<RecordSet2>

<Plant/>

<File Type/>

<Header2>

<id_order_header_/>

<LineItems1>

<id_order_line_/>

</LineItems1>

<LineItems2>

<id_order_line_/>

</LineItems2>

</Header2>

</RecordSet2>

<RecordSet3>

header 3

</RecordSet3>

<RecordSet4>

header 4

</RecordSet4>

........

</ns1:MT_PurchaseOrder_myFirm>

</ns0:Message1>

</ns0:Messages>

Heres's my UDF

public String SetFileName(String zPlant,String zIDOrderHeader,String zFileType,Container container){

//write your code here

//@Fabio Boni:- UDF for generating the file name in the form of NameSystemdate.txt

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

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

String fileName = " ";

Date now1 = new Date();

SimpleDateFormat formatter = new SimpleDateFormat ("yyyyddmm_hhmmss");

String dateString1 = formatter.format(now1);

String InitFileType = zFileType.substring(0,1);

if (InitFileType.equals("L")) {

if (zPlant.equals("DB10")) {

fileName = "Confirmed_PO.xml";

}

if (zPlant.equals("DR10")) {

fileName = "Confirmed_RICAMBI_PO.xml";

}

}

if (InitFileType.equals("F")) {

if (zPlant.equals("DB10")) {

fileName = "Confirmed_PO_"zIDOrderHeader"_"dateString1".xml";

}

if (zPlant.equals("DR10")) {

fileName = "Confirmed_RICAMBI_PO_"zIDOrderHeader"_"dateString1".xml";

}

}

conf.put(key, fileName);

return "";

Thanks

Fabio Boni

Edited by: Fabio Boni on Oct 11, 2010 3:29 PM

Edited by: Fabio Boni on Oct 11, 2010 3:37 PM

Edited by: Fabio Boni on Oct 11, 2010 3:39 PM

Edited by: Fabio Boni on Oct 11, 2010 4:05 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 11, 2010 at 08:42 PM

    You have to create 3 receiver CC for sure... you cannot use one receiver CC to produce 3 different files names at same time.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 11, 2010 at 04:29 PM

    Fabio,

    If I'm not wrong, you can't achieve this using Dynamic code. I would say try it using Variable substitution method instead.

    Thanks,

    raj.

    Add comment
    10|10000 characters needed characters exceeded