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: 

Small report error

Former Member
0 Kudos

TABLES:PA0000.

data:begin of itable occurs 0,
     pernr type pa0000-pernr,
     massn type pa0000-massn,
     stat1 type pa0000-stat1,
     stat2 type pa0000-stat2,
     end of itable.

parameters:p_pernr type pa0000-pernr.

select pernr,massn,stat1,stat2 from pa0000 into table itable where pernr = p_pernr.

write itable-massn.

the output is always

EMP-PA0000 1

-


I dont know why,it is not picking correct massn from the table.why?

1 ACCEPTED SOLUTION

former_member1349771
Participant
0 Kudos

loop at itable.

write itable-massn.

endloop.

10 REPLIES 10

former_member1349771
Participant
0 Kudos

loop at itable.

write itable-massn.

endloop.

0 Kudos

thanks for your prompt reply.i think that is correct,let me check.Why should we loop it?Why cannot we display directly?any idea?

0 Kudos

Bcoz, your itable is an internal table and while u r using

write itable-massn it will print the last headerline massn .

bcoz while fetching records, there may be much records and your code will only write the last output massn.

Regs

Manas

0 Kudos

if loop is not specified than it will print the only value which is in header which is the last record.

so to print all entries we hav to use loop concept

0 Kudos

Hi ,

u cant write the contents directly bcoz u r using an internal table

and u can only print the contents of the internal table one by one which is done

through looping , otherwise only the last record stored in the work area will get

displayed.

Former Member
0 Kudos

Hi,

There may be multiple entries (histories) in table pa0000. Specify the endda and begda ranges correctly. Since u have nt give the date ranges, by default its picking the first record.

Regards,

Vani.

Former Member
0 Kudos

TABLES:PA0000.

data:begin of itable occurs 0,

pernr type pa0000-pernr,

massn type pa0000-massn,

stat1 type pa0000-stat1,

stat2 type pa0000-stat2,

end of itable.

parameters:p_pernr type pa0000-pernr.

start-of-selection.

select pernr,massn,stat1,stat2 from pa0000 into table itable where pernr = p_pernr.

end-of-selection.

loop at itable.

write itable-massn.

endloop.

regs

Manas

former_member386202
Active Contributor
0 Kudos

Hi,

Try like this.

TABLES:PA0000.

data:begin of itable occurs 0,

pernr type pa0000-pernr,

massn type pa0000-massn,

stat1 type pa0000-stat1,

stat2 type pa0000-stat2,

end of itable.

select-options : p_pernr for pa0000-pernr.

select pernr,massn,stat1,stat2 from pa0000 into table itable where pernr in p_pernr.

Loop at itable.

write itable-massn.

endloop.

Regards,

Prashant

Former Member
0 Kudos

Hai,

Just check in the table pa0000 whther the other values exists for massn

As u have declared itable as a table with header line ,it will only write the record that is in the header as u are only writing itable-massn .For writing ather values u need to give

LOOP AT itable.

WRITE : / itable-massn.

ENDLOOP.

Neeraj

0 Kudos

thanks everyone,the problem is solved.I have put the content in sapscript and it is printing too.I had a problem with my last sapscript program where i dont use internal table,but unable to print it.I tried many ways,but in vain.