-1

How to access dynamically created work area in ABAP 7.4?

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!!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 08, 2017 at 06:46 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • Jul 07, 2017 at 12:03 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content