cancel
Showing results for 
Search instead for 
Did you mean: 

Variable Substitution

former_member745782
Active Participant
0 Kudos

hello everybody,

i have a Idoc to Flat File (ftp) interface.

I configured a variable substitution for file name.

so the ouput structure is the following:

MT_MESSAGE

---FileName

-


ROW1

-


Field1

-


Field2

-


Field3

-


ROW2

-


Field4

-


Field5

File Name Shema is %nomef%.txt

and variable substitution is:

nomef =payload:MT_MESSAGE,1,FileName,1

but i have an error in adapter

processing failed in XML parser: 'Conversion configuration error: Unknown structure 'ns0:MT_MESSAGE' found in document'

I tried to move field 'FileName' under ROW1 and changing Variable Substitution.

In this case it work fine but i have 'FileName' field in my flat file, and i don't want it....

I hope someone understand me

any suggestion?

thanks in advance

Alex

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Alex,

effectively it's strange. Litle questions:

0. does your field "FileName" is well a String?

1. Does your field "FileName" is well an element ? and not an attribute ?

2. in your Message Type (defined in ESR), does the namespace is also in the field "XML Namespace" ?

3. In your Message Mapping, when you test, look at the queue: have you only one entry or several entries inside the context on field FileName ? if you have several, do a "removeContext", in order to have only one entry.

regards.

Mickael

Edited by: Mickael Huchet on Oct 17, 2011 4:16 PM

former_member745782
Active Participant
0 Kudos

hello Mickael,

so i answer to your question:

0. does your field "FileName" is well a String? YES IS A STRING

1. Does your field "FileName" is well an element ? and not an attribute ? IS A ELEMENT

2. in your Message Type (defined in ESR), does the namespace is also in the field "XML Namespace" ? YES

3. In your Message Mapping, when you test, look at the queue: have you only one entry or several entries inside the context on field FileName ? WHEN I TEST MESSAGE MAPPING I HAVE ONLY ONE ENTRY

Answers (4)

Answers (4)

Shabarish_Nair
Active Contributor
0 Kudos

Any reason why you have gone for variable substitution rather a dynamic configuration?

Former Member
0 Kudos

Alex

As per your structure if FileName is a field (Not Node) then

nomef =payload:MT_MESSAGE,1,FileName,1

is correct.

Do take care for the follwoing points :

1. Variable substitution is case sensitive, the reference should be in Capital (after the "payload:")if the Nodes appear in Capital case in the actual receiving (target) message.

2. variable names used in the variable substitution table should always be in smallcase.

Try considering these points in your configuration. Variable substitution will work.

Regards

Raj

former_member745782
Active Participant
0 Kudos

hello Raj

i check the 2 points you suggest me

everything is correct

seems i can use variable substitution only with fields that are used on Content Conversion.

So when i put FileName under ROW1...in this case everything work fine. (I use ROW1 in Content Conversion)

But the problem now is that i don't want have FineName value in my file!!!!

Former Member
0 Kudos

Check this

Regards

Raj

anupam_ghosh2
Active Contributor
0 Kudos

HI,

If you do not need filename value in target file then you can remove it altogether from target XSD in message mapping.

Then use this UDF in your message mapping


public String getFileName(String filename,Container container){
 DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String s;
if(filename.indexOf(".")<0)
{
       s=filename+".txt";
}
else
{
    s=filename.substring(0,filename.indexOf(".")) +".txt";
}
String receiverFileName=s ; 
conf.put(key,receiverFileName);
return ourSourceFileName;
}

In message mapping


             field carrying filename --------> getFileName -------> root of target XML message.

Now following steps are also important

1. Receiver Communication Channel has Adapter Specific Message Attribute(ASMA) and file name ticked

2. "fail if ASMA missing" tick this.

3. In receiver communication channel -> File access parameters-> File name scheme -


> put any default filename.

Since if you use ASMA file name scheme is ignored.

If in source XML file name comes as say "abc.csv" in target directory you will find file "abc.txt".

else if in source XML file name comes as say "abc" in target directory you will find file "abc.txt".

Hope this solves your problem.

regards

Anupam

Edited by: anupamsap on Oct 18, 2011 2:15 PM

Edited by: anupamsap on Oct 19, 2011 7:52 AM

Former Member
0 Kudos

Hi.

Try this

nomef =payload:MT_MESSAGE,1,FileName,1,Row,1 for the value of element.

prasanthi_chavala
Active Contributor
0 Kudos

Hi,

Make sure your filename is not attribute and it is element and try to give filename field at the same level as row and check it.

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

check the Variable Substitution (Target Directory/File Name Scheme) in above link.

Thanks,

Prasanthi.