SAPJco invoking BAPI_MATERIAL_DISPLAY - sap

I was trying to invoke BAPI_MATERIAL_DISPLAY functional module from SAP JCO, This is how i pass my input parameter.
function.getImportParameterList().setValue("MATERIAL", "10");
From my program output i got
The material 10 does not exist or is not activated.
If I execute BAPI_MATERIAL_DISPLAY using SAP logon, iam getting the entry. Using debugger I found that,
My input is going as 00000000000010. And so returning response.
Dunno, how to handle this in a proper way in SAPJCO.
I had directly passed the value 00000000000010 from SAPJCo and this time i got an error,
com.sap.conn.jco.JCoException: (104) JCO_ERROR_SYSTEM_FAILURE: Screen output without connection to user.
Hope SAP is opening a popup. Let me know how to solve both the issues in SAPJCO

Field Material has a conversion exit routine. See also its domain MATNR in the DDIC.
These conversion exits are always called automatically by SE37 but not when the Remote Function Module is called directly - like here from outside from a a JCo program.
So if the BAPI expects to get certain parameters in their SAP internal representation format (I don't know if this is the case here), then you have to do this data transformation on your own beforehand, either by doing this purely within an own routine at Java side, or by calling the appropriate conversion routines at ABAP side via RFC.
For more details on this I recommend to study SAP note 206068.
Regarding your second question with the error message "Screen output without connection to user", I guess that this BAPI expects to have a connection to an SAP GUI for displaying the selected data. With a remote function call you don't have a SAP GUI connection by default, but you can attach a SAP GUI to your RFC connection with JCo, namely by specifying the additional logon parameter jco.client.use_sapgui=1. For this to work, an SAP GUI frontend (either for Windows or for Java) also needs to be installed on your host where JCo is running, of course.

Related

How to get the name of the calling program in an asynchronous background task?

How to get the name of the calling program from within an asynchronous remote function call (aRFC) ?
CALL FUNCTION 'BAPI_MATERIAL_SAVEREPLICA' STARTING NEW TASK lv_taskname
DESTINATION IN GROUP DEFAULT
The called BAPI triggers a user exit that I need to disable for this particular calling program. However, the local part of the stack is lost after the RFC and the name of the calling program on the local system is unknown.
The closest solution I could think of was disabling the user exit when the calling program is SAPMSSY1 (RFC calls), but that it not as accurate.
Maybe the parameter CALLER_PROGRAM of the function module RFC_GET_ATTRIBUTES. I'm not sure it works in all kinds of RFC calls.

Old ABAP code still active for PyRFC even after TR was imported. Why?

I changed an ABAP RFC module in a SAP system X and transported the changes the Y. Now when I call the RFC SAP stills executes the old code.
I compared both versions from X and Y with a diff tool and found no differences, so it looks like the changes where transported. Is there a special step needed to activate my ABAP RFC code?
I use PyRFC as a client library.
We had the same problem with one of our RFC FMs. Reason was that the connection remained open once it was established. In this case, the binaries are not refreshed in the RFC context. Simply restart the connection and everything should work as desired.
This is a known issue: https://github.com/SAP/PyRFC/issues/89
Quoting the issue:
After the Python script ended, the connection should be automatically
closed and SAP NW RFC SDK initialised. Here what happens under the
hub.
Python interpreters and PyRFC instances share the same SAP NW RFC SDK
lib instance and when the remote enabled function module (RFM) is
called for the 1st time, the RFM metadata are cached inside SAP NW RFC
SDK. When the 2nd call of the same RFM requested from Python/PyRFC,
the SAP NW RFC SDK returns the metadata from cache, rather than
reading again from ABAP system, saving one Python/ABAP roundtrip and
some performance, especially in case of complex RFMs. If the RFM
signature changed in the meantime, the cached RFM metadata are not
changed and Python "sees" the old ABAP code.
I hope a developer friendly solution will get used for the future.
There is no need for activating anything. It should be fine as you transport it.
You can try these;
Transport everything again.(Including other tasks of the same request)
Check the destination field in your call to see if you are calling the correct system
Clear the buffer => TCode /$sync

Calling COM component method from IBM Notes 9 fails

When calling a 32 bit COM component method registered in sysWOW64 fails with an error message:
"type mismatch in method OleVarToLsVal, Unknown found, Unknown
expected"
Its win7 64 bit, but the Notes client is installed by default as a 32 bit application. The code looks like:
dim c as Variant
dim n as Variant
set c = createobject("MSWC.counters")
n = c.Get("xx")
When debugging the call, the object is set and testable with "isObject(c)", (although you can't inspect each method/property in detail in LotusScript debug).
The method is supposed to return a primitive long. I've tried setting n as long, clng-ing the values, cstr-ing the values, the parameter, strconv the parameter, using a variable for the parameter, all to no avail.
The exact same code run by WScript VBS host (in syswow64) runs the code as expected.
So, does anybody know:
If Notes 9 COM value marshalling is working for any components?
Is Notes 9 COM set to recognize the 'wow64' alternate 32 bit registry
Are there some COM related marshalling settings somewhere in the registry I can check (if so what/where are they)?
Is there some setting to tell Notes to use 32 bit components (like IIS 32bit compatibility option)
Is there anything I need to do or could do in the main OS to 'redirect or configure' COM
Or is Notes just broken again and nobody cares?
Any help appreciated - Thanks.
The easiest and probably most productive way to solve this would be to open a PMR with IBM. They should be able to answer this quite quickly.
Well, 7 years on (and seriously obsolete!) just an update for anybody looking for an answer... There are a couple of Notes settings needed and not all COM/Active-X componenets or data types are supported by LotusScript, so even if Notes is setup correctly, you still may not be able to acces/use any specific component or some methods in the component.
The user must be allowed to run unrestricted agents/code in the 'Sign or run unrestricted methods and operations:' in the security section of the server(s) document.
The Notes client execution control list ('ECL') must allow access to 'External programs' either by default or to the code-signer. An ECL warning box will ask the user to continue if the external access has not been granted.
If you try to execute an unsupported method or unsupported data type, then further errors will be issued either by LotusScript or COM/Active-X error reporting. The Notes developer help file for 'CreateObject' gives a bit more detail about unsupported data types:
LotusScript does not support identifying arguments for OLE methods or properties by name rather than by the order in which they appear, nor does LotusScript support using an OLE name by itself (without an explicit property) to identify a default property.
Results are unspecified for arguments to OLE methods and properties of type boolean, byte, and date that are passed by reference. LotusScript does not support these data types.
Relying on the 'default property' to access a default method is a common mistake and requires you to pay extra attention to the component details. It is easy to assume the component is not working, but in fact you're just not using it properly.
One way to test this is to try to open a common object available on all Windows machines (maybe others?) maybe 'FileSystemObject' (FSO) or VbScript 'regExp' component. If these work, you can build on that. Getting the 32/64bit registration correct for your client install is another element to test/get right.
For my issues, I suspect that I was using unsupported methods or data types and having used COM/Active-X in Notes occasionally, its all worked ok in general.

Using search help for different system?

I need a search help for my bukrs field. The problem is data should come from different system. There are 2 systems like X and Y. i am in X system and running a program.
At selection screen bukrs field exists. When i click on search help data should come from system Y.
I heard that it is possible to pull data to search help but couldn't find enough info in sites.
Best Regards.
5 month experienced with SAP/ABAP :)
To create a search help with a custom data selection, you can define a search-help exit in your search help. To select data in a custom way and not from a database table, go to the tab "Definition" of the search help, remove the content of the input "Selection Method" and enter a function module into the input "Search help exit". This function module must have the same signature as the example module F4IF_SHLP_EXIT_EXAMPLE. The comments in the sourcecode of this example module will explain you how to implement it. Your implementation of this function module can then perform the data acquisition from another system with a remote function call.
To get data from another system, you have to call a function module in a remote system via RFC (remote function call). To do this you need:
the RFC-capable function module in the remote system which exports the data you need. You can set a tick on the properties tab of a function module to make it RFC-capable.
An RFC connection from the local system to the remote system. RFC destinations can be created and configured with the transaction SM59.
To call a function module via RFC, you just have to add DESTINATION [rfc-destination] to the function call.
CALL FUNCTION 'Z_YOUR_RFC_CAPABLE_FUNCTION_MODULE'
DESTINATION 'my_rfc_destination'
IMPORTING [...]
The user will have to log into the remote system in order to call RFC function modules in it, unless you define a username with password in the RFC connection. When you do that, you should create a dedicated system user in the remote system with minimal permissions especially for this RFC connection. When the user has too wide permissions, the RFC connection can be abused for other purposes.

Exception: RFC callback server not available while calling RFC

I'm trying to upload a file from a server directory to the SAP CRM System (attachment to an Opportunity), therefore I am using the method create_with_file of the cl_crm_documents class.
To call this method I am using a RFC-Function created by myself.
If I test my RFC-Function within the Function Builder, everything works fine.
If I execute the RFC from a external System (in my case MS-Outlook) an error occurs: "Exception: RFC callback server not available".
I started the debugger and the program runs about half way through (So the connection works):
The create_with_file calls a couple of functions until the RFC_START_PROGRAM function is called. The error occurs exactly at this line.
Does anybody know why the error occurs only if I call the function remotely? How to solve this?
I don't have access to a CRM system, but this is what's probably happening: The class you use tries to perform some action on the front-end PC using the SAP GUI. For this, it performs an RFC call back or the SAP GUI. This works fine as long as you are using the function builder because there's a GUI connection available. Once you use some other means to invoke the function module, the GUI is no longer there and the program won't work. I'd suggest you check the code to see whether there is some parameter or customization that allows you to suppress the RFC call...