‎2006 Jun 05 6:03 AM
Hi.
What is set and get parameter? where and how can we use this?
‎2006 Jun 05 6:06 AM
Hi,
You can use the SET and GET parameter for HOTSPOT. i.e. if you have provided a hotspot on Report Output and when user clicks on that value, you want to call another transaction with the clicked value as input, then use SET Parameter in the report program. In the called program, use GET parameter to retrieve the value.
It can also be used to pass value from one screen to another in module pool.
Best regards,
Prashant
‎2006 Jun 05 6:08 AM
IMPORT and EXPORT are program specific (ABAP Memory) and it depends on what memory id the developer is giving.
Where SET / GET PARAMETER, there is a memory id associated with a field all the time.
You cannot use IMPORT / EXPORT when you want to pass something to Standard programs, like for example CALL TRANSACTION tcode AND SKIP FIRST SCREEN. Here you will have to use the SET/GET.
example........
data: cac_kokrs like coas-kokrs,
get parameter id 'CAC' field cac_kokrs.WRITE CAC_KOKRS.
parameter ID 'CAC' is checked in SAP MEMORY and if it is there, it is assigned to cac_kokrs.
The parameter id will be unique for a particular field in
SAP MEMORY.
U CAN ALSO USE
SET parameter id 'CAC' field cac_kokrs. ABOVE.
BUT THE DIFFERENCE BETWEEN THE TWO IS AS FOLLOWS:
get parameter id
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.
1.in the above syntax para is a variable for which parameter id is assigned.
2. get parameter id returns sy-subrc.
set parametr id
SET PARAMETER ID: 'CAR' FIELD carrier,
'CON' FIELD connection.
1. the parameter id 'CAR' is static , u cant use variables.
‎2006 Jun 05 6:07 AM
Hi,
SET PARAMETER ID pid FIELD f.
Writes the contents of the field f to the global user-specific SAP memory and the local transaction-specific SAP memory under the ID pid. Any existing values under the same ID are overwritten.
Parameter IDs can be up to 20 characters long. They cannot consist entirely of spaces. The SAP system description contains an overview of parameter IDs. You can also produce a list using the ABAP Workbench.
The global, user-specific SAP memory is available to a user for the duration of a single terminal session. Values written to it are retained even when the user exits a program
GET PARAMETER ID pid FIELD f.
First, the value stored under the key pid is transferred from the local SAP memory into the field f. If this key is not available in the local SAP memory, the value stored under the same key pid is transferred from the global user-related SAP memory to the field f.
A parameter ID can have up to 20 characters. You can find an overview of the keys (parameters) used in the SAP system description or the appropriate function in the ABAP Workbench.
The Return Code is set as follows:
SY-SUBRC = 0: A value was read from SAP memory. SY-SUBRC = 4: No value was found in SAP memory under the specified key.
Notes
The global user-related SAP memory is available to each user for the entire duration of a terminal session. For this reason, set values are retained when you leave a program.
Reward points if it helps
gunjan
‎2006 Jun 05 7:16 AM
Hi Onkar,
Set parameter and Get Parameter are used to store and retrieve variables form SAP memory.
SET PARAMETER ID pid FIELD f. : Writes the contents of the field f to the global user-specific SAP memory under the ID pid
eg:
DATA : post(1) TYPE c value 'X'.
SET PARAMETER ID 'PST' FIELD post.
The contents of the variable post are stored in the SAP memory under the id 'PST'. If the id already exists, then it will be overwritten. The user can get its value even from another program.
The global, user-specific SAP memory is available to a user for the duration of a single terminal session. Values written to it are retained even when the user exits a program.
GET PARAMETER ID pid FIELD f. : Transfers the value stored under the key pid from the global user-related SAP memory to the field f.
eg.
DATA : post1(1) TYPE c value 'X'.
GET PARAMETER ID 'PST' FIELD post1.
The value in the SAP memory variable 'PST' is read into the variable post1. If the read was successful, the return code will be 0. Else, due to reasons like SAP memory variable not found etc, sy-subrc = 4.
You should not use SAP memory for temporary storage because a user's parallel sessions use the same global memory.
Just to give a simple example to show how two programs reads the same memory variable and thus communicate with each other, even when one of them has been terminated.
A program zreport_all, performs many functionalities like posting document, viewing document, deleting document etc. Another report zreport_post(tcode : zpost), calls the second report zreport_all for posting the document. Second report calls a function module for posting the documents and automatically exits after executing that function. The control thus returns to the first report. In the first report, if the documents have been posted, the information message should be given as well as commit work should be done.
How can the first report know whether the documents have been posted or not?
report zreport_all.
....
case sy-tcode.
...............
when 'zpost'.
Select the document to be posted based on some selection criteria. If no documents have been selected or if the document was created by the same user, then document should not be posted, else the document will be posted. Set the parameter if the document is posted.
select single * from vbkpf where ....
if sy-subrc ne 0.
exit.
elseif vbkpf-uname eq sy-uname.
exit.
else.
SET PARAMETER ID 'PST' FIELD post.
CALL FUNCTION 'ZPRELIMINARY_POSTING_POST_ALL'
EXPORTING
bupbi = xbinp
TABLES
t_vbkpf = tbkpf.
endif.
when 'zdel'.
.............
endcase.
In the second program.
report zreport_post.
..........
SUBMIT zreport_all AND RETURN.
....
GET PARAMETER ID 'PST' FIELD post1.
if post1 = 'X'.
Write : 'The document has been posted'.
endif.
............
Thus even though the other program was terminated, still, the first program is able to retrieve the value of a variable set by the other program in SAP memory.
Regards,
Susmitha.
‎2006 Jun 05 7:20 AM
Hello Osk,
In simple words SET and GET paramater is used to transfer data from one program to another. By using SET u can set a variable in one program and by using GET u can retrive the same in another program. This is only true in online mode and not in background mode, also active in the session. This gets reset as soon as the session closes.