‎2007 Mar 27 10:58 AM
Hi Gurus,
how <b>loop at itab transporting no fields where....</b> is different than normal loop at itab.thanks in advance....
‎2007 Mar 27 11:15 AM
hi all,
thx a lot i got d working of this syntax...now i wish to learn the exact use of such statement i mean where all we use such kind of statement??
‎2007 Mar 27 11:00 AM
If you do not need to transfer the contents of the current table line to a work area or assign them to a field symbol, you can use the following statement:
LOOP AT <itab> TRANSPORTING NO FIELDS <condition>.
This form of the LOOP statement is useful if you want to find the index of a particular internal table, or the number of lines in a table that meet a particular condition.
‎2007 Mar 27 11:01 AM
... TRANSPORTING NO FIELDS
Effect
There is no field transport in the output area of the internal table. This addition can be used only in conjunction with a WHERE condition. Since it would make no sense to specify a work area with INTO wa when using the addition TRANSPORTING NO FIELDS, this option does not exist.
This addition can be used to determine a set of line indexes (index set) or to determine the number of lines in a table which satisfy a given condition
REGARDS
SHIBA DUTTA
‎2007 Mar 27 11:01 AM
Hi Shaheen
you do not need to transfer the contents of the current table line to a work area or assign them to a field symbol, you can use the following statement:
LOOP AT <itab> TRANSPORTING NO FIELDS <condition>.
This form of the LOOP statement is useful if you want to find the index of a particular internal table, or the number of lines in a table that meet a particular condition.
Hope this helps.
Britto
‎2007 Mar 27 11:02 AM
loop at itab transporting no fields will just loop the internal table without moving the contents of the current record in to the header.
A normal loop would get all the fields's values into the work area's fields.
Regards,
ravi
‎2007 Mar 27 11:03 AM
LOOP AT itab
Syntax
LOOP AT itab result [cond].
...
ENDLOOP.
Effect
The LOOP and ENDLOOP statements define a loop around a statement block. The LOOP statement reads lines from internal table itab sequentially. You can either read all the lines or specify conditions cond to restrict which lines to read. The output result determines when and where the line contents are read. The statement block between LOOP and ENDLOOP is executed once for each line. To exit processing of the statement block , you can use the statements described in Section leave loops.
The sequence in which the lines are read depends on the table type:
Standard tables and sorted tables
The lines are read by ascending table index.
Hashed Tables
The lines are processed in the sequence in which they were inserted in the table, and in the sort sequence following use of the SORT statement.
The loop continues to run until all the table lines that meet conditition cond have been read or until it is exited with a statement. If no appropriate lines are found or if the internal table is blank, the loop is not run at all.
System Fields
The LOOP ATstatement sets system field sy-tabix to the table index of the current table line for Standard tables and sorted Tables, and to 0 for Hashed-Tables, after every loop pass. It leaves sy-subrc unchanged. When the loop is exited with ENDLOOP, sy-tabix is reset to the value it had before the loop was entered, and the following applies sy-subrc: sy-subrc Relevance
0 The loop was run at least once.
4 The loop was not run at all.
The system fields sy-tfill and sy-tleng are also supplied with data.
Changing Internal tables in a loop
If you insert or delete lines in the statement block of a LOOP , this will have the following effects:
If you insert lines behind the current line, these new lines will be processed in the subsequent loop passes. An endless loop can result.
If you delete lines behind the current line, the deleted lines will no longer be processed in the subsequent loop passes.
If you insert lines in front of the current line, the internal loop counter is increased by one with each inserted line. This affects sy-tabix in the subsequent loop pass.
If you delete lines in front of the current line, the internal loop counter is decreased by one with each deleted line. This affects sy-tabix in the subsequent loop pass.
Notes
Within classes, you cannot change table itab in the statement block of the LOOP using statements that access the entire table. Statements such as CLEAR, FREE, LOCAL, REFRESH, SORT and all types of assignments to itab are not allowed.
If you specify the internal table itab through a Reference variable, then the loop is processed completely at the table referenced at entry. Possible changes of the reference variable do not have an effect on the loop. The respective object cannot be deleted from the Garbage Collector, as long as the loop is not completed.
Example
Nested LOOP-loops. The contents of the current row for the outer loop are analyzed in the WHERE-condition for the inner loop.
PARAMETERS p_name TYPE scarr-carrname DEFAULT '*'.
DATA: scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrname,
spfli_tab TYPE SORTED TABLE OF spfli
WITH NON-UNIQUE KEY carrid.
FIELD-SYMBOLS LIKE LINE OF scarr_tab.
DATA spfli_line LIKE LINE OF spfli_tab.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
SELECT *
FROM spfli
INTO TABLE spfli_tab.
LOOP AT scarr_tab ASSIGNING
WHERE carrname CP p_name.
LOOP AT spfli_tab INTO spfli_line
WHERE carrid = -carrid.
WRITE: / spfli_line-carrid,
spfli_line-connid.
ENDLOOP.
ENDLOOP.
Syntax
... { INTO wa }
| { ASSIGNING <fs> }
| { REFERENCE INTO dref }
| { TRANSPORTING NO FIELDS } ... .
Effect
You have four alternatives to influence the display:
With the addition INTO, you assign the content of the current line to a work area wa.
With the addition ASSIGNING, you assign the current line to a field symbol <fs>; within the loop, you are not allowed to assign a different memory area to the field symbol or cancel the assignment with UNASSIGN.
With the addition REFERENCE INTO, you set a reference to the current line in a reference variable (since release 6.10).
With the addition TRANSPORTING NO FIELDS, you only fill the corresponding system fields. This addition is only possible, if the addition WHERE is used simultaneously in the conditions cond.
With the one exception, that behind INTO wa there is no further specifiction of transport_options, the syntax and meaning of the specification of the display behaviour are the same as in the statement READ TABLE. Additionally, there are the same limitations regarding the manipulation of key fields as with sorted tables and hashed tables.
Note
At LOOP, you can omit the specification INTO wa outside of classes if the internal table has a homonymous header line itab. The statement is then amended by INTO itab.
‎2007 Mar 27 11:07 AM
hi,
loop at itab transporting no fields where....
in this case loop is repeated as many number of times as the records present in the internal table with out filling the work area or header line in each loop pass.
We don't know the data of the present record, but we know the number of the loop pass or record.
‎2007 Mar 27 11:15 AM
hi all,
thx a lot i got d working of this syntax...now i wish to learn the exact use of such statement i mean where all we use such kind of statement??
‎2007 Mar 27 11:30 AM
Hi Shaheen,
You go for this syntax, when you have got nothing to do with the contents of the fields, but only with the system fields like sy-tabix, which tells you the record number. This would improve the performance due to the factt that it is not transporting the data into the work area, especially in case of larger work areas.
Regards,
ravi