This part is a kind of semiconductor called BESMxxMG-xxxxxB.
Function of this product has Inductive Sensors.
Manufacturers : Balluff
Image and pinout :

Some of the text within the PDF file :
Ǿ /Z /Z M18x1 /Z 24 40 46 .'& Ǿ Ǿ .'& Ǿ LED .'& /Z /Z M18x1 /Z 24 40 46 .'& Ǿ Ǿ .'& Ǿ LED .'& M8x1 M8x1 M8x1 13 13 13 25.5 26 35 37 30 45 47 LED LED LED 35 M8x1 M8x1 M12x1 M12x1 3 13 13 3 17 25.5 27.5 17 37 39 35 37 30 43 59 45 47 LED LED LED LED 61 M12x1 M12x1 17 17 27.5 37 30 55 LED LED M12x1 39 M12x1 M12x1 M12x1 17 5 5 17 27.5 17 32.5 37 39 5 42 43 LED 59 61 LED LED M12x1 60 M18x1 M18x1 M18x1 24 2 [ ... ]