Customer Portal

lpad not declared

Comments 6

  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hi yichuansancun,

    The third argument of lpad should be a string. If you want to use zero as the filler, use it this way: lpad($in.0.RptTo, 8, "0").

    Regards,
  • Avatar
    yichuansancun
    0
    Comment actions Permalink
    I changed the code to the following:

    $out.0._23_ID = "SO-" + lpad($in.0.RptTo, 8, "0");

    $out.0._26_ID = "P-" + lpad($in.0.PosNbr,8,"0") + "-" + $in.0.EmplID;


    I still get the error "Function 'lpad' is not declared" :(
  • Avatar
    imriskal
    0
    Comment actions Permalink
    What data type do you use in fields $in.0.RptTo, $in.0.PosNbr, $out.0._23_ID and $out.0._26_ID, please? For example "Nbr" in one of the names somehow suggests number while lpad function expects it to be a string. See the documentation page for lpad function.

    If nothing else helps, send me your whole graph, please.
  • Avatar
    julrych
    0
    Comment actions Permalink
    lpad function was introduced in CloverETL 4.0. Are you by any chance using version 3.5 or earlier?
  • Avatar
    yichuansancun
    0
    Comment actions Permalink
    yes, i am on 3.5.2 i believe
  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hi,

    Our online documentation always matches to the most recent version we have. If you want to use the documentation exactly for your version, you can see it when you press F1 button directly in Designer. As my colleague mentioned, lpad is not present in CloverETL 3.5. You can use workaround like this:
    //#CTL2

    // Transforms input record into output record.
    function integer transform() {
    string input = $in.0.field1;

    while (length(input) < 8) {
    input = concat("0", input);
    }

    $out.0.field1 = input;

    return ALL;
    }
    I hope this helps.

Please sign in to leave a comment.