VI job addDays to add business days

SUGGESTED

Hello,

I've used VI jobs for various import and export jobs to import things from sales order info to bill structure. I dont use a lot of conditional based columns.

What im trying to do is have the ShipExpireDate be 5 business days added to the order date. The calculated column below gets me the adding 5 days to the order date going to the ShipExpireDate column

_OBJ'addDays$({SO_SalesOrderHeader.OrderDate$},5)

Looking around online I dont see the option to do a IF statement in the calculation. My next through would be using the conditional section to have multiple calculated fields for each of the days of the week where the days would need to be off set for the weekend.

Thanks,

Tim

  • 0
    SUGGESTED

    There is no IF statement in VI. You have to have a line for each day of the week with your condition statement for that day of the week.

  • 0
    SUGGESTED

    A BOI script could do the same thing, and it would apply the same logic for manually entered SO too.

  • 0 in reply to BigLouie

    Whats the syntax that checks what day a date is?

  • 0 in reply to BigLouie
    SUGGESTED

    For sake of completeness, you can achieve this within VI or you could do this in a BOI script as Kevin said, which has the benefit of affecting all sales orders if that is the desired result. If you only want to affect orders processed through VI or you are curious, continue reading.

    You can use an IF statement if you use ProvideX syntax AFTER a semi-colon which follows a proper value with the correct type for the field so it is seen as a compound statement.

    Also, for a numeric field, normally, whatever you enter in the calculation field prior to the semi-colon is stored in a variable name VAR, for a string field, whatever you enter in the calculation field prior to the semi-colon is stored in a variable name VAR$. See the following examples.

    For a numeric field.

    0; IF 0=1 THEN VAR=1 ELSE VAR=0 END_IF

    For a string field.

    ""; IF "abc"="ABC" THEN VAR$="True" ELSE VAR$="False" END_IF

    Both variables can be referenced and set in the subsequent statements that make up the full compound statement.

    One way to use ProvideX to add 5 business days is by using the following.

    ""; DaysToAdd=5; DateToUse$={SO_SalesOrderHeader.OrderDate$}; IF DateToUse$<>"" THEN VAR$=%SYS_SS'GetFormattedDate$(DTE(JUL(%SYS_SS'FormatDate$(DateToUse$, isTrue))+DaysToAdd+TBL(NUM(DTE(JUL(%SYS_SS'FormatDate$(DateToUse$, isTrue))+DaysToAdd:"%W")),0,0,0,0,0,0,2,1))) ELSE VAR$=DateToFallBackTo$ END_IF

    Now you could use a numeric temp field to hold the number of days to add and a string temp field to hold the date field to use so you don't have to change either through the calculation like you would have to if you hardcoded them into the calculation at every point they are referenced. To keep it simple, i just placed the values into my the variables DaysToAdd and DateToUse$. 

    Take note that string fields and variables have the trailing dollar sign ("$") unlike the numeric fields and variables. This is important when setting or referencing them.

  • 0 in reply to Kevin M
    SUGGESTED

    Thanks, using DTE in the condition did the trick with multiple calculated fields