/scripts/ahub.form.attachments.js
-1

How to access dynamically created work area in ABAP 7.4?

Jul 07, 2017 at 11:54 AM

121

avatar image

When trying to execute the following code I am getting the error:

The variable "WA-EBELN" cannot be used here.

DATA: gt_tab1_tmp TYPE TABLE OF ekpo.
SELECT * FROM ekpo INTO TABLE gt_tab1_tmp.
DATA(lv_sum) = REDUCE i( INIT x = 0 FOR wa IN gt_tab1_tmp NEXT x = x + 1 ).
WRITE: wa-ebeln.

How to access the work-area that is being created dynamically?

Please help!!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Matthew Billingham
Jul 08, 2017 at 06:46 AM
1

Why do you want to? What value are you after? If it's the last entry, then

gt_tab1_tmp[ lines( gt_tab1_tmp) ]-ebeln should do it.

By the way - that's a terrible name for a variable. What's wrong with items or po_items? Meaningful names are an important part of decent programming. But I guess this is just some kind of proof of concept, since no-one would really select everything from EKPO, nor rely on the last record being read having any significance whatsoever.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Its just a test program to clear a concept.

0

I've heard that excuse before. I don't buy it. It takes exactly as long to use a meaningful name as a meaningless one, even for a test program. Why not get into the habit immediately of using meaningful names?

But you haven't answered my other question:

Why do you want to? What value are you after? If it's the last entry, then

gt_tab1_tmp[ lines( gt_tab1_tmp) ]-ebeln should do it.

0
Fabian Lupa Jul 07, 2017 at 12:03 PM
2

Your variable wa is declared inline in your REDUCE statement and just like LET it is only visible within the inline statement. So you cannot use it outside.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

But in the debugging mode, I am seeing that after executing the reduce statement, the wa visibility still there in write line also!! So, isn't there a way by which we can access that runtime variable?

See the screenshots below. I have changed the last line of the code to check the visibility.

debug.png (63.9 kB)
0

It is "visible" but not usable. There is a simple trick (implicitly mentioned in the docu), but I don't tell it, because you should not use it.

4
Skip to Content