sap-commerce-cloudimpex

How to export data with condition


I need to export some instances of a model but I don't want them all. I need only the one that have a specific attribute.

I can do that by code, I wonder how to do this with Impex?


Solution

  • I can generate the export model from the Backoffice -> Tools -> Script generated.

    Then I can add a flexible search query to filter exported results :

    # ---- Extension: core ---- Type: Customer ----
    "#% impex.setTargetFile( ""Customer.csv"" );"
    insert_update Customer;&Item;Europe1PriceFactory_UDG(code,itemtype(code));Europe1PriceFactory_UPG(code,itemtype(code));Europe1PriceFactory_UTG(code,itemtype(code));allowSubstitution[allownull=true];...
    "#% impex.exportItemsFlexibleSearch(""select {PK} from {Customer} where {uid}='anonymous'"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1  );"
    

    Cf : Impex API for the documentation about impex.exportItems[FlexibleSearch] and this page for more example