Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script line error: End If

Hello Friends

I am writing a script

When I run it I am getting the error

Script line error:

End If

To the eye it looks correct I am confused which end if I am making a mistake in.

Below is my piece of script that it is erroring out

Sub LoadTableNames // LoadTableNames Sub

     CurrTable: // Get the current run states of the Summary Table

  Sql  SELECT RUN_SUMM_TYPE,

             RUN_PERIOD,

             'AT_'||REPLACE(RUN_PERIOD,'-','_') TABLENAMES,

             MAX(RUN_TIME_END) MXRUNTIME,

             'Y' RUN_FLAG

        FROM RPRO_RI_PRE_SUMM_RUN_LOG

      WHERE RUN_STATUS IN ('COMPLETED', 'COMPLETE')

            AND RUN_SUMM_TYPE = 'BY TRANSACTION'

            AND RUN_PERIOD IS NOT NULL

          GROUP BY RUN_SUMM_TYPE, RUN_PERIOD

          ORDER BY MAX (RUN_TIME_END) DESC;

     Let ATLoadExists = Not IsNull( QvdCreateTime('$(vDirectory)ATLoadList.csv'));

  If(ATLoadExists) Then // Check if the AT Load List Exist (Full Load or Incremental)

     Trace ' Incremental Load of AT';

  NewTable:

  Outer Join (CurrTable)

  Load

  RUN_SUMM_TYPE,

  RUN_PERIOD,

  TABLENAMES,

  MXRUNTIME as O_MXRUNTIME

  from $(vDirectory)ATLoadList.csv

  (txt, utf8, embedded labels, delimiter is ',', msq);

  TmpTableList:

  Load

  RUN_SUMM_TYPE,

  RUN_PERIOD,

  TABLENAMES,

  if(MXRUNTIME>if(isNull(O_MXRUNTIME),'01/01/1900',O_MXRUNTIME),MXRUNTIME,O_MXRUNTIME) as MXRUNTIME,

  if(MXRUNTIME>if(isNull(O_MXRUNTIME),'01/01/1900',O_MXRUNTIME),'Y','N') as RUN_FLAG

  Resident CurrTable;

  Store TmpTableList into $(vDirectory)ATLoadList.csv(txt);

  Drop Table CurrTable;

  Drop Table TmpTableList;

  Else

      Trace ' Full Load of AT';

    Store CurrTable into $(vDirectory)ATLoadList.csv(txt);

      Drop Table CurrTable;

               

    End If // End AT Load List Exists

  End Sub; // End LoadTableNames Sub

// ======================================================//

// Subroutine to Load Summary by Periods into QVD        //

// ======================================================//

  Sub LoadTableData(vTabCount) // LoadTableData Sub

  For i = 0 To $(vTabCount)-1

  Let vMyTabName = Peek('TABLENAMES',$(i),'TableList');

  Let vPeriodName = Peek('RUN_PERIOD',$(i), 'TableList');

  $(vMyTabName):

  SQL SELECT *

        

  FROM "RPRO_RI_PS_RF_SOLNID_REP_V" where "PERIOD_NAME"='$(vPeriodName)';

  Store $(vMyTabName) into $(vDirectory)$(vMyTabName).qvd;

  Drop Table $(vMyTabName);

  Next i

  End Sub;  // End LoadTableData Sub

// ======================================================//

// ======================================================//

// *** Main ***

// ======================================================//

  Let vDirectory = 'AT_QVD\';

  Trace ' Get Table to Process';

  Call LoadTableNames;

  TableList:

  Load

  RUN_SUMM_TYPE,

  RUN_PERIOD,

  TABLENAMES,

  MXRUNTIME,

  RUN_FLAG

  from

  $(vDirectory)ATLoadList.csv (txt, utf8, embedded labels, delimiter is ',', msq)

  where RUN_FLAG='Y';

  Let vStoreCount = NoOfRows('TableList');

  Trace 'Store Rowcount: $(vStoreCount)';

  If Not isNull($(vStoreCount)) then

  Call LoadTableData($(vStoreCount));

  Else

  Trace ' No AT incremental changes';

  End If

  Drop Table TableList;

End If

3 Replies
swuehl
MVP
MVP

Maybe the very last line is the problem?

d_pranskus
Partner - Creator III
Partner - Creator III

Hi

The last End If looks unnecessary. My suggestion would be to properly format code with indents, it would be easier to see.

Cheers

Darius 

Not applicable
Author

Yes I got it

Thank You