The main question inspiring this research is: How to split the capacity of distributed energy resources (DERs) for provision of different products and services. Among different DERs, the focus is on controllable photovoltaic (PV) systems. An algorithm based on optimal products split selection method is developed to ensure efficient and secure operation of distribution grids for provision of the flexibility services. The algorithm consists in two stages of decision making. The first stage deals with the forecast of DERs productions, i.e., PV systems outputs, in a time-ahead basis, whereas the second stage deals with scheduling of controllable DERs in different energy and flexibility markets based on optimization problem. The definitions of flexibility services to be considered by the distribution system operator (DSO) are provided. These flexibility services are formulated as relative cost coefficient terms, with respect to the techno-economic considerations, in the objective function of DSO. Then, the forecast error and the penalties associated with the deviations of DERs generation from the schedule is modeled in the optimization problem. Finally, to demonstrate the effectiveness of the proposed method, a simulation case study is developed using the data of a realistic distribution grid in Western Switzerland.