Application Development 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: 

Error in ABAP Program

Former Member
0 Kudos

hi ,

I am a basis person and very new to ABAP.

Pls let me know the error in the folllowing program

REPORT Z_ROLES.

data : count type i.

data : begin of it_role occurs 0,

agr_name type AGR_NAME,

end of it_role.

data : begin of obj_table occurs 0,

objct type XUOBJECT,

end of obj_table.

select OBJCT from TOBJ into table obj_table

where OCLSS IN ('RS','RSR', 'RSBC').

clear count.

loop at obj_table.

add 1 to count.

endloop.

select AGR_NAME from AGR_1250

into table it_role

for all entries in obj_table

where OBJECT = obj_table.objct

AND

AGR_NAME LIKE 'Z%'.

clear count.

loop at it_role.

add 1 to count.

endloop.

write : count.

1 ACCEPTED SOLUTION

0 Kudos

Hi,


data : count type i.
data : begin of it_role occurs 0,
agr_name type AGR_NAME,
end of it_role.
data : begin of obj_table occurs 0,
objct type XUOBJECT,
end of obj_table.

select OBJCT from TOBJ into table obj_table
where OCLSS IN ('RS','RSR', 'RSBC').
clear count.
loop at obj_table.
add 1 to count.
endloop.

select AGR_NAME from AGR_1250
into table it_role
for all entries in obj_table
where OBJECT = obj_table-objct AND " Check here you have used '.' you should use '-'
AGR_NAME LIKE 'Z%'.

clear count.
loop at it_role.
add 1 to count.
endloop.
write : count.

Regards,

Sesh

6 REPLIES 6

former_member189059
Active Contributor
0 Kudos

REPORT Z_ROLES.

DATA : count TYPE i.

DATA : BEGIN OF it_role OCCURS 0,

agr_name TYPE agr_name,

END OF it_role.

DATA : BEGIN OF obj_table OCCURS 0,

objct TYPE xuobject,

END OF obj_table.

SELECT objct FROM tobj INTO TABLE obj_table

WHERE oclss IN ('RS','RSR', 'RSBC').

CLEAR count.

LOOP AT obj_table.

ADD 1 TO count.

ENDLOOP.

SELECT agr_name FROM agr_1250

INTO TABLE it_role

FOR ALL ENTRIES IN obj_table

WHERE object = <b>obj_table-objct</b>

and

agr_name like 'Z%'.

CLEAR count.

LOOP AT it_role.

ADD 1 TO count.

ENDLOOP.

WRITE : count.

********

to refer to a field, we use tablename-fieldname

Message was edited by:

Kris Donald

Former Member
0 Kudos

Hi,

I've boldened the mistakes, plz make the changes accordingly,

REPORT Z_ROLES.

data : count type i.

data : begin of it_role occurs 0,

agr_name type AGR_NAME,

end of it_role.

data : begin of obj_table occurs 0,

objct type XUOBJECT,

end of obj_table.

select OBJCT from TOBJ into table obj_table

where OCLSS IN ('RS','RSR', 'RSBC').

clear count.

loop at obj_table.

add 1 to count.

endloop.

select AGR_NAME from AGR_1250

into table it_role

for all entries in obj_table

where OBJECT = <b>obj_table-objct</b>

AND

AGR_NAME LIKE 'Z%'.

clear count.

loop at it_role.

add 1 to count.

endloop.

write : count.

<b>Reward points if this helps,</b>

Kiran

0 Kudos

Hi,


data : count type i.
data : begin of it_role occurs 0,
agr_name type AGR_NAME,
end of it_role.
data : begin of obj_table occurs 0,
objct type XUOBJECT,
end of obj_table.

select OBJCT from TOBJ into table obj_table
where OCLSS IN ('RS','RSR', 'RSBC').
clear count.
loop at obj_table.
add 1 to count.
endloop.

select AGR_NAME from AGR_1250
into table it_role
for all entries in obj_table
where OBJECT = obj_table-objct AND " Check here you have used '.' you should use '-'
AGR_NAME LIKE 'Z%'.

clear count.
loop at it_role.
add 1 to count.
endloop.
write : count.

Regards,

Sesh

Former Member
0 Kudos

Hi There,

The syntax error is cause by have a '.' to separate your table name and field name rather than a '-'

i.e. its should be like this: obj_table-objct

Former Member
0 Kudos

Hi

select AGR_NAME from AGR_1250

into table it_role

for all entries in obj_table

where OBJECT = obj_table-objct

AND

AGR_NAME LIKE 'Z%'.

replace "." with "-".

Regards

Ravish

Former Member
0 Kudos

Hi balaji

check the field name

select OBJCTfrom TOBJ into table obj_table

where OCLSS IN ('RS','RSR', 'RSBC').

clear count.

loop at obj_table.

add 1 to count.

endloop.

select AGR_NAME from AGR_1250

into table it_role

for all entries in obj_table

where OBJECT =<b> obj_table-objct</b>

AND

AGR_NAME LIKE 'Z%'.

clear count.

loop at it_role.

add 1 to count.

endloop.

write : count.

<b>

Regards,

Azhar</b>