Generally, you can create a new ABAP code block and insert it before the first source table or after the last source table in the program flow. If you use a nested loop to join tables, you can also insert an ABAP code block between source tables. The SQL generation mode you select in the Application Source Qualifier determines the position you can insert the ABAP code block in the program flow.
The following table lists the rules for inserting an ABAP code block:
Generation Mode
Rules
Exec SQL
You can insert code blocks before the first source or after the last source. You cannot insert code blocks between sources in the program flow.
If you insert a code block before the first source, the Designer inserts the code block before the exec statement.
If you insert a code block after the last source, the Designer inserts the code block after the FORM WRITE_DSQNAME_TO_FILE statement.
ABAP join syntax
You can insert code blocks before the first source or after the last source. You cannot insert code blocks between sources in the program flow.
If you insert a code block before the first source, the Designer inserts the code block before the select statement.
If you insert a code block after the last source, the Designer inserts the code block after the where clause.
Open SQL (nested loop)
You can insert code blocks between sources in the program flow. The Designer inserts code blocks between the select statements. You can insert code blocks before the first source or after the last source.
If you insert a code block before the first source, the Designer inserts the code block before the first select statement.
If you insert a code block after the last source, the Designer inserts the code block after the last where clause.
The following rules apply when you create a code block to specify the initial value of ABAP program variables:
If you create a code block to initialize variables used in a filter condition, insert the code block before the first source.
If you create a code block to initialize variables used in data movement, insert the code block after the last source.
You cannot insert a code block for table type fields.