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: 

AT First

Former Member
0 Kudos

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,

1 ACCEPTED SOLUTION

former_member705122
Active Contributor
0 Kudos

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

9 REPLIES 9

former_member181995
Active Contributor
0 Kudos

Chandrika,

have you aurthorize for SE38? if yes why you can't execute it?

Amit.

0 Kudos

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.

0 Kudos

Hi,

Your internal table 'T' might be empty.......

Cheers,

Jose.

0 Kudos

hi,

there is no select statement in your code.

write "SELECT" statement before the loop at itab.

reward if useful.

thnks and rgds,

raghul.

0 Kudos

Chandrika,

itab T doesnt conatin any data so how can you expect to go into loop?

Amit.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi chnadrika,

your internal table has no data.

append the data first,

thanks

karthik

former_member705122
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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