Application Development 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: 

Sy-TCODE CAPTURE WHILE RFC COMMUNICATION.

Former Member
0 Kudos

Hi ,

I am not able to get desired result from function module.

RFC_GET_ATTRIBUTES.

Actually I am trying to get SY-TCODE from caller programe which is a web service  because all the check which are available in my BADI are based on Sy-Tcode which is not having the value at run time(Blank when called from outside). Hence I am TRING TO fetch s-tcode using this FM  RFC_GET_ATTRIBUTES but still it is failed.

Kindly Suggest some solution.

Regards:

Himanshu Sharma.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Well transaction code is often undefined in background or other not transaction environment...

  • Why do you check sy-tcode, does the BAdI not provide other informations (like a AKTYP field) that you could use ?
  • Is your BAdI executed in a BAPI and in transaction, and this is the first call from outside of transactions ?
  • Else when implementing WS, you could pass a transaction code as a new parameter

Regards,

Raymond

6 REPLIES 6

Former Member
0 Kudos

You have to send it as a parameter.

Neal

0 Kudos

Hi Neal,

Thanks for your support.

I am wondering why this standard function module is not giving desired result.

Well it is working as Set parameter ID in starting of BAPI call and Get Parameter ID just before the BADI check. It is working.

Can you help me in this function module method.

Regards:

Himanshu Sharma

0 Kudos

It is working as SAP always works.  An alternative is to use an export import pair.  When you would have set the PID, export.  When you would have read the PID, import. You may have to export to database instead of memory.

Neal

raymond_giuseppi
Active Contributor
0 Kudos

Well transaction code is often undefined in background or other not transaction environment...

  • Why do you check sy-tcode, does the BAdI not provide other informations (like a AKTYP field) that you could use ?
  • Is your BAdI executed in a BAPI and in transaction, and this is the first call from outside of transactions ?
  • Else when implementing WS, you could pass a transaction code as a new parameter

Regards,

Raymond

0 Kudos

HI Raymond,

Thanks for your reply.

In regard to your second point.

yes, BADI is being executed in BAPI environment.

What I have done is: I have set parameter ID before calling BAPI(RFC)  and putting Get Parameter ID at before the BADI check.

E.G.

Set Parameter ID 'VT01N' Field 'PID'        "Just before Bapi is called

CALL FUNCTION 'BAPI_SHIPMENT_CREATE'

-----

-----

Get parameter ID 'LTCODE' field 'PID'.

use ltcode instead of sy-tcode.

If SY-TCODE = 'VT01N ' OR LTCODE = ' '.

endif.

It is working in this way. But is their any Better Solution ??

Please suggest.

Thanks.

Regards:

Himanshu Sharma

0 Kudos

No you solution works and is clean, it's okay. Another solution would have to analyze the abap call stack in the BAdI to identify the caller (FM SYSTEM_CALLSTACK) but only if you want the BADI react the same way every call from this BAPI (so you no longuer have to code the SET PARAMETER ID before each call, and clear it after)


Regards,

Raymond