I am trying to alter the standard transportation problem from the model library. I want to include several more “producers” and “markets” into the problem and define their distance in the d(i,j) matrix.
Here I run into my problem: I have a working excel import to get all the values for the distance matrix and to define the parameters a(i) and b(i), but I want certain connections to be non existent and their distance to bet set as zero (You cant ship from San-Diego to Topeka for example). I tried if and $ functions but everytime the solution remains 0 and I cant figure out my mistake. The program works with with other values for those distances and the solution seems to be fine.

Short: Where and how do I have to set the $ or an if function so the algorithm isnt considering those connections?

The fact that your solution is zero makes sense if you set some distances to zero. You are minimizing cost, which is proportional to the distance between plant i and market j. If the distance for an (i,j) pair is zero, there is no cost involved in transporting product between those two. Hence minimization returns zero.

You can create another parameter valid(i,j), which is mapping of the (i,j) with 1 and 0.
1 means the transportation is valid. 0 means not valid. For your case, table may look like this

Table valid(i,j) ‘if the transportation is valid’
new-york chicago topeka
seattle 1 1 1
san-diego 1 1
;
with equations subjected to valid (i,j)
supply(i)… sum(j$valid(i,j), x(i,j)) =l= a(i);
demand(j)… sum(i$valid(i,j), x(i,j)) =g= b(j);

Hope this helps.
Alternatively, you can place an upper bound on x(i,j) value of a pair