Retrieving High Value


%{=============================================%}
%{=== Retrieve highest value on file ==========%}
%{=============================================%}

%FUNCTION(DTW_SQL) GetLast()
  {

  SELECT *
    FROM PNAELDPF AS LAST
    WHERE ELDELM = '$(ELM)' AND LAST.ELDSEQ = (SELECT MAX(LAST1.ELDSEQ)
			FROM PNAELDPF AS LAST1
			WHERE ELDELM='$(ELM)' AND LAST1.ELDSEQ = LAST1.ELDSEQ
			)

        %MESSAGE { 100 :  { @DTW_ASSIGN(MAXCDE,"0") %}  : continue %}

   %REPORT {
     %ROW{
       @DTW_ASSIGN(MAXCDE,V_ELDSEQ)
   %}
 %}
%}