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 New ?

Former Member
0 Likes
1,204

Hi Experts,

When the control is encoutering the AT NEW / AT END OF statements, some fileds (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.) r bcoming **************** (in dbug mode, observed)!

So,

1 - Why its happeing like that? By that moment the system does not know the values of (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.)?

2 - Or just its showing in dbug mode like that! Actually, internally Is it knows?

3- If it knows internally, Can I use thses (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.) in my WHERE condtion?

ThanQ.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,177

At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:

<b>All character type fields (on the right) are filled with "*" after the current control level key.</b> ...it is the rule..

All other fields (on the right) are set to their initial values after the current control level key.

for details see:

9 REPLIES 9
Read only

Former Member
0 Likes
1,177

try this

LOOP AT ITAB.

AT NEW FIELD .

<b> READ TABLE ITAB INTO WA_ITAB.</b>

ENDLOOP.

Read only

Former Member
0 Likes
1,177

Hi

<b>after AT NEW

read table ITAB index sy-tabix.</b>

See the sample code and correct

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 if useful

regards,

Anji

Message was edited by:

Anji Reddy Vangala

Read only

Former Member
0 Likes
1,178

At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:

<b>All character type fields (on the right) are filled with "*" after the current control level key.</b> ...it is the rule..

All other fields (on the right) are set to their initial values after the current control level key.

for details see:

Read only

0 Likes
1,177

In a LOOP which processes an internal table, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between them is then executed if a control break occurs.

You can use these key words for control break processing with internal tables only if a loop is actively processing an internal table and reference is to the innermost currently active loop.

The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.

At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:

All character type fields (on the right) are filled with "*" after the current control level key.

All other fields (on the right) are set to their initial values after the current control level key.

Between AT and ENDAT, you can use SUM to insert the appropriate control totals in the numeric fields (see also ABAP Number Types) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level (AT FIRST, AT NEW f) and also the end of a control level (AT END OF f, AT LAST).

At the end of the control level processing (i.e. after ENDAT), the old contents of the LOOP output area are restored.

Notes

When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.

If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.

With LOOPs on extracts, there are also special control break control structures you can use.

Note

Non-Catchable Exceptions:

SUM_OVERFLOW: Overflow when calculating totals with SUM.

Variant 1

AT NEW f.

Variant 2

AT END OF f.

The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Compatible Work Area with Control Level Processing and Field Symbols Not Allowed as Control Level Criterion.

Effect

f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before fhas a different value than in the preceding (AT NEW) or subsequent (AT END OF) table line.

Example

TYPES: BEGIN OF COMPANIES_TYPE,

NAME(30),

PRODUCT(20),

SALES TYPE I,

END OF COMPANIES_TYPE.

DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,

WA_COMPANIES TYPE COMPANIES_TYPE.

...

LOOP AT COMPANIES INTO WA_COMPANIES.

AT NEW NAME.

NEW-PAGE.

WRITE / WA_COMPANIES-NAME.

ENDAT.

WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.

AT END OF NAME.

SUM.

WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.

ENDAT.

ENDLOOP.

The AT statements refer to the field COMPANIES-NAME.

Notes

If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.

By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.

A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.

If you use AT within a LOOP with an explicitly-specified output area, the area must be compatible with the line type of the internal table so that it can be initialized properly (as described above) at the start of a new control level.

You can restrict control break criteria further, regardless of whether they were defined statically or dynamically, by specifying offset and/or length.

Read only

alex_m
Active Contributor
0 Likes
1,177

No, the value is only * by internal also. You have to store the value before the control statement and use inside.

Read only

former_member632991
Active Contributor
0 Likes
1,177

Hi,

When the control is encoutering the AT NEW / AT END OF statements, some fileds (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.) r bcoming **************** (in dbug mode, observed)!

So,

1 - Why its happeing like that? By that moment the system does not know the values of (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.)?

<b>System will show all the values except the numeric feild as ****,for all the fields of internal table in which u r using at new</b>

2 - Or just its showing in dbug mode like that! Actually, internally Is it knows?

<b>It is internally stored as ****, and not only in debugging</b>

3- If it knows internally, Can I use thses (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.) in my WHERE condtion?

<b>yes u can, before at new, move these values into another WA of same type.

and use that value.</b>

Hope it helps.

Regards,

Sonika

Read only

Former Member
0 Likes
1,177

It is the normal behaviour of control break command AT NEW. In such cases we usually follow like this:

Loop at itab into wa_itab.

move wa_itab-field4 to v_field4.

move wa_itab-field5 to v_field5.

move wa_itab-field6 to v_field6.

AT NEW

*----


Process

  • Use above varaibles

ENDAT.

Endloop.

Thanks,

SKJ

Read only

Former Member
0 Likes
1,177

Hi Sridhar,

1 - Why its happeing like that? By that moment the system does not know the values of (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.)?

At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:

- All default key fields (on the right) are filled with "*" after the current control level key.

- All other fields (on the right) are set to their initial values after the current control level key.

2 - Or just its showing in dbug mode like that! Actually, internally Is it knows?

The output area will be filled output area with "*" after the current control level key.

Also during debugging as well.

3- If it knows internally, Can I use thses (like, wa_bsad-bukrs, wa_bsad-belnr, wa_bsad-buzei etc.) in my WHERE condtion?

You can use work area or field symbol to read the output area.

Using a Work Area:

To place the current loop line into a work area, specify result as follows:

LOOP AT itab INTO wa bedingung.

The contents of the table lines must be convertible into the data type of the work area wa. In each loop pass, one line of the table is copied into the work area. The end of the loop does not affect the work area, that is, the contents of wa are the same after the ENDLOOP statement as they were in the final loop pass. If no table entries are processed in the loop, because the table is entry, or no line meets the condition cond, the work area is not changed.

Using a Field Symbol:

To assign the contents of the current loop line to a field symbol, specify result as follows:

LOOP AT itab ASSIGNING <fs> condition.

In each loop pass, the field symbol <fs> points to the table entry read in that pass. If the line type is structured, you should specify the same type for the field symbol when you declare it. This allows you to address the components of the field symbol. If you cannot specify the type statically, you must use further field symbols and the technique of assigning components of structures to address the components of the structure.

The end of the loop does not affect the field symbol, that is, after ENDLOOP it is still assigned to the same line as in the final loop pass. If no table entries are processed in the loop, because the table is entry, or no line meets the condition cond, the field symbol is not changed.

For further information about assigning table lines to field symbols, refer to Access Using Field Symbols.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,177

Hi,

AT NEW checks for the combination of unique values.

say work-area has

AUFNR

POSNR

MATNR

MAKTX

MEINS

MENGE

AT NEW wa_output-MATNR.

here all the fields after MATNR will have *.

Before AT NEW WA_OUTPUT-MATNR move work area to some other work area.

wa_output_temp = wa_output.

AT NEW wa_output_temp-MATNR.

===> Now refer wa_output.. all field with correct values would be available.

Best regards,

Prashant