[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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
<[1]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
<[2]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:
[3]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:sk@xxxxxxxxxxxxxxxx
3. 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
-----------------------------------------------------------------------