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 Program

Former Member
0 Likes
867

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
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
817

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
Read only

former_member189059
Active Contributor
0 Likes
817

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

Read only

Former Member
0 Likes
817

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

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
818

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

Read only

Former Member
0 Likes
817

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

Read only

Former Member
0 Likes
817

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

Read only

Former Member
0 Likes
817

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>