cancel
Showing results for 
Search instead for 
Did you mean: 

Get File name from incoming IDoc

Former Member
0 Kudos

HI All,

I am in an IDOC to File scenario using Fcc. (R/3 --> XI --> 3rd party)

I need to use the idoc-number(EDI_DC40-Docnum) as my output file name. I planned using variable substitution but there it expects me to get the idoc number from payload which I do not have it in. (refer c ode below)

As I understand, variable substitution can be used only on payload(the FINAL data set that we will be writing to the file).

Can we use the data which is part of incoming IDOC and not part of payload(final data what we are writing to file).??

Other idea was to map this IDOC no to a field in final file, but this field should not be written in the output file, so am confused about how to achieve this.

E.g
*Incoming Data*
IDOC
  |_EDI_DC40
    |_DOCNUM

Final data (Payload)
Header
Data
Trailer

As seen in my example above I do not have the IDOC no in the final data so how do I use the Idoc no as my filename? Apprecaite your help on same.

Regards

Shirin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use dynamic configuration UDF to get filename..

You dont have field in your target structure to map this filename with..write? .. Then this trick would do

Map the output of UDF to root node(MT_..) at target...

IDocNo-> UDF-> MT_target ... UDF of cache Value

The UDF, if you dont have..

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);

String ourSourceFileName = conf.get(key);

return ourSourceFileName;

Former Member
0 Kudos

Hi,

I have created the UDF and completed the mapping.

In the receiver comm-channel field "File-name-scheme", what should I write there? Currently I have my variable-sustitution variable written there, which is making the comm channel fail.

Regards

Shirin

Former Member
0 Kudos

Hi,

No Need of Any Variable Substitution here.Just Use this UDF in MApping and Just check the Check Boxes ASMA in the Communication channel.

1) Write one UDF & map Like this

IdocNumber-----UDF--


MT_Target

2) Check the ASMA Option in Receiver Adapter Aloneu2026..No need to check in Sender channel

UDF Code:

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

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

String Outputfile = conf.put(key,a);

return Outputfile;

REgards

Seshagiri

Answers (4)

Answers (4)

Former Member
0 Kudos

In Receiver File Communication channel,

In File name scheme : %var1%.txt

Then check an enable variable substituion,

Variable name-> var1

Reference -> payload:EDI_DC40,1DOCNUM,1

Then u file will come with IDOC number.

No need of Ud=sing UDF

"Award points if helpful

Former Member
0 Kudos

use an additional field in the target structure as filename.

Use cache parameter value

public String GetFileName(String a,Container container)
{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String ourSourceFileName = conf.put(key,a);

return  ourSourceFileName;  
}

Enable adapter specific attributes on the sender channel.

Do the mapping as below

idocnum->GetFileName(UDF)->Filename(target element)

Former Member
0 Kudos

Hi,

Refer this:

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

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

String Outputfile = conf.put(key,a);

return Outputfile;

Regards,

Nithiyanandam

former_member190389
Active Contributor
0 Kudos

Hi

You can use dynamic configuration to get the file name .

Use Adapter Specific Message Attributes for the target Comm Chanel check the indicator for filename in the advanced tab of CC

create a UDF with i/p as file name i.e the Idocnum field and

paste this code


DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//conf.removeAll();
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");


//String filename= conf.get(key);
conf.put(key, fileName);
key= null;


return fileName;



PS: use cache as value in UDF

ands assign the o/p of this UDF to a root node