[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: FTP-Transfer - CCSID-Problem
Hello
I forget to attach the program. Here ist comes.
Rgds
Jan
-------- Original-Nachricht --------
Betreff: FTP-Transfer - CCSID-Problem
Datum: Mon, 24 Sep 2012 17:27:13 +0200
Von: Jan Grove Vejlstrup [1]<jgv@xxxxxxxx>
An: HTTPAPI and FTPAPI Projects [2]<ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Hello
I use attached program bsr020 to transfer files from one IBM i to
another. I have two file, both with CCSID 1208 (UTF-8). The files are
transferred to the target system and place in the receiving directory.
But here they are tagged with CCSID 437.
The program bsr100 just makes a dsply of the received parameter.
If I use to commend dspf to look at the contents of the files, it looks
allright. But the three first bytes seems to be the UTF-8
ByteOrderMark, x'EFBBBF'.
I cannot find the reason for that. Can you help me?
Here comes the joblog:
call bsr020
1-: FTPAPI version 3.0beta1 released on 2010-02-21
99-: Connecting to host chwemag2 at address 192.168.80.11 using port
21.
0: 220-QTCP at CHWEMAG2.WEMAG.CH.
0: 220 Connection will close if idle more than 5 minutes.
0: > USER jgv
0: 331 Enter password.
0: > PASS **********
0: 230 JGV logged on.
0: > CWD /edi/export/orders
0: 250-NAMEFMT set to 1.
0: 250 "/edi/export/orders" is current directory.
0: > TYPE A
0: 200 Representation type is ASCII nonprint.
0: > PORT 192,168,80,10,101,215
0: 200 PORT subcommand request successful.
0: > NLST
0: 125 List started.
0: 250 List completed.
0: > TYPE I
0: 200 Representation type is binary IMAGE.
0: > PORT 192,168,80,10,63,255
0: 200 PORT subcommand request successful.
0: > RETR 120918 order_3247_3247_3
0: 150 Retrieving file /edi/export/orders/120918 order_3247_3247_3
0: 226 File transfer completed successfully.
DSPLY bsr100*/jgvtmp/BShop/import/120918 order_3247_3*
0: > TYPE I
0: 200 Representation type is binary IMAGE.
0: > PORT 192,168,80,10,89,247
0: 200 PORT subcommand request successful.
0: > RETR 120917 oder_3247_3247_2
0: 150 Retrieving file /edi/export/orders/120917 oder_3247_3247_2
0: 226 File transfer completed successfully.
DSPLY bsr100*/jgvtmp/BShop/import/120917 oder_3247_32*
0: > QUIT
0: 221 QUIT subcommand received.
Thank you very much in advance.
Best regards
Jan
References
1. mailto:jgv@xxxxxxxx
2. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
H BNDDIR('FTPAPI') DFTACTGRP(*NO) ACTGRP(*new)
W*E CRTBNDRPG bsr020 srcfile(*libl/qrpglesrc)
W*E+ DBGVIEW(*SOURCE)
W*E+ REPLACE(*YES)
E*W
* +
* Copyright (c) 2001-2005 Scott C. Klement +
* All rights reserved. +
* +
* Redistribution and use in source and binary forms, with or without +
* modification, are permitted provided that the following conditions +
* are met: +
* 1. Redistributions of source code must retain the above copyright +
* notice, this list of conditions and the following disclaimer. +
* 2. Redistributions in binary form must reproduce the above copyright +
* notice, this list of conditions and the following disclaimer in the +
* documentation and/or other materials provided with the distribution. +
* +
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ''AS IS'' AND +
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +
* SUCH DAMAGE. +
* +
*/ +
* This code contains contributions from Thomas Raddatz:
* -- Added STRPRPRC statements to allow easier object creation.
CPY /copy ftpsrc,FTPAPI_H
/copy bshop_p
D CompMsg PR
D peMsgTxt 256A Const
d FTPADR C 'chwemag2'
d FTPUSER C 'jgv'
d FTPPWD C 'XXXXXXX'
d RMTDIR C '/edi/export/orders'
d LCLDIR C '/jgvtmp/BShop/import'
D Incoming S 256A DIM(300)
D num_files S 10I 0
D fileno S 10I 0
D rc S 10I 0
D fd S 10I 0
D ErrNum S 10I 0
D gotfiles S 10I 0
d ifspath s 500a varying
d newpath s 100a
/free
// *************************************************************
// This tells FTPAPIR4 to log the FTP session to the joblog
// so we can debug any problems that occur:
// *************************************************************
ftp_logging(0: *on);
// *************************************************************
// connect to FTP server. Log in with user name & password:
//
// Here we also specify that we want to use the default
// port for FTP, as well as a time-out value of 120 seconds.
//
// If we don't receive data for 120 seconds, the connection
// will "time-out"
//**************************************************************
fd = ftp_conn(FTPADR
: FTPUSER
: FTPPWD
: FTP_PORT
: 120);
B01 if fd < 0;
CompMsg(FTP_errorMsg(0));
*inlr = *on;
return;
E01 endif;
// *************************************************************
// get a list of up to 300 files in the rmtdir dir
// (we intend to download all the of these files)
// *************************************************************
B01 if ftp_chdir(fd: RMTDIR) < 0;
CompMsg(ftp_errorMsg(fd));
ftp_quit(fd);
*inlr = *on;
return;
E01 endif;
rc = ftp_list(fd: ' ': 300
: %addr(incoming): num_files);
B01 if rc < 0;
ftp_errorMsg(fd: ErrNum);
B02 if ErrNum = FTP_NOFILE;
num_files = 0;
X02 else;
CompMsg(FTP_errorMsg(fd));
ftp_quit(fd);
*inlr = *on;
return;
E02 endif;
E01 endif;
// *************************************************************
// download everything in tools dir into our incoming dir.
// *************************************************************
gotfiles = 0;
B01 for fileno = 1 to num_files;
// download the rest of the files
B02 if ftp_get(fd: incoming(fileno)
: LCLDIR + '/' +incoming(fileno))>=0;
gotfiles += 1;
ifspath = LCLDIR + '/' + incoming(fileno);
bsr100(ifspath);
endif;
E01 endfor;
// *************************************************************
// Close FTP session, and end program:
// *************************************************************
ftp_quit(fd);
B01 if gotfiles > 0;
CompMsg('Success!');
X01 else;
CompMsg('No files received!');
E01 endif;
*inlr = *on;
/end-free
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// This sends a completion message to the calling program
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P CompMsg B
D PI
D peMsgTxt 256A Const
D dsEC DS
* Bytes Provided (size of struct)
D dsECBytesP 1 4B 0 INZ(256)
* Bytes Available (returned by API)
D dsECBytesA 5 8B 0 INZ(0)
* Msg ID of Error Msg Returned
D dsECMsgID 9 15
* Reserved
D dsECReserv 16 16
* Msg Data of Error Msg Returned
D dsECMsgDta 17 256
D SndPgmMsg PR ExtPgm('QMHSNDPM')
D MessageID 7A Const
D QualMsgF 20A Const
D MsgData 256A Const
D MsgDtaLen 10I 0 Const
D MsgType 10A Const
D CallStkEnt 10A Const
D CallStkCnt 10I 0 Const
D MessageKey 4A
D ErrorCode 1A
D wwMsgLen S 10I 0
D wwTheKey S 4A
/free
// ' ' checkr peMsgTxt wwMsgLen
SndPgmMsg('CPF9897': 'QCPFMSG *LIBL'
: peMsgTxt: wwMsgLen: '*COMP':'*PGMBDY'
: 1: wwTheKey: dsEC);
/end-free
P CompMsg E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------