DOS commands within ABAP

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.

Similar Messages

  • 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

  • Results of Query Wrap Within DOS Command Window.

    Greetings,
    I am using SQL*PLUS within the DOS command window.
    The results of my query is wrapping down the page, instead of using the entire width of the window.
    I have set the windows mode command, before going into SQL*PLUS:
    MODE CON: COLS=100 LINES=40
    So, I was hoping to have Oracle use all 100 columns, when displaying the answer set.
    Regards,
    Dave

    Hi Dave,
    Size of lines, columns and pages are controlled by SQL*Plus system variables
    For width of lines
    SET LINES[IZE] which defaults to 80
    For number of lines per "page"
    SET PAGES[IZE] which defaults to 14
    To control formatting, including width of indicidual columns you have COL[UMN], e.g:
    COLUMN your_column FORMAT a20
    For more settings:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve040.htm
    If you want certain settings each time you open SQL*Plus, you can add those to your glogin.sql
    Regards
    Peter

  • Executing a dos command from java in windows nt

    i need to execute the
    " net send"
    command from the command line in windows nt, from within my java program... is there any way that i can execute cmommands in the dos command shell? or rather, does anybody know a way i can send a message ( in windows ) from java, from one computer to another over the lan?? I cannot have a java programming running on all the other computers, so i cannot make my program serve, it must just send the messges using a lan command....
    (the net send command just sends a message in the form of a pop up box on the receiver's screeen)
    thanks a bunch guys!!!
    Thanks a bunch guys!!!!

    you can do that with exec() in Runtime.
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command here);but before you do that you need to read this:
    http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
    hth
    partha

  • Calling DOS command from a webpage?

    How would I go about doing this? I want a webpage that when an image is clicked this DOS command is called:
    rundll32.exe C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen Image_Location\image.jpgThis command opens the image in Windows Picture and Fax Viewer. I'm not worried about portability since this is only going to be on my home network. I figure I'll probably need Java or something to do this, but I've no clue where to start looking. Help is appreciated!

    How would I go about doing this? I want a webpage
    that when an image is clicked this DOS command is
    called:First of all, this is not a Java-related question. It is an HTML and browser capabilities question.
    Second of all, in general this is not possible. If it were, imagine the security issues allowing a web page to arbitrarily allow executing anything on the client victim's machine. At best the user has to configure his browser to "trust" content from the site in question. Since you as the application provider can't force this configuration to happen automatically, you're out of luck unless you are in complete control over the clients (such as if they are all within the corporate intranet only).

  • Arp / Dos command format output

    Hi
    Im looking to run the arp command within powershell and format the output so I only see the mac addresses
    Ive been trying for a while and gotten as far as         arp -A | sort-object "Physical Address"
    alternatively is the a powershell equivelent of arp?  Ive tried Get-Macaddress but tht dosent work.
    Generally how do I choose which column info I want from a dos command?
    Anyone?
    Thanks for reading
    confuseis

    THis works.
    arp -a | %{$($_[24..41])-join ''} | select -skip 3
    I can paste these mac address to nirsofts Macaddressview and that resolves all the mac addresses to the manufacturers.
    Then is simply pick out all the printers.  Hurrah
    Thanks
    confuseis
    If you're searching for printers, you can run
    nmap -p 9100 -sT 192.168.1.1-254 -T2
    or use page countster: http://www.laptechnologies.com/printers dot exe.
    I personally prefer page countster, but I increase the timeout, otherwise some printers will be missed as they don't reply before the timeout. Run it as an admin as it require raw sockets.

  • Unning DOS commands

    Is there any way to run a command-line (DOS) command from within Java? For instance, If I wanted to run another app from a java program, and used a DOS command like app.exe -param1 -param2 ?

    soulknight wrote:
    you may try Runtime.exec();Did you bother reading other replies before you posted?

  • Issue DOS commands?

    How do I issue DOS commands from within a Java program and retrieve the DOS output as input to the program?

    See this JavaWord article for lots of detail and some
    traps and pitfalls...
    ChuckOh, and I suppose you wanted the link too... ;-<
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Executing a DOS Command from JSP

    How do i execute a Dos command from within JSP. I would like to execute a sql Loader command .
    Thanks

    You use Runtime.execute().
    Take a look here for a few of the tricks involved in it:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • I want to execute UNIX COMMAND in ABAP

    Hi All,
    I want to execute a UNIX XOMMAND sh <scriptname> <filename> to replace divsion codes.in ABAP.
    But, I came to know that we can't (2) or try the following program but unfortunately the command CALL SYSTEM is not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
    REPORT ZUNIXCOM .
    DATA: U_COMMAND(200).
    Table for system messages
    DATA: BEGIN OF RT OCCURS 100 ,
    LINE(100) ,
    END OF RT .
    START-OF-SELECTION .
    MOVE 'unix command' to U_COMMAND .
    REFRESH RT.
    CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
    ID 'TAB' FIELD RT-SYS .
    LOOP AT RT.
    WRITE : / RT-LINE .
    ENDLOOP. 
    So please can u help me how to call a unix command from ABAP. it is very urgent. I want complete details and all possible solutions
    <removed_by_moderator>
    Thanks,
    gyanaraj
    Edited by: Julius Bussche on Aug 26, 2008 11:29 AM

    Selvaraj Gyanaraj wrote:>
    > So please can u help me how to call a unix command from ABAP.
    I was about to help you.
    >it is very urgent.
    I changed my mind.
    >I want complete details and all possible solutions
    I'm glad I changed my mind.
    >Points are surely rewarded.
    Too late.

  • AT NEW command in ABAP Objects

    Hi everyone!
    Is there an equivalent of the AT NEW command in abap oo? When I try to use this command inside a BAdi, I get an error message.
    Best Regards,
    Luís.

    Hi,
    Thank you for your response
    Sample code:
    LOOP AT c_t_data ASSIGNING  variants are no longer supported in the OO context. Use dynamic variants instead.
    Regards,
    Luís.

  • UNIX command in ABAP code

    Hi All,
    I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
    Can any one help with how to used unix commands in ABAP?
    Thanks in advance.
    Regards,
    Hemendra

    The recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc.  For example:
    Command name       OS         Type             OS command                                 Parameters for operating system command 
    Z_FILE_MOVE        SunOS      Customer    mv                                                 ? ?   
    You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
    Jonathan

  • Command in ABAP Editor to improve the source code

    Which command in ABAP Editor to be used to improve the readability of the program code ?plzz tell
    Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:48 PM

    Use Pretty Printer or do a CTRL+F1.
    Also u can change the settings of the way u want preety printer to behave by
    going in the Settings->Abap Editor -> Pretty Printer

  • Unix commands in ABAP

    Hi,
       I need to call the following unix command in ABAP to encrypt a file on the app server .
    crypt password <org filename> new_filename
    1 But when i run it using call 'SYSTEM' .. i get message security risk , command not executed ..
    2 I also created the command in SM69 and tries to run it but same error.
    3 I also created a shell script , but i get another message when i try to run sh ...
      Please help to find out a way to make it work ..
    Kunal

    Hi kunal,
    1. probably ur basis team might be able to help u.
    2. even if we have authorisations thru sap
       to run external os command,
       the actual OS user on application server
       must have the right for it
       and access/write/read/modify
       for the files (provided thru the command)
       in question.
    3. Due to this , the systems gives the message
       of SECURITY RISK.
    regards,
    amit m.

  • How to run multiple DOS commands from a single Webutil Client_Host session?

    Hello all,
    I have a requirement where I need to create an interface with SVN from Forms for basic checkin-checkout of files.
    So, I've been trying to use webutil client_host to open a command line session and issue svn commands.
    For svn, sometimes I need to give multiple commands like change to a particular directory and then run an svn command.
    But client_host takes in only one command at a time and I'm unable to issue a series of DOS commands to perform
    a particular task.
    Is there a way to do this?
    Pls suggest.
    Regards,
    Sam

    First your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
    mkdir c:\abc & cd abc & dir*
    Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
    Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
    So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine.

Maybe you are looking for

  • Remote app upgrade issues..question. help!!!

    I have been using my iPad with the remote app to control my iTunes music that is on my Mac mini in my living room. I have had the same app on my iPod and Iphone where all 3 units could request, communicate and interact with iTunes dj...and we could a

  • Customer service knolwedge is critical in order for me to consider giving you my money

    Dear Verizon, There's no substitution for a knowledgeable person. I have been experiencing sub standard internet service from my current provider, not Verizon. Being that I live in an area with very few choices for brand band service, one of them not

  • How do I get my apps to my phone from my computer?

    It is that simple! How do I get my apps from my computer to my phone? When I press SYN that will not do it.

  • List of cutomer ship to addresses.

    Hi, How can I get all the ship to addresses of a cutomer from prod system. We are in the process of updating the addresses of particular cutomer. So I have to back up all the addresses of the same cutomer. Please give me an idea of how to do it. Than

  • Load Balancing behind firewall

    Hi, Can load balancing be done behind a firewall with CSS. For e.g. CSS (on the outside of the firewall) load balances on the servers connected to the DMZ of the firewall. If so, should there be any performance issues. And what if the firewall had IP