Application Development and Automation 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: 
Read only

Create new user session after RFC connects

Former Member
0 Likes
2,006

Hi,

My client is non SAP. They connect to SAP through an intermediate software , using RFC connections. My client requires that when creating a BOM through BAPI, the "created by" column should have a user name they pass, and not the username with which the RFC connected .

Is it possible to have a FM in which I can create a new user session, passing username and password, call the bapi that will create the BOM with this username, and close the session?

Kindly help.

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,540

Dear Mr. Raymond,

When I started coding I realised that I cannot get the return table that gets populated in the BAPI,which I have written inside a report that I use to submit, since a report can't return anything. Can you provide me a solution for this?

Thanks a lot in advance.

Edited by: philipte on Feb 9, 2012 1:45 PM

Hi,

My client is non SAP. They connect to SAP through an intermediate software , using RFC connections. My client requires that when creating a BOM through BAPI, the "created by" column should have a user name they pass, and not the username with which the RFC connected .

Is it possible to have a FM in which I can create a new user session, passing username and password, call the bapi that will create the BOM with this username, and close the session?

Kindly help.

Thanks in advance

10 REPLIES 10
Read only

Former Member
0 Likes
1,540

Hi,

You just create an FM(RFC) to create a BOM and user name. if the user name is already exist then skip the creation part and reuse the same user. Creating a user there is some function modules try that one.

Read only

Former Member
0 Likes
1,540

These users already exist in the system. But they connect to SAP using a common communication userid. The requirement is that, although there is only one communication userid, once connected to SAP, login again with the userid, password passed by the caller, then call the bapi.

Read only

Former Member
0 Likes
1,540

Can anybody help me on this issue?

All i need to know is this.

If i have logged in with user 'A' , inside a FM, can i write any kind of code that would let me login with a different username 'B', so that sy-uname would be 'B' now instead of 'A' , so that all my transactions with create stuff with the "created by" field as 'B'.

Thanks in advance,This is very urgent.Please help

Read only

0 Likes
1,540

AFAIK it is not possible in interactive mode. You could try to create a background job with user 'B' from user 'A' RFC session (Connection user 'A' will require authorization S_BTCH_NAM, sample in )

Regards,

Raymond

Read only

0 Likes
1,540

Thanks Mr. Raymond. That was very useful. I was able to create a Material BOM using a different username. My only question is, will this cause any audit issue, ie providing username exolicitly?

Read only

0 Likes
1,540

Most security audits will trigger a warning when they determinate that the RFC common user is allowed to use another logon id. Usually you can provide auditors a list of such id with explanation before the audit execution, sample of explanation to provide :

- The RFC enabled FM which create the batch job must pass the logon id to be used, and the calling application must not allow user to change this value.

- The RFC default logon, should be allowed to the minimal authorization required, and could be for example allowed to no transaction, only some RFC FM. (start with [Note 460089 - Minimum authorization profile for external RFC programs|https://service.sap.com/sap/support/notes/460089])

Regards,

Raymond

Read only

Former Member
0 Likes
1,541

Dear Mr. Raymond,

When I started coding I realised that I cannot get the return table that gets populated in the BAPI,which I have written inside a report that I use to submit, since a report can't return anything. Can you provide me a solution for this?

Thanks a lot in advance.

Edited by: philipte on Feb 9, 2012 1:45 PM

Read only

0 Likes
1,540

One suggestion (many solutions to synchronioze two jobs/sessions)

In the calling report (in the RFC session)

- Submit the batch job with immediate execution

- In an endless do-loop, wait the job end (eventually abort) via BP_JOB_CHECKSTATE or similar FM and WAIT some SECONDS statement

- Read (import from database) the return table

In the called report (in the batch job)

- Execute the BAPI and COMMIT/ROLLBACK

- Store the return table in a database table (like an INDX table, insert via export to database statement) with the jon number as a key

Regards,

Raymond

Read only

Former Member
0 Likes
1,540

Hi Philipte,

Actually this requirement is getting complex for you, better you change the created by field with the new user name, there are certain exit's available in this BAPI, or even you can modify the stack data and change this details. This will let you get the exact user name in your document also this will not look for a new session.

Best Regards,

Tapodipta Khan.

Read only

Former Member
0 Likes
1,540

Thanks Everyone for replying, Esp. Mr. Raymond. I was able to resolve the issue. I used Export to Database & Import from Database as suggested.There is an inconsistency sometimes, but I will try to resolve that myself.

Thanks a lot once again.