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

problems with READ STATEMENT

Former Member
0 Likes
1,083

Hello ABAPers,

I have this code:

SELECT ebeln bukrs

FROM ekko

INTO TABLE it_ekko

FOR ALL ENTRIES IN idata

WHERE ebeln = idata-vbeln_p.

LOOP AT idata WHERE ebeln IS NOT INITIAL.

READ TABLE it_ekko WITH KEY ebeln = idata-ebeln

bukrs = idata-bukrs_r.

MODIFY idata.

ENDLOOP.

I'm getting this error:

The internal table IT_EKKO has no header line - explicit specification of an output area with INOT wa or ASSIGNING <fs> is required.

I don't see what I'm doing wrong. Please advise.

Thanks in advance.

Ol Pom.

10 REPLIES 10
Read only

Former Member
0 Likes
1,055

Hi,

The internal table it_ekko is declared with out header line..

For this...You have a declare a work area and use INTO addition for the READ TABLE IT_EKKO..

DATA: WA LIKE LINE OF it_ekko.

LOOP AT idata WHERE ebeln IS NOT INITIAL.

READ TABLE it_ekko <b>INTO WA</b>

WITH KEY ebeln = idata-ebeln

bukrs = idata-bukrs_r.

MODIFY idata.

Thanks,

Naren

Read only

0 Likes
1,055

Do I have to do a MOVE statement after I added the WA?

Read only

Former Member
0 Likes
1,055

just say

it_ekko occurs 0 with header line.

this should solve your problem.

Prince

Read only

Former Member
0 Likes
1,055

Hi,

Once you do "READ TABLE it_ekko INTO WA" that record that matches the key will be stored in WA..You don't have to write specific move statement..

Is that what you are asking??

Thanks,

Naren

Read only

0 Likes
1,055

Yes Naren, Thanks.

Read only

0 Likes
1,055

Hi Ol,

please tell us what it is you want to do with the internal table and we will be able to advise you.

Read only

former_member186741
Active Contributor
0 Likes
1,055

others have pointed out why you are getting the syntax error.but why are you doing the read anyway? You are not referring to the data after the read and are immediately doing a modify. <b>This loop is not actually doing anything.</b>

LOOP AT idata WHERE ebeln IS NOT INITIAL.

READ TABLE it_ekko into wa WITH KEY ebeln = idata-ebeln

bukrs = idata-bukrs_r.

MODIFY idata.

ENDLOOP.

Read only

0 Likes
1,055

Neil, How can I fix this problem then?

Read only

0 Likes
1,055

Hi Ol Pom

What Neil was pointing to is highlighted below. Please check the same to have some understanding.

<b>Current Logic</b>:
SELECT ebeln bukrs
   FROM ekko
   INTO TABLE it_ekko
   FOR ALL ENTRIES IN idata
   WHERE ebeln = idata-vbeln_p.

LOOP AT idata WHERE ebeln IS NOT INITIAL.
     READ TABLE it_ekko WITH KEY ebeln = idata-ebeln
     bukrs = idata-bukrs_r. 
     MODIFY idata.
ENDLOOP.
--> Nowhere between the loop and end, any data of 
internal table <b>idata</b> is modified, hence the 
statement MODIFY IDATA doesnt make any modifications.

For avoiding the syntax error, declare a work area of 
type IT_EKKO or declare IT_EKKO with header line.

Options to do the same:
data: wa_ekko like it_ekko.
<b>OR</b>
data: begin of it_ekko <b>occurs 0</b>,
       ...
      end of it_ekko.

Above will rectify the syntax error.

Please see that your code resembles something like below:
data: wa_ekko like it_ekko.
IF NOT it_ekko[] is INITIAL.
   SELECT ebeln bukrs
     FROM ekko
     INTO TABLE it_ekko
     FOR ALL ENTRIES IN idata
     WHERE ebeln = idata-vbeln_p.
ENDIF.

LOOP AT idata WHERE ebeln IS NOT INITIAL.
     READ TABLE it_ekko into it_ekko 
          WITH KEY ebeln = idata-ebeln
                   bukrs = idata-bukrs_r. 
     check sy-subrc eq 0.
*     ... change contents of idata w.r.t it_ekko.
     MODIFY idata.
ENDLOOP.

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,055

Hi,

Looks like you want to update ebeln and bukrs in the internal table idata.

SELECT ebeln bukrs

FROM ekko

INTO TABLE it_ekko

FOR ALL ENTRIES IN idata

WHERE ebeln = idata-vbeln_p.

DATA: V_TABIX TYPE SYTABIX.

LOOP AT idata WHERE ebeln IS NOT INITIAL.

v_tabix = sy-tabix.

READ TABLE it_ekko into wa

WITH KEY ebeln = idata-vbeln_p.

if sy-subrc = 0.

idata-ebeln = wa-ebeln.

idata-bukrs_r = wa-bukrs.

MODIFY idata index v_tabix

transporting ebeln bukrs_r.

endif.

ENDLOOP.

Thanks,

Naren