Visual Integrator

SUGGESTED

We have an export for item quantities. At the moment we're exporting 3 columns of data which include "Item Code", "Temp001" (which is a calculated field), and "Suggested Retail Price".

We're having negative numbers that are exporting in the "Temp001" field which is calculated by taking the "IM_ItemWarehouse01.QuantityOnHand" and subtracting "IM_ItemWarehouse01.QuantityOnPurchaseOrder" & "IM_ItemWarehouse01.QuantityOnSalesOrder". We don't want to update our site with negative numbers. This export is created and pushed over to an FTP server which pushes it out to the website.

Is the a way to say that if "Temp001" is less than "0" then export only "0" with visual integrator?

Would I use a conditional expression to do so?

If it's possible, how? I can't figure out the syntax of the conditional expression.

  • 0
    SUGGESTED

    You would use two Temp fields and on one if the calculation is less than "0" and one if it is greater.

  • 0
    SUGGESTED

    If you want to have the value exported to a single column, you can do it one of two ways, with a single temp field set up as a string or two temp fields, the first as a string and the second and a number.

    You can tweak the first part of the expression (seen in the below examples) within the STR() function but everything after the semi-colon needs to stay the same. In short, the expression is taking the results of the equation within the STR() function and using the STR() function, converts it to a string, this value is stored into a variable named VAR$ which is referenced in the latter portion of the expression to convert it back to a number using NUM() and check if it is less than zero, if it is, then set the VAR$ variable to "0".


    If using one temp field because you don't mind the output being treated like a string, the temp field should be set up like this.

    STR(IM_ItemWarehouse01.QuantityOnHand + IM_ItemWarehouse01.QuantityOnPurchaseOrder - IM_ItemWarehouse01.QuantityOnSalesOrder); IF NUM(VAR$) < 0 THEN VAR$ = "0" END_IF


    If using two temp fields so the output is treated like a number, the first should be set up like this.

    STR(IM_ItemWarehouse01.QuantityOnHand+IM_ItemWarehouse01.QuantityOnPurchaseOrder-IM_ItemWarehouse01.QuantityOnSalesOrder); IF NUM(VAR$) < 0 THEN VAR$ = "0" END_IF

    The second should be set up like this, where the Temp002$ equals the string temp field that has the above expression. This example had another temp field in as 001 so you'll need to adjust accordingly.


  • 0 in reply to David Speck

    These examples are fantastic. I will give this a try and see if I can make it work for a single column. We have a python script already built on the FTP server configured to give the 3 columns the needed headers.

    Thank you very much!

  • 0 in reply to dDub

    If you want column headers, you can click the "Options" button on the "Configuration" tab and check the option to export the column names as first record.

  • 0 in reply to David Speck

    We have two warehouses. Is there a way to modify this to use the warehouse with the highest amount available, but put a zero if both are in the negative?

    We want to be able to sale the product if we have some in either warehouse. Sometimes the big warehouse which has larger quantities runs out, but we'll have enough to complete a small order in the smaller warehouse.

  • 0 in reply to dDub

    Not with that code. Since the temp field, while being processed, will only see the warehouse values for the current warehouse being read. It is possible to use two other approaches to do what you want but both involve even more ProvideX code to make it happen. 

    Perhaps you should consider using VisulCut, you design a crystal report and then configure VisualCut to run and export it. It has options for emailing the exported file too.

    Another approach would be using any programming language capable of querying data via ODBC and query against the SOTAMAS90 DSN and execute a SQL statement that will return the recordset containing the data you want and then write the data to a flat file with your choice of a delimiter.

  • 0 in reply to dDub

    You may not be able to do it with VI, but you should be able to create a script on sales orders that performs this logic after it is imported.