Q. This year we are suffering again from bees and wasps. What can we do in the Suka?
A. On question 372, on how to avoid having the wasps in the suka, anf if one can put outside food or honey that attracts them on Shabos and Yom Tov or is it prohibited as feeding animals that don’t belong to us, we wrote:

“Shulchan Aruch (O.H. 324: 11) rules that one should not feed water or food to bees on Shabbos. Mishnah Berurah (ibid. 29) explains that this applies even if the bees belong to the one feeding them. The reason being that since it is not necessary to feed them, as they usually take care of themselves, feeding them is a prohibited unnecessary effort. (Tos’ Shabbos 19a)

However, Horav Shlomo Miller’s Shlit’a opinion is that since your intention in this particular case is not really to provide food for them but rather the great need of not having bees and wasps in your Sukah, it is therefore permitted.

On question 1142 regarding if one can one place on Shabbos a glass with a mixture of vinegar or wine and a little liquid detergent, to attract and trap little very bothersome fruit flies, we wrote: “Mishna Berura (316:18) rules that it is forbidden to set a trap (as a mouse trap) on Shabbos, and if an animal is trapped as he sets the device, he transgresses a biblical proscription. If it is trapped afterwards it is rabbinical prohibition. However, it is permitted to set a trap before Shabbos.

In regards to flypaper, Poskim disagree whether you are allowed to hang it on Shabbos. Some rule it is prohibited (Tal Nosson p. 172, P’ri Hagan 4: 316 – p. 369, Sdei Tzoifim – Beitza 36a – p. 438). However, Piskei Teshuvos (316: 9) quoting Ateres Moishe (1: 77) permits hanging flypaper since to begin with, a fly may not immediately be caught. Besides, flies and the like are not normally trapped for any particular use (Beminom Notzud), and he is only doing it to be rid of them (Melocho Sheino Tzricho Legufo). Other Poskim permit when in great need (Sdei Tzofim ibid. See also Chashukei Chemed – Shabbos 5a, in regards to placing food on an already set glue trap).

Migdal Dovid (39 Melochos 3: Tzad n. 124) permits placing a bottle with a narrow opening and draw bees into it with an attracting substance when needed, since in essence they can still exit the bottle. You may also argue that the holding power of detergent is not necessarily the equivalent of glue, and the flies can still escape
.
Horav Shlomo Miller’s Shlit’a opinion is that when in need, you can set up the mixture of an attracting substance mixed with detergent on Shabbos.

Rabbi A. Bartfeld as revised by, Horav Dovid Pam, Horav Aharon Miller, Horav Chanoch Ehrentreu and Horav Kalman Ochs Shlit’a