2008 Jul 07 12:47 PM
hi,
can any one say the output for the following code.
DATA: BEGIN OF t OCCURS 0,
code(4) VALUE 'four', sales TYPE p, discount TYPE p,
END OF t.
LOOP AT t.
AT FIRST.
SUM.
WRITE:/4 'Grand Total:',
20 t-sales, 40 t-discount.
ULINE. SKIP.
ENDAT.
WRITE:/ t-code,
20 t-sales, 40 t-discount.
AT END OF code.
SUM.
WRITE:/ t-code, 10 'Total:',
20 t-sales, 40 t-discount.
SKIP.
ENDAT.
ENDLOOP.
Thanks,
2008 Jul 07 1:00 PM
Hi,
Your Internal table is empty, fill some value and check.
DATA:
BEGIN OF t OCCURS 0,
code(4) type c ,"value 'four',
sales TYPE p,
discount TYPE p,
END OF t.
t-code = 'four'.
t-sales = '100'.
t-discount = '10'.
append t.
t-code = 'four'.
t-sales = '200'.
t-discount = '20'.
append t.
LOOP AT t.
AT FIRST.
SUM.
WRITE:/4 'Grand Total:',
20 t-sales, 40 t-discount.
ULINE. SKIP.
ENDAT.
WRITE:/ t-code,
20 t-sales, 40 t-discount.
AT END OF code.
SUM.
WRITE:/ t-code, 10 'Total:',
20 t-sales, 40 t-discount.
SKIP.
ENDAT.
ENDLOOP.
Regards
adil
2008 Jul 07 12:49 PM
Chandrika,
have you aurthorize for SE38? if yes why you can't execute it?
Amit.
2008 Jul 07 12:54 PM
hi,
i did not get any output for this. while debugging, the control did not enter into the loop.
LOOP AT T.
AT FIRST.
SUM.
WRITE: /4 'Grand Total:',
20 T-SALES, 40 T-DISCOUNT.
ULINE. SKIP.
ENDAT.
WRITE: / T-CODE,
20 T-SALES, 40 T-DISCOUNT.
AT END OF CODE.
SUM.
WRITE: / T-CODE, 10 'Total:',
20 T-SALES, 40 T-DISCOUNT.
SKIP.
ENDAT.
ENDLOOP.
control directly comming to endloop.
2008 Jul 07 12:56 PM
2008 Jul 07 1:01 PM
hi,
there is no select statement in your code.
write "SELECT" statement before the loop at itab.
reward if useful.
thnks and rgds,
raghul.
2008 Jul 07 1:16 PM
Chandrika,
itab T doesnt conatin any data so how can you expect to go into loop?
Amit.
2008 Jul 07 12:55 PM
Hi Chandrika,
The Internal Table is INITIAL, i.e. it doesn't contain any value, so there will be no Output,
to Insert some values into the Internal Table, you have to use APPEND statement.
Best Regards,
Sunil.
2008 Jul 07 12:58 PM
Hi chnadrika,
your internal table has no data.
append the data first,
thanks
karthik
2008 Jul 07 1:00 PM
Hi,
Your Internal table is empty, fill some value and check.
DATA:
BEGIN OF t OCCURS 0,
code(4) type c ,"value 'four',
sales TYPE p,
discount TYPE p,
END OF t.
t-code = 'four'.
t-sales = '100'.
t-discount = '10'.
append t.
t-code = 'four'.
t-sales = '200'.
t-discount = '20'.
append t.
LOOP AT t.
AT FIRST.
SUM.
WRITE:/4 'Grand Total:',
20 t-sales, 40 t-discount.
ULINE. SKIP.
ENDAT.
WRITE:/ t-code,
20 t-sales, 40 t-discount.
AT END OF code.
SUM.
WRITE:/ t-code, 10 'Total:',
20 t-sales, 40 t-discount.
SKIP.
ENDAT.
ENDLOOP.
Regards
adil
2008 Jul 07 1:06 PM
Hi chandrika,
Loop.....Endloop statement works only when there is some data in the internal table ..As your table does not have any entries,the loop statement does not any data through which it should loop.Hence, all other statements between loop..endloop are ignored..
TRY SOMETHING like;-
DATA:
BEGIN OF t OCCURS 0,
code(4) type c value 'four',
sales TYPE p,
discount TYPE p,
END OF t.
t-code = '001.
t-sales = '15'.
t-discount = '2'.
append t.
t-code = '002'.
t-sales = '30'.
t-discount = '15'.
append t.
LOOP AT t.
AT FIRST.
SUM.
WRITE:/4 'Grand Total:',
20 t-sales, 40 t-discount.
ULINE. SKIP.
ENDAT.
WRITE:/ t-code,
20 t-sales, 40 t-discount.
AT END OF code.
SUM.
WRITE:/ t-code, 10 'Total:',
20 t-sales, 40 t-discount.
SKIP.
ENDAT.
ENDLOOP.
*Hope this is useful
Regards,
Bhumika