Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SAP ABAP Control Break Statements

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SAP ABAP Control Break Statements

Control break processing in a internal table loop is used to execute statements written within the block AT and
END AT, when the control structure changes. The AT statements (Begining of the blocks) determine the control
break at which the statements written within the blocks are executed. Within these statement blocks, the SUM
statement can be use to total the numeric components of a control level.

The prerequisite for using control break statements is that the internal table must be sorted in the exact order of
the components of its row type according to the processing sequence in which the LOOP loop reads the rows of
the internal table.

The control break "ON CHANGE OF - ENDON", can be used in any loop, not just LOOP... ENDLOOP. It can also be
used in WHILE ... ENDWHILE.

There are Five control break statements -


1. At First / End At
2. At Last / end At
3. At New / End At
4. At End Of / End At
5. On Change Of / EndOn

Q. What is the difference between 'At New / End At' and 'On Change Of / EndOn'?
1. 'On Change Of' can be used in any loop construct, not just 'Loop At'.
2. A Single 'On Change Of' can be triggered by a change within one or more fields named after of and separated by
OR.
3. When used within a loop, a change in a field to the left of the control level does not trigger a control break.
4. When used within a loop, fields to the right still contain their original values; they are not changed to contain
zero or asterisks.
5. You can use 'else' statement between 'On Change OF' and 'End On'. You can also use ELSEIF statements in
conjunction with special implementation of ON, but should always try to avoid this because they may not be
supported in future.
6. You can use it with 'Loop At' IT WHERE clause……
7. You can use 'SUM' with 'On Change Of'. It sums all numeric fields except the one(s) named after Of.
8. Another difference is while using 'at new' in case if you code any write statements between 'at new' and 'end at'
the value for the numeric fields will be returned as 0 and that of no numeric fields will be returned as *(asterisk).
But in on change of the original values will be returned.

NOTE: Use the 'At First' and 'At Last' statement to perform during the first or last pass of internal table. These
statements can only be used within 'LOOP AT'; they cannot be used within select.

What is the difference between collect and sum?


Following are the differences -

- COLLECT statement is used to sum the value on a default key fields in the work area. The default key is composed
of the values from all fields of type c, n, d, t, and x. Where the SUM statement is used to sum the value to the right
of control level. The key is formed with the control level defined on the control break processing statement.

- SUM statement is used with the control break AT...ENDAT processing statement though COLLECT statement do
not so.

- In the COLLECT statement, the system searches the body of the internal table for a row that has the same key as
the key in the work area. If it doesn't find one, the row is appended to the end of the table. If it does find one, the
numeric fields (types I, p, and f) in the work area are added to the corresponding fields in the found row.

While SUM, calculates a total for the current value of the control level that contains it. It finds all rows that have
the same values within the control level field and all fields to the left of it. It sums each numeric column to the
right of the control level. It places the totals in the corresponding fields of the work area.

SAP ABAP SUBMIT Report Statement

The ABAP SUBMIT report statement is used to starts the program. But you can only start programs with type '1'
(Executable Program only) using SUBMIT. If the program has a different type, the system triggers a runtime error.

The basic forms of SUBMIT command is -

1. SUBMIT Rep.
2. SUBMIT (Name).

Additionals:
1. LINE-SIZE col - The list generated by the report has the line width col.
2. LINE-COUNT line - The list generated by the report has line lines per page.
3. TO SAP-SPOOL List - output to the SAP spool database
4. USING SELECTION-SCREEN scr
5. VIA SELECTION-SCREEN
6. AND RETURN - Returns to the calling transaction or program after the called program
have been executed. SUBMIT ... AND RETURN creates a new internal session.
7. EXPORTING LIST TO MEMORY
8. USER user VIA JOB job NUMBER n
9. Various additions for passing parameters to rep
10. USING SELECTION-SETS OF PROGRAM prog

What is the effect of using SUBMIT rep.... USING SELECTION-SCREEN scr?


When you execute the report, the system uses the selection screen number that you specify in the scr field. This
must be a selection screen defined using the SELECT-OPTIONS, PARAMETERS and SELECTION-SCREEN statements.
If you omit the addition, the system uses the standard selection screen 1000. This addition allows you to start the
same report in different situations, using a different selection screen each time (what you explicitly mentioned for
scr). This is the difference between USING SELECTION-SCREEN and VIA SELECTION-SCREEN. VIA SELECTION SCREEN
takes its own exec report selection screen.

Q. What is the effect of using SUBMIT rep....USER user VIA JOB job NUMBER n?
Schedules the specified report in the job specified by the job name job and the job number n. The job runs under
the user name user and you can omit the addition USER user. The assignment of the job number occurs via the
function module JOB_OPEN This addition can only be used with the addition ...AND RETURN.

Note: When scheduling a report with the SUBMIT ... VIA JOB job NUMBER n statement, you should always use the
addition ...TO SAP-SPOOL to pass print and/or archive parameters. Otherwise, default values are used to generate
the list and this disturbs operations in a production environment.

What is the effect of using SUBMIT rep....VIA SELECTION SCREEN?


The addition VIA SELECTION SCREEN determines whether the report is processed in the foreground or the
background.

What is the effect of using SUBMIT rep.... USING SELECTION-SETS OF PROGRAM prog?
Uses variants of the program prog when executing the program rep.

WITH SELECTION-TABLE rspar - You can dynamically transfer different values. An internal table rspar with the
Dictionary structure RSPARAMS is created. This table can be filled dynamically in the calling program with all the
required values for the selection screen of the called program.

Except for WITH SELECTION-TABLE, you can use any of the above options several times and in any combination
within a SUBMITstatement. In particular, you can use the WITH sel addition several times for one single criterion
sel. The only combination possible for the WITH SELECTION-TABLE addition is USING SELECTION-SET.

You might also like