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

Error in ABAP code whield efining structures

Former Member
0 Likes
743

Hello,

I am getting following error when I run ABAP code.

Tables: ZROLE_OWNER, ZROLEMAP, AGR_1251, AGR_USERS.

DATA: BEGIN OF I_ROLE occurs 0,

ROLE LIKE ZROLE_OWNER-ROLE,

END OF I_ROLE.

DATA: BEGIN OF I_RATT occurs 0,

ROLENAME LIKE AGR_1251-AGR_NAME,

OBJECT LIKE AGR_1251-OBJECT,

FIELD LIKE AGR_1251-FIELD,

LOW LIKE AGR_1251-LOW,

HIGH LIKE AGR_1251-HIGH,

END OF I_RATT.

DATA: WA_RATT LIKE I_RATT occurs 0.

SELECT ROLE from ZROLE_OWNER into table I_ROLE

where SFLAG = ''.

LOOP AT I_ROLE.

*This will append all the values for above condition in WA-RATT.

SELECT AGR_NAME OBJECT FIELD LOW HIGH FROM AGR_1251

INTO TABLE WA_RATT

WHERE AGR_NAME = I_ROLE-ROLE.

APPEND WA_RATT TO I_RATT.

ENDLOOP.

I am getting error that WA_RATT cannot be converted to line type I_RATT.

1 ACCEPTED SOLUTION
Read only

alison_lloyd
Active Participant
0 Likes
677

why not select for all entries in I_role into table I_Ratt ?

wa_ratt - work area or table?

You can append a workarea to a table or lines of a table to a table

5 REPLIES 5
Read only

Former Member
0 Likes
677

Hi,

You have declared it wrong:

DATA: WA_RATT LIKE I_RATT occurs 0.

define it as : DATA: WA_RATT LIKE line of I_RATT.

Regards,

Subramanian

Read only

Former Member
0 Likes
677

Hi,

try this:

append lines of wa_ratt to to i_ratt. --> if u want to append set of lines that was resultant of the select statment.

if u want only one line...then use "select single "

But why select in the loop??u can instead use FOR ALL ENTRIES!

regards,

madhu

Read only

Former Member
0 Likes
677

hi,

Tables: ZROLE_OWNER, ZROLEMAP, AGR_1251, AGR_USERS.

DATA: BEGIN OF I_ROLE occurs 0,

ROLE LIKE ZROLE_OWNER-ROLE,

END OF I_ROLE.

DATA: BEGIN OF I_RATT occurs 0,

ROLENAME LIKE AGR_1251-AGR_NAME,

OBJECT LIKE AGR_1251-OBJECT,

FIELD LIKE AGR_1251-FIELD,

LOW LIKE AGR_1251-LOW,

HIGH LIKE AGR_1251-HIGH,

END OF I_RATT.

DATA: WA_RATT LIKE line of I_RATT .

SELECT ROLE from ZROLE_OWNER into table I_ROLE

where SFLAG = ''.

LOOP AT I_ROLE.

*This will append all the values for above condition in WA-RATT.

SELECT AGR_NAME OBJECT FIELD LOW HIGH FROM AGR_1251

INTO WA_RATT

up to 1 rows

WHERE AGR_NAME = I_ROLE-ROLE.

endselect.

APPEND WA_RATT TO I_RATT.

ENDLOOP.

Thanks,

Rajinikanth.

Read only

Former Member
0 Likes
677

You could have a better performance if your used ranges instead of looping at i_role. Also a join or a for all entries can work

Read only

alison_lloyd
Active Participant
0 Likes
678

why not select for all entries in I_role into table I_Ratt ?

wa_ratt - work area or table?

You can append a workarea to a table or lines of a table to a table