cancel
Showing results for 
Search instead for 
Did you mean: 

file adapter: Variables in OS command

Former Member
0 Kudos

Hi All,

Is it possible to put variable (from variable substitution) into OS command line? I need to create a specific filename, that issues from its payload. But substitution doesn't work - filename appears with percentage symbols and var names.

Thank you.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member189441
Active Participant
0 Kudos

Hi,

Run Operating System Command Before/After Message Processing

● Command Line

The operating system command specified here is executed before or after successful file processing. The default value is an empty character string (no command).

When the operating system command is called, the file name currently being processed can be specified with the following placeholders:

%f (file name)

%F (absolute file name including path)

Former Member
0 Kudos

Guys,

Let me explain situation in details.

I have on source message split into several target messages. Then these messages are written as xml files. Finally, these files should be packed into zip archive, and zip archive should be named according to payload values.

In this scenario I can't use payloadzipbean - it creates many archives for each final message, while I need many in one. That's why I've decided to use os command to archive files:

jar -cvf pack_%var1%_%var2%.zip file_xml*

And it works, but at the end archive's name is pack_%var1%_%var2%.zip.

So, I know how variable substitution works, and how os command does... I just need to know if their collaboration is possible...

Former Member
0 Kudos

Hi Dmitriy

AFAIK this is not possible. You can pass only the file name (with/without path) dynamically to the script. No other parameter can be passed dynamically. I have tried the same earlier and came to this conclusion. However I have not found any SAP statement saying so.

Thanks

Jaishankar

Former Member
0 Kudos

Thanks to all,

thank you Jaishankar.

Syed1234
Explorer
0 Kudos

Sorry very late...but one can play with DOS commands to do such requirement, similar scenario I used a little trick of creating and deleting a dumb filename to get my required filename and relevant data/

former_member192295
Active Contributor
0 Kudos

Hi,

I think it is possible but better to choose UDF technique to generate file, why because it is easiest way to generate file.

former_member183906
Active Contributor
0 Kudos

In these blogs you have examples for OS command:

You can try with this commmand

with your receiver adapter where your file name comes with counter

and prefix as e.g. "abc".

this command will extract the filename starting only with abc and you can then move that file into any folder you want or simple you can generate a file name in name.txt.

save this command as bat file and give path in your in NFS file adapter and after processing.

@echo off

for /F %%a in ('dir /b abc.') do set FileName=%%~nxa

echo %FileName%>name.txt