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

SAP Memory - GET PARAMETER statement doesn't work

Jacek_Dev
Explorer
0 Likes
2,592

Hi,

I've searched the forum and SAP Notes but couldn't find a hint to explain the following system's behavior.

I've got 2 simple reports :

"===========================

REPORT yca_set_param.

PARAMETERS:

p_value TYPE c LENGTH 4.

START-OF-SELECTION.

SET PARAMETER ID 'ABCD' FIELD p_value.

WRITE 'Parameter Set'.

"===========================

and

"===========================

REPORT yca_param_monitor.

DATA:

lv_value TYPE c LENGTH 4.

WHILE lv_value IS INITIAL.

GET PARAMETER ID 'ABCD' FIELD lv_value.

ENDWHILE.

WRITE: 'Value:', lv_value.

"===========================

As you can see there is a loop in yca_param_monitor report which will continue until lv_value is initial.

First I run report yca_param_monitor.

Next (in a separate session) I run yca_set_param and set the parameter to '1234' for example.

What is surprising to me is that yca_param_monitor cannot read the parameter value from the SAP memory and it'll never exit the loop.

If I run yca_param_monitor in debug mode everything works as expected (GET PARAMETER gets the value).

Can you repeat this behavior in your systems?

Can you explain this?

Thank you,

--

Br,

Jacek

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
2,407
REPORT  yca_param_monitor.
 DATA:
  lv_value TYPE c LENGTH 4.
 
 WHILE lv_value IS INITIAL.
   GET PARAMETER ID 'ABCD' FIELD lv_value.
   WAIT UP TO 1 SECONDS .
 ENDWHILE.
 
 WRITE: 'Value:', lv_value.

Try with this WAIT statement after GET PARAMETER

Edited by: Pawan Kesari on Feb 25, 2010 6:51 PM

20 REPLIES 20
Read only

Former Member
0 Likes
2,407

My system doesn't have a parameter id ABCD. Did you create this (in se80)??

Read only

0 Likes
2,407

Hi Dave,

You should be able to compile and run the reports without adding the parameter to TPARA table.

Are you?

--

Br,

Jacek

Read only

0 Likes
2,407

In debugging mode check the sap memory wether the parameter id is getting creatid and containing values or not..

Hope it helps..!

Read only

0 Likes
2,407

Hi,

In the debug mode it works as expected, it fails only in "normal run" mode.

--

Br,

Jacek

Read only

0 Likes
2,407

jacek,

strange things are happening obviously. I copied and pasted your reports and did exactly the same you are doing now. And it works just fine (not only in debugging mode).

Correction: I did NOT exactly do what you did. You first ran the MONITOR report. Well I guess, that just won't work since you first have to set the parameter ID before retrieving it with a GET PARAMETER. Not quite sure how to explain this, but when you are running the MONITOR report without setting the parameter ID first, you can not access the SAP memory that is meanwhile set in another (same) user session. The MONITOR report will still access the not filled parameter ID in the SAP memory.

Don't think this makes it any clearer now does it?

Edited by: Micky Oestreich on Feb 25, 2010 2:18 PM

Read only

0 Likes
2,407

Hi Micky,

Were you able to reproduce the behavior on your system?

>

>Not quite sure how to explain this, but when you are running the MONITOR report without setting the parameter ID first, you can not access the SAP memory that is meanwhile set in another (same) user session. The MONITOR report will still access the not filled parameter ID in the SAP memory.

>

Yes, this is what I suspect too. The strange thing is that it works fine in the debug mode.

I thought that the parameter set in the SAP Memory will be immediately available to other programs, but it seems it's not.

I'm running out of ideas.

Anyone?

--

Br,

Jacek

Read only

Former Member
0 Likes
2,407

Hi,

Try this

"===========================

REPORT yca_set_param.

PARAMETERS:

p_value TYPE c LENGTH 4.

START-OF-SELECTION.

SET PARAMETER ID 'ABCD' FIELD p_value.

WRITE 'Parameter Set'.

"===========================

and

"===========================

submit yca_param_monitor and return.

REPORT yca_param_monitor.

DATA:

lv_value TYPE c LENGTH 4.

WHILE lv_value IS INITIAL.

GET PARAMETER ID 'ABCD' FIELD lv_value.

ENDWHILE.

WRITE: 'Value:', lv_value.

"===========================

******************************************8

Now you can get the value.

Regards

Nehruu

Read only

0 Likes
2,407

Hi Nehruu,

"submit yca_param_monitor and return" will call the report in the same internal session and I want this to work in two different sessions.

--

Br,

Jacek

Read only

StMou
Active Participant
0 Likes
2,407

Hi,

First You create your Parameter ID ABCD with SE80 and create ABCD (or other good transaction)

After in your first program make this


REPORT yca_set_param.

PARAMETERS:
p_value TYPE c LENGTH 4 memory ID ABCD   " without Quote
* The set is implicite

*START-OF-SELECTION.
*SET PARAMETER ID 'ABCD' FIELD p_value.
*WRITE 'Parameter Set'.

In second report


