If your laptop is no longer holding a charge for long periods of time or always needs to be plugged into a power source to work, use this Lenovo IdeaPad U530 Touch Does Not Hold Charge problem page for possible causes and solutions.
If you have a DMM (digital multimeter) use its Voltmeter function to verify that there is +20V DC on the output plug of the charger when it is connected to the power and turned on.
Here’s an image from p.21 of the HMM (see link below) showing how to test the charger’s output.
(click on image to enlarge for better viewing)
If the charger is OK then the laptop will have to be opened and the DC power jack on the systemboard will need to be checked, first that it is not loose from the systemboard and if it is OK then that there is continuity through the connector to the systemboard.
Here’s the hardware maintenance manual for the laptop. Go to p.53 to view the necessary pre-requisite steps and then the procedure to remove the systemboard. Initially it won’t have to be removed but if it is determined that the connector is faulty (sometimes the centre pin breaks away internally) the board will have to be removed so that it can be unsoldered and a replacement soldered back in its place.
Replacement sockets (supplier example only to show part and cost) are available online. Just search for Lenovo L340 -15IWL DC power jack, to find suppliers that suit you.
Also as the laptop appears to be a relatively recent model, perhaps it is still covered by the manufacturer’s warranty. If the warranty period is still valid then opening the laptop may void the warranty. Although if the socket was faulty, the manufacturer may deny a warranty repair claim, saying that it was caused by the user. Something to consider perhaps.