sleep mode doesn't work
When I select the sleep mode, the iMac G5 17" Model A1058 shuts down. Is this a problem with the logic board or is this related to the power supply
Sounds like it could be either, but I'm inclined to think power supply, I'd try first resetting your SMU:
1) Turn off the computer by choosing Shut Down from the Apple menu, or by holding the power button until the computer turns off.
2) Unplug all cables from the computer, including the power cord.
3) Wait 10 seconds.
4) Plug in the power cord while simultaneously pressing and holding the power button on the back of the computer.
5) Let go of the power button.
6) Press the power button once more to start up your iMac.
An important thing to do with iMacs of this vintage is to open up the back (there are 3 screws along the bottom edge) and check the capacitors carefully for swelling or leakage. Shine a bright flashlight into the holes of the power supply; sometimes you can see if there's a bad cap in there, which could cause power issues.
See how to take the back of at iMac G5 17" Model A1058 Power Supply Replacement