sqlsap-commerce-cloudimpexflexible-search

Specific type code is invalid and Method Invocation impex.exportItemsFlexibleSearch error


Asking for your help, I don't know why I'm still getting these errors :(

20.06.25 18:47:40:992   ERROR   line 3 at main script: Flexiblesearch error: type code 'StockLevel ' invalid
20.06.25 18:47:40:992   ERROR   line 3 at main script: query was 'SELECT DISTINCT {sl.pk} AS PK, {sl.productCode} AS SKU, {p.name} AS Brand_Name, {aas.code} AS Approval_Status, {p.onlineDate} AS Online_From_Date, {p.offlineDate} AS Online_To_Date, {cv.version} as Catalog_Version, {sl.available} AS Available_Stocks, {sl.reserved} AS Reserved_Stocks FROM {StockLevel AS sl}, {Product AS p}, {ArticleApprovalStatus AS aas}, {CatalogVersion AS cv} WHERE {p.code}={sl.productCode} AND {aas.pk}={p.approvalStatus} AND {cv.pk}={p.catalogVersion} AND {cv.version}='online' AND {aas.code}='approved' ORDER BY {sl.pk}'
20.06.25 18:47:41:173   ERROR   line 3 at main script: error executing code line at 3 : Sourced file: inline evaluation of: ``impex.exportItemsFlexibleSearch("SELECT DISTINCT {sl.pk} AS PK, {sl.productCode} . . . '' : Method Invocation impex.exportItemsFlexibleSearch

Here is my Impex for exporting data:

INSERT_UPDATE StockLevel;pk[unique=true];product(code);product(name[lang=en]);product(approvalStatus(code));product(onlineDate[dateformat=MM-dd-yyyy]);product(offlineDate[dateformat=MM-dd-yyyy]);product(catalogVersion(version));available[allownull=true];reserved[allownull=true]
"#% impex.exportItemsFlexibleSearch(""SELECT DISTINCT {sl.pk} AS PK, {sl.productCode} AS SKU, {p.name} AS Brand_Name, {aas.code} AS Approval_Status, {p.onlineDate} AS Online_From_Date, {p.offlineDate} AS Online_To_Date, {cv.version} as Catalog_Version, {sl.available} AS Available_Stocks, {sl.reserved} AS Reserved_Stocks FROM {StockLevel AS sl}, {Product AS p}, {ArticleApprovalStatus AS aas}, {CatalogVersion AS cv} WHERE {p.code}={sl.productCode} AND {aas.pk}={p.approvalStatus} AND {cv.pk}={p.catalogVersion} AND {cv.version}='online' AND {aas.code}='approved' ORDER BY {sl.pk}"");"

Thank you. :)


Solution

  • I tried to run your script in my local machine and it exported data. Did you check if the StockLevel type exists? It's part of the basecommerce extension.

    Also, try this refactored impex. It will work when there's no result:

    INSERT_UPDATE StockLevel;pk[unique=true];product(code);product(name[lang=en]);product(approvalStatus(code));product(onlineDate[dateformat=MM-dd-yyyy]);product(offlineDate[dateformat=MM-dd-yyyy]);product(catalogVersion(version));available[allownull=true];reserved[allownull=true]
    "#% impex.exportItemsFlexibleSearch(""SELECT DISTINCT {sl.pk} FROM {StockLevel AS sl JOIN Product AS p ON {p.code}={sl.productCode} JOIN ArticleApprovalStatus AS aas ON {aas.pk}={p.approvalStatus} JOIN CatalogVersion AS cv ON {cv.pk}={p.catalogVersion}} WHERE {cv.version}='online' AND {aas.code}='approved'"");"