An algorithm for nonlinear optimal generalized predictive functional control is defined for controlling discretetime piecewise affine systems. The main piecewise affine form is transferred into a corresponding state-dependent system form. The principal piecewise affine system's hybrid properties are retained, and both the continuous and switching dynamics are combined in the same system description. This method enables the use of nonlinear generalized predictive functional control for this hybrid system class. In the generalized predictive functional control method, different classical controller structures can be employed in the feedback loop, such as PI, PID or other classical transfer-function structures. The loop controller is defined here to have a PI structure, and its selected linear transfer-functions set is multiplied by gains that are found to minimize a GPC type of cost-index. The simulation results are shown using a model of a continuous stirred tank reactor.