SAP StackFICOHRMMSDPMPSABAPNetWeaverTablesTcodes ☰MENU

ABAP LOOP Statement

LOOP statement in ABAP programming is used for looping through extracts, internal tables and screen fields. LOOP can have a nested structure. Means inside a LOOP block another LOOP statement can be used. Now lets us check the LOOP statement for each of these operations.

Extracts looping

Syntax:

LOOP.

The control block with LOOP statement should end with ENDLOOP statement. One by one record of the extract dataset will be read in each loop pass. We can store the extracted fields in other field variables inside the loop statement for other processing.

Internal Tables Looping

Syntax Variations

LOOP AT <itab> INTO <wa> WHERE <logexp>.

LOOP AT <itab> ASSIGNING <FS> WHERE <logexp>.

LOOP AT <itab> REFERENCE INTO <dref> WHERE <logexp>.

LOOP AT <itab> TRANSPORTING NO FIELDS WHERE <logexp>.

The main run-time errors with internal table looping are

 

SCREEN fields looping

Syntax

LOOP AT SCREEN [INTO wa].

ENDLOOP.

“LOOP AT SCREEN” statement is used for looping through the fields on current screen. We can retrieve name and other attributes of each screen field in the loop iteration. The main components of screen field are listed below.

  1. name
  2. group1
  3. group2
  4. group3
  5. group4
  6. required
  7. input
  8. output
  9. intensified
  10. invisible
  11. length
  12. active
  13. display_3d
  14. value_help
  15. request
  16. values_in_combo

System field sy-subrc with Loop

With the LOOP statement system field sy-subrc will have the following values.

See a sample ABAP program with nested LOOP structure.


Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes

SAP ALECRMSCMSRMSAP Solutions SAP ReferencesSAP BasicsPP ModuleWMSAP Partners
HomeContact & Privacy PolicyTwitter
All of the product names here are trademarks of their respective companies. The site sapstack.com is not affiliated with SAP AG.
©2024 sapstack.com