Hi Pablo,
somehow I have the feeling there's a conflict in terminology.
A job that runs and fails will return some exit code (usually one that is unequal zero).
This exit code is mapped (by the used exit state mapping) to some exit state.
This exit state is either a final or restartable state.
If this exit state is restartable, the job won't reach a final state and remains in state FINISHED.
If this exit state is defined to be a final state (this is done in the exit state profile), the job will reach the state FINAL.
This conversion from RUNNING -> FINISHED -> FINAL happens within a single transaction.
Hence you won't ever see a job that exited with an exit code that maps to a final exit state that is still in state FINISHED.
Jobs that are FINAL are immutable. Jobs that are FINISHED can be restarted, you can set their exit state manually (usually to some final state), or you can cancel them.
First after the operator action "Cancel", a job will end up in state CANCELLED.
A job in state CANCELLED is immutable too. This means that there's a fundamental difference between being in a FINISHED state compared to the CANCELLED state.
Thus there's no way that a job cancels some batch (with the exception of a job that executes a program that is designed to cancel batches and in fact automates the operator's intervention) in a natural way.
This again means that you use the word "(to) cancel" for something else than we do.
With the batch structure you've showed (only a master (BATCH) with n jobs as children), the query you need is probably very simple:
SELECT id
FROM SUBMITTED_ENTITY
WHERE id = master_id /* masters only */
AND cnt_finished > 0; /* with children in a FINISHED state */
And sure, you can join with the scheduling_entity table to retrieve the full name.
As an alternative, you can execute the query in sdmsh and use
SELECT id, se_id
FROM SUBMITTED_ENTITY
WHERE id = master_id /* masters only */
AND cnt_finished > 0 /* wiith children in a FINISHED state */
WITH se_id job;
Note: this simple approach doesn't work in deeper hierarchies!
I might have missed your point entirely, but in that case I simply don't understand your terminology.
Best regards,
Ronald