Skip to Content
0

External command to execute Batch file in Windows REMOTE desktop

Apr 05, 2017 at 09:26 AM

1k

avatar image
Former Member

we have to execute a external command from SAP server to trigger a batch file placed in remote desktop.

Our basis consultant successfully created a RFC TCP\IP connection in SM59 by the standalone gateway in the remote desktop.

setup

SAP server running in Linux OS

Batch file placed in Windows OS as a Remote Desktop.

Now the question is how to frame the external command in SM69 to trigger the batch file in the windows machine by using the RFC connection ?

As we tried external commands is runnnig at OS level accepting only Linux commands

if we give a directory path as the external command and executing using the RFC connection it is always failing ... do we need to enable anything or write windows compatible shell command . Please suggest if this is workable ..

10 |10000 characters needed characters left characters exceeded

Why do you need this? What is this mysterious batch file on a remote PC supposed to do? Why must it be triggered from the SAP server?

Sorry but this kind of "architecture" sounds like something from the 80s. And not in a good way. If you can explain the end goal perhaps an alternative solution could be suggested.

0

Jelena, are you calling me old :) ... I beg to differ about the 80's - through most of the 90's it was still the most reliable way to connect to SAP "real-time"

0

OK, let it be 90s. It's ancient times either way. :)

0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Roberto Vacca Apr 05, 2017 at 10:37 AM
0

Hi.

My suggest is trying to use simple different command as "ls" for unix or "dir" for windows and see what happens. If your problem is your actual working directory you should launch before an other command to change it. What do you mean with "RFC is always failing", what's the message?

Hope to help

Bye

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

already tried with ls , ls is listing the files in the working directory and i could see the output in sm69 .

RFC connection is the connection created for connecting to Remote desktop through standalone gateway. if we execute this connection in sm59 to connect to RDP, it is successful

Target dest option is used to execute the external commands by choosing the RFC connection.

and the external command i m executing is \\sharepathid\test\test.bat ( share path of the Windows RDP ) it looks like the below

Error when executing external commands pl refer the screen print of SM21


o86ng.png (35.3 kB)
0

You mean commands in test.bat?

In that case I'm agree with Matthew, once you'll have a webservice on windows server that could be consumed, you can get an XML reply in ABAP.

I put here some screen to show how could be a web-service call from ABAP to Windows System.

For a windows web service implementation there are lot of documentation on internet.

Hope to help

Bye

WebServiceDocument

0
Matthew Billingham
Apr 05, 2017 at 11:09 AM
0

For a similar scenario, we created a web service on the windows server, that could be consumed from an ABAP program. The webservice ran a batch file with supplied parameters.

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Could you please elaborate with the steps ?

0

Sure. Create a web service on windows that runs your batch job with supplied parameters. You can use C++, C#, Java or whole host of languages for this. Make sure that the web service starts when the service starts. From this web service, get the WSDL file. (This is all standard stuff that anyone who develops on Windows can do).

On the SAP side, generate a consumer proxy from the WSDL file, and write a program that uses the generated proxy classes to call the web service. (This is also standard stuff,. and documented in help.sap.com, and blogs/wiki entries on this site).

Using web services to manage communications between two computer systems is an industry wide technology.

0
Former Member

Hi Matthew,

" " The web service ran a batch file with supplied parameters. " " Is this batch file ( with some instructions / rules / commands ) running in Foreground ? Pl. clarify.

Thanks, Uma

0

Like logged into windows and with a command console you might run

MyBatch.bat param1 param2

0
avatar image
Former Member Apr 05, 2017 at 09:57 PM
0

Thanks matthew and Robert, In my case Windows machine is a remote desktop and we installed stand alone gateway for communication. Is this sufficient to create a webservice ? I will create a webservice with the help document and get back

Meanwhile trying to understand what is the issue in the windows connect RFC connection, Can it not support to execute external commands or in other words just wanted to try that option if there is any workaround available as we already tried with this approach.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

"In my case Windows machine is a remote desktop and we installed stand alone gateway for communication. Is this sufficient to create a webservice ?"

I think you need to ask this on a windows OS support site.

0
Former Member
Matthew Billingham

posted in Microsoft support site.. waiting for the answer

0
Raghu Govindarajan Apr 08, 2017 at 09:30 PM
0

I remember doing things like this many years ago... here is a little brain dump of what I remember...

1) The program being executed on the remote system needs to implement an RFC connection back to SAP in order to let SAP know the call was successful

2) The program could work without #1 above, but SAP wouldn't know

3) The permissions to execute the program on the remote system were always tricky to setup - If everything else looked ok, I would bet this is your problem

4) I think Matthew's WSDL idea would be easier to manage in the long run.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks for the reply. If you could recollect provide the #1 steps . RFC connection created using the option Start on expicit host. this solution is half the way, sap is running under Unix OS and the external created to execute batch file in remote desktop is not working, sm21 log shows unable to execute the external command

0

Sorry, it's been close to 20 years ago that I was involved with that. What I do remember was that we had a program written in C++ that established the connection back to SAP. Check out this document, maybe it will help https://assets.cdn.sap.com/sapcom/docs/2016/09/faa21fe1-8a7c-0010-82c7-eda71af511fa.pdf

Also do a Google Search for "SAP RFC SDK" or "SAP NW RFC SDK", you should get information about newer ways of connecting to SAP that I believe are much easier to use than the old methods.

0
avatar image
Former Member Nov 10, 2017 at 12:11 PM
0

To connect the external command to an RFC proceed as follows:

1. Create an RFC (Type T) with the following options:

a. Program: sapxpg

b.Target Host: <your remote OS (e.g. IP)>

c. Gateway Host: <your remote OS (e.g. IP)>

d. Gateway service: <the gateway service of the installed SAP Gateway on the remote host>

2. Create the external command in SM69/SM49 ==> Press Save and Press Execute ==> You will see another screen where you can specify the target destination (Target Dest.), created at point 1 ==> Execute the command in Dialog or create a Background job.

Share
10 |10000 characters needed characters left characters exceeded