\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\newwrite\extracttable
\immediate\openout\extracttable=extract.ext
\newcommand{\extracttables}{
\begin{longtable}[l]{p{3cm}p{2cm}p{2cm}p{2cm}}\caption{Extract}\\
\textbf{fromtable}& \textbf{value}&
\textbf{value}&\textbf{comment}\\\endfirsthead \textbf{table}&
\textbf{value}& \textbf{val}&comment\\\endhead
\immediate\closeout\extracttable
\input extract.ext
\end{longtable}}
\newcommand{\extract}[2]{#1 \immediate\write\extracttable{Tabelle \thetable \noexpand\noexpand\noexpand\\}}
\begin{document}
\begin{longtable}[l]{p{1cm}p{1cm}p{1cm}}\caption{Erste}\\
\extract{ATest&ATest}{comment}\\
BTest&BTest\\
\extract{CTest&CTest}{comment}\\
\extract{DTest&DTest}{comment}\\
\end{longtable}
\begin{longtable}[l]{p{1cm}p{1cm}p{1cm}}\caption{Zweite}\\
\extract{VTest&VTest}{}\\
WTest&WTest\\
\extract{XTest&XTest}{}\\
\extract{YTest&YTest}{}\\
\end{longtable}
\extracttables
\end{document}