2011 Jul 21 6:12 AM
Hi Experts,
My requirement is to call a RFC Java function in SAP. The Java function is an encryption function which has 4 parameters (Password, Message, Strength128, Strength256). I need to pass the data for the parameters from SAP to JAVA. With the help of SDN, I tried to call this function in ABAP. A destination named 'INTEGRATION' is created in SM59, with the registered Program ID 'ASEncryptionHelper'. ASEncryptionHelper is the Java function name and the program ID is registered with this name only. The following is the code I wrote in my report
DATA: XPASS TYPE STRING.
XPASS = 'PASS'.
CALL FUNCTION 'ASENCRYPTIONHELPER' DESTINATION 'INTEGRATION'
EXPORTING
PASSWORD = XPASS
MESSAGE = XML_RESULT
STRENGTH128 = ' '
STRENGTH256 = 'X'
.
I have created a RFC function module in my SAP system with the name ASENCRYPTIONHELPER
FUNCTION ASENCRYPTIONHELPER.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(PASSWORD) TYPE STRING
*" VALUE(MESSAGE) TYPE STRING
*" VALUE(STRENGTH128) TYPE BOOLEAN
*" VALUE(STRENGTH256) TYPE BOOLEAN
*"----
ENDFUNCTION.
When I execute the program I get a runtime error "Bean ASENCRYPTIONHELPER not found on host HOSTNAME".
I am not able tofigure out the exact problem.
Also I wanted to know whether the way I am coding is right. Do I need to create a RFC function module in SAP also as I did above?
Does the Uppercase of the function 'ASENCRYPTIONHELPER' matter? In SM59 the program id is mentioned as 'ASEncryptionHelper'.
I tried to change the function name with 'ASEncryptionHelper' in the CALL FUNCTION, but then I get another error, "JCO.Server could not find server function 'ASEncryptionHelper' '. What is wrong? I am confused.
Please guide.
Thanks
Anu.
2011 Jul 21 6:45 AM
Hi,
I didn't get your requirement wxatly but you can do as below,
What I am assuming is you have a java batch file at your desktop and you want to encrypt the file through this batch file execution from SAP.
Now to execute the batch file at runtime and to pass data at runtime you can use below function module
W_RFCENCRY = 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'.
W_RFCDEST = 'ZRFC'.
CALL FUNCTION 'RFC_REMOTE_PIPE'
DESTINATION W_RFCDEST
EXPORTING
COMMAND = W_RFCENCRY
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 4.
Here ZRFC is the RFC created in SM59 as below
1) select TCP/IP and create ZRFC
in program option type as below C:\RfcSdk\bin\rfcexec.exe
Note: RFCDSK folder is required to execute the batch file at your workstation at path specified as above
2) In activation type select start on front end work station radio button.
Now save the RFC and check the connection, same will be there if RFC SDK folder is available as specified in the program option
In W_RFCENCRY give the inputs that you want to pass with the batch file.
here I have mentioned as 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'. in the program where C:\Encrypt\enc.exc is the path for batch file and C:\Encrypt\test.txt is the path of the file on the work station which is to be encrypted.
Hope this will help you, I think at your end batch file can be different and inputs to be passed in the batch file can also be different.
2011 Jul 21 7:02 AM
Thanks Umang for your reply.
But in my requirement I already have the encrypt and decrypt function at the Java end. What I need to do is call this encrypt function in SAP and pass the four parameters as I mentioned in my post above. I don't have any batch files generated here. The XML_RESULT is the xml output of the data that I need to send to JAVA. XML_RESULT contains SAP data that I get after I use CALL TRANSFORMATION in my report. Without the CALL FUNCTION..DESTINATION my report is able to make connection to the JAVA system and its able to send the SAP data also. The error comes when I use CALL FUNCTION.
Please guide.
Thanks
Anu.