VI IMPORT strip or sub?

SUGGESTED

Hi,

I am trying to load some sales orders using VI, the file that the customer is sending has some unwanted charecters in the ship to name field.

I am wanting to remove them during the import.

i noticed in the field properties of the ship to name that their allows for a Conditional Expression, in the list it has two that i think may help me but i am not sure how to use.

say we are trying to get rid of commas,

which and how would i use either of these  STP()  or SUB() 

or is there a better expression to use??

using MAS100 4.5

Thanks,

  • 0

    I think you want STP.

    STP( ) Function STP( ) Strip Leading/Trailing Characters Strip Leading/Trailing Characters

    Formats

    1. Strip Character from a String: STP(string$,[stp_code[$]][,Starstp_char$][,ERR=stmtref])

    2. Remove Mnemonic from a String: STP(MNEMONIC string$[,ERR=stmtref])

    Where:

    Returns Stripped character string.

    Description The STP( ) function returns a character string generated by stripping specified

    instances of a character, or a mnemonic, from a string expression.

    Format 1: Strip Character from a String

    STP(string$,stp_code[$][,Starstp_char$][,ERR=stmtref])

    This format strips the character stp_char$ (spaces if omitted) from a string expression.

    Depending on the stp_code value, the data can be stripped from the beginning of the

    string$, the end of the string$, or from both the beginning and end. STP( ) can also be

    used to strip all occurrences of stp_char$ within the string.

    Format 2: Remove Mnemonic from a String

    STP(MNEMONIC string$[,ERR=stmtref])

    This format removes all mnemonics contained within the string$.

  • 0 in reply to TomTarget

    Tom,

    Thanks for reply, i am trying to remove a , and it can be anywhere from beginning or end or in the middle of ship to name field.

    i have this, i get an error message so i know its not right.

    STP({SO_SalesOrderHeader.ShipToName$},[,])

  • 0 in reply to stircrazy08

    Oops.   Sorry,  my cut and paste didn't transfer the parameter options (and a few other things) for some reason?

    Where:

    * Asterisk indicates a list of characters to strip. For example,

    STP(X$,1,*" ,:") strips any trailing spaces, commas, or colons from

    X$. A null string results in an Error #46: Length of string

    invalid.

    stp_char$ Characters to be stripped from string. If omitted, blanks are stripped; e.g.,

    STP(PTR$,3,$1B$) ! strips out all escape characters

    STP("Hello there",3,"e") ! strips out every lower-case "e"

    stp_code[$] Strip code, either numeric or string:

    0 or L Strip Left (leading characters)

    1 or R Strip Right (trailing characters) - default.

    2 or B Strip Both Left and Right, and leave center (C)

    3 or A Strip All occurrences.

    stmtref Program line number or label to transfer control to.

    string$ String expression to be processed.

    Try:

    STP({SO_SalesOrderHeader.ShipToName$},3, ",")

    The brackets in the documentation mean an optional parameter.  If the double quote doesn't work, try a single quote.

  • 0 in reply to TomTarget

    BTW,  here is a good source for providex function information.   This is where I got the info above.

    docs.pvxplus.com/PVXV7.pdf

  • 0 in reply to TomTarget

    does 3 represent the column from the source?

    i am trying

    STP({SO_SalesOrderHeader.ShipToName$},3, ',')

    and

    STP({SO_SalesOrderHeader.ShipToName$},3, ",")

    and get the same error message

    #Error # 26  Variable type invalid

    IF STP(SO_SalesOrderHeader.ShipToName$,3, ",") { ASSIGN = isTRUE }

  • 0 in reply to stircrazy08

    3 means to strip all occurrences of the comma.   Apparently "A" means the same thing.

    Try:

    STP({SO_SalesOrderHeader.ShipToName$},"A", ",")

    If that doesn't work try this to narrow down which parameter it is choking on.

    STP("PLEASE REMOVE ALL ,,,,  from this STRING"},"A", ",")

  • 0 in reply to stircrazy08

    ok, from your previous post i see what the 3 means.

    STP({SO_SalesOrderHeader.ShipToName$},3, ',')

    i did change it to single quotes but get the following error msg.

    Error #29: Invalid Mnemonic or position specification

    IF STP(SO_SalesOrderHeader.ShipToName$,3, ',') { ASSIGN = isTRUE }

  • 0 in reply to stircrazy08

    What happened to your brackets around the field name?

    I would leave the IF THEN stuff out until you get the formula to cooperate first.  I've never seen the ASSIGN stuff before so the problem might be coming from that and throwing us a red herring.

  • 0 in reply to TomTarget

    i am using

    STP("PLEASE REMOVE ALL ,,,,  from this STRING"},"A", ',')

    and get the same error #29

    i even tried

    STP("Hello there",3,"e")

    and get error #26

    the IF statment is what is showing up in the Expression Syntax Check error box not what i am putting in the Expression text box.

    been trying different variations of what you gave me above from the A to 3 to the single to dbl quotes and keep getting error.

  • 0 in reply to stircrazy08

    put it in as calculation not as conditional.