We consider a flowshop with m machines each of which perform a specific operation of the identical parts to be processed. Two specific adjacent machines among all machines are capable of performing an additional operation required by each part, which is named as the flexible operation. The problem is to decide on the machine to perform this flexible operation for each of the n parts to be processed. The assignment can be different from one part to another. Therefore, although the parts are identical, their actual processing times on the machines can be different from each other. The objective is to minimize the makespan. One application of such production systems can be found in metal cutting industries where highly flexible CNC machines are used. These machines are capable of performing different operations as long as the required cutting tools are loaded on the tool magazines. Similar problems also exist in assembly lines with human operators where the workers are cross-trained. We first formulate the problem as a mixed integer program and determine some properties of the optimal solutions. We identify some special cases of the problem where it can be solved trivially. For the remaining cases we develop a heuristic algorithm and test the efficiency of this algorithm through a computational study. The results of this analysis indicate that the developed heuristic is very efficient in terms of both solution quality and the required CPU time.