cancel
Showing results for 
Search instead for 
Did you mean: 

how to trigger a tcode using JCO3.0

Former Member
0 Kudos

Hi I am new to SAP and i am working with JCO 3.0. I want to trigger a tcode using JCO. How to achieve that any sample program or idea how to trigger a tcode using JCO API.

Accepted Solutions (1)

Accepted Solutions (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Utsav,

the function module ABAP4_CALL_TRANSACTION will allow to call a crtain transaction. Please note that this will require that the connection is opened with SAPGUI as transactions are typically triggering functionality that wants to do some output on GUI screens. See DestinationDataProvider.JCO_USE_SAPGUI for more info. But one remark from my side: It will be better to use a dedicated function module that provides the functionality you need for your purposes. Calling a transaction is not the preferred approach.

Best regards,

Markus

Former Member
0 Kudos

thanks markus for your reply. What i understood is i have to create a property for this

ex:     connectProperties.setProperty(DestinationDataProvider.JCO_USE_SAPGUI, "1");

Now here i want to confirm one thing that JCO_USE_SAPGUI property should be tid or tcode

or

i have to set Set the Property USE_SAPGUI to 1 (dark) or 2 (light) as mention in the doc.

Starting SAP GUI - Components of SAP Communication Technology - SAP Library

I have not seen any sample JCO program using the above link. If you have any sample program to trigger the tcode please share that will be helpful for me.

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

DestinationDataProvider.JCO_USE_SAPGUI is a constant that specifies the logon property jco.client.use_sapgui. You may add this logon property to your *.jcoDestination file like every other logon parameter. Valid values are: 0 - do not start [default], 1 - start GUI, 2 - start GUI and hide (invisible)

I think the online docu (via provided link) is not correct regarding the meaning of values 1 and 2.

I suggest that you use the JavaDoc documentation that is shipped with the JCo SDK download archive.

Open ./javadoc/intro.html or directly ./javadoc/index.html

As explaiined by Markus, using remote function module ABAP4_CALL_TRANSACTION is a very uncommon approach for RFCs. Calling appropriate dedicated remote function modules that provide the needed functionality is recommended instead. Therefore I do not think that any JCo examples using ABAP4_CALL_TRANSACTION exist at least from SAP side.


In general, the difficulty is not with the technical handling in Java but to know what functionality an existing ABAP function module provides, what values to fill in for the import/changing/tables parameters and how to interpret the returned values in export/changing/tables parameters. So knowledge about the business logic.

The first thing to do for understanding a function module is to look into its function module documentation, if available (via SE37, for example). As the RFM ABAP4_CALL_TRANSACTION basically offers the ABAP language command "CALL TRANSACTION" with various additions to be executed remotely, appropriate ABAP knowledge would help most here.

Answers (1)

Answers (1)

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Utsav,

just a gentle hint from my side:

I realized that you do not seem to reward people with points for giving correct and/or helpful answers in this forum so far. So I'm not sure if you will find further motivated users that are willing to help you here.

Best regards,

Stefan

Former Member
0 Kudos

oh ! i didnt knew that , i will do that, can you please let me know how can i trigger a tcode using JCO

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks, Utsav.

Markus already gave the correct answer.

Best regards,

Stefan