Call batch program from ABAP program
hai guys,
I have created one batch file in WINDOWS NT.
Now i want to call this file from my ABAP program.
How can i do this..is there any FM here..pls let me know.
ambichan.
Hi ambichan,
To execute a program on the application server, it really is best if you create an external command (using SM69).
Here is an example call of the program:
* call executable
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = command " Your external program
ADDITIONAL_PARAMETERS = param " Your parameters
OPERATINGSYSTEM = 'WINDOWS NT'
* TARGETSYSTEM = sy-host
* DESTINATION = destination
* STDOUT = 'X'
* STDERR = 'X'
* TERMINATIONWAIT = 'X'
* TRACE =
IMPORTING
STATUS = status
EXITCODE = exitcode
TABLES
EXEC_PROTOCOL = exec_protocol
EXCEPTIONS
NO_PERMISSION = x_no_permission
COMMAND_NOT_FOUND = x_command_not_found
PARAMETERS_TOO_LONG = x_parameters_too_long
SECURITY_RISK = x_security_risk
WRONG_CHECK_CALL_INTERFACE = x_wrong_check_call_interface
PROGRAM_START_ERROR = x_program_start_error
PROGRAM_TERMINATION_ERROR = x_program_termination_error
X_ERROR = x_x_error
PARAMETER_EXPECTED = x_parameter_expected
TOO_MANY_PARAMETERS = x_too_many_parameters
ILLEGAL_COMMAND = x_illegal_command
WRONG_ASYNCHRONOUS_PARAMETERS = x_wrong_async_parameters
CANT_ENQ_TBTCO_ENTRY = x_cant_enq_tbtco_entry
JOBCOUNT_GENERATION_ERROR = x_jobcount_generation_error
OTHERS = x_others.
if sy-subrc <> 0 or exitcode <> 0.
* error dialog only, if caller is a dialog user
if sy-batch is initial.
call function 'DB6_SHOW_SXPG_ERROR'
exporting
command = 'DB6CLP'
parameters = param
server = sy-host
return_code = sy-subrc
exitcode = exitcode
tables
exec_protocol = exec_protocol.
endif.
endif.
With this code, if the user is in dialog mode the output from the external command is displayed to them. Otherwise, you can do what you want with the EXEC_PROTOCOL table which contains the output from the external program.
Hope that helps.
Cheers,
Brad
Similar Messages
-
Call SXPG _ CALL _ SYSTEM from ABAP program
Hi,
Someone may help me? I need to call the function module SXPG _ CALL _ SYSTEM from ABAP program for to encrypt a file.
I created the command by SM49 , but I don't know how I can call it from ABAP program.
Thanks
Maria CHi Maria.
This is a possible code you can use:
DATA: log LIKE TABLE OF btcxpm WITH HEADER LINE.
Can contain STDOUT, STDERR
commandname =
CALL FUNCTION SXPG_CALL_SYSTEM
IMPORTING
COMMANDNAME = commandname
PARAMETERS = parameters
EXPORTING
STATUS = status
TABLES
EXEC_PROTOCOL = 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 = 12.
The following are the comments of the parameters taken from:
http://help.sap.com/saphelp_40b/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm
Parameters
IMPORTING Parameters
Parameter name
Use
COMMANDNAME
The name of the definition of the external command, as specified in the maintenance function (transaction SM69).
PARAMETERS
Arguments for the external command as specified by the definition in the R/3 System and by the calling program or user.
These arguments are checked for impermissible characters, such as the ; under UNIX. Problems are registered with the SECURITY_RISK exception.
EXPORTING Parameters
Parameter name
Use
STATUS
Returns the final status of the execution of the external command:
· Value O: The external command was started and ran to end successfully.
· Value E: An error occurred; the external command was not run successfully.
Tables Parameters
Parameter name
Use
EXEC_PROTOCOL
Contains the STDOUT and STDERR output of the external command and any output from the target host system.
Exceptions
Exception name
Meaning
X_ERROR
Reserved for future use.
NO_PERMISSION
The AUTHORITY-CHECK of the users authorization for the authorization object S_LOG_COM failed. The user is not authorized to carry out the command named with the specified arguments on the target system.
COMMAND_NOT_FOUND
Command name, as identified by COMMANDNAME and OPERATINGSYSTEM, has not been defined in the maintenance function (transaction SM69).
PARAMETERS_TOO_LONG
The combined argument string (ADDITIONAL_PARAMETERS and the DEFINED_PARAMETERS, as returned in ALL_PARAMETERS) exceeds the limit of 128 characters in length.
SECURITY_RISK
Either:
· The command contains impermissible characters. These are characters with potentially dangerous properties, such as ; under UNIX.
· The command definition specifies that an extra-check function module be run. This function module has rejected execution of the command.
WRONG_CHECK_CALL_
INTERFACE
The command definition specifies that an extra-check function module is to be run. Either this function module is missing, or the interface defined for this function module does not match that of the standard R/3 function module SXPG_DUMMY_COMMAND_CHECK. For more information, please see SXPG_DUMMY_COMMAND_CHECK: Interface for Extra-Check Function Modules.
TOO_MANY_PARAMETERS
The command definition specifies that user-specified arguments for the external command are not allowed. However, an additional string of command arguments was specified.
PARAMETER_EXPECTED
The command definition includes the placeholder character ?, which signifies that additional user-defined arguments are required. However, no additional arguments string was supplied.
PROGRAM_START_ERROR
An error occurred while starting the external command. The R/3 system field SY-MSGV1 contains additional information on the problem.
PROGRAM_TERMINATION_
ERROR
An error occurred while trying to obtain the return code of the external program. The R/3 system field SY-MSGV1 contains additional information on the problem.
ILLEGAL_COMMAND
The external command definition was modified "illegally". That is, the command was not modified by means of the maintenance function (transaction SM69).
The modified command is registered in the system log in its substituted form. The message is registered under the system log ID "LC".
OTHERS
Catch any new exceptions added to this function module.
Hope this will be useful.
Sandro Lombardo -
Procedure to Call Workflow Object from ABAP program in Se38
Hi All,
I have one scenario like i have to call one Workflow object from ABAP program in SE38.The scenario is like below.....
I have to select some records from database table.For example there are 100 records in the internal table.
For all that records i have to invoke Workflow for getting approval from the authorized persons. Once Approval has come to program, It will post one document in SAP and process ends.
Please suggest me how to move forward with this scenario.
Regards
Manas Ranjan PandaHi,
So you want to start a workflow from an ABAP, if an event exists for that particular workflow then the best way is to use fm SAP_WAPI_CREATE_EVENT,
to start a workflow from an ABAP you can use fm SAP_WAPI_START_WORKFLOW.
Kind regards, Rob Dielemans -
Call Java Program from ABAP Program
Dear all,
In our scenario, we need to let ABAP call services provided by a standalone Java program. From online help I found some overview introduction and I'd make the called program a registered program in a RFC with type "T" (TCP/IP Connection). Can anybody give some concrete documentation? A step-by-step guide would be greatly appreciated.
Best Regards
Jeromecheck this thread
Re: Calling Java API from ABAP using JCo -
Calling oracle procedure from ABAP program
There is a requirement to call the oracle stored procedure with some input parameter from ABAP program.
Suppose we have order number which is entered by the user in ABAP program.
This order number needs to be passed to oracle stored procedure as an input parameter in the same ABAP program.
We can call the oracle stored procedure without parameter using the following syntax
exec sql
execute procedure <procedure name>
end exec.
But do not know how to execute the oracle stored procedure with some input parameter?Apologies , following is the correct code.
This will definetly solve your problem.
DATA scarr_carrid TYPE scarr-carrid.
SELECT-OPTIONS s_carrid FOR scarr_carrid NO INTERVALS.
DATA s_carrid_wa LIKE LINE OF s_carrid.
DATA name TYPE c LENGTH 20.
TRY.
EXEC SQL.
CREATE FUNCTION selfunc( input CHAR(3) )
RETURNING char(20);
DEFINE output char(20);
SELECT carrname
INTO output
FROM scarr
WHERE mandt = '000' AND
carrid = input;
RETURN output;
END FUNCTION;
ENDEXEC.
LOOP AT s_carrid INTO s_carrid_wa
WHERE sign = 'I' AND option = 'EQ'.
TRY.
EXEC SQL.
EXECUTE PROCEDURE selfunc( IN :s_carrid_wa-low,
OUT :name )
ENDEXEC.
WRITE: / s_carrid_wa-low, name.
CATCH cx_sy_native_sql_error.
MESSAGE `Error in procedure execution` TYPE 'I'.
ENDTRY.
ENDLOOP.
EXEC SQL.
DROP FUNCTION selfunc;
ENDEXEC.
CATCH cx_sy_native_sql_error.
MESSAGE `Error in procedure handling` TYPE 'I'.
ENDTRY.
Reward points if usefull.
Thanks and regards,
Veerendranath. -
Calling GUI Scripting from ABAP program
Is it possible to call GUI Scripting from ABAP and thus to use GUI Scripting as an alternative to CALL TRANSACTION?
Is the class CL_JAVA_SCRIPT suitable to access GUI Scripting engine? Accessing ABAP data object would work as well in this case as i think. What SAP Logon and WAS releases are required? Is the 6.20 release sufficient for this case?
I would appreciate if somebody could post an example.Hi,
CL_JAVA_SCRIPT has nothing to do with SAPGUI Scripting.
Calling SAPGUI Scripting API from ABAP could be possible for programmes experienced with OLE automation calls from ABAP coding.
The hardest thing will be, to access the scripting engine handle as an entry point. Once you have a handle in your abap session, any api function can be invoked.
Best regards
Jens
BTW: SAP testtool eCATT does call SAPGUI-Scripting from ABAP. -
Call VB Script From ABAP Program
Hi,
I need to call a VBS program from an abap program. This abap will run on both 4.6 and 4.0.
I would be very grateful for any suggestions on how this can be done.
Thanks and Kindest Regards
Danielledata: commandline(1000).
commandline = v_vbs_filename. "complete path of vbs file
call function 'WS_EXECUTE'
exporting
commandline = commandline
program = 'WSCRIPT.EXE'
exceptions
frontend_error = 1
no_batch = 2
prog_not_found = 3
illegal_option = 4
others = 5.
if sy-subrc <> 0.
raise execution_failed.
endif.
Raja -
Calling batch file from java Program
I have made the java program in which i have called the batch file.But the problem is this that when i call batch file locally it executes normally but when i try to execute batcvh file from remote machine it doesn't runrather it gives Runtime IO execption.Error123.Can anyone provide me the solution for this?
Not without a lot more information. Like for example how you are trying to execute this remote batch file, the code you are using to do that, what kind of server you have no the remote machine to let you remotely execute code, and so on.
-
Hi,
I Create WS in BE1 (Server ) and i want to call it explicitly via Code from other backend BE2 (Client) .
I followed this procedure
1. Create WS on the Target system (in the Server).
2. Generate proxy on the client (in the client).
3. Create logical port Via Lpconfig (in client).
I use this code to call to the service :
DATA: lv_port_name TYPE srt_lp_name,
lv_text TYPE string,
lt_return TYPE bapirettab.
DATA: lref_client_proxy TYPE REF TO z_ser_test_perf,
in TYPE z_ser_tst_per,
out TYPE z_ser_tst_per_r.
* Get Default Logical Port for Proxy
CONSTANTS: lc_proxy TYPE srt_lp_proxyclass VALUE 'ZHCO_SER_T_PER'.
in-user = 'AST'.
in-work_id = '00570538637'.
CALL METHOD cl_srt_lp_maintenance=>get_default_port_by_proxy
EXPORTING
proxyclass = lc_proxy
RECEIVING
lp_name = lv_port_name.
TRY.
CREATE OBJECT lref_client_proxy
EXPORTING
logical_port_name = lv_port_name.
CATCH cx_ai_system_fault.
ENDTRY.
TRY.
CALL METHOD lref_client_proxy->z_tst_performance
EXPORTING
input = in
IMPORTING
output = out.
catch CX_AI_SYSTEM_FAULT into lr_error.
lv_message = lr_error->get_text( ).
CATCH cx_ai_application_fault.
ENDTRY.
In the method lref_client_proxy- i get exception :
SOAP:14 Unexpected element -el=definitions ns=http://schemas.xmlsoap.org/wsdl/
Does anyone have an idea how to avoid this exception?
P.S.
I also create logical port via Soamanager but the first and the second method don't find it (i saw the entry in table SRT_CFG_CLI_ASGN ) and when i call to the third method alone i get dump for null reference.
Best Regards
Nina
Edited by: Nina C on May 5, 2009 10:33 PMhi , nina
the null poitnexception is that u r referring to the logicl port while creatign the object
dotn pass anything , just use
create object proxy name
Data : l_proxy type ref to ZSTRCO_ZSTARWEB,
lo_sys_exception TYPE REF TO cx_ai_system_fault,
out type ZSTRZSTAR_RESPONSE,
in type ZSTRZSTAR,
it_controller type PRXCTRLTAB,
wa_controller type prxctrl.
create object l_proxy.
in-a = 8.
in-b = 4.
TRY.
CALL METHOD l_proxy->zstar
EXPORTING
input = in
IMPORTING
output = out
. CATCH cx_ai_system_fault into lo_sys_exception .
ENDTRY.
write : out-c.
i never used logical port , i created it but never used
just instantiate the object and pass the input an dout put paramters , the logical port will be picked form run time
and u can test the proxy from se80
1) just double click on th eproxy name in SE80 , u can select the package in which u created the pproxy , then under enterprise services --> client proxy and ur proxy name
just test from there u get a pop up of test service consumer and select the logical port from drop down and seelct the generate template data and execute it , u will get a screen where the input values will be autmatically proposed and then u execute from there u wil get the output.
2) seond method is when in SE80 when u select the proxy u can see the prxy name in the prpoerties which will be Proxy Class (generated) , then test this class by using execute button u get a screen where u haev to instantiate the class , give the logical port name and click the instance button, then ur method wil be shown execute it and u get ur input paramters just clikc them, give the values and come back and execute u will get the output
hope it solves ur prob
regards
afzal -
Calling Non SAP programe from SAP program
Hi Experts...
Can we cal Non SAP programs Like Windows EXE programs from ABAP programs ?
If yes Then How .....
Regards ...
..AshishHi Ashish ,
Ya we can call a non SAP program from SAP program.
For example we can call a EXE program from the SAP program using the RFC connection created in SM59.
In Sm 59 you can create a TCP/IP connection and give the path of the executable there. -
Error while calling java program from ABAP
Hi Experts,
We are trying for RFC inbound scenario.
We followed the below blog
/people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
We are working with SAP JCO 3.0.2
We are getting the error : 'STFC_CONNECTION' could not be found in the server repository.
After I run the Java server program if I execute the RFC destination directly from SM 59 it is showing successful messages.
If I stop the java program then this RFC is failing. Based on this we concluded that RFC to Java connection is working fine.
But as mentioned in blog if we call the RFC Destination from ABAP program it is giving the below error,
'STFC_CONNECTION' could not be found in the server repository.
If we test the RFC destination using RFC_TRUSTED_CHECK standard FM we are getting the below error.
'RFCPING' could not be found in the server repository.
We create the RFC destination of Type : TCP/IP as exactly mention in the blog.
Please help us in resolving this issue.
Thanks
PrincePabi,
Using the RFC connection,we can establish a link between Java and SAP.
Afterwards,hope we can call Java program from ABAP.
Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
DATA: REQUTEXT LIKE SY-LISEL,
RESPTEXT LIKE SY-LISEL,
ECHOTEXT LIKE SY-LISEL.
DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
DATA: RFC_MESS(128).
REQUTEXT = 'HELLO WORLD'.
RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
CALL FUNCTION 'STFC_CONNECTION'
DESTINATION RFCDEST
EXPORTING
REQUTEXT = REQUTEXT
IMPORTING
RESPTEXT = RESPTEXT
ECHOTEXT = ECHOTEXT
EXCEPTIONS
SYSTEM_FAILURE = 1 MESSAGE RFC_MESS
COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
IF SY-SUBRC NE 0.
WRITE: / 'Call STFC_CONNECTION SY-SUBRC = ', SY-SUBRC.
WRITE: / RFC_MESS.
ENDIF.
Regards,
Sree -
How to call java program from ABAP
Hi Experts,
My requirement is to call java programs from ABAP. For that i have set up SAP JCO connection by using this link http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/739. [original link is broken] [original link is broken] [original link is broken] Connection gets sucessfully. After this how to call java program from ABAP as per our requirement. Please help me out.
Also i tried this way also.. but while executing the DOS Command line appear & disappear in few seconds. So couldnt see the JAVA output. Please help me out to call java programs in ABAP..
DATA:command TYPE string VALUE 'D:Javajdk1.6.0_20 injavac',
parameter TYPE string VALUE 'D:java MyFirstProgram'.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
application = command
parameter = parameter
OPERATION = 'OPEN'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
OTHERS = 8.
Thanks.This depends on the version of your Netweaver Java AS. If you are running 7.0, you will have to use the Jco framework. The Jco framework is deprecated since 7.1 though. If you want to build a RFC server in 7.1 or higher, it is adviced that you set it up through JRA.
Implement an RFC server in 7.0:
http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/frameset.htm
Implement an RFC server in 7.1 or higher:
http://help.sap.com/saphelp_nwce72/helpdata/en/43/fd063b1f497063e10000000a1553f6/frameset.htm -
Is it possible to call website from ABAP Program?
Hi Experts,
Is it possible to call website from ABAP Program?
It is very Urgent Help me.
Regards,
Ashok.Hi,
Check the following program:
REPORT ZURL NO STANDARD PAGE HEADING.
DATA: BEGIN OF URL_TABLE OCCURS 10,
L(25),
END OF URL_TABLE.
URL_TABLE-L = 'http://www.lycos.com'.APPEND URL_TABLE.
URL_TABLE-L = 'http://www.hotbot.com'.APPEND URL_TABLE.
URL_TABLE-L = 'http://www.sap.com'.APPEND URL_TABLE.
LOOP AT URL_TABLE.
SKIP. FORMAT INTENSIFIED OFF.
WRITE: / 'Single click on '.
FORMAT HOTSPOT ON.FORMAT INTENSIFIED ON.
WRITE: URL_TABLE. HIDE URL_TABLE.
FORMAT HOTSPOT OFF.FORMAT INTENSIFIED OFF.
WRITE: 'to go to', URL_TABLE.
ENDLOOP.
CLEAR URL_TABLE.
AT LINE-SELECTION.
IF NOT URL_TABLE IS INITIAL.
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
program = 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'
commandline = URL_TABLE
INFORM = ''
EXCEPTIONS
PROG_NOT_FOUND = 1.
IF SY-SUBRC <> 0.
WRITE:/ 'Cannot find program to open Internet'.
ENDIF.
ENDIF.
Regards,
Bhaskar -
Calling Java program from ABAP
Hi All,
my ABAP program downloads one file to one folder. Then one Java program is running to Encrypt the file.
Now , they want to call the JAVA program in ABAP, so that they can encrypt the file before downloading.
Is it possible to call a Java program from ABAP ? If Yes, please give me the detailed procedure.
Thanks
pabiPabi,
Using the RFC connection,we can establish a link between Java and SAP.
Afterwards,hope we can call Java program from ABAP.
Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
DATA: REQUTEXT LIKE SY-LISEL,
RESPTEXT LIKE SY-LISEL,
ECHOTEXT LIKE SY-LISEL.
DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
DATA: RFC_MESS(128).
REQUTEXT = 'HELLO WORLD'.
RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
CALL FUNCTION 'STFC_CONNECTION'
DESTINATION RFCDEST
EXPORTING
REQUTEXT = REQUTEXT
IMPORTING
RESPTEXT = RESPTEXT
ECHOTEXT = ECHOTEXT
EXCEPTIONS
SYSTEM_FAILURE = 1 MESSAGE RFC_MESS
COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
IF SY-SUBRC NE 0.
WRITE: / 'Call STFC_CONNECTION SY-SUBRC = ', SY-SUBRC.
WRITE: / RFC_MESS.
ENDIF.
Regards,
Sree -
Call C++ program from ABAP on remote server
Hello folks! I have C++ program on remote server (not application server!). I want to call it from ABAP program. I know about RFC, but I haven't touch with this area, can anybody help me?
HI,
Please go through link
SAP R/3 : System Functions
which has example of using C++ program residing in remote server. Hope your question gets clarification.
Best Regards,
Krishna
Maybe you are looking for
-
Counting number of frames played
Hi i am interesting in counting the number of frames which are already received and played. I am not interesting in grabbing or editting the frames. Just count them. Any propositions will be greatly appreciated. I think i should use getSequenceNumber
-
m thinking about buying a 20 dollar leather case for my ipod but i already dropped it 3 times before finally deciding to buy a case im worried that even though buying a case will guard against future drops, but the damage is already done and it would
-
Suggestion firmware MuVo v200 Radio
I have a MuVo v200 GB vith 32 radios FM. Firmware .02.0e. It's a marvellous produced. Suggestion: To be able to indicate the name of the stations FM memorized. How: by creating a file fm.ini (simple textual file) containing following informations. Ex
-
hi everyone, When i install the systems with BS_2005_SR3_SAP_Installation_Master,SR3 After the step: choose typical/custom ,error occured:change user/install error (originally result should be "log you off"and restart the sapinst) My operation system
-
Java.util.vector value to String
Hi I am trying to use some API calls for securecomputing. One of the value when i print using API, i get the result as java.util.Vector$1@93d6bc How do i convert this value into readable string format. Thanks for any help Joseph