Field help (SYNQLY) 

Select this check box to:

Different cases are possible.

Loop on STOQLYD:

Loop on STOCK:

Loop on STOQLYH:

When no record exists in STOQLYD then the STOQLYH record is purged.