On Thu 05-May-2011 11:48 , James Lampert wrote:
We have a situation in which a CPYF, to load data from an older
version of a file into a newer version, is failing because a field is
being changed from zoned decimal in the old version to character in
the new:
> CPYF FROMFILE(&LIB/&RNMPHYS) TOFILE(&LIB/&CURRPHYS) +
>      MBROPT(*ADD) FMTOPT(*MAP *DROP)
Any ideas on how to handle this situation?
  CPYF does not know how to "edit" the numeric data to satisfy that 
mapping, so the utility simply denies the request rather than making 
some intelligent guess [or having to add great complexity to deal with 
various field-level preferences].
  Consider the following, after review of results, then describe what 
the result should for various decimal definitions and data, so more 
about the requirements are known:
<code>
    set current schema qtemp ;
    create table old (s72 numeric(7,2), s40 numeric(4)) ;
    insert into qtemp/old values(12345.67, 1234),(0, 0)
     ,(-12345.67, -1234),(-0.12, -1), (1, 1) ;
    create table new1(s72 char(7) ,     s40 char   (4)) ;
    create table new2(s72 char(9) ,     s40 char   (6)) ;
    insert into qtemp/new1 (s72, s40)
     select  digits(s72), digits(s40) from qtemp/old ;
    insert into qtemp/new2 (s72, s40)
     select s72, s40 from qtemp/old ;
    runqry *n qtemp/new1
              S72      S40
       000001 1234567  1234
       000002 0000000  0000
       000003 1234567  1234
       000004 0000012  0001
       000005 0000100  0001
       ****** ********  End of report  *
    runqry *n qtemp/new2
              S72        S40
       000001 12345.67   1234
       000002 .00        0
       000003 -12345.67  -1234
       000004 -.12       -1
       000005 1.00       1
       ****** ********  End of report  *
    clrpfm qtemp/new1
    clrpfm qtemp/new2
    opnqryf qtemp/old format(qtemp/new1) opnid(old1)
    cpyfrmqryf old1 qtemp/new1 mbropt(*add)
    clof old1
    runqry *n qtemp/new1
    /* Note: internal BCD data direct maps like FMTOPT(*CVTSRC) */
    /* and like LF remap to Alpha of [only allowed] same length */
              S72      S40
       000001 1234567  1234
       000002 0000000  0000
       000003 123456P  123M
       000004 000001K  000J
       000005 0000100  0001
       ****** ********  End of report  *
    opnqryf qtemp/old format(qtemp/new2) opnid(old2)
    cpyfrmqryf old2 qtemp/new2 mbropt(*add)
    clof old2
    runqry *n qtemp/new2 /* same as recorded earlier */
</code>
Regards, Chuck
As an Amazon Associate we earn from qualifying purchases.