× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: CPYF using Variables in CLP
  • From: Mel Rothman <melrothman@xxxxxxxx>
  • Date: Mon, 22 Jan 2001 16:12:11 -0600

An ugly, but effective, workaround is to build the entire CPYF command in
a character field and pass that field to QCMDEXC.

In the sample that follows, field LASTN is 16 bytes.  Six records in file
FUNCLAST
start with the character 'A' but only one of them is 'A' followed by 15 blanks.
When the sample code is called &FUNCLAST = 'A ', it copies only that one record.

PGM        PARM(&FUNCLAST)                                                      
DCL        VAR(&CMD) TYPE(*CHAR) LEN(200)                 
DCL        VAR(&FUNCLAST) TYPE(*CHAR) LEN(16)
CHGVAR     VAR(&CMD) VALUE('CPYF +                        
             FROMFILE(ROTHMAN/FUNCLAST) TOFILE(*PRINT) +  
             PRINT(*COPIED) INCREL((*IF LASTN *EQ +       
             ''' *CAT &FUNCLAST *CAT '''))')              
CALL       PGM(QCMDEXC) PARM(&CMD 200)                    
DSPSPLF    FILE(QSYSPRT) SPLNBR(*LAST)                    
DLTSPLF    FILE(QSYSPRT) SPLNBR(*LAST)                    
ENDPGM                                                    

Mel Rothman


Evan Harris wrote:
> 
> Darlene
> 
> I have encountered this annoying behaviour before (and just tested it again
> this morning). If you specify a variable as the value to test, the CPYF
> seems to strip off the blanks from the variable before performing the test
> (as you observed). Specifying a string in the CPYF with a blank between the
> quotes seems to work. I can kind of see why this might be the case although
> it can be annoying.
> 
> There may be some history as to why the behaviour is so (or I could be
> wrong :) )
> 
> Perhaps you would be better placed using OPNQRYF and CPYFRMQRYF which seems
> to behave more as one would expect.
> 
> Hope this helps
> Evan Harris
> 
> >If I define the variable (&FPRDN) as *CHAR 15, the CPYF command truncates the
> >ending blanks, and the result I get are any product numbers at start with
> >'E-1182PF', so I get all the E-1182PF records and all the E-1182PFS
> >records  and
> >so on....
> >
> >CLP CPYF CODE <snip>
> >DCL        VAR(&FPRDN) TYPE(*CHAR) LEN(15)
> >  CPYF       FROMFILE(&LIBRARY/&FILE) +
> >               TOFILE(QTEMP/BMHSP100X) FROMMBR(&FMEMBER) +
> >               TOMBR(&TMEMBER) MBROPT(*ADD) +
> >               CRTFILE(*YES) INCREL((*IF PRDNO *EQ +
> >               &FPRDN)) FMTOPT(*MAP *DROP)
> ></snip>
> >
> >Joblog...
> >  4500 - CPYF FROMFILE(*LIBL/BMHSP100) TOFILE(QTEMP/BMHSP100X)
> >  FROMMBR(M202) TOMBR(M102) MBROPT(*ADD) CRTFILE(*YES) INCREL((*IF PRDNO
> >  *EQ 'E-1182PF'))
> >
> >I also just received a message about the archives having some information on
> >this subject, I looked at the archive links, but they do not help me any
> >on this
> >problem..
> >
> >Thanks again for all your responses,
> >Darlene
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.