Program Comprehension – Program Slicing Part 2
Following up from Part 1 of this topic, let me conclude the Program Slicing topic by making an RPG example that should make it very clear.
In this very simple example of Backward Slicing two files have new records written; the naming conventions should be self-explanatory for which fields are in which file.

After Step 2, the five red statements represent the backward program slice for the WRITE CUSTFMT statement. After Step 4, the three blue statements represent the backward program slice for the WRITE ITEMFMT statement.