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

AT First

Former Member
0 Likes
1,087

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

Former Member
0 Likes
1,062

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

Former Member
0 Likes
1,062

Chandrika,

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

Amit.

Read only

0 Likes
1,062

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.

Read only

0 Likes
1,062

Hi,

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

Cheers,

Jose.

Read only

0 Likes
1,062

hi,

there is no select statement in your code.

write "SELECT" statement before the loop at itab.

reward if useful.

thnks and rgds,

raghul.

Read only

0 Likes
1,062

Chandrika,

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

Amit.

Read only

Former Member
0 Likes
1,062

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.

Read only

Former Member
0 Likes
1,062

Hi chnadrika,

your internal table has no data.

append the data first,

thanks

karthik

Read only

Former Member
0 Likes
1,063

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

Read only

Former Member
0 Likes
1,062

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