Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Call Java from ABAP

former_member190312
Active Participant
0 Kudos

Hi all,

I have installed JCO & created the RFC in SAP. i have used below code to test my RFC connection & it's working fine.

But In the below report, where to call the JAVA Program & what code i should use to call java code .

Actually my ABAP requirement is to download a file. Then i need to call JAVA program, inside ABAP, to encrypt the downloaded file. Here, Java program is used to encrypt the file. Now question is, how to call the Java program inside the ABAP code. Please advice with the code sample. Thanks a lot.

REPORT z_jco_test.

PARAMETERS: requtext LIKE sy-lisel.

DATA: echotext LIKE sy-lisel,

resptext LIKE sy-lisel,

rfctest TYPE TABLE OF rfctest,

wa_rfctest TYPE rfctest.

wa_rfctest-rfcdata1 = requtext.

wa_rfctest-rfcdata2 = 'Hello World'.

APPEND wa_rfctest TO rfctest.

CALL FUNCTION 'RFC_PING'

DESTINATION 'JCO'.

CALL FUNCTION 'STFC_CONNECTION'

DESTINATION 'JCO'

EXPORTING

requtext = requtext

IMPORTING

echotext = echotext

resptext = resptext

TABLES

rfctest = rfctest.

WRITE: 'Echo Text: ', echotext.

WRITE: 'Response Text: ', resptext.

LOOP AT rfctest INTO wa_rfctest.

WRITE: / 'rfcdata1: ', wa_rfctest-rfcdata1.

WRITE: / 'rfcdata2: ', wa_rfctest-rfcdata2.

ENDLOOP.

1 ACCEPTED SOLUTION

former_member190312
Active Participant
0 Kudos

Hi all,

Anybody can help on this requirement.

Thanks

pabi

5 REPLIES 5

former_member190312
Active Participant
0 Kudos

Hi all,

Anybody can help on this requirement.

Thanks

pabi

0 Kudos

Anybody can help on this requirement. Thanks

0 Kudos

Hi pabitra,

perhaps a bit more complex. You will have to distribute a HTTP Request Using the SAP Web Dispatcher. Check here for more details: [SAP Web Application Server with ABAP and J2EE|http://help.sap.com/saphelp_47x200/helpdata/EN/53/97583c2439e66fe10000000a114084/frameset.htm]

Didn't you ask yesterday? ([Calling Java program from ABAP|]).

Regards

Clemens

0 Kudos

Hi,

You might accomplish your goal using external operating system commands.

1) Define in SM69 an external command, letu2019s say ZJAVA. This command will execute a script on the operating system, letu2019s call it calljava.sh.

2) In script calljava.sh you just call java, passing some parameters. For example, java $1 $2 $3 $4 $5 $6 $7

3) In your ABAP program you call the ZJAVA external command and pass parameters to it. Of course, one of the parameters must be your Java program name.


  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
    EXPORTING
      commandname                   = l_command
      additional_parameters         = l_param
      trace                         = 'X'
    IMPORTING
      status                        = l_status
      exitcode                      = l_exitcode
    TABLES
      exec_protocol                 = l_exec_protocol_itab
    EXCEPTIONS
      no_permission                 = 1u2026

0 Kudos

Hi Clemens,

Thanks for your information. what are the things i should install so that i can use SSF function modules in ABAP to encrypt the file.

Thnak a lot.

pabi