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

set get parameter

Former Member
0 Likes
1,192

HI all,

I have written code for locking a field, the code is as below

FORM LOCK-RECORD.

CALL FUNCTION 'ENQUEUE_EZHEAT'

EXPORTING

MODE_YHEAT = 'E'

MANDT = SY-MANDT

ZHEAT = YHEAT-ZHEAT

  • X_ZHEAT = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

IF SY-SUBRC EQ 0.

  • V_USER = SY-UNAME.

SET PARAMETER ID 'USER' FIELD SY-UNAME.

ENDIF.

IF SY-SUBRC <> 0.

GET PARAMETER ID 'USER' FIELD V_USER.

MESSAGE E010(ZMSG) WITH 'This Transaction is Locked by' V_USER.

ENDIF.

when I am going to tcode for first time Iam locking the field and using

IF SY-SUBRC EQ 0.

    • V_USER = SY-UNAME.*

SET PARAMETER ID 'USER' FIELD SY-UNAME.

ENDIF.

when I open other session and try to modify I am getting the user name from get parameter as follows

IF SY-SUBRC <> 0.

GET PARAMETER ID 'USER' FIELD V_USER.

MESSAGE E010(ZMSG) WITH 'This Transaction is Locked by' V_USER.

ENDIF.

but second time it is not getting the user name into v_user. I am getting same problem when I am opening screen in oher client.

Can anybody please solve my problem

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
881

You can do this without using PARMETER ID


*&---------------------------------------------------------------------*
*&      Form  enqueue_zlmlead
*&---------------------------------------------------------------------*
FORM enqueue_zlmlead.

  CHECK sy-tcode = 'ZLM02'.

  CALL FUNCTION 'ENQUEUE_EZLMLEAD'
   EXPORTING
     mode_zlmlead         = 'X'
     mandt                = sy-mandt
     leadid               = zlmlead-leadid
   EXCEPTIONS
     foreign_lock         = 1
     system_failure       = 2
     OTHERS               = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "<== This message will handle who has it locked.
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*
ENDFORM.                    " enqueue_zlmlead

5 REPLIES 5
Read only

Former Member
0 Likes
881

Hi

Hope it will help you.

Reward if help.

SET PARAMETER

Syntax

SET PARAMETER ID pid FIELD dobj.

Effect:

This statement sets the content of the SPA/GPA parameter specified in pid to the content of the data object dobj. For pid, a flat character-type field is expected that can contain a maximum of 20 characters, which cannot be exclusively blank characters. pid is case-sensitive. For dobj, a flat, (as of release 6.10 character-type) field is expected, whose binary content is transferred in an unconverted format.

If the SPA/GPA parameter specified for the current user in pid does not yet exist in the SAP memory, it is created. If the SPA/GPA parameter has already been created for the current user, its value is overwritten.

In a program, SPA/GPA parameters can only be created or assigned values if a name exists for them in the table TPARA. The extended program check reports an error if it can statically determine that a name specified in pid is not contained in the database table TPARA. ist.

Note:

For a SPA/GPA parameter specified in pid to match a name in the database table TPARA, it must be entered in upper case.

Example:

If the user selects a flight displayed in the basic list, when the event ATLINE-SELECTION takes place, the SPA/GPA parameters CAR and CON are set to the ID of the airline and the connection number. The names of both parameters are defined in the table TPARA for this purpose. In the initial screen of the transaction DEMO_TRANSACTION, two input fields are linked with SPA/GPA these parameters and are displayed with the selected values as start values.

DATA: carrier TYPE spfli-carrid,

connection TYPE spfli-connid.

START-OF-SELECTION.

SELECT carrid connid

FROM spfli

INTO (carrier, connection).

WRITE: / carrier HOTSPOT, connection HOTSPOT.

HIDE: carrier, connection.

ENDSELECT.

AT LINE-SELECTION.

SET PARAMETER ID: 'CAR' FIELD carrier,

'CON' FIELD connection.

CALL TRANSACTION 'DEMO_TRANSACTION'.

*******************************************************************************************************

GET PARAMETER

Syntax

GET PARAMETER ID pid FIELD dobj.

Effect

