cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Filename in File adapter

Former Member
0 Kudos

Hi,

I am doing idoc-file scenario.I get the filename as a field in one of the segments of my idoc.Can anyone please let me know how i can get the filename from my idoc and use this filename in my file adapter.

--Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Refer this weblog for the variable substituion method.

/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i

/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii

Thanks,

Prateek

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I have looked into the SAP note and would see to the patch suggested.

I have used MATMAS iDoc which has no '_' in it. Even then i get the same error.

"Caught exception while initializing variable substitution engine: com.sap.aii.adapter.file.varsubst.VariableException: The following variables cannot be resolved by any variable data source: "var". Please check the spelling of each value's prefix."

The variable substitution is "MATMAS03,1,E1MARAM,1,MATNR,1" , according to which the material number will be the filename.

So i wanted to know if '_' is the reason, since i get same error even without '_'.

Thanks a lot for your replies,

Regards,

moorthy
Active Contributor
0 Kudos

Hi Vani,

Try to give some other name instead of var of the variable substitution. For e.g var1, var2 etc . Use the same in the File Name schema with %var1% etc.

And I assume that , you did not use " (quotes) in the Variable Substitution.

Most of the thing is based on the SAP Note. Still the same error, then first try without variable substitution and create the file. Then change into the Variable Substitution and check the same.

Still error , then try to look the latest J2EE patches for the SP12 pack for the Adapter.

Hope this helps,

Regards,

Moorthy

Former Member
0 Kudos

Hi,

This is the error that i still get,

History:

- 2006-04-26 21:11:31 GMT+05:30: The following configuration errors were detected:

- Caught exception while initializing variable substitution engine: com.sap.aii.adapter.file.varsubst.VariableException: The following variables cannot be resolved by any variable data source: "FILENAME". Please check the spelling of each value's prefix.

Could you please help.

Regards,

moorthy
Active Contributor
0 Kudos

Just check with giving some other variable like

var in the Variable Substitution instead of filename.

Second option is , it may be because of the Underscores(_) in the Message Structure. That's the reason I told you to go with the SAP Note mentioned in my earlier post.

If Underscore is the problem with the Variable Substitution, then you may end up with having dummy mapping for dynamic naming purpose.

Regards,

Moorthy

Former Member
0 Kudos

Hi all,

Thanks a lot for your replies.

Please find below the inbound message that i get. Now i need to get the filename that i get in one of the segments and use that in the file adapter.

<?xml version="1.0" encoding="UTF-8" ?>

- <ZSSV_GENERIC_IDOC>

- <IDOC BEGIN="1">

- <EDI_DC40 SEGMENT="1">

<TABNAM>EDI_DC40</TABNAM>

<MANDT>100</MANDT>

<DOCNUM>0000000000203015</DOCNUM>

<DOCREL>620</DOCREL>

<STATUS>30</STATUS>

<DIRECT>1</DIRECT>

<OUTMOD>2</OUTMOD>

<IDOCTYP>ZSSV_GENERIC_IDOC</IDOCTYP>

<MESTYP>ZSSV_GENERIC_MSG</MESTYP>

<SNDPOR>SAPYRA</SNDPOR>

<SNDPRT>LS</SNDPRT>

<SNDPRN>YRACLNT100</SNDPRN>

<RCVPOR>YXDTEST_GI</RCVPOR>

<RCVPRT>LS</RCVPRT>

<RCVPRN>IDES_LS1</RCVPRN>

<CREDAT>20060420</CREDAT>

<CRETIM>184948</CRETIM>

<SERIAL>20060420184948</SERIAL>

</EDI_DC40>

- <Z1SSV_ITEMS_SUMMARY SEGMENT="1">

<IDOC_SEQ_NUM>1</IDOC_SEQ_NUM>

<TOTAL_REC_COUNT>50</TOTAL_REC_COUNT>

<IDOC_SEG_COUNT>50</IDOC_SEG_COUNT>

