Thursday, November 26, 2015

Control Break - AT FIRST and AT LAST



AT FIRST triggers at the first loop iteration whereas AT LAST triggers at the last loop iteration. We can’t mention any particular field here as we can do in AT NEW or AT END OF. The main purpose of this control break is to write some header or footer information. We can write some header info by using AT FIRST statement and similarly some footer info by using AT LAST statement.

REPORT  zctrlbrk_at_first_last NO STANDARD PAGE HEADING.

TYPES: BEGIN OF ty_tab,
        werks TYPE mard-werks,
        matnr TYPE mard-matnr,
        lgort TYPE mard-lgort,
       END OF ty_tab.

DATA: wtab TYPE ty_tab,
      itab TYPE TABLE OF ty_tab.

START-OF-SELECTION.

  SELECT matnr werks lgort
    UP TO 25 ROWS FROM mard
    INTO CORRESPONDING FIELDS OF TABLE itab.

  IF sy-subrc = 0.
    SORT itab BY werks.
    WRITE: / 'Material', 20 'Plant', 27 'Storage Location'.
    ULINE.

    LOOP AT itab INTO wtab.
      WRITE: / wtab-matnr, 20 wtab-werks, 27 wtab-lgort.

      AT FIRST.
        WRITE: '===AT FIRST will trigger here'.
      ENDAT.

      AT LAST.
        WRITE: '===AT LAST will trigger here'.
      ENDAT.
    ENDLOOP.
  ENDIF.

Now at the debugger level we see the following results. AT FIRST triggers at 1st loop iteration when SY-TABIX = 1. Here all fields of work area are ***.


After that the system triggers AT LAST statement at the last loop iteration when SY-TABIX = 25. Previously the values of work area are also ***.


The output is as follows.

7 comments:

python training said...

Nice information providing .Thank you for sharing this valuable information about Sap Modules.
Sap Abap Online Training
sap Hana Course Training
Sap BO Online Course Training
Sap Lumira Online Training
Sapui5 Online Training

Satti said...

Good blog posting about SAP, this is very useful information to me. thank you
SAP HANA Online Training
SSAP ABAP Online Training
SAP BASIS Online Training
SAP BI BW Online Training
SAP FICO Online Training

Anonymous said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Anonymous said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Unknown said...

Best SAP MM Material Managemnt Real time hands on Training in chennai

http://thecreatingexperts.com/sap-mm-training-in-chennai/

Anonymous said...

Informative Blog...For a long time I was craving for a career growth in programming and then I came to know that THE CREATING EXPERTS is the one who provide training with hands on training and real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact 8122241286

leka said...

Hi!!
The information has been given by this blog, which is very informative and truly helpful, for who are looking for SAP MM TRAINING in Hyderabad.sieve software is the best sap mm training and placements in Hyderabad.