Logic to run Unix script file through ABAP program
Hi Friends,
I need to run the Unix script file from abap program, for that user provided file directory of application server.
Is there any logic/FM to run through abap programing.
pls can any one provide logic.
Thanks,
Ravi
report zsrchsap.
*-This is a demo report for Search Sap
*-Author : Sandeep Kulkarni
*-Date : 09/20/2001
parameters : p_sfile(60) lower case
"File to be moved
"Eg : /home/in/SFILE1.txt
p_dfile(60) lower case.
"File's Destination
"Eg: /home/archive/SFILE1.txt
data : t_btcxpm
like btcxpm occurs 0,
p_addparam
like sxpgcolist-parameters.
concatenate
'/home/ABAP/scripts/Archive_file.sh'
p_sfile
p_dfile
into p_addparam separated by space.
refresh t_btcxpm. clear t_btcxpm.
call function 'SXPG_CALL_SYSTEM'
exporting
commandname = 'ZSHELL'
additional_parameters = p_addparam
tables
exec_protocol = t_btcxpm
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 = 12.
if sy-subrc = 0.
write : /
'File',p_sfile,'moved to',p_dfile.
else.
write : / 'Error Occured'.
endif.
Similar Messages
-
How to run script file ( unix script file like ksh or sh file) using Java
How to run script file ( unix script file like ksh or sh file) using Java Program?.
I am using the following code snippet to run the simple commands like top or ls ,etc....
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("top");
Thanks In Adavance
-SivaString [] { "ksh" , "-c" , "script", "arg 1", "arg 2", "arg 3"}
-
I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections
You should be able to just place them in your Books library in iTunes and check to ensure that your Book library is configured to sync to your iPod when you sync your iPod to iTunes.
-
Reg: How to Run a Script File in WebLogic Server 10.3.3
Hi WebLogic Experts,
In our project we are using WebLogic Serve 10.3.3. I need to run one script file. could you please suggest me where should i need to place that script file in WebLogic Server 10.3.3 and How to run & stop that Script file.?
please experts i waiting for your's reply..
Thanks & Regards,
Induja..1. You can put a command line into startWebLogic.sh to start your script file.
2. In your proyect you can create a java class to run the script file.
3. You can create a java class to run the script file an setup it like a startup class into weblogic server.
4. You can create a java class to run the script file an setup it like a job scheduler into weblogic server.
In what time you need run this script file? -
How do i run a Labview file through a windows phone?
Hello there
How do i run a Labview file through a windows phone or a tablet? is it possible
is there any phone specifications required? or steps?
Thanks alotBlokk wrote:
na1992 wrote:
hahaha my baad
i mean if i have done my labview file on laptop and i want it to connect my file to a microcontroler using usb or any serial connection, i want a way that my labview file will run if i store it on a phone.
i searhced about exe format but i didnt find enough info
Sorry, but you should define more precisely what is your goal:
" i searhced about exe format but i didnt find enough info"
If you build an exe using Labview, that exe will not run on iOS, or Android, if this is what you ask...
Nor Windows Phone or Windows RT. A LabVIEW exe is compiled and linked for x86 or AMD64 architecture with Win32 API architecture and will only run on Windows for x86 or x64 systems.
Windows Phone and Windows RT are despite the similarity in the name technically completely different platforms to the normal Desktop Windows system, just as different as MacOS X or iOS.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How can i run unix script from my apex page
how can i run unix script from my apex page and take the output of unix script as a hidden variable and display it on the report region of that page
I had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
2. In Apex,
a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
b. I created a PL/SQL process whose source looks as follows:
shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
and which was conditioned on the the button P2_RUN_SHELL.
It works like a charm.
Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
Ackness -
How to execute application server file from abap program
Hi Friends,
i have a requirement to execute application server file using abap program.
i got a file directory like '/home/im3/hrintf/xxx.sh' , it's of unix file, so they want me to execute through abap program.
pls suggest me with relevant logic.
Thank you.
Regards
Ramesh MDefine the external command in SM49/SM69
Try with SXPG_CALL_SYSTEM or SXPG_COMMAND_EXECUTE
Also check this link
link:[Execute Unix Script|http://searchsap.techtarget.com/tip/0,289483,sid21_gci774071,00.html] -
Unzip files using ABAP program
Hi All,
Can anybody guide me how to Unzip a .zip file using ABAP program... Appreciate your immediate reply...
actually, my scenario is to check whether zip file is created in appl.server or not.., and if zip file created then i need to check whether its blank file or any content exist inside the file...
Thanks in advance
Bhaskerhi
good
parameters: command(236) lower case.
data: std_lines(255) occurs 0 with header line.
call function 'RFC_REMOTE_PIPE'
destination 'SERVER_EXEC'
exporting
command = command
read = 'X'
tables
pipedata = std_lines
exceptions
communication_failure = 1
system_failure = 2.
You should put your Unix command in the command parameter. "gunzip /yourfilepath/yourfilename" works on my Unix system. Once you determine the proper Unix command, you should be set. This technique is also nice because it provides you with echos back from Unix in table std_lines. For more complex Unix activity, you may want to consider throwing together a Unix script, and calling that via this code.
reward point if helpful.
thanks
mrutyun^ -
Creation of IDOC through abap program.
hello all,
I hav created idoc through abap program. I hav used FM 'Master_idoc _distrribute'.this program creates an idoc but giving status 30. can any one tell me how to get status 03. I hav already created port, Logical sys,partner no.,distribution model.
My Program is as follows:
ABLES : CRMD_ORDERADM_I,CRMD_ORDERADM_H,CRMD_SCHEDLIN.
DATA : S_CTRL_REC LIKE EDIDC OCCURS 0 WITH HEADER LINE,"Idoc Control Record
ORDER_NO TYPE CRMT_OBJECT_ID VALUE '5000000032'," SEGMENT ORDER DATA
PRODUCT TYPE CRMT_ORDERED_PROD VALUE 'SRV_01',
QUANTITY TYPE CRMT_SCHEDLIN_QUAN VALUE '1.000'.
DATA : ZORDER LIKE ZORDER_NUM OCCURS 0 WITH HEADER LINE.
DATA : T_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE. "Data Records
DATA : T_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE. "Generated Communication IDOc
CONSTANTS :
C_ZRZSEG1 LIKE EDIDD-SEGNAM VALUE 'ZORDER_NUM'.
PARAMETERS : C_MESTYP LIKE EDIDC-MESTYP DEFAULT 'ZORDER_IDOC2', "Message Type
C_RCVPRT LIKE EDIDC-RCVPRT DEFAULT 'LS', "Partner type of receiver
C_LOGSYS LIKE EDIDC-RCVPRN DEFAULT 'BSNL_OUT',
C_RCVPOR LIKE EDIDC-RCVPOR DEFAULT 'A000000006',
C_SNDPOR LIKE EDIDC-SNDPOR DEFAULT 'SAPBCD0000',
C_SNDPRN LIKE EDIDC-SNDPRN DEFAULT 'BCDCLNT100',
C_IDOCTP LIKE EDIDC-IDOCTP DEFAULT 'ZORDER2',
C_SNDPRT LIKE EDIDC-SNDPRT DEFAULT 'LS'. "Destination System
***START-OF-SELECTION
START-OF-SELECTION.
PERFORM GENERATE_CONTROL_RECORD.
PERFORM SEND_IDOC.
*& Form generate_control_record
FORM GENERATE_CONTROL_RECORD .
S_CTRL_REC-RCVPOR = C_RCVPOR. "Receiver Port
S_CTRL_REC-MESTYP = C_MESTYP. "Message type
S_CTRL_REC-IDOCTP = C_IDOCTP. "Basic IDOC type
S_CTRL_REC-RCVPRT = C_RCVPRT. "Partner type of receiver
S_CTRL_REC-SNDPOR = C_SNDPOR. "SENDER PORT
S_CTRL_REC-RCVPRN = C_LOGSYS. "Partner number of receiver
S_CTRL_REC-SNDPRT = C_SNDPRT. "Sender Partner type
S_CTRL_REC-SNDPRN = C_SNDPRN. "Sender Partner Number
APPEND S_CTRL_REC.
ENDFORM. " generate_control_record
*& Form send_idoc
FORM SEND_IDOC.
ZORDER-ORDER_NO = ORDER_NO.
ZORDER-PRODUCT = PRODUCT.
ZORDER-QUANTITY = QUANTITY.
APPEND ZORDER.
T_EDIDD-SEGNAM = C_ZRZSEG1.
T_EDIDD-SDATA = ZORDER.
APPEND T_EDIDD.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = S_CTRL_REC
TABLES
COMMUNICATION_IDOC_CONTROL = T_COMM_IDOC
MASTER_IDOC_DATA = T_EDIDD
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
COMMIT WORK.
LOOP AT T_COMM_IDOC.
WRITE:/ 'IDoc Generated - ', T_COMM_IDOC-DOCNUM.
ENDLOOP.
ENDIF.
ENDFORM. " send_idoc
I hav created segment , basic type,message typealso and release also .I also linked them.
Plz help me.
HemlataHi Hemalatha,
Just call this Progream RSEOUT00 from your Zprogram and pass the basic parameters like IDOC number, Basic type,Partner number etc.
You can check the parameters by executing the Program RSEOUT00.
This Program will change the status of your IDOC 30 to 03.
Thanks.
Note:Reward Points if you find useful. -
How to pass table data to brf plus application through abap program
Dear All,
i have a question related to BRF Plus management through abap program.
In brf plus application end, Field1,field2,field3 these 3 are importing parameters.
Table1->structure1->field4,field5 this is the table,with in one structure is there and 2 fields.
in my abap program, i am getting values of fields let us take field1,field2,field3,field4,field5.
And my question is
1) How to pass fields to BRF Plus application from abap program.
2)How to pass Table data to BRF Plus application from abap program.
3)How to pass Structure data to BRF Plus application from abap program.
4)How to get the result data from BRF Plus application to my abap program.
And finally , how to run FDT_TEMPLATE_FUNCTION_PROCESS.
How do i get the code automatically when calling the function in brf plus application.
Regards
venkata.Hi Prabhu,
Since it is a Custom Fm i cant see it in my system.
Look if u want to bring data in internal table then there could be two ways::
1) your FM should contain itab in CHANGING option , so that u can have internal table of same type and pass through FM,
2) read values one by one and append to internal table.
Thanks
Rohit G -
How to print external file using ABAP program
Hello
I want to print an external file which is located in server (
20.99.0.18\GUI\xyz\8.0QUALITY\QM_TS.DOC) .....i want to print these kind of files(which i have retrieved from table 'DRAW' field 'filep' )......i need to print these files using ABAP program.
thank you
Vikram.
Message was edited by:
Vikram Bojjaextract the data and pass to script or smartform for printing
-
I have a script that runs well the vast majority of the time. On occasion I get an exception. I would appreciate any insight as to why it fails on occasion. I can't understand why the new-object cmdlet wouldn't be recognized:
Message: The term 'new-object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Source: System.Management.Automation
StackTrace: at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Here is the script I am running:
param([string]$endpoint)
$ErrorActionPreference = "Stop";
try
[System.Reflection.Assembly]::LoadFile("D:\dotNET_Apps\dotNETCOExBatch\DotNETCOExBatch\bin\DotNETCOExBatch.dll")
$schedule = new-object DotNETCOExBatch.CallService
$reply = $schedule.CallWebService($endpoint)
if ($reply)
$host.setshouldexit(0)
else
$host.setshouldexit(8)
Catch
$nl = [Environment]::NewLine
$evt=new-object System.Diagnostics.EventLog("Application")
$evt.Source="BatchPowerShell"
$infoevent=[System.Diagnostics.EventLogEntryType]::Error
$batchException = $_.Exception
$logMessage = " "
while ($batchException)
$exMessage = $batchException.Message
$exStackTrace = $batchException.StackTrace
$exSource = $batchException.Source
$logMessage += "$nl $nl Message: $exMessage $nl $nl Source: $exSource $nl $nl StackTrace: $exStackTrace"
$batchException = $batchException.InnerException
$evt.WriteEntry(" Error starting or process cancellation of $endpoint $logMessage",$infoevent)
$host.setshouldexit(15)Hi,
Please close your current powershell console, and start a new Window, and then check the result.
Like David replied, this is a strange issue, hard to find the cuase, but I will report the issue, hope
someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
Regards,
Yan Li
TechNet Subscriber Support
If you are
TechNet Subscription
user and have any feedback on our support quality, please send your feedback
here.
Cataleya Li
TechNet Community Support -
I am trying to run the following Powershell in orchestrator to move a new user into a specific OU based on the Department field specified by the creator.
$dept = {Department from "Initialize Data"}
if ($dept -contains 'IT') {$NewContainer = OU=IT,DC=test,DC=net}
When I run the Powershell it is returning the following
The term 'IT' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
How can I get it to not try and pass 'IT' as a cmdlet?I think I may have actually found the solution I was missing { } around the command
I encapsulated the powershell in { }
$dept = {Department from "Initialize Data"}
if ($dept -contains 'IT') {$NewContainer = OU=IT,DC=test,DC=net} -
I have developed a batch harness whereby all scheduled tasks (W2012) invoke a common powershell script that acts as a wrapper to all our housekeeping jobs.
The first step in the wrapper is to create a Transcript file using following code
if ($Host.name -ne "Windows PowerShell ISE Host") # Transcript does not work within ISE
$timestamp = (get-date -format "yyyy-MM-dd-HH-mm-ss.fff")
$path = "c:\corp\$timestamp" + "_$pid.txt"
Start-Transcript -path $path -append
As expected the folder contains files with timestamp & pid in name
08/08/2013 11:00 AM 14,388 2013-08-08-11-00-01.158_1620.txt
08/08/2013 11:00 AM 12,506 2013-08-08-11-00-01.485_936.txt
08/08/2013 11:00 AM 12,994 2013-08-08-11-00-01.735_9328.txt
08/08/2013 11:00 AM 12,024 2013-08-08-11-00-01.766_8624.txt
08/08/2013 11:00 AM 13,902 2013-08-08-11-00-01.860_1756.txt
08/08/2013 11:01 AM 15,142 2013-08-08-11-01-31.392_10120.txt
08/08/2013 05:00 AM 14,982 _1692.txt
However note the last file, it has a zero length date time value in the name
The error recorded by PowerShell is
get-date : The term 'get-date' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Corp\Powershell\DMPRun-ScheduledTask.ps1:171 char:18
+ $timestamp = (get-date -format "yyyy-MM-dd-HH-mm-ss.fff")
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-date:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
IE get-date has failed and returned a zero length field as the timestamp
Can anyone think of a good reason why get-date would fail intermittently?
Do I have to code defensively for base Powershell functions?I implemented David's suggestion and now I intermittently get
import-module : Access to the path 'PowerShell_CommandAnalysis_Lock' is denied.
At D:\temp\loop_jc2_2013_11_25_08_55_02.ps1:15 char:1
+ import-module Microsoft.Powershell.Utility
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], UnauthorizedA
ccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow
erShell.Commands.ImportModuleCommand
I added a trap chain (My Powershell skills do not yet include recursive trap coding, any suggestions welcome)
trap {
trap {
"Trap1"
"Exception: " + $_
"Error: " + $Error[0]
"Message: " + $_.Exception.Message
"InnerException: " + $_.Exception.InnerException
"StackTrace: " + $_.Exception.StackTrace
"FailedItem: " + $_.Exception.ItemName
import-module Microsoft.Powershell.Management
import-module Microsoft.Powershell.Security
import-module Microsoft.Powershell.Utility
"Trap2"
"Exception: " + $_
"Error: " + $Error[0]
"Message: " + $_.Exception.Message
"InnerException: " + $_.Exception.InnerException
"StackTrace: " + $_.Exception.StackTrace
"FailedItem: " + $_.Exception.ItemName
import-module Microsoft.Powershell.Management
import-module Microsoft.Powershell.Security
import-module Microsoft.Powershell.Utility
import-module Microsoft.Powershell.Management
import-module Microsoft.Powershell.Security
import-module Microsoft.Powershell.Utility
trap {
"Trap3"
"Exception: " + $_
"Error: " + $Error[0]
"Message: " + $_.Exception.Message
"InnerException: " + $_.Exception.InnerException
"StackTrace: " + $_.Exception.StackTrace
"FailedItem: " + $_.Exception.ItemName
exit 1
get-date
Now I intermittently get ..
Trap2
Exception: Access to the path 'PowerShell_CommandAnalysis_Lock' is denied.
Error: Access to the path 'PowerShell_CommandAnalysis_Lock' is denied.
Message: Access to the path 'PowerShell_CommandAnalysis_Lock' is denied.
InnerException:
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew)
at System.Management.Automation.AnalysisCache.CacheExportedCommands(PSModuleInfo module, Boolean force, ExecutionContext context)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(PSModuleInfo parentModule, Boolean found, IEnumerable`1 modulePath, String name, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags,
PSModuleInfo& module)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
FailedItem:
import-module : Access to the path 'PowerShell_CommandAnalysis_Lock' is denied.
At D:\temp\loop_jc2_2013_11_25_09_19_52.ps1:26 char:1
+ import-module Microsoft.Powershell.Security
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], UnauthorizedA
ccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow
erShell.Commands.ImportModuleCommand -
How to crete Button through ABAP programming
Hello Friends,
I am creating 2 selection screens through ABAP code and using them in my Tabstrip control also created through ABAP programming.
Can I also create button on the selection screen through abap programming. If yes then how, and how to assign funtion code and capture the Function Code???
Moderator Message: Read the below advice.
Edited by: kishan P on Dec 30, 2010 7:44 PMHave a look at F1 help on SELECTION-SCREEN. There should be an example as well.
Maybe you are looking for
-
Audigy 2 ZS Platinum Pro - External rack
Hi, I have a Creative Sound Blaster Audigy 2 ZS Platinum Pro. I would like to use the external rack. I wonder if it's possible... I searched on the net, but i couldn't find anything. Could someone help me? Thanks NexusNeminis Last edited by NexusNemi
-
I have this posted in other threads that talk about the Creative X-Dock but I am reposting the question here because I am starting to think it is not X-Dock related... I can pretty much get my 120g to charge on my X-Dock by pressing and holding Play/
-
Getting XML data of SSIS Package (which is located in File System) from a query
Hi, We have around 200 SSIS packages deployed to File System. These pacakges are being scheduled using SQL Agent job. So, currently I have a list of all the packages and their respective File Path. Note : **They are NOT deployed to Server**. Now, my
-
with the old version of mozilla. when i got off line it would ask if i wanted to save the tabs. version 4 does not, it is very bad move to get rid of this feature. are there any add-on that i can use to get this back?
-
One file to two different folders simultaneously?
Is there a way to copy one file to two different folders simultaneously? Maybe a script? Drew