Passport control above A25 may not be open in the evening, so the only passport control between A and Z will be near gate A13. The flight to BEG is more likely to depart from a B gate but some shorthaul non-Schengen flights occasionally depart from Z gates.
For 'one ticket' read 'same ticket'. If you bought a ticket from HAM to BEG via FRA and miss your connection in FRA, you will not be charged extra to fly on a later flight (in this case the following day) and LH will pay for your hotel with up to €30 to spend on food or drinks. Don't expect to be put up at the airport Sheraton or Hilton if you are flying in Economy and/or have no status.