Site icon SAP Human Resources Experts And Solutions

Working with OS level from SAP

<p>We have a task &&num;8211&semi; manage OS level requests from SAP job scheduling tool &lpar;SM36 transaction&rpar;&period; You know&comma; there are a lot of tools to perform OS level tasks&comma; that are built into OS or some 3rd party tools&comma; which support command line access&period;<&sol;p>&NewLine;<p>For example&comma; I&&num;8217&semi;ve created a simple executable file with just one command&colon;<&sol;p>&NewLine;<p>echo &&num;8220&semi;SAP running&&num;8221&semi; &gt&semi;&gt&semi; sap&period;log<&sol;p>&NewLine;<p>We want to run this script from OS level locally on the server where SAP is running&period; Then&comma; remotely&comma; where no SAP system is installed&period;<&sol;p>&NewLine;<p><&excl;--more--><&sol;p>&NewLine;<h2>Running OS level commands in SAP step by step guide<&sol;h2>&NewLine;<p>To start we need to allow SAP run these scripts on OS level&period; Open SM69 transaction and create a new record like this&period;<&sol;p>&NewLine;<p><a href&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;01&period;png"><img class&equals;"alignnone size-full wp-image-2543" src&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;01&period;png" alt&equals;"SAP SM69 transaction" width&equals;"648" height&equals;"607" &sol;><&sol;a><&sol;p>&NewLine;<p>Run it&period;<br &sol;>&NewLine;<a href&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;02&period;png"><img class&equals;"alignnone size-full wp-image-2544" src&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;02&period;png" alt&equals;"" width&equals;"694" height&equals;"491" &sol;><&sol;a><&sol;p>&NewLine;<p>Pay attention&comma; the command was run from one folder&comma; but the result is shown in SAP work directory&period; To avoid this we need to specify full file paths or use OS level environment variables for adm user&period;<&sol;p>&NewLine;<p><a href&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;03&period;png"><img class&equals;"alignnone size-full wp-image-2545" src&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm69&lowbar;03&period;png" alt&equals;"" width&equals;"768" height&equals;"662" &sol;><&sol;a><&sol;p>&NewLine;<p>If look closer&comma; there is one more way to run the script remotely on the screen&comma; setting Target or Remote host&comma; but it works only for SAP systems&period;<&sol;p>&NewLine;<p>In SM36 transaction there is an interesting option&colon;<&sol;p>&NewLine;<p><a href&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm36&lowbar;01-1&period;png"><img class&equals;"alignnone size-full wp-image-2547" src&equals;"http&colon;&sol;&sol;saphr&period;ru&sol;wp-content&sol;uploads&sol;sm36&lowbar;01-1&period;png" alt&equals;"" width&equals;"751" height&equals;"718" &sol;><&sol;a><&sol;p>&NewLine;<p>It allows running OS level script from the scheduler&period;<&sol;p>&NewLine;<p>If we want to use ABAP to run something interesting&comma; then there are options to do that&colon;<br &sol;>&NewLine;Functional module SXPG&lowbar;COMMAND&lowbar;EXECUTE or OPEN DATASET command&period;<&sol;p>&NewLine;<p>RSBDCOS0 program can run a script without any records in SM69&period;<&sol;p>&NewLine;<h2>Running OS level commands from SAP remotely<&sol;h2>&NewLine;<p>All we need is to find how to run a script remotely&comma; where no SAP installed&period; From my experience&comma; all I could imagine is using remote shell calls like PowerShell for windows or ssh for unix-like systems&period; On SAP side we write a script&comma; which connects remotely and runs script there&period;<&sol;p>&NewLine;<p>ssh osuser&commat;host &&num;8220&semi;cd testdir&semi;&period;&sol;test&period;sh&&num;8221&semi;<&sol;p>&NewLine;<p>Or for Windows&colon;<br &sol;>&NewLine;Invoke-Command -ComputerName Server01&comma; Server02 -ScriptBlock &lbrace;Get-UICulture&rcub;<&sol;p>&NewLine;<p>Prooflink&colon; <a href&equals;"https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;powershell&sol;scripting&sol;core-powershell&sol;running-remote-commands&quest;view&equals;powershell-5&period;1" target&equals;"&lowbar;blank" rel&equals;"noopener">https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;powershell&sol;scripting&sol;core-powershell&sol;running-remote-commands&quest;view&equals;powershell-5&period;1<&sol;a><&sol;p>&NewLine;<p>So&comma; typical integration process looks like&colon;<br &sol;>&NewLine;&&num;8211&semi; develop File Event Scheduler&comma; which watches files on OS level<br &sol;>&NewLine;&&num;8211&semi; if a file appears&comma; HR program is run to read file with data&period; The program reads a file and deletes a flag file from step one&period;<&sol;p>&NewLine;<p>Or<br &sol;>&NewLine;&&num;8211&semi; run program to export data to OS level<br &sol;>&NewLine;&&num;8211&semi; run OS level file monitor which would upload a file over FTP&sol;CURL or send a signal to SAP<&sol;p>&NewLine;<p>Or everything mentioned above could be developed with ABAP calling FTP&sol;HTTP&sol;SMTP&sol;WebService services of external systems&period;<&sol;p>&NewLine;<p>The only one situation I believe ABAP can&&num;8217&semi;t do is to run a script with another user permissions but adm&period; Yes&comma; I know about SUDO &colon;&rpar;<&sol;p>&NewLine;

Exit mobile version