Integrating External Operating System Commands into ABAP program.
Hi folks,
using the transaction code sm69 it is possible to create an SAP command that's executing an operating system command.
Is it possible to integrate such an SAP command into our ABAP programs ?
How would we do so ?
Regards
Thomas
Hello Thomas,
We have an easier way of achieving this without declaring a command in SM69.
Try the below piece of code:
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'ls -l'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.
Replace the string in the variable 'comand' with any UNIX command.
Regards
Sabu
Similar Messages
-
Execute external operating system command
Hi Friends,
I have a requirement to run a script file with extention '.PL' on the application server using ABAP.
i have sample how to run it in XI.
XI3.0 provides a very simple way of handling this using the "Operating System Command" in the File Adapter.
I post my output file in the following folder,
/usr/sap/sapout/test/
The shell script is available in the following path,
/usr/sap/bin/convert.pl
The figure below explains as to how we call the shell script using "Operating System Command".
File Acess parameters
Target Directory = /usr/sap/sapout/test/
File Name Scheme = TestOutput.txt
Processing Parameters
File Construction Mode = Add Time Stamp
File Type = Binary
Operating System Command = /usr/sap/bin/convert.pl %F
I have to do the same thing in ABAP as it has been done for XI as mentioned in the above example.
My operating system is UNIX.
If any one can give me a sample it would be really helpful to me.
Thanks in advance,
Arundhathi.Hi Arundhati,
You can run operating system commands from ABAP.
e.g. If you want to change UNIX right for any file, you can use following code.
lv_ucomm = 'chmod a+rwx 123.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_ucomm.
whatever command you provide in Field parameter ( lv_ucomm in the above case ), ABAP run that command at operating system level.
In your case, you can provide command in lv_ucomm to run script at operating system level.
Hope it will help you.
Regards,
Naren -
External Operating system Commands -GPG
Hi Experts,
Im quite new in SAP and we have a task to encrypt a file generated from SAP for upload to bank. We use the external operating system commands to call the gpg commands for file encryption. But we encounter an error when we execute the command
below is the error we encounter
gpg: [Recptient's ID]: skip : public key not found
gpg: [Filename] : encryption failed : public key not found
but when I run the command on OS level it execute properly without any problem.
hope you guys could me an idea on how to fix the issue i encounter
Thanks in advance!!Louie,
What is the command that you used? which OS?
Thank you
Regards -
Executing Operating system commands in ABAP
Hi
I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
Thank You.
EswarHi,
you can try something like this.
data:cmd(254) type c.
data: RESULT(255) OCCURS 100 WITH HEADER LINE.
cmd = 'ls'.
** Execute command
REFRESH RESULT.
CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
ID 'TAB' FIELD RESULT-*SYS*.
Kostas -
Re: Error while Execute External Operating System Command using T.code SM49
Dear Experts,
I Have uploaded one .exe file in the application server (eg: sum.exe) and created the OS command in SM69 transaction .
And maintained the application server path in the 'operating system command' field in SM69 t.code.
Our SAP system, oprating system is UNIX.
After I have executed the external command using transaction SM49 , but I got the below error.
Can not execute external program (permission denied) , External program terminated with exit code 1
Immediately I run the SU53 transaction code to check the authorization, but Authorization was successful.
Could any one please help on this error.
Thanks in advance.>>Can not execute external program (permission denied) , External program terminated with exit code 1
You need to give the permission as 755 to your file.
>>I Have uploaded one .exe file in the application server (eg: sum.exe)
You are on UNIX and do not expect to any result of .exe file as UNIX doesn't know about this. -
Wild Cards in External Operating System Commands for HP-UX
Hello,
Is it possible to use wildcards for HP-UX commands in SM69?
For example, I would think the following would work in HP-UX:
mv /directory/file_name.* /directory2
But whenever I execute a command with the * wildcard in SM69 I get the message 'No such file or directory'
Thanks,
JoelThis is wierd, I can't even do 'ls *.TRC'
Here's another example, using absolute path names that didn't work:
mv /usr/afisinw_cpafiscd/WHSE/ready/portalActivity_311688752_1243622628104.* /usr/afisinw_cpafiscd/WHSE/ready/portalActivityOld
error: cannot access: No such file or directory External program terminated with exit code 1
But when I replace the * with txt it works. Unfortuneately I need to move multiple portalActivity files each time, and the beauty of using an external command is that my ABAP program is only a few lines long.
Could there be some sort of a safety feature in SAP to prevent the use of * in external commands? -
Auto-Reaction Method - External Operating System Command
Hello ,
I am trying to run a script (test.cmd) on a monitored java system out of solution manager via ccms auto-reaction method, but without success.
I have created a RFC Connection to the java system in transaction sm59, defined an external operation command in transaction sm69 (/usr/sap/test.cmd) and an auto-reaction method using that command. But when I test the command in transaction sm49 with the RFC connection as target destination, the command is executed on the local CEN system (SolutionManager system) instead of the monitored java system. I have no clue where's the problem???
Thanks for any help (points, points, points)
MirkoHi Anand,
can you please send me that doc too pleae.
[email protected]
I really appreciate your help.
Thanks, -
SM69 (external operating system commands)
how can i use the MKDIR dos command in SAP using SM69
Here i am using LS command in SAP :
data: begin of t_tabl occurs 0,
line(132),
end of t_tabl.
data: lc_command(100) type c.
start-of-selection.
Get all the file name falling under specified directory...
lc_command(3) = 'ls '.
lc_command+3(45) = p_dir. " Directory of file path
call 'SYSTEM' id 'COMMAND' field lc_command
id 'TAB' field t_tabl-sys.
Check any files exits in the directory.......................
if t_tabl[] is initial.
message e006 with 'No files exist in the specified directory ' p_dir.
endif.
You can use MKDIR instaed of LS
Thanks
Seshu -
Re: Operating System Commands
Hi All,
Can any one suggest me how to Execute Operating System Commands from ABAP Environment( i.e from ABAP Editor).
Thanks & Regards,
Jayarama Krishna M.Hi,
Check
https://forums.sdn.sap.com/click.jspa?searchID=11589075&messageID=3391825
https://forums.sdn.sap.com/click.jspa?searchID=11589075&messageID=3442178
Regards
Kiran Sure -
How to call Operating System commands / external programs from within APEX
Hi,
Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
Any pointers will be greatly appreciated.
Thanks & Regards,Hi Guys,
I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
sqlplusw.exe user/password@database @script1.sql
sqlplusw.exe user/password@database @script2.sql
sqlplusw.exe user/password@database @script3.sql
sqlplusw.exe user/password@database @script4.sql
What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
Any help will be greatly appreciated.
Thanks & Regards, -
Vista: use the windows program manager to execute operating system commands
attempting to run forms 6 on vista... the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.
in windows vista i get a message box indicating "use the windows program manager to execute operating system commands".
is this windwos vista message? would this have to do with permissions?
any insight most appreciated and thanks in advance.I don't know about the HOST-problem, but..
the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.What about putting the logic from the SQL*Plus-scripts into a database-procedure and call that instead. I think,, with the current approach you will get problems at least when you have to migrate to Web (e.g. Forms 10g). -
Executing a Operating System command from Stored Procedure ??
I want to execute a Operating System command from a PL/SQL Stored Procedure, can anyone suggest me how can I do this ??
I am on Sun-Solaris with Oracle 8.1.7 database.
Please do email me at [email protected]
Thanks in Advance,
Ramesh L.Are you using a webserver? If so, you could make your operating system script into a CGI program, then execute it from pl/sql using utl_http.request.
-
Executing operating system command within trigger or procedure
Hello
Can some one help me out as how to execute operating system command (unix or windows ex.. stop,start,cc,del or copy etc...) in a trigger or procedure.
My requirement is, if some predefined error occure then listener listener should be stopped automatically.
Thanks in advance
kvssHere is some code to tell you how to do:
First a small Java program that taker a string as a parameter and executes it as an os-command
import java.lang.Runtime;
import java.lang.Process;
public class Commands extends Object {
* Constructor
public Commands() {
// On NT the command should be like this "cmd /c del c:\temp\readme.txt"
// exec execute('cmd /c del c:\temp\readme.txt');
public static void execute (String cmd ) {
try {
Process p = Runtime.getRuntime().exec(cmd);
try {
p.waitFor();
catch (java.lang.InterruptedException intex ) {
intex.printStackTrace();
System.out.println("Return = "+ p.exitValue());
System.out.println(" Done ...");
catch ( java.io.IOException iox) {
iox.printStackTrace();
===================end of java ====
Use loadjava to load it into the database and create a pl/sql wrapper around the java code.
See the manual about loadjava details.
Log in to sqlplus as SYSTEM and create a role for this purpose e.g. 'JAVA_ROLE'
and exec the following as SYSTEM or SYS to make sure the user has the the needed privs.
dbms_java.grant_permission('JAVA_ROLE','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete');
dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','writeFileDescriptor',null);
dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','readFileDescriptor',null);
and you're done. -
Is it possible to call ms-dos command in abap program?
Hi,
is it possible to call ms-dos command in abap program?
Thanks.Hi Cemil,
You probably have your answer here:
[Re: DOS/Windows command in app server;
You create your external command with SM69 (you can test it with SM49).
Then you call this command with function module "SXPG_COMMAND_EXECUTE".
(See function group SXPT for all the calls to external commands).
Regards,
Thomas -
File Adapter 7.11 - set operating system command line dynamically
Hi,
is there any way to set the "Operating System Command Line" in the file adapter as ASMA / dynamic attribute?
I need to set a command line exec depending on some XSL mapping values.
thx
holgerhi,
>>>is there any way to set the "Operating System Command Line" in the file adapter as ASMA / dynamic attribute?
>>>I need to set a command line exec depending on some XSL mapping values.
think about this approach:
you put the XSL values into the filename after the real name of the file
in the batch script you use those values in order to execute a dynamic exe command
after processing you just change the name of the file in the script by removing the xsl values
simple ? I think so
Regards,
Michal Krawczyk
Maybe you are looking for
-
How do you move Lion from one physical drive to another?
I've studied the forums & there's lots of discussion about having to install SL, then download Lion (again) then other thread says to copy the downloaded Lion (in the Apps folder) to an 8gb thumb drive, etc, etc. I'm installing a new 512GB SSD in b
-
MS Office 2008 Update: fixes some print issues?
I noticed the first update for Office 2008 is out, and one "fix" they list for Word is: Blank pages are no longer printed when you print to a high resolution printer. This update fixes an issue in Mac OS X 10.5 Leopard that causes blank pages to prin
-
I have an ipad with 5.0.1 and trying to learn how to use it. When I click on the icon Calender, I get the calendar presentation but I do not know how to make an entry. Every tutorial I have looked at says that you click on a + sign in the lower ri
-
i have save an MS Project Plan as an Excel Workbook, the problem is that the outlining of the project plan didn't come across. the Task name did not indented at all. I can see the outline level .so i assume that as first , second and third in outlin
-
Infinit loop of Toolkit for CreativeJS
Hi I created HTML/Javascript with Toolkit for CreativeJS(instead of Wallaby), the source fla is exported by InDesign animation. But The published HTML is played with infinit loop. How to stop this infinit loop? Any information or advice is greatly ap