Multiply each hourly rate by x ( time to complete the work) add it to the service call for each and then set the equations equal:
50 + 40x = 30 +45x
Subtract 30 from both sides:
20 + 40x = 45x
Subtract 40x from both sides:
20 = 5x
Divide both sides by 5
x = 4
The length is 4 hours.