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

By using Internal Table

Former Member
0 Likes
741

Hi all,

Could u please write the below program by using a Internal table and without using Endselect.

Example to find the number of passengers, the total luggage

weight, and the average weight of the luggage for all Lufthansa flights on 02/28/2001:

DATA: count TYPE I,

sum TYPE P DECIMALS 2,

avg TYPE F,

connid LIKE sbook-connid.

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

INTO (connid, count, sum, avg)

FROM sbook

WHERE

carrid = 'LH ' AND

fldate = '20040424'

GROUP BY connid.

WRITE: / connid, count, sum, avg.

ENDSELECT.

Thanks in Advance

Sri...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
715

data : begin of itab occurs 0,

carrid like spfli-carrid,

count type i,

sum like sbook-luggweight,

avg like sbook-luggweight,

end of itab.

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

INTO table itab FROM sbook

WHERE

carrid = 'LH ' AND

fldate = '20040424'

GROUP BY connid.

regards

shiba dutta

6 REPLIES 6
Read only

Former Member
0 Likes
716

data : begin of itab occurs 0,

carrid like spfli-carrid,

count type i,

sum like sbook-luggweight,

avg like sbook-luggweight,

end of itab.

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

INTO table itab FROM sbook

WHERE

carrid = 'LH ' AND

fldate = '20040424'

GROUP BY connid.

regards

shiba dutta

Read only

Former Member
0 Likes
715

Use this code:


data: begin of it_out occurs 0,
        connid type sbook-connid,
        count type i,
        sum type i,
        avg type i,
      end of it_out.

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight )
INTO TABLE it_out
FROM sbook
WHERE
carrid = 'LH ' AND
fldate = '20040424'
GROUP BY connid.

LOOP AT it_out.
  write: it_out-connid, it_out-count, it_out-sum, it_out-avg.
ENDLOOP.

Read only

Former Member
0 Likes
715

hi dude,

in your sample code, the author uis not using any internal table. he is using select and end select for which INTO internal table is not required, he directly passing the values to the variables and writing them.

Any how for ur reference consieder this example:

Types: Begin of t_mara,

mara type mara-matnr,

maktx like mara-maktx,

end of i_mara. This is the structue.

The internal table for it will declared as :

Data: I_mara type standard table of t_mara.

The Work area as :

Data: Wa_mara type t_mara.

Regards,

vinay

Read only

Former Member
0 Likes
715

Hi krishna,

DATA: begin of itab occurs 0,

count TYPE I,

sum TYPE P DECIMALS 2,

avg TYPE F,

connid LIKE sbook-connid,

end of itab.

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

INTO table itab

FROM sbook

WHERE

carrid = 'LH ' AND

fldate = '20040424'

GROUP BY connid.

loop at itab.

write:/itab-connid,itab-count,itab-sum.

endloop.

regards,

keerthi

Read only

former_member192022
Participant
0 Likes
715

DATA: BEGIN OF itab occurs 0,

connid LIKE sbook-connid,

count TYPE i,

sum TYPE sbook-luggweight,

avg TYPE sbook-luggweight,

end of itab.

select connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

into table itab from sbook group by connid .

loop at itab.

write:/ itab-connid,itab-count, itab-sum, itab-avg.

endloop.

Read only

Former Member
0 Likes
715

hi

use select single

like following without using endselect.

DATA: count TYPE I,

sum TYPE P DECIMALS 2,

avg TYPE F,

connid LIKE sbook-connid.

SELECT SINGLE connid COUNT( * ) SUM( luggweight ) AVG( luggweight )

INTO (connid, count, sum, avg)

FROM sbook

WHERE

carrid = 'LH ' AND

fldate = '20040424'

GROUP BY connid.

WRITE: / connid, count, sum, avg.

Thanks

sarath