REPORT yca_param_monitor.
DATA:
lv_value TYPE c LENGTH 4.

WHILE lv_value IS INITIAL.
GET PARAMETER ID ABCD FIELD lv_value. " without Quote
ENDWHILE.

WRITE: 'Value:', lv_value.

Read only

Former Member
0 Likes
2,407

Hi,

I tried same code as your's and its working fine.

First run the report where you are setting the parameter id, that is report where you have used SET PARAMETER ID

, and then report with GET PARAMETER ID.

Thanks

Tejaswini

Read only

0 Likes
2,407

Thanks Tejaswini,

I know that this works fine if I first run the report with SET PARAMETER statement but the problem is that I need this to work other way round

This is what I want to achieve:

I run one report with a loop that checks if a parameter is set (GET PARAMETER). It'll exit the loop only if it finds the parameter in the SAP Memory.

I've got another report which will export a value to the SAP Memory (SET PARAMETER) while the first report is still running.

My problem is that the first report cannot see the exported parameter, it seems that the SAP Memory is not updated while the program is running.

Any other ideas what might be the solution?

Thanks,

Jacek

Read only

0 Likes
2,407

You might want to try with Shared memory, but not sure if it works the way you want it to work, namely the other way around, first trying to retrieve the data and meanwhile setting it.

Read only

0 Likes
2,407

Hi,

Instead of using SET GET Function Try IMPORT EXPORT Memory Function. That will help u.

Read only

Pawan_Kesari
Active Contributor
0 Likes
2,408
REPORT  yca_param_monitor.
 DATA:
  lv_value TYPE c LENGTH 4.
 
 WHILE lv_value IS INITIAL.
   GET PARAMETER ID 'ABCD' FIELD lv_value.
   WAIT UP TO 1 SECONDS .
 ENDWHILE.
 
 WRITE: 'Value:', lv_value.

Try with this WAIT statement after GET PARAMETER

Edited by: Pawan Kesari on Feb 25, 2010 6:51 PM

Read only

0 Likes
2,407

Hi Pawan,

I've tried that too It worked also for me but I would prefer to avoid WAIT UP TO 1 SECONDS..

I'd like know the exact time (with milliseconds accuracy) when the parameter was set - and if I use WAIT UP TO 1 seconds I could measure it only with 1 second accuracy).

...but anyway thanks for your advice.

--

Jacek

Read only

0 Likes
2,407

Hi Jacek,

I don't think there is any delay (ignoring any delay less than micro/nano sec) in setting the parameter, its the monitor program which needs interuption before it can see the parameter value. It seems, the monitor program is too busy with GET PARAMETER execution to read the updated value of PARAMETER.

If your monitor program stops after 1 sec of setting the parameter, will that affect any functional aspect ?

FYI you can not specify less than 1 sec in WAIT statement.

Pawan.

Read only

0 Likes
2,407

Hi Pawan,

It all depends on the process allocation, its working in Debugging mode but while u run the same program in foreground the GET params doesn't work or it show's that way as if it is not fetching the value(But it fetches the value and its over written with Space while displaying)....the real cause could be due to the Memory overlapping which could be set right with the help of Basis Guys.......

Regards Shravanthi.

Read only

0 Likes
2,407

If you are going across sessions like that, you will need to use the shared memory buffer. I believe this has already been suggested, but here is some sample code.

REPORT yca_set_param.

PARAMETERS:
p_value TYPE c LENGTH 4.

START-OF-SELECTION.
export p_value = p_value to shared buffer indx(st) id 'ABCD'.  
*SET PARAMETER ID 'ABCD' FIELD p_value.
WRITE 'Parameter Set'.

REPORT yca_param_monitor.
DATA:
lv_value TYPE c LENGTH 4.

WHILE lv_value IS INITIAL.
*GET PARAMETER ID 'ABCD' FIELD lv_value.
  import p_value = lv_value           "<-- notice here that we are delaring P_VALUE as the imported variable into(=) LV_VALUE
              from shared buffer indx(st) id 'ABCD'.
ENDWHILE.

WRITE: 'Value:', lv_value.

Regards,

Rich Heilman

Read only

0 Likes
2,407

Thanks Rich! That has solved my problem!

NOTE:

It seems that the SAP Memory is updated/loaded only when a program is initialized!

Programs behavior is the same in debug mode and in normal mode when using the New Debugger - the "monitoring" program is unable to get the parameter that has been set in the meantime (using the Classic Debugger has some side effects which causes the SAP Memory to be refreshed).

And this is what I found regarding WAIT UP TO statement (help);

The statement WAIT causes a change in the work process. This is connected with rolling in and rolling out all the loaded programs.

That's the reason why the SAP Memory is updated after WAIT statement.

Problem solved.

Thanks to you all!

--

Br,

Jacek

Read only

Former Member
0 Likes
2,407

It may be a statement of the obvious, but SAP Memory (SPA/GPA Parameters) is always allocated to a single user. If you run the reports using different users then this would explain your problem. If this is the case then IMPORT/EXPORT may be the better alternative.