[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FTPAPI Code Page Question



   Scott,



   I'm having a devil of a time here. Here is what I tried (as a test):



   CPYF FROMFILE(ARQCCOM/AROCH) TOFILE(FMLLIB/AROCH) TOMBR(AROCH)
   MBROPT(*REPLACE) FMTOPT(*CVTSRC) SRCOPT(*SEQNBR) SRCSEQ(.01 .01)

   CPYTOSTMF FROMMBR('/qsys.lib/fmllib.lib/aroch.file/aroch.mbr')
   TOSTMF('/flapeyre1/testoch.txt') STMFOPT(*REPLACE)
   STMFCODPAG(1252)



   Then, I tried to manually transfer the file over to Windows, using the
   AS/400 FTP client. I transferred it as Binary. I opened it up
   in Notepad, did a File, Save as, and the Encoding is ANSI (where I
   expected it to be Unicode).



   Any other suggestions? I would rather not do any post-processing on
   the files under Windows, if
   possible.                                         , but that's my last
   resort.

   On Fri, Apr 18, 2008 at 7:05 PM, Francis Lapeyre
   <[1]flapeyre@xxxxxxxxx> wrote:

   Hi, Mike,

   I tried binary, and that resulted in garbage data (and the created
   file was still ANSI). In MS Notepad, you can do File, Save as, and
   change it to Unicode.



   I might try a different tack - I bookmarked a utility that supposedly
   can change ANSI to Unicode (under Windows), so I'll revert my program
   and try to get the server-side program to run that in the file before
   it imports it.



   Thanks for your suggestions.

   On Fri, Apr 18, 2008 at 4:42 PM, Mike Krebs
   <[2]mkrebs@xxxxxxxxxxxxxxxxxx> wrote:

     Francis,
     If I understood Scott's reply, if you translate to 1208 on the i
     Side, then
     you need to use binary transfer in FTP. I don't see that you are
     using
     binary. Did you try that?
     Also, if the file doesn't exist on the server side, don't you have
     to create
     it somehow with the 1208 CCSID or change it once it is created?
     FWIW, in my tests, opening any file in my version of notepad (a
     vendor
     product-not standard MS) seemed to always indicate that it was
     ANSI. I
     couldn't really tell that it was in some other CCSID as if some
     magic
     translation was taking place. Could that be happening to you as
     well?
     Mike Krebs

   -----Original Message-----
   From: [3]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [mailto:[4]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Francis
   Lapeyre
   Sent: Friday, April 18, 2008 3:35 PM
   To: HTTPAPI and FTPAPI Projects
   Subject: Re: FTPAPI Code Page Question
   Scott,
   I'm still beating my head against the wall on this one.
   This is what I'm doing (Quote is a named constant ''''):
                // Copy the records for this date to a temporary file so
   that
                // one file per deposit date is produced.
                // Copy from position
   74.
                Command = 'DLTF
   FILE(QTEMP/ARLBFX)';
                Callp(E) Qcmdexc(Command :
   %LEN(%TRIMR(Command)));
                Command = 'CRTSRCPF FILE(QTEMP/ARLBFX) RCDLEN(92)
   MBR(ARLBFX)
   S+
                IZE(*NOMAX)
   CCSID(1208)';
                Callp(E) Qcmdexc(Command :
   %LEN(%TRIMR(Command)));
                Command = 'CPYF FROMFILE(QTEMP/ARLBF)
   TOFILE(QTEMP/ARLBFX)
   TOMBR+
                (ARLBFX) MBROPT(*REPLACE) INCCHAR(*RCD 74 *EQ ' + Ocdddt
   +
                ')
   FMTOPT(*CVTSRC)';
                Callp(E) Qcmdexc(Command : %LEN(%TRIMR(Command)));
                Command = 'DEL OBJLNK(' + Quote + '/tmp/aru1105.txt' +
   Quote
   +
   ')';
                Callp(E) Qcmdexc(Command :
   %LEN(%TRIMR(Command)));
                Command = 'CPYTOSTMF FROMMBR(' + Quote
   +
                '/QSYS.LIB/QTEMP.LIB/ARLBFX.FILE/ARLBFX.MBR' + Quote
   +
                ') TOSTMF(' + Quote + '/tmp/aru1105.txt' + Quote
   +
                ') STMFOPT(*REPLACE) CVTDTA(*AUTO)
   STMFCODPAG(*STMF)';
                Callp(E) Qcmdexc(Command :
   %LEN(%TRIMR(Command)));
                // Append file to FTP server (create if not found).
                If Ftp_Append(File_Id : Ftp_Filename :
   '/tmp/aru1105.txt') >=
   0;
             Else;
                P_Error = 'Unable to append to or write ' +
   %TRIM(Ftp_Filename)
                + '. Check FTP Server.';
               Exsr End_Program;
              Endif;
   I specified CCSID 1208 at record-level on the DDS for ARLBF:
        A
   UNIQUE
        A
   CCSID(1208)
        A          R LBF
        A                                      TEXT('HMIS Lockbox Flat
   File')
        A            LBFTYP         1A         COLHDG('Record' 'Type')
        A            LBFBCH         3A         COLHDG('Batch')
        A            LBFITM         7A         COLHDG('Item')
        A            LBFHXF        10A         COLHDG('Hexadecimal'
   'Facility')
        A            LBFHBC        30A         COLHDG('Hexadecimal' 'Brn'
   'Cont')
        A            LBFCDG         1A         COLHDG('Check' 'Digit')
        A            LBFAMT         9A         COLHDG('Statement'
   'Amount')
        A            LBFCD2         1A         COLHDG('Amt.' 'Check'
   'Digit')
        A            LBFAM2        11A         COLHDG('Payment' 'Amount')
        A            LBFDDT         6A         COLHDG('Deposit' 'Date'
   'YYMMDD')
        A            LBFFIL         1A         COLHDG('Filler')
        A          K LBFDDT
        A          K LBFBCH
        A          K LBFITM
   What this snippet is trying to do is copy a certain deposit date over
   to a
   file on the server (Ftp_Filename), which I'be named to include the
   date.
   The test files get to the server all right, but they are still in
   ANSI, not
   Unicode.
   I must be missing something obvious here. Thanks in advance.
   FTPAPI is a great gift to the community. Thanks so much for making it
   available.
   On Thu, Apr 17, 2008 at 1:11 PM, Francis Lapeyre
   <[5]flapeyre@xxxxxxxxx> wrote:
   > Thanks, Scott. I'll probably have to go the CPYTOSTMF route for now;
   this
   > is a very hot project that can't wait.
   >
   >
   > On Thu, Apr 17, 2008 at 12:54 PM, Scott Klement
   <[6]sk@xxxxxxxxxxxxxxxx>
   > wrote:
   >
   > > Hi Francis,
   > >
   > > In it's current state, FTPAPI only supports single-byte character
   sets.
   > >  So you can't use it to translate to UTF-8 (CCSID 1208) since
   that's a
   > > mixed-byte CCSID.
   > >
   > > To achieve the results you're looking for, you'll need to modify
   > > FTPAPI's method of translating data...  if you do so, please
   contribute
   > > your changes back to the project.
   > >
   > > Another approach might be to work around the problem.  If you want
   to do
   > > that, my suggestion is to use CPYTOSTMF to convert it to a
   (temporary)
   > > IFS stream field that's in UTF-8, then send that stream file with
   FTPAPI
   > > in binary mode.
   > >
   > >
   > > Francis Lapeyre wrote:
   > > >    I'm tranferring a physical file (a flat one) to a MS SQL
   Server
   > > 2005
   > > >    application. It expects the file to be in Unicode, but it's
   > > appearing
   > > >    over there as ASCII, and that doesn't work.
   > > >
   > > >
   > > >
   > > >    What do I need to do? A quick Google seems to indicate that
   CCSID
   > > 1208
   > > >    is Unicode; I tried this in my program:
   > > >
   > > >
   > > >
   > > >    // Switch to ASCII mode.
   > > >
   > > >    If Ftp_Binarymode(File_Id : *OFF) < 0;
   > > >      P_Error = 'Cannot switch to ASCII mode. Check FTP Server.';
   > > >      Exsr End_Program;
   > > >
   > > >    Endif;
   > > >
   > > >
   > > >
   > > >    // Files must be in Unicode CCSID (1208).
   > > >
   > > >    If Ftp_Codepage(File_Id : 1208 : 37) < 0;
   > > >      P_Error = 'Cannot translate files to Unicode. Check FTP
   Server.';
   > > >      Exsr End_Program;
   > > >
   > > >    Endif;
   > > >
   > > >
   > > >
   > > >    That did not work. On the desination server, if you open the
   file
   > > in
   > > >    Notepad, File, Save as, the type is showing up as ANSI.
   > > >
   > > >
   > >
   ----------------------------------------------------------------------
   -
   > > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > > [7]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >
   ----------------------------------------------------------------------
   -
   > >
   >
   >
   >
   > --
   >  Francis Lapeyre
   >
   > Da mihi sis crustum Etruscum cum omnibus in eo.
   >
   --
   Francis Lapeyre
   Da mihi sis crustum Etruscum cum omnibus in eo.
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [8]http://www.scottklement.com/mailman/listinfo/ftpapi
   ----------------------------------------------------------------------
   -

     --

   Francis Lapeyre
   Da mihi sis crustum Etruscum cum omnibus in eo.

   --
   Francis Lapeyre
   Da mihi sis crustum Etruscum cum omnibus in eo.

References

   1. mailto:flapeyre@xxxxxxxxx
   2. mailto:mkrebs@xxxxxxxxxxxxxxxxxx
   3. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   4. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   5. mailto:flapeyre@xxxxxxxxx
   6. mailto:sk@xxxxxxxxxxxxxxxx
   7. http://www.scottklement.com/mailman/listinfo/ftpapi
   8. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------