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

internal tables

Former Member
0 Likes
809

What is the use of at new statement?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
789

Hi

All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table

FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.

Some time you will get * when mopving data from this int table to other table using these commands

so you have to use

READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them

DATA: sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate,

sflight_wa LIKE LINE OF sflight_tab.

SELECT *

FROM sflight

INTO TABLE sflight_tab.

LOOP AT sflight_tab INTO sflight_wa.

AT NEW connid.

WRITE: / sflight_wa-carrid,

sflight_wa-connid.

ULINE.

ENDAT.

WRITE: / sflight_wa-fldate,

sflight_wa-seatsocc.

AT END OF connid.

SUM.

ULINE.

WRITE: / 'Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

SKIP.

ENDAT.

AT END OF carrid.

SUM.

ULINE.

WRITE: / 'Carrier Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

NEW-PAGE.

ENDAT.

AT LAST.

SUM.

WRITE: / 'Overall Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

ENDAT.

ENDLOOP.

Reward points for useful Answers

Regards

Anji

7 REPLIES 7
Read only

Former Member
0 Likes
789

Hi

this comes under control statements.

for suppose ur having an internal table with values :

A B

10 raghu

20 ram

10 kumar

20 sham

10 raj

U want to print like this

10 raghu

10 kumar

10 raj

-


10 ram

20 sham

-


first sort the internal table then

use this logic

loop at itab.

at new A.

write : '----


'.

endat.

endloop.

for every new value of A varialbe it is going to trigger (at new).

<b>reward points if helpful,

Regards

Raghunath.S</b>

Read only

Former Member
0 Likes
790

Hi

All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table

FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.

Some time you will get * when mopving data from this int table to other table using these commands

so you have to use

READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them

DATA: sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate,

sflight_wa LIKE LINE OF sflight_tab.

SELECT *

FROM sflight

INTO TABLE sflight_tab.

LOOP AT sflight_tab INTO sflight_wa.

AT NEW connid.

WRITE: / sflight_wa-carrid,

sflight_wa-connid.

ULINE.

ENDAT.

WRITE: / sflight_wa-fldate,

sflight_wa-seatsocc.

AT END OF connid.

SUM.

ULINE.

WRITE: / 'Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

SKIP.

ENDAT.

AT END OF carrid.

SUM.

ULINE.

WRITE: / 'Carrier Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

NEW-PAGE.

ENDAT.

AT LAST.

SUM.

WRITE: / 'Overall Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

ENDAT.

ENDLOOP.

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
789

Hi,

AT NEW <f> | AT END OF <f>.

...

ENDAT.

A control break occurs when the value of the field <f> or a superior field in the current record has

a different value from the previous record (AT NEW) or the subsequent record (AT END). Field

<f> must be part of the HEADER field group.

Regards,

Bhaskar

Read only

Former Member
0 Likes
789

hi,

[control break statements] at new statement is one of the control break statement used inside a loop for giving o/p as

matnr matktx ersda............

1000 nbmncvb bjcflbj

klbvhxkvh cbhbvxbv

1001 klvnkvnzd mnvxvnv -


using at new only this o/p is given like this.

1002 dvkhvhvh klhvkxhv

.........................

and at new is triggered when ever the current field of a record in a internal table is different from next field of th another record.

it works only when it follows some conditions like.

1. internal table should be sorted.

2. the field which we give in at new should be the first field of internal table otherwise this event triggers for the fields which are before of given filed and leads to problems.

if helpful reward some points.

with regards,

suresh.

Read only

Former Member
0 Likes
789

Hi,

The AT NEW (and others like AT END OF...) are specially for table loop

processing. The coding between AT new FIELD and ANDAT is triggerd

whenever the field or any field defined to the left is changed. Your

table should be sorted by all fields from the left up to the considered

FIELD. Btw all fields to the right contain *, so it can be usefull to

have a second workarea filled to be printed or what ever you want.

Thanks,

Sandeep.

Read only

Former Member
0 Likes
789

NEW}|{END OF} compi/>

Effect

: Control levels are defined by the beginning or end of a group of lines with the same content in the component compi (where i = 1, 2, and so on) and in the components to the left of compi. The control breaks take place when the content of the component compi or another component to the left of compi changes.

The compi components can be specified as described in Specification of Components, with the limitation that access to object attributes is not possible here.

Note

If the INTO or ASSIGNING additions are used in the LOOP statement, a field symbol can be entered after AT |{END OF} outside classes, to which the corresponding component of the work area wa or the field symbol <fs> is assigned. This form of dynamic component specification is obsolete and has been replaced by specification in the format (name).

Girish

Read only

Former Member
0 Likes
789

Hi

To all gurus helping me out. As iam new to this field.

Thanks&Regards

Suri