Customer Portal

Reformat - replace on all the fields

Comments 2

  • Avatar
    Pedro Vazquez Rosario
    0
    Comment actions Permalink
    Hi,

    You can try the following code example, it will let you replace all fields in go:


    // Transforms input record into output record.
    function integer transform() {
    integer count = 0;

    while(count < length($in.0))
    {

    setStringValue($out.0.*,count,replace(getStringValue($in.0,count),"abcdefg","abc"));
    count++;
    }
    return ALL;
    }


    Cheers,
  • Avatar
    paulhbartosik
    0
    Comment actions Permalink
    As you see from the error message:

    Function replace(string,string,string) is not applicable for the arguments (record(TRN_045_ROL_TYPE),string,string)".

    You cannot change all of the fields in one single operation. You will have to step through the fields one by one.

    Try:
    //#CTL2
    // Transforms input record into output record.
    integer columncounter;

    function integer transform() {
    /* first copy all fields */
    copyByPosition($out.0,$in.0);
    /* Then step through the fields */
    for(columncounter = 0; columncounter < length($in.0); columncounter++)
    {
    if (getFieldType($in.0, columncounter) == "string")
    {
    setStringValue($out.0,columncounter, replace(getStringValue($in.0, columncounter),"abcdef","abc"));
    }
    } // end for next
    return ALL;
    }

Please sign in to leave a comment.