RE: Shipment was not fully allocated, difference in work quantity and shipment quantity.
Out of curiosity, for what type of locations will the above logic not work in your case?
Release load to warehouse
To come back to the scenario you forwarded, if the shipment and load was created for 100, the release to load batch job will make sure that the remaining 40 in your scenario will be associated with the same shipment and load, see example below (note: some different quantities have been used).

Figure 1. Shipment creation for a quantity of 20; however, work has only be created for a quantity of 10

Figure 2. Sales order picking work for a quantity of 10 only
A warehouse worker later on puts the remaining 10 quantities away to a suitable picking location. As a result, this quantity can be released now as well. In order to make sure this quantity will be part of the same shipment and load, the release load to warehouse batch job will be used.

Figure 3. Release the load to the warehouse
Note: if it occurs frequently in your case that for a particular reason you have partially released loads you could configure the release to load as a batch job as well.
After releasing the load to the warehouse, the system will create work for the remaining 10 quantities against the same load and shipment.

Figure 4. Sales order picking work for the same shipment and load