Once you change the code to Automatic, the changes in "User written body" will be removed. U need to keep the code in User written body only or check if its feasible to add your extra line of code in either Precode or Postcode part.
... View more
Its because of below condition c.ID=d.ID and a.LOEND<=d.Ordering<=c.LOSTART Replace it with c.ID=d.ID and a.LOEND<d.Ordering<c.LOSTART It should work.
... View more