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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
priyarane
Specialist
Specialist

Loop error with Mapping load

Hi Community,

Hi I have a code like this.

IF not  IsNull(TableNumber('SBLC_TYPE_MAP')) THEN
Trace SBLC_TYPE_MAP table found;
Concatenate (SBLC_TYPE_MAP)
Mapping LOAD
IF(ACCOUNT_DEAL_ID_001='','NOACCTID',ACCOUNT_DEAL_ID_001)&'_'&IF(FTP_ARRANGEMENT_LOC_NUM_241='','NOALN',FTP_ARRANGEMENT_LOC_NUM_241) AS CONTRACT_REFERENCE,
SBLC_TYPE_057
FROM [$(vCDMPathEXTQVD)EXT_HNAH_STG_WHO_PRODUCT_$(vRptDate).qvd] (qvd);


ELSE
Trace SBLC_TYPE_MAP table not found;
SBLC_TYPE_MAP:
Mapping LOAD
IF(ACCOUNT_DEAL_ID_001='','NOACCTID',ACCOUNT_DEAL_ID_001)&'_'&IF(FTP_ARRANGEMENT_LOC_NUM_241='','NOALN',FTP_ARRANGEMENT_LOC_NUM_241) AS CONTRACT_REFERENCE,
SBLC_TYPE_057
FROM [$(vCDMPathEXTQVD)EXT_HNAH_STG_WHO_PRODUCT_$(vRptDate).qvd] (qvd); 


next a

and getting error like below:

$(vRptDate) = Date

If I change my code like below and every thing is fine

SBLC_TYPE_MAP:

Mapping LOAD

IF(ACCOUNT_DEAL_ID_001='','NOACCTID',ACCOUNT_DEAL_ID_001)&'_'&IF(FTP_ARRANGEMENT_LOC_NUM_241='','NOALN',FTP_ARRANGEMENT_LOC_NUM_241) AS CONTRACT_REFERENCE,

SBLC_TYPE_057

FROM [$(vCDMPathEXTQVD)EXT_HNAH_STG_WHO_PRODUCT_$(vRptDate).qvd] (qvd);

next a

*******************

I am using the same code for other tables and no issue found

for ex:

IF NOT IsNull(TableNumber('CRC_RANK_MAP')) THEN
Trace CRC_RANK_MAP table found;
Concatenate (CRC_RANK_MAP)
Mapping LOAD
COUNTRY_CODE as INCORPORATION_COUNTRY,
ATTRIBUTE_1
FROM [$(vCDMPathEXTQVD)EXT_COUNTRY_$(vRptDate).qvd] (qvd);

ELSE
Trace CRC_RANK_MAP table not found;
CRC_RANK_MAP:
Mapping LOAD
COUNTRY_CODE as INCORPORATION_COUNTRY,
ATTRIBUTE_1
FROM [$(vCDMPathEXTQVD)EXT_COUNTRY_$(vRptDate).qvd] (qvd);
ENDIF


next a

Can some pls help me in this error.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I am a little confused by your post, but the statement "next a" needs a "for a = ...." somewhere and I don't see that. I don't see an END IF for the last IF, so even if there is a "for", it will fail because the "next" is inside an IF statement, which is not allowed. Therefore it looks like you are missing an END IF or ENDIF.

In your working example, the second IF is closed before the next. If this is working there is a for somewhere not included in your post.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

7 Replies
Anonymous
Not applicable

Remove the Next a remove try it

priyarane
Specialist
Specialist
Author

That is loop to get updte the dates in $(vRptDate).

Chanty4u
MVP
MVP

comment //next a

tamilarasu
Champion
Champion

There is no for statement in your script. Obviously, you will get this error. Is this your full code.?

priyarane
Specialist
Specialist
Author

This is the loop

All_MI_Context:
LOAD Serial,
REPORT_DATE
FROM
'$(vCDMPathEXTQVD)EXT_ALL_MI_CONTEXTS.qvd'(
qvd)
;
NoConcatenate
All_RptDates:
Load * Resident All_MI_Context
Order By Serial;

Drop Table All_MI_Context;

IF NoOfRows('All_RptDates') > 0 THEN
If $(vHistoric)=1 THEN
Let vCount = NoOfRows('All_RptDates');
Trace $(vCount);
ELSE
Let vCount = 3;
ENDIF
ELSE
Trace 'No Date Found.';
EXIT SCRIPT;
ENDIF

//Let vCount = 4;

for a = $(vFromMonth)  to $(vCount)-1

Let vRptDate = peek('REPORT_DATE',a,'All_RptDates');
//Let vRpt_Date = Replace(peek('REPORT_DATE',a,'All_RptDates'),'-','_');

Trace 'All_RptDates: $(vRptDate)';
Trace 'A= $(a)';

jonathandienst
Partner - Champion III
Partner - Champion III

I am a little confused by your post, but the statement "next a" needs a "for a = ...." somewhere and I don't see that. I don't see an END IF for the last IF, so even if there is a "for", it will fail because the "next" is inside an IF statement, which is not allowed. Therefore it looks like you are missing an END IF or ENDIF.

In your working example, the second IF is closed before the next. If this is working there is a for somewhere not included in your post.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
priyarane
Specialist
Specialist
Author

Thanks Jonathan... Missed - END IF