ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

From a parm 10 char len field to a usable 5 6 or 7 length field value for a copy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • From a parm 10 char len field to a usable 5 6 or 7 length field value for a copy

    I have a .net application calling a cl program on my as400. I am passing in a variable length field (example M1900-01 or just M1900 ) into a fixed length 10 char dcl in my cl program. The data is indeed trimmed as it leaves the .net application When I do a cpyf
    Code:
     
    DCL VAR(&SUPPLYCDE) TYPE(*CHAR) LEN(10)
     
    CPYF FROMFILE(DOBSOJM1/BACKO00001) + 
    TOFILE(BGLIB/BACKO0001A) CRTFILE(*YES) + 
    INCREL((*IF SUPPL00001 *EQ &SUPPLYCDE))
    the value in &SUPPLYCDE can not contain any blanks or I get no data returned with the copy. How can I code this to functionally trim the blanks (so I use "M1900-01" instead of the value "M1900-01 " ) ??????


    Thanks

    gollnick

  • #2
    Re: From a parm 10 char len field to a usable 5 6 or 7 length field value for a c

    The best way is to use an SQL statement like CREATE TABLE.....WITH DATA instead of a CPYF
    Patrick

    Comment


    • #3
      Re: From a parm 10 char len field to a usable 5 6 or 7 length field value for a c

      There's no possibility to define a variable field in CL so pass in also the parm length and enclose the parm with quotes using the length.
      Philippe

      Comment


      • #4
        Re: From a parm 10 char len field to a usable 5 6 or 7 length field value for a c

        the only thing i can think of (and i haven't tried this) other than the SQL option (or using an HLL like RPG,etc.) is to find the last character and use %SST(&supplycode) on the INCREL() keyword. i think the %SST will work but as i said i haven't tested it.
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: From a parm 10 char len field to a usable 5 6 or 7 length field value for a c

          @Tom,
          I don't believe the %SST() or any other substring functions exist for the CPYF INCREL() kwd.
          Additionally to my latter suggestion above, if the OP doesn't want or can't use a supplemental parameter he/she could also add a quote in a work field, scan and fill this work field with every char of the &supplycode parm up to the last non blank character and append another quote to the end. Then he/she should use the work field instead of &supplycode in the CPYF. It's plain vanilla but that'd work.
          Philippe

          Comment

          Working...
          X