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

RE: FTPAPI Code Page Question



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: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto: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 <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 <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:
> > 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:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------