Skip to Content
avatar image
-3
Former Member

Unable to get Selection screen parameter value of main program inside RFC

Hello experts,

I have created a program ZTEST_01 in which I am calling a remote enabled FM inside the program.

In RFC, I am assigning a field symbol dynamically with the value of a selection-screen parameter of my main program ZTEST_01. Somehow, the assign statement is failing/ unable to assign the correct value to the target field symbol.

Here is the code snippet for the main Program and RFC FM

Code snippet for the main Program:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
 PARAMETERS p_rel TYPE boole_d AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b1.

Here is the piece of code from RFC :

LV_FIELD_NAME = '(' && SY-CPROG && ')' && 'P_REL'.
IF <RELEASE_ACTIVE> IS NOT ASSIGNED.
  ASSIGN (LV_FIELD_NAME) TO <RELEASE_ACTIVE>. 
    IF SY-SUBRC = 0 AND <RELEASE_ACTIVE> IS NOT INITIAL.
      LV_RELEASE_REQUIRED = ABAP_TRUE.
    ELSE.
      LV_RELEASE_REQUIRED = ABAP_FALSE.
    ENDIF.
ENDIF.

P_REL is a parameter of main program ZTEST_01.

Here, sy-cprog returns the program name as SAPMSSY1 and hence system tries to find the paramater P_REL in program SAPMSSY1 rather than looking into main program ZTEST_01.

Kindly help !

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 25, 2017 at 06:55 AM

    Hi!

    If you are calling RFC FM it starts in new LUW and you will not see your parameter from other LUW via direct assign (see link https://help.sap.com/saphelp_nw73/helpdata/en/48/88068ad9134076e10000000a42189d/content.htm).

    So if you need to get the value from selection screen of the calling program you should pass it into RFC FM via FM interface or via memory.

    Hope it's helpful

    Evgeny

    Add comment
    10|10000 characters needed characters exceeded

    • Not sure for "set/get parameter" (which is using the memory named "SAP memory") as the OP didn't say which kind of RFC he/she used, as for instance synchronous RFC "NONE" doesn't "traverse" user sessions.

      The following link is better for understanding the memory context : General Memory Organization.

      Addendum: and for shared memory, one needs also be careful that it happens on the same server (if the system has more than one server; it also depends on the type of RFC, SRFC "NONE" would go to the same server for instance if I remember well)

  • Apr 25, 2017 at 08:03 PM

    Just pass all the information to the FM in the parameters, as the mother nature intended.

    See this blog about ASSIGN - it has a moderator warning for a reason.

    Add comment
    10|10000 characters needed characters exceeded