Syntax for LOOP on Internal Table part two

This syntax check on loop in internal table is in continuation with part one .

Addition 1

... FROM n1

Addition 2

... TO n2

Effect

Places all internal table entries from the entry with the index (SY-TABIX ) = n1 to the entry with the index = n2 inclusive in the output area in turn.

If either one of the additions " FROM n1 " or " TO n2 " is missing, then the table is processed either from the first entry or up to the last entry (according to what is missing).

Example

Output table entries 7 and 8:

DATA: BEGIN OF T OCCURS 100,

BAREA(5), BLNCE(5),

END OF T.

LOOP AT T FROM 7 TO 8.

WRITE: / T-BAREA, T-BLNCE.

ENDLOOP.

Addition 3


... WHERE logexp

Effect

Places all internal table entries which satisfy the condition logexp in turn in the output area. The condition logexp can be almost any logical expression . The only restriction is that the first field for each comparison must be a sub-field of the line structure of the internal table itab .

Example

DATA: BEGIN OF T OCCURS 100,

BAREA(5), BLNCE(5),

END OF T.

LOOP AT T WHERE BAREA > 0.

WRITE: / T-BAREA, T-BLNCE.

ENDLOOP.

which has the same effect as:

LOOP AT T.

CHECK T-BAREA > 0.

WRITE: / T-BAREA, T-BLNCE.

ENDLOOP.

Avoid using either the AT NEW/END OF or FIRST/LAST statements in a LOOP loop with a WHERE condition.

The performance of a LOOP AT ... WHERE statement can be improved significantly if the fields to be compared always have the same data type. The comparison fields should be defined as follows:

DATA LIKE .

Example

DATA: BEGIN OF T OCCURS 100,

BAREA(5), BLNCE(5),

END OF T.

DATA CMP_BAREA LIKE T-BAREA.

CMP_BAREA = '01'.

LOOP AT T WHERE BAREA = CMP_BAREA.

WRITE: / T-BAREA, T-BLNCE.

ENDLOOP.

(92.1)

ABAP TOPIC WISE COMPLETE COURSE

BDC OOPS ABAP ALE IDOC'S BADI BAPI Syntax Check
Interview Questions ALV Reports with sample code ABAP complete course
ABAP Dictionary SAP Scripts Script Controls Smart Forms
Work Flow Work Flow MM Work Flow SD Communication Interface

SAP Financial Part Two
SAP Financial Customer Vendor AccountsEnjoySAP Financial Invoice EntrySAP Financial Automatic Payments
SAP Financial General Ledger AccountsSAP Financial Customer and Vendor AccountsSAP Financial Open Item ClearingSAP Financial CorrespondenceSAP Financial Receivables
SAP Financial General Ledger Special TransactionsSAP Financial Credit Risk ManagementSAP Financial Reporting ToolsSAP Financial Closing Process

Thank you for visiting SAP ABAP.If you liked the post, please subscribe to RSS FEED or get the updates directly into your mail box through EMAIL SUBSCRIPTION.

No comments:

Post a Comment