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
Similar Messages
-
How to execute dos command in Java program?
In Perl, it has System(command) to call dos command.
Does java have this thing?
or any other way to execute dos command in java program?
Because i must call javacto compile a file when the user inputed a java file name.Look in the Runtime class, it is implemented using the Singleton design pattern so you have to use the static method getRuntime to get its only instance, on that instance you can invoke methods like
exec(String command) that will execute that command in a dos shell.
Regards,
Gerrit. -
IP - Is it possible to call exit planning function from ABAP Report..
Hi All,
Greetings.
Is it possible to call exit planning function from ABAP Report (t-code SE38) ? Or I mean is not limited only to be called from ABAP Report, perhaps from BSP / Web-Dynpro / Function Module.
If somebody here has been doing it before, I'm keen to ask to kindly share it. Particularly how to call and transfer data to that exit function.
Or if somebody has done in BPS, appreciate if it can be shared too .
Thanks a lot and have a good day,
Best regards,
Daniel N.Hi.
You can achive this as suggested by Mattias in your previous post.
Lets say you have next data structure:
CostCenter | Amount | PercentForDistibution |
Create input ready query in this format. Restrict cost center by variable type range.
Create WAD with analysis item.
When you run web page you enter range of cost centers (lets say you will enter 101004 to 101010).
I assume you have data only for 101004 in your cube (lets say 1000).
You will see only one record in your webpage.
CostCenter | Amount | PercentForDistibution |
101004 | 1000 | NOTHING
When you create WAD in analysis item properties set "NUMBER_OF_NEW_LINES" to lets say 1 (so in WAD you will see always one blank line for entering new data).
Just add 6 new records:
CostCenter | Amount | PercentForDistibution |
101005 | NOTHING| 10
101006 | NOTHING| 30
101007 | NOTHING| 20
101008 | NOTHING| 25
101009 | NOTHING| 5
101010 | NOTHING| 10
Then run planning FOX function like this:
FOREACH Z_COST_CENTER.
IF {Amount, Z_COST_CENTER} <> 0
Z_AMNT_TO_DISTRIBUTE = {Amount, Z_COST_CENTER}.
ENDIF.
ENDFOR.
FOREACH Z_COST_CENTER.
IF {PercentForDistibution Z_COST_CENTER} <> 0.
{Amount, Z_COST_CENTER} = Z_AMNT_TO_DISTRIBUTE * {PercentForDistibution Z_COST_CENTER}.
ENDIF.
ENDFOR.
It is not perfect FOX, but as an idead, it should work.
Regards. -
How to batch convert bmp files into jpg by dos command or c# program language?
How to batch convert bmp files into jpg by dos command or c# program language?
Many thanks for replying.Try
GraphicsMagick. -
Calling two smartforms in one Abap program
Hi ABAPers,
Can anybody know how to call 2 smartforms in 1 abap program?actually i used the FM SSF_FUNCTION_MODULE_NAME...and two smart forms are called...but my main problem is...the first smartforms is called and the print dialog box appeared...once i click the button back ...the second smartforms is called and print dialog box appeared again..
I want to correct this...i want this to be happen once i click the print button...the two smart forms will be combined in a one printing...meaning the first page is the first smartforms and the next page will be the second smart forms...no matter how many pages will be the first smartforms...the second smartforms will concatenate or will append to the last page of the first smartforms..how can i do this?
Please help...this is my sample code..kindly correct the error.
Will reward points...
suppressing the dialog box****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
Call the First Smartforms *******************
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSF_CHEQUE'
IMPORTING
fm_name = ly_formname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION ly_formname
EXPORTING
prepared_by = p_prepb
approved_by = p_apprb
TABLES
it_cheque = it_final
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
Call the Second Smartforms *******************
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSF_TSHEET'
IMPORTING
fm_name = ly_formname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION ly_formname
EXPORTING
prepared_by = p_prepb
approved_by = p_apprb
TABLES
it_cheque = it_final
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
Thanks in advance
aVaDuDzhi,
i never used these function but i've found this link.
[http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450]
[http://help.sap.com/saphelp_nw2004s/helpdata/en/64/bf2f12ed1711d4b655006094192fe3/content.htm]
[http://help.sap.com/saphelp_nw04/helpdata/en/64/bf2f12ed1711d4b655006094192fe3/frameset.htm]
[SMartform printing;
hope that is useful.
bye
Marco
Edited by: nicolai marco on Jan 14, 2008 12:36 AM -
Can a transaction be called in background dynamically using ABAP program??
Hi Experts,
Can a transaction be called in background dynamically using ABAP program without BDC???
Regards,
Mansi.u can create job dynamically through programming..Try this sample code..
data: jobname like tbtcjob-jobname value
' TRANSFER TRANSLATION'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.
Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc ne 0.
"error processing
endif.
Insert process into job
SUBMIT zreport and return << Here it is a static call but u can make it dynamic
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.
Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
exporting
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
Regards,
JOy. -
Is it possible to call operating system command after file receive?
Hi expert,
I'm trying to call operating system command after file receive comm.channel receive a txt file.
operating system command uses txt file name as parameter.
Is it possible? How?
Thanks.Hi,
It should be possible, actually we have two options that are
1.RUN OS command before message processing
2.RUN OS command after message processing.
So you can give the commands in the RUN OS command after message processing.
Check this links for more info
http://wiki.sdn.sap.com/wiki/display/XI/SAP%20XI%20File%20Adapter%20OS%20Command%20Line%20Feature
http://help.sap.com/saphelp_nwpi71/helpdata/en/44/556cb799c93677e10000000a114a6b/content.htm
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417200)ID1690747750DB11724434094963199241End?blog=/pub/wlg/10392
Regards
Ramesh -
Please tell me how to execute DOS commands from within ABAP.
1.create your shell script your_shell_script.sh:
src=$1
dst=$2
mv -f $src $dst
2. Create your command Z_YOUR_COMMAND using SM69:
- Operating system command: /bin/sh (the path to your shell interpretator)
- Parameters for operating system command:
/home/sap/bin/your_shell_script.sh (the path to your shell script)
- Set "Additional parameters allowed" checkbox
3. Call your command from ABAP:
data:
param type sxpgcolist-parameters.
status type extcmdexex-status,
exitcode type extcmdexex-exitcode,
it_log type table of btcxpm.
p_src = '/common/home/edw/parsekb/b2/*'.
p_dst = '/common/home/edw/parsekb/b1'.
concatenate p_src p_dst into param separated by space.
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
COMMANDNAME = 'Z_YOUR_COMMAND'
ADDITIONAL_PARAMETERS = param
IMPORTING
STATUS = status
EXITCODE = exitcode
TABLES
EXEC_PROTOCOL = it_log
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
OTHERS = 99.
if sy-subrc <> 0.
*TODO: add your error handling logic
endif. -
Problem while running dos command from java program
Dear friends,
I need to terminate a running jar file from my java program which is running in the windows os.
For that i have an dos command to find process id of java program and kill by using tskill command.
Command to find process id is,
wmic /output:ProcessList.txt process where "name='java.exe'" get commandline,processid
This command gives the ProcessList.txt file and it contains the processid. I have to read this file to find the processid.
when i execute this command in dos prompt, it gives the processid in the ProcessList.txt file. But when i execute the same command in java program it keeps running mode only.
Code to run this command is,
public class KillProcess {
public static void main(String args[]) {
KillProcess kProcess = new KillProcess();
kProcess.getRunningProcess();
kProcess = new KillProcess();
kProcess.readProcessFile();
public void getRunningProcess() {
String cmd = "wmic /output:ProcessList.txt process where \"name='java.exe'\" get commandline,processid";
try {
Runtime run = Runtime.getRuntime();
Process process = run.exec(cmd);
int i = process.waitFor();
String s = null;
if(i==0) {
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(process.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println("--> "+s);
} else {
BufferedReader stdError = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
while ((s = stdError.readLine()) != null) {
System.out.println("====> "+ s);
System.out.println("Running process End....");
} catch(Exception e) {
e.printStackTrace();
public String readProcessFile() {
System.out.println("Read Process File...");
File file = null;
FileInputStream fis = null;
BufferedReader br = null;
String pixieLoc = "";
try {
file = new File("ProcessList.txt");
if (file.exists() && file.length() > 0) {
fis = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(fis, "UTF-16"));
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
} else {
System.out.println("No such file");
} catch (Exception e) {
e.printStackTrace();
return pixieLoc;
} when i remove the process.waitFor(), then while reading the ProcessList.txt file, it says "No such file".
if i give process.waitFor(), then it's in running mode and program is not completed.
Colud anyone please tell me how to handle this situation?
or Is there anyother way to kill the one running process in windows from java program?
Thanks in advance,
SathishHi masijade,
The modified code is,
class StreamGobbler extends Thread
InputStream is;
String type;
StreamGobbler(InputStream is, String type)
this.is = is;
this.type = type;
public void run()
try
InputStreamReader isr = new InputStreamReader(is, "UTF-16");
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
ioe.printStackTrace();
public class GoodWindowsExec
public static void main(String args[])
try
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
if( osName.equals( "Windows 95" ) )
cmd[0] = "command.com" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
} else {
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
Runtime rt = Runtime.getRuntime();
System.out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec(cmd);
System.out.println("Executing.......");
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
}when i execute the above code, i got output as,
Execing cmd.exe /C wmic process where "name='java.exe'" get commandline,processid
and keeps in running mode only.
If i execute the same command in dos prompt,
CommandLine
ProcessId
java -classpath ./../lib/StartApp.jar;./../lib; com.abc.middle.startapp.StartAPP 2468
If i modify the command as,
cmd.exe /C wmic process where "name='java.exe'" get commandline,processid > 123.txt
and keeps in running mode only.
If i open the file when program in running mode, no contents in that file.
If i terminte the program and if i open the file, then i find the processid in that file.
Can you help me to solve this issue? -
How to execute MS DOS command through Java program???
Dear Sir,
I want to run a MS-DOS command through my Java program. I have tried "Dir" command but no other command which takes command line args doesn't work at all. Please help.
import java.io.*;
class CommandPrompt
public static void main(String[] args)
try
File file = new File("C:/Temp/Java");
String[] cmd = {"command.com","/c","md folder"};
String[] envp = {""};
Process m;
String s = "";
m = Runtime.getRuntime().exec(cmd,null,file);
BufferedReader buf = new BufferedReader(new InputStreamReader(m.getInputStream()));
while ((s = buf.readLine())!=null)
System.out.println(s);
catch (Exception ex)
System.out.println("Exception is "+ex);
ex.printStackTrace();1. This forum is for Swing-related issues only. This question should be posted to the "Java Programming" forum.
2. Please enclose your sample code in code blocks; it's much easier to read that way. See here for how it's done: http://forum.java.sun.com/faq.jsp#messageformat
3. Please provide more information, like what error messages you got and what OS you're running. For instance, if you're running WinXP, Win2k or NT4, your command processor should be "cmd.exe", not "command.com". When I made that change, your program worked for me. -
Possibility of calling standard actions from a java program
Hi ,
I am working for a project where customer wants to have option of saving orders as draft only and later convert to order if need be. However since we do not want many drafts to reside on server there is a need to delete these at a specified time. For draft orders I am using order templates since they stay in the database without getting converted to orders. Now I do not know how to go about the deletion part.
i need to write a program that would run on the server and which would fetch the templates (drafts) that have been created till a particular time and call the delete action of the template. Now the question is how do i call these actions from a java program where this java program will have to run on the server end (ie will be a backend process).
Please suggest.
Thanks
Roopalihello roopali,
you can create a separate thread that will run your
code that will check for stale drafts and delete them.
it is just like a session management program but here
we will be looking over the drafts and not the session
objects.
now if you want the invocation of the action from another
program, a socket program would suffice but opening ports
will cause you network connections thru firewall.
if you can make use of HTTP servlet as your service
provider e.g., you can then just pass some action params
to invoke it.
regards
jo -
How to Move file / call UNIX command using ABAP Program
Hi, ABAP Guru.
I need to Cut & Paste file (Move file from one location to another location) on Network Shared Drive using ABAP program.
But I can't figured out how to do this and what ABAP Command / FM / Method (and maybe UNIX command) that being used.
Please give me the advice.
Best regard and Thank you all.
Nattapash C.all methods for your requirements should be in class CL_GUI_FRONTEND_SERVICES
-
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
ThomasHello 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 -
How to execute os command from ABAP program?
I want to execute some window commands from ABAP. What is the way to do it?
Hi,
See ht e coding below, I have used these Fm to connect to FTP server and get the Files..
*types for the ftp command result internal table
TYPES : BEGIN OF ty_result,
text TYPE char512,
END OF ty_result.
data it_result type standard table of ty_result.
*Connect to the FTP server
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = lv_user " user name pass word to connect
password = l_v_pwd
host = 'dev.eu.pm.com' " Host name here
rfc_destination = 'SAPFTPA' "destination name
*Ask your functional people for the above data
IMPORTING
handle = v_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*Changing directory
CONCATENATE 'cd' '<file path>' INTO l_v_cmd SEPARATED BY space.
you can also ser 'DIR in l_v_cmd which opens the directory and all the folders *get into it_result table..
*Execute the FTP Command
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = v_handle
command = l_v_cmd
TABLES
data = it_result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
rewards if useful,
regards,
nazeer -
Exec a "MV" (move) Linux command from ABAP program using wildcard "*"
Hi,
I have a problem by using FM "SXPG_COMMAND_EXECUTE", SM49 while i try to move the whole content of a SAP folder into another.
Foders are on the same file system:
source: /tmp/
dest: /usr/sap/tmp
I made a command in SM69 named ZMOVE:
I put OS: Linux (is case sensitive)
command: "mv"
parameters: /tmp/* /usr/sap/tmp
hence the final sentence should be "mv /tmp/* /usr/sap/tmp". I did it directly by using program "rsbdcos0" and works fine.
Now if I try to execute the command ZMOVE from SM49 or using the function module it gives the same error
*mv: cannot stat /tmp/ ': No such file or directory**
I made several tries by changing the parameter section (also using a script on the same directory).
The permissions are ok, so the only problem seems to be the wildcard (*) character.
Any suggestions?
Thanks in advance
FabrizioProblem solved.
Forget function modules, SM69 etc. there's an ABAP command in order to perform a SO command.
Here an example:
data: lf_file like rlgrap-filename,
lf_idx(3) type n,
cmd(254),
result(255) occurs 100 with header line.
cmd = 'mv /dir_source/* /dir_dest'.
call 'SYSTEM' id 'COMMAND' field cmd
id 'TAB' field result-sys.
Maybe you are looking for
-
I went to my iTunes on my computer to update it that way and iTunes does not show the new update.
-
Error in downloading itunes in windows, all the .exe files turn into the itunes icon
-
Quicktime error that won't let me use iTunes
I have used an iPod video 60GB since Dec 2005 with Windows XP Pro. Recently, my Quicktime Pro began to show a failed codec type-thing when I would try to play a .mov. I uninstalled Quicktime Pro and attempted a reinstall but it will not allow me to i
-
Help with Linking A Report in SCCM 2012
I've got a report that shows us Flash Players Versions by Count. I'd like to be able to create a linked report that shows the specific computers that have a specific version. The current report looks like this I'd like to be able to click on a link i
-
Drag and drop in ScreenSharing. Broken.
So, I can drop a file from my desktop to an open ScreenSharing app window - and a window pops up, labeled "File Transfers". I see my file in the list: "<filename> to <machine>" with an animated progress bar (grey white striped) with "Pending" undern