using the following code, when I click on references (having red boxes), they do not refer to proper places.
\documentclass{article}
\usepackage{array,longtable}
\usepackage{hyperref}
\begin{document}
\renewcommand\theenumii{\alph{enumii}}
\makeatletter
\def\subitem{\omit\@arstrut
\ifnum\value{enumii}=0 \stepcounter{enumi}\fi
\refstepcounter{enumii}\theenumi\theenumii\hfill}
\def\item{\omit\setcounter{enumii}{0}\let\omit\relax}
\makeatother
\begin{longtable}{>{\refstepcounter{enumi}\setcounter{enumii}{0}\theenumi}lr}
\item
\subitem \label{1a}& fooo \\
\subitem \label{1b}& foo \\
\item
\subitem \label{2a}& foo \\
\subitem \label{2b}& foo \\
\label{3}& foo \\
\label{4}& foooo \\
\end{longtable}
we have \ref{1a}, \ref{2b}, \ref{4}
\end{document}
\subitem
as a command name, since it's used in thetheindex
environment. All's well until you need to make an index, when disaster might be approaching.\item
and\subitem
definitions into the start code of a custom environment just before starting longtable, to keep the scope of the redefinition local.