Explicit form of S-matrix on the line Consider the Hamiltonian $H$ on functions on the line with
\begin{eqnarray}
H=H_0+V,\\
H_0=-\frac{1}{2m}\frac{d^2}{dx^2}
\end{eqnarray}
where $V$ is a potential vanishing outside of a bounded interval and $m>0$. To avoid discrete spectrum of $H$ one may assume $V\geq 0$. One even may assume that $V(x)=V_0>0$ for $x\in [0,a]$ and $V(x)=0$ otherwise.

How to write down explicitly the $S$-matrix for this Hamiltonian?
  Namely how does $S$ act on $e^{ipx}$? 

Remark. Since $S$ commutes with $H_0$ then necessarily 
$$S(e^{ipx})=A(p)e^{ipx}+B(p)e^{-ipx}.$$

My question is how to write down $A(p),B(p)$ explicitly.

ADDED. Let me ask a more precise question. The equation $H\psi=\frac{p^2}{2m}\psi$ has a solution $\psi_p$ such that
\begin{eqnarray}
\psi_p(x)=\left\{\begin{array}{cc}
e^{ipx}+\tilde B(p)e^{-ipx},&x<\inf supp(V)\\
\tilde A(p)e^{ipx},&x>\sup supp(V)
\end{array}\right.
\end{eqnarray}
where $\tilde A(p),\tilde B(p)$ are appropriate constants.

Is it true that for $p>0$ one has $\tilde A(p)=A(p)$ and $\tilde B(p)=B(p)$?

(If my understanding is correct, $\psi_p$ is the IN state corrresponding to plane wave $e^{ipx}$ provided $p>0$.)
I believe this should be a basic example in the scattering theory, so a reference will be most helpful.
 A: Paraphrasing L.I.Schiff, "Quantum Mechanics", the $S$-matrix $S=\langle \beta | \alpha^{+} \rangle $ is the amplitude of the final asymptotic state $\beta $ contained in what became of an initial asymptotic state $\alpha $ after the scattering has taken place. So you should construct this for a complete set of states $\alpha $ and $\beta $. Evidently, you have decided to use bases of energy eigenstates. In your case, this infinite-dimensional matrix decomposes into $2\times 2$ blocks on the diagonal, associated with given energy $p^2 /2m$, which indeed contain your amplitudes $\tilde{A} $ and $\tilde{B} $, namely,
$$
S(p^2 )=\left( \begin{array}{cc}
\tilde{B} (p) & \tilde{A} (p) \\
\tilde{A} (p) & -\tilde{B}^{*} (p) \tilde{A} (p) / \tilde{A}^{*} (p)
\end{array} \right)
$$
(the first column is directly read off your wave function solution, the second column follows from unitarity and time reversal invariance). Your first question and the "Remark" following it are phrased a bit too sloppily. You have to distinguish between the  asymptotic states for $x\rightarrow \pm \infty $. The incoming states are $e^{ipx} $ for $x\rightarrow -\infty $ and $e^{-ipx} $ for $x\rightarrow \infty $. The outgoing states are $e^{-ipx} $ for $x\rightarrow -\infty $ and $e^{ipx} $ for $x\rightarrow \infty $ (in that specific order, for the concrete matrix representation given). 
A: construction of the scattering states, $\psi_p(x)$ incident from the left, $\psi'_p(x)$ incident from the right (for $p>0$)
\begin{eqnarray}
\psi_p(x)=\left\{\begin{array}{cc}
e^{ipx}+r(p)e^{-ipx},&x\rightarrow-\infty\\
te^{ipx},&x\rightarrow+\infty
\end{array}\right.
\end{eqnarray}
\begin{eqnarray}
\psi'_p(x)=\left\{\begin{array}{cc}
e^{-ipx}+r'(p)e^{ipx},&x\rightarrow+\infty\\
t'(p)e^{-ipx},&x\rightarrow -\infty
\end{array}\right.
\end{eqnarray}
I write $x\rightarrow\pm\infty$, since if the line has a nonzero extension in the transverse $y$-direction it is not enough to take $x$ outside of the support of $V$, because of evanescent waves: waves that decay exponentially into the region where $V=0$, but have not yet decayed to zero. 
the reflection coefficients $r(p),r'(p)$ and transmission coefficients $t(p),t'(p)$ define the scattering matrix:
$$S(p)=\begin{pmatrix}
r(p)&t'(p) \\
t(p)&r'(p)
\end{pmatrix}$$
unitarity: $S(p)S^\dagger(p)=\mathbb{1}$, time-reversal symmetry: $S^t(p)=S(p)$, so $t(p)=t'(p)$. These constraints may be incorporated in the polar decomposition
$$S=\begin{pmatrix}
e^{2i\phi}\sqrt{1-T}&e^{i\phi+i\phi'}\sqrt{T} \\
e^{i\phi+i\phi'}\sqrt{T}&-e^{2i\phi'}\sqrt{1-T}
\end{pmatrix},$$
with $\phi(p),\phi'(p)\in[0,2\pi)$ and $T(p)\in[0,1]$.
There is no simple closed-form expression for $\phi,\phi',T$ for arbitrary $V(x)$, this will typically require a numerical solution. For an overview of approximate methods, you might take a look at Scattering by one-dimensional smooth potentials: between WKB and Born approximation.
