cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Directory not reliable with XSLT

peter_wallner2
Active Contributor
0 Kudos

Dear experts,

I have set up an XSLT mapping that dynamically sets the Directory:


<xsl:param name="inputparam"/>
<xsl:param name="TargetFolder">
        <xsl:choose>
            <xsl:when test="$storeCode='1234'">
                <xsl:value-of select="'BDX'"/>
            </xsl:when>
            <xsl:when test="$storeCode='4998'">
                <xsl:value-of select="'CRB'"/>
            </xsl:when>
            <xsl:when test="$storeCode='1326'">
                <xsl:value-of select="'OLR'"/>
            </xsl:when>
            <xsl:when test="$storeCode='88746'">
                <xsl:value-of select="'ROM'"/>
            </xsl:when>
            <xsl:when test="$storeCode='16781'">
                <xsl:value-of select="'TRY'"/>
            </xsl:when>
        </xsl:choose>
</xsl:param>
...

<xsl:variable name="__function"  select="dyncfg:init($inputparam)" />
<xsl:variable name="__function"  select="dyncfg:putValue('http://sap.com/xi/XI/System/File', 'Directory', $TargetFolder)" />

In receiver FTP channel I use:

- AF_Modules/DynamicConfigurationBean

key.0 "write http://sap.com/xi/XI/System/File Directory"

value.0 "message.interface"

- Variable replacement

targetfolder "message:interface_namespace"

- ASMA

Directory

- Target Directory

%targetfolder%

So everything is set up correctly and it also works fine. But sometimes the FTP receiver channel does not get the Directory (I do not know why) and RWB gives the error:


com.sap.aii.af.ra.ms.api.RecoverableException: The Adapter Message Property 'Directory' was configured as mandatory element, but was not supplied in the XI Message header: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'Directory' was configured as mandatory element, but was not supplied in the XI Message header

Is there a safer way to accomplish what I am doing? Should I go for a Java mapping?

Thank you for your ideas and best regards,

Peter

Edited by: Peter Wallner on Jul 4, 2011 8:53 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Peter

You can do it with XSLT mapping. Check this help page:

http://help.sap.com/saphelp_nw70/helpdata/en/43/03fe1bdc7821ade10000000a1553f6/frameset.htm

The syntax shown there is a bit different from what you wrote in your post.

Regards,

Giuseppe

Answers (1)

Answers (1)

Former Member
0 Kudos

Check the source message contents for "storeCode" values. It seems some times when your source file doesn't contain the "storeCode" hardcoded values (as mentioned in your code) then it is going into error becaue there is no default directory name present when your condition fails.

peter_wallner2
Active Contributor
0 Kudos

Hello Sarvesh,

Thank you for your hint. In this scenario messages are sent once during the night, 5 messages at once. And always the first message does not get the correct directory. Somehow it does not get the "storeCode". The other 4 messages that come after have no problem. I am on PI 7.0.

Are there any workarounds for that?

Best regards,

Peter

Former Member
0 Kudos

>Somehow it does not get the "storeCode".

If you are sure that storeCode should be there for 1st message but it is not getting somehow then you need to find that reason.

The workaround could be sttting up a default "storeCode" in case when conditions fails.

You can also setup the directory by using a UDF (dynamic configuration method) if you think XSLT is not working fine.

peter_wallner2
Active Contributor
0 Kudos

Hello Sarvesh,

Thank you again. I did go for a JAVA mapping now because I can't use graphical mapping in this scenario.

Now I created it and when I look in SXMB_MONI in the "DynamicConfiguration" it tells me "Directory" and "FileName" which is good.

But when I check in RWB the messages get stuck and it says "write property message.interface from key (http://sap.com/xi/XI/System/File)Directory with value null;"

Does the order in the DynamicConfiguration matter? In MONI it looks like this:


- <SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
  <SAP:Record namespace="http://sap.com/xi/XI/System/Directory" name="Directory">CRB</SAP:Record> 
  <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">EXPORT_1401_2011-07-03.xml.zip</SAP:Record> 
  </SAP:DynamicConfiguration>

But normally the "FileName" is always first, isn't it?

Thanks again and best regards,

Peter

Shabarish_Nair
Active Contributor
0 Kudos

the order doesnt really matter i assume

More @

/people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

peter_wallner2
Active Contributor
0 Kudos

Hello,

I found my last error


<SAP:Record namespace="http://sap.com/xi/XI/System/Directory"

Should be


<SAP:Record namespace="http://sap.com/xi/XI/System/File"

of course.

Best regards,

Peter

peter_wallner2
Active Contributor
0 Kudos

Hello,

I found my last error


<SAP:Record namespace="http://sap.com/xi/XI/System/Directory"

Should be


<SAP:Record namespace="http://sap.com/xi/XI/System/File"

of course.

Best regards,

Peter

Former Member
0 Kudos

No, the order does not matter.

Make sure in ASMA setting you have selected File Name & Directory check boxes under receiver CC.

peter_wallner2
Active Contributor
0 Kudos

Hello Sarvesh,

In the Sender Channel I have checked "Filename" and in the Receiver Channel I have checked "Directory". And that works too.

And I assume that Java is more reliable than XSLT when having numerous directories to write the files to.

Best regards,

Peter

Edited by: Peter Wallner on Jul 5, 2011 3:26 PM