<OUTPUT_REC_LENGTH>90</OUTPUT_REC_LENGTH>

<INTERFACE_DESCRIPTOR>OUT_RYDER_0001</INTERFACE_DESCRIPTOR>

<b><HOST_FILENAME>TEST1</HOST_FILENAME></b>

<RECORD_DELIMITER>^</RECORD_DELIMITER>

<SEGMENT_DELIMITER>|</SEGMENT_DELIMITER>

</Z1SSV_ITEMS_SUMMARY>

In the file adapter, I have specified "%filename%.xml" as my file name and in variable substitution the reference is "payload:ZSSV_GENERIC_IDOC,1,IDOC,1,EDI_DC40,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1".

I still get the same error "Message processing failed: Error during variable substitution: "

Waiting for your help in this matter.

Regards,

Former Member
0 Kudos

Hi Vani,

the value shud be:

payload:ZSSV_GENERIC_IDOC,1,IDOC,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1

but not payload:ZSSV_GENERIC_IDOC,1,IDOC,1,EDI_DC40,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1

as u r refering to Z1SSV_ITEMS_SUMMARY not EDI_DC40.

hope this helps.

Anil

Former Member
0 Kudos

Hi,

You need the value of <HOST_FILENAME> of the structure <Z1SSV_ITEMS_SUMMARY SEGMENT="1">. So you need to specify only this and not the structure <EDI_DC40 SEGMENT="1">.

So, the payload: will have

payload : ZSSV_GENERIC_IDOC,1,IDOC,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1".

You need to specify the structure <idoc> and only the structure (under idoc ) that you want the value to be extracted from.

Regards,

Smitha.

moorthy
Active Contributor
0 Kudos

Hello vani,

The Value should be

filename:ZSSV_GENERIC_IDOC,1,IDOC,1,Z1SSV_ITEMS_SUMMARY,1,HOST_FILENAME,1

If you have still problem then check the SAP Note 850694

Hope this helps,

Regards,

Moorthy

Former Member
0 Kudos

Hi

This is the error that i am getting.

As i have mentioned, i need to take the value of one of the field in my idoc segment.

Caught exception while initializing variable substitution engine: com.sap.aii.adapter.file.varsubst.VariableException: The following variables cannot be resolved by any variable data source: "filename". Please check the spelling of each value's prefix.

Thanks for your help once again

bhavesh_kantilal
Active Contributor
0 Kudos

hi vani,

can you give us your destination data as well as the file adapter configuration details.

Your error states that the variable FILENAME cannot be resolved.

I think you must have given the file name in your file adapter configuration as %FILENAME% and then you must have used payload: the path of your node which will contain the name to be used.

With more details, the problem can be easily resolved.

Regards,

bhavesh

moorthy
Active Contributor
0 Kudos

HI Vani,

Just check this SAP Note- 850694

If you have any underscore in the Message Types.

It is better if we have Message Type and the Adapter configuration details

Hope this helps

regards,

Moorthy

Former Member
0 Kudos

Hi,

In the target file name you need to give %file%.

And in variable substitution:

payload: <header>,1,<name>,1,<subject>,2

for

<header>

---<name>

-


<subject>

-


<subject>

The value of the second <subject> field will be taken as the value.

The error tells that one of the variables is misplelt.

Recheck the variables.

Regards,

Smitha.

bhavesh_kantilal
Active Contributor
0 Kudos

hi Vani,

The dynamic filename generation concept is as follows.

In your filename field. just give a variable with % symbols. (eg: %file% ).

Now, under the option Variable Name Substitution, you can give how the value has to be created.

It can be your interface name, sender service name, etc or it can be some value dynamically from your payload.

For the former, your give

message:interface_name ,etc

and for the payload part you give,

Payload: "your element root which u wanna acecss"

Just check this link out,

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

And read the contents under variable substitution and it will help you understand the concepts better.

If you have any clarifications, do get back,

Regards,

Bhavesh