-3

I am currently developing a C# application with SAP NCo 3. I am wondering if I could invoke BAPI into CUA and this BAPI would pass details to child system.

This field is available through Test Function Module (field "RFC target sys"), but it is unavailable directly in standard BAPIs when accessed from SAP NCo.

RFC target sys:

In ABAP, devs can use:

call function 'BAPI_USER_CHANGE' destination '<TARGET_SYS>'

Can I use something similar in NCo library?

IRfcFunction rfcs = rfcDest.Repository.CreateFunction("BAPI_USER_CHANGE");

Does anybody know how this could be achieved?

Main intent is to reset user passwords to initial ones through App(BAPI) --> CUA --> ChildSystem

Without direct access into child systems.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
scetu
  • 47
  • 9
  • Could you split into two distinct questions "how to reset a password via BAPI in a CUA environment" and "how to call a BAPI function on a given SAP system via NCO C#", or could you clarify the question if I didn't understand well? – Sandra Rossi Jan 30 '20 at 15:13
  • Does this answer your question? [How to execute RFC function on explicit destination using JCo?](https://stackoverflow.com/questions/51082276/how-to-execute-rfc-function-on-explicit-destination-using-jco) – Suncatcher Jan 30 '20 at 15:24
  • @Suncatcher no, this is not suitable for our environment – scetu Jan 31 '20 at 09:38
  • @SandraRossi well I am not asking for your second suggestion, I know how to do that, but I will edit my post per your first suggestion – scetu Jan 31 '20 at 09:40
  • nothing special in your environment. `GetDestination(String name)` perfectly [do this](https://help.sap.com/doc/saphelp_tm81/8.1/en-US/5b/617bcd479b46a1829ac0d7886903fb/content.htm?no_cache=true) – Suncatcher Jan 31 '20 at 10:48
  • @Suncatcher I am already using this, but problem is that business requirement is that everything should be managed through CUA, not directly in the end system (child systems). We are able to change passwords through CUA in child systems (set initial password thorough SU01 where we select destination system) but through BAPI there is missing "DESTINATION" field where I could put RFC conn which is present in CUA (SM59) So basically I am invoking BAPI in CUA and I would like to change password in child system through this BAPI – scetu Feb 01 '20 at 12:35
  • Also during my testing, I was connected to end system, and everything was OK, I was able to change password for user through BAPI. But as I said, I am not able to change password in child systems when BAPI is invoked in CUA - I am only able to change password directly for CUA. – scetu Feb 01 '20 at 12:42

2 Answers2

0

Hmm, it looks like you have not yet fully understood the meaning of "RFC target sys".

In SE37 "RFC target sys" you enter the name of an RFC destination, which provides details about in which SAP system you want to execute the function module. These details are then defined in SM59, where you can specify parameters like hostname, system number, client, user, password, language, etc.

In the NCo library you do the same via the Class RfcDestinationManager. Here you define the parameters (hostname, system number, client, user, password, language, etc.) of the target system in which you want to execute the function module.

So the line

"RFC target sys: TARGET_SYS"

in SE37 corresponds to a line like

RfcDestination myDest = RfcDestinationManager.GetDestination("TARGET_SYS");

in your .NET program.

And a line of ABAP code like

call function 'BAPI_USER_CHANGE' destination 'TARGET_SYS'

would then correspond to some .NET code like

RfcDestination targetSys = RfcDestinationManager.GetDestination("TARGET_SYS");
IRfcFunction bapiUserChange = targetSys.Repository.CreateFunction("BAPI_USER_CHANGE");
targetSys.Invoke(bapiUserChange);

Note: setting of the input values and error handling is omitted here.

Lanzelot
  • 15,976
  • 4
  • 18
  • 14
0

Ok, so I found out that what I wanted to achieve is not possible with just sapnco.

But, in SAP I created function module, which calls function module and uses DESTINATION 'target_sys' to run in end system. This way I achieved what I wanted. By calling my Z_FUNC_MODULE from sapnco I pass variable target_sys and FN is called in child system of CUA.

Hope this helps to someone.

scetu
  • 47
  • 9