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
Jerome
check this thread
Re: Calling Java API from ABAP using JCo
Similar Messages
-
Java API from ABAP program.
Hi
I have a requirement to call a Java API from ABAP program.
We are using a third party component for encrypting the files
using Java API The component consist of ".jar" files. I need to
know exactly where we need to copy the ".jar" files on application server,
so that I can call the API methods in my ABAP code and process the file in SAP,
and how to establish a connect with there server for the encryption.
Thanks
Regards
LalithLInk is:
/people/puru.govind/blog/2006/12/20/let-abap-speak?page=last&x-maxdepth=0 -
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 -
Calling Java API from ABAP using JCo (Part 2)
Hello,
This is an additional question to thread Calling Java API from ABAP using JCo
Has anyone managed to get the input parameter value
input.getString("REQUTEXT")
that is being passed from ABAP?
If yes, what kind of setting you need to do? Because when I execute, it has no value.
Thus, the below ECHOTEXT parameter returns blank value:
output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
When I debug by printing the below line, the input XML is indeed without value:
System.out.println(input.toXML());
Anybody knows how to pass input variable from ABAP to JAVA using JCo?
rgs,
hiroshiHallo Hiroshi,
as far as I can see, you are doing it the right way. The problem might be that the ABAP program does not fill in this parameter because something went wrong in the SAP System.
Have you tried setting a breakpoint (an HTTP session - remote breakpoint) and tried checking step by step if the value is being processed and put into the REQUTEXT field?
Bye,
Sameer -
Calling Java API from ABAP using JCo
I need to call Java API from ABAP & BSP also. For this I have got useful information related to JCo from following blog:
/people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
But, I am facing one problem. On executing Java program myExample5.java (recommended by Gregor Wolf) from command line I get following error message:
Server JCOSERVER01 changed state from [ STOPPED ] to [ STARTED ]
Exception in server JCOSERVER01:
com.sap.mw.jco.JCO$Exception: (129) JCO_ERROR_SERVER_STARTUP: Server startup failed at Thu Apr 26 13:46:32 IST 2007.
This is caused by either a) erroneous server settings, b) the backend system has
been shutdown, c) network problems. Will try next startup in 1 seconds.
Connect to SAP gateway failed
Connect_PM TPNAME=JCOSERVER01, GWHOST=gateway, GWSERV=3300
LOCATION CPIC (TCP/IP) on local host
ERROR hostname 'gateway' unknown
TIME Thu Apr 26 13:46:32 2007
RELEASE 640
COMPONENT NI (network interface)
VERSION 37
RC -2
MODULE ninti.c
LINE 336
DETAIL NiPGetHostByName2: hostname 'gateway' not found
SYSTEM CALL gethostbyname_r
COUNTER 1.
Can anyone please help me out. Do I need to do any setting?
I'll surely reward points.
Thanks & Regards,
Nilesh KumarHi Nilesh,
From the error i think that the error is with the hostname.
Please enter the the Application Server IP/Hostname.
If you are loggin to SAP System "XX1" from SAP GUI. Then click the change Item tab and see Application server name/IP let say "XX2" for hostname or "xx.xx.xx.xx" for IP.
Replace <i>srv[0] = new Server("gateway","sapgw00","JCOSERVER01",repository);</i>
with <i>srv[0] = new Server("XX2","sapgw00","JCOSERVER01",repository);</i>
If App Server is IP then replace with
<i>srv[0] = new Server("xx.xx.xx.xx","sapgw00","JCOSERVER01",repository);</i>
Let me know if it is throwing any error.
Thanks,
Prashil -
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 -
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 Java methods from C program
After a year or so using these excellent forums to answer my queries, without ever having to post a question, I've finally had to ask for help with this one. I've already looked through the JNI tutorial, and these forums, extensively, but I'm still not quite sure of how best to solve my problem.
I need to call Java methods from a C program. I've already used JNI to call a simple C program from Java, and that's fine, but I just can't determine exactly what I need to do for the reverse to work.
What is the definitive solution for calling Java from C? Is it to use the invocation APIs to create a JVM, and then access it through the various GetMethod, FindClass methods? Or can I 'reverse engineer' the process I followed to get Java to call C?? The tutorial is a bit confusing, as the example it gives uses Callback stuff, but I guess that's only useful when you want to go Java-C-Java??
Advice appreciated,
RichForgive my blatant bumping, but anyone, please?
-
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. -
Hi All,
I need to call a Java function from ABAP. Currently i work on client machine and i have a sample java program with me. What do i need to do in order to execute that Java program from ABAP se38 program?
1. Should i place that java program on server in order to execute?
2. How to maintain RFC Destination in SM59? what is meant by program id and gateway mentioned in in SM59 under create option.
Can some one help me with this regard?
Points will be awarded!!
Thanks in advance,://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/59ef6011-0d01-0010-bfb0-b51381e00509
http://www.erpgenie.com/abap/bapi/example.htm
Reward points if it is useful... -
JCo Outbound( calling Java Function from ABAP )
HI,
I want to call a JAVA function from ABAP.I have installed the JCo toolkit and included the sapjco.jar file in the classpath of my system.
When i execute the program(Example5.java,provided with sapjco.zip) from the command prompt,it is working fine,the server listens to the calls made from ABAP via RFC destination.
But if i copy the same program in NWDS in a JAVA project,to run it from there as JAVA application,after including the sapjco.jar file in the project JAVA build path,i get the following error,marked by a red cross ,at the head of the program,even before i run it.
<b>This compilation unit indirectly references the missing type com.sap.jdsr.writer.DsrIPassport (typically some required class file is referencing a type outside the classpath)</b>
What changes do i need to make,to run it from NWDS?
I tried to include the sapjcorfc.dll file along with the sapjco.jar in the java build path,but it doesn't help.
Please tell how to solve this issue?
Regards,
Siddharthahello sid,
which jco version are you using?
are you using the same jco lib when running in command
line and in nwds?
if you are, try checking the order of the your classpath.
your jco lib (which you are using in command line) should
come first in order prior to the default libraries in your project.
regards
jo -
Calling java class from abap function moduile
Is it possible to call java class from function module.
i am a java guy. my need is to call a java class from a function module in the backend. which in turn performs certain functions.
i would be highly obliged if someone could let me know if this is possible.
regards
Srikumar VHi Srikumar ,
you can call a java webservice in ABAP .
u can call the webservice and via that u can trigger the java class..
Regards
Renu -
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 -
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 Java Services from ABAP code
Hi,
How to call Java services (not web service) from ABAP code?
I have a requirement where JAVA team has developed some services that can be called from URL or from a Java application.
Ex: when this URL is executed,
http://localhost:8080/artemis7_802/triton/mycompany.remoteFunctions.RequirementsList.a7x?requestid=3023&requestname=I6PRAO1&skill=SAP&skill=JAVA
It returns a XML file on browser.
And I have no idea about the 2nd way i.e. from Java application!
Now, how can ABAP call these java methods?
I heard that something can be done via maintaining RFC destinations in SM59 to call Java services? Can this be done with my requirement?
Please help.
Thanks and regards,
AmeyPosted it in WD ABAP forum.
Maybe you are looking for
-
I recently had my macbook stolen so I have purchased a new one. My entire music library is stored on my ipod touvh, I know I should of backed it up somewhere else, but it is too late for that. I am trying to move my music to my new laptop but the maj
-
Local user account is trying to autenticating against domain controller
Hi all. I am seeing a weird user logon issue on one of my laptop and on another user's PC. Both of the laptop and the PC is a member of our domain. However, on this particular laptop and PC, we are not login with a domain user account, rather we'v
-
Samsung M320 Bluetooth connection to Tx
I can pair my Samsung to the Tx, but it will not connect. Are there drivers suitable for the phone? I have updated the drivers however there are none listed for Samsung, Can another be used? Currently, I have paired using the universal driver. Post
-
Problems with South Park Season 12
Is anyone else having trouble buying a season pass for South Park season 12? I can add it to my shopping card, but when I try to buy I get an error message saying "This product is not available in the US store".
-
I have windows XP with Pentium 4 processor, Phonic Helix 8ch mixer with firewire, XFI extreme music sound card and Cubase Le. The issue we are having is that it is not playing back. Is there a conflict between these? We had a friend who uses Cubase f