This statement sets the content of the data object dobj to the content of the SPA/GPA parameter specified in pid. pid must be a flat character-type field that contains no more than 20 characters and does not consist solely of blanks; it is also case-sensitive. dobj must be a flat and (as of Release 6.10) character-type field into which the binary content of the SPA/GPA parameter is transferred unconverted.

If the SPA/GPA parameter specified in pid was not yet created in the SAP Memory for the current user, the data object dobj is initialized and sy-subrc is set to 4.

In a program, only those SPA/GPA parameters can be read for which there is a name in the table TPARA. The extended program check reports an error, if it can be statically determined that an ID specified in pid is not in the table TPARA.

System fields

sy-subrc Meaning

0 The SPA/GPA parameter specified in pid exists for the current user in the SAP Memory and its value was transferred to the target field.

4 The SPA/GPA parameter specified in pid does not exist for the current user in the SAP Memory.

Notes

An SPA/GPA parameter that is readable with GET PARAMETER can previously have been created in the SAP Memory using the SET PARAMETER statement or automatically during the event PAI of a screen or selection screen.

For an SPA/GPA parameter specified in pid to match a name in the database table TPARA, it must be specified in uppercase.

Example

In this example, the current value of the SPA/GPA parameter RID is read from the SAP Memory to the data object prog. In the screens of the ABAP Workbench, this parameter is linked with the input fields for a program name. When an ABAP Workbench tool, in which an ABAP program is processed, is first called, the parameter is created at the event PAI and assigned the name of the program specified there. If in the same user session, no screen is processed that set the parameter RID and no corresponding SET PARAMETER statement was executed beforehand, RID is not found in the SAP Memory.

DATA: para TYPE tpara-paramid VALUE 'RID',

prog TYPE sy-repid.

GET PARAMETER ID para FIELD prog.

IF sy-subrc <> 0.

MESSAGE 'Parameter not found' TYPE 'I'.

ENDIF.

Read only

Former Member
0 Likes
881

Hi,

what exactly happening is that you are setting the memory

with some value and you are not clearing the memory before starting of the second session . So it is not getting the user name into v_user. What you can do is try to free the memory id through this statement

FREE memory id 'USER' .

Your problem will be solved.

Reward some points.

Bye,

Anomitro

Read only

0 Likes
881

Thanks for your response,

I am not clear, can you please explain clearly, As I modified the code as below,

FORM LOCK-RECORD.

CALL FUNCTION 'ENQUEUE_EZHEAT'

EXPORTING

MODE_YHEAT = 'E'

MANDT = SY-MANDT

ZHEAT = YHEAT-ZHEAT

  • X_ZHEAT = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

IF SY-SUBRC EQ 0.

  • V_USER = SY-UNAME.

SET PARAMETER ID 'USER' FIELD SY-UNAME.

ENDIF.

IF SY-SUBRC <> 0.

FREE memory id 'USER'.

GET PARAMETER ID 'USER' FIELD V_USER.

MESSAGE E010(ZMSG) WITH 'This Transaction is Locked by' V_USER.

ENDIF.

ENDFORM. " LOCK-RECORD

It is not working, as If we clear the memory how can we retrieve back.

Read only

Former Member
0 Likes
882

You can do this without using PARMETER ID


*&---------------------------------------------------------------------*
*&      Form  enqueue_zlmlead
*&---------------------------------------------------------------------*
FORM enqueue_zlmlead.

  CHECK sy-tcode = 'ZLM02'.

  CALL FUNCTION 'ENQUEUE_EZLMLEAD'
   EXPORTING
     mode_zlmlead         = 'X'
     mandt                = sy-mandt
     leadid               = zlmlead-leadid
   EXCEPTIONS
     foreign_lock         = 1
     system_failure       = 2
     OTHERS               = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "<== This message will handle who has it locked.
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*
ENDFORM.                    " enqueue_zlmlead

Read only

0 Likes
881

Thanks for your response.

Can you please explain me clearly,

How you are getting as I think you have taken that field leadid = zlmlead-leadid in lock object. but my purpose is different, I want to diplay message as below " MESSAGE E010(ZMSG) WITH 'This Transaction is Locked by' V_USER."

System should dynamically display the message dynamically when this is called from other client (that Tcode is locked by previous user).