|
Bob, I do not beleive that is the problem as I have done this before by transfering a database file to an FTP server with the same data output from the program and then opened using EXCEL. When I wrote to a database file, my data in the file did not contain any garbage characters. The problem I am having now is that when I create the file directly on the IFS, I am unable to open directly using EXCEL, and also that I have some garbage characters in my data. These characters are not in the data that is being passed to the WRITE command. (I verified that using DEBUG to display the contents of the record area at the time of the write). Does anyone have any idea why this is happening? I am on V5R2 and the PTF level is current. Thanks, Bob Cozzi <cozzi@xxxxxxxxx> wrote: You might be confusing Excel by using the XLS suffix on the file since the file has HTML in it... I would leave it at .HTM or .HTML -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 1:42 PM To: RPG programming on the AS400 / iSeries Subject: RE: IFS Output problem Bob, I changed my second open to use the options Open_Flag = (O_WRONLY + O_TEXTDATA + O_APPEND); and now I can read it in NOTEPAD. I still can not open it in EXCEL unles I first SAVE it in NOTEPAD. Then, when I open using EXCEL, I get the same results as my first posting. HELP (-: Bob Cozzi wrote: Too bad you don't have RPG xTools, you could have just done this: fd = CrtAsciiFile(%TrimR(IFS_File_Name)); Which open are you using? I use the open64() function since it's supposed to be "faster" and more contemporary than just the plain "open" function. D open64 PR 10I 0 ExtProc('open64') D szIFSFileName * Value options(*string) D openFlags 10I 0 Value D ModeFlags 10U 0 Value options(*nopass) D CCSID 10U 0 Value options(*nopass) Also, is O_CODEPAGE defined as follows: D O_CODEPAGE C CONST(8388608) -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 12:33 PM To: RPG programming on the AS400 / iSeries Subject: RE: IFS Output problem Bob, I tried your suggestions and have the same result. I have mapped the directory using windoz map network drive after setting the share in iSeries Access. The RPG code that creates the file is: // Remove file if it exists first, so we don't overwrite beg file seg RC=unlink(%TrimR(IFS_File_Name)); // Create file with correct code page, in text mode Open_Flag = O_CODEPAGE + O_RDWR + O_CREAT ; Mode_Flag = S_IWUSR + S_IRUSR + S_IRGRP + S_IROTH; fd=open(%TrimR(IFS_File_Name) :Open_Flag : Mode_Flag : Code_Page); // Close file RC=close(fd); // File Created - Open for text output Open_Flag = (O_TEXTDATA + O_RDWR + O_APPEND); fd=open(%TrimR(IFS_File_Name) : Open_Flag); Bob Cozzi wrote: Looks like you've obfuscated your HTML. So, you open the file to create it. You close the file. You re-open the same file and then write data to it. The data looks okay when viewing it via a 5250 screen. You open it in Notepad and it looks obfuscated. This is again, a CCSID issue. Something's obviously not right, and I'm sorry to state the obvious because without seeing the code, I can't really do much else. You might also look at how you're mapping the IFS folder to your PC. I remember in Client Access there was a CCSID setting that defaults to something completely screwy. If you not using the standard Windows method to Map a Network Drive, and are using CA to do it, that could be your issue. Just a shot in the dark here, before you do all that investigating, try changing the flags for the Initial Open to use O_RDWR instead of O_WRONLY. I use: O_CODEPAGE + O_RDWR + O_CREAT To create the file, then I use: O_TEXTDATA + O_RDWR + O_APPEND To open the file the second time to write data to it. Again, the purpose of this sequence is to create or replace a file and then open it for output. -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 11:53 AM To: RPG programming on the AS400 / iSeries Subject: RE: IFS Output problem Bob, I added the O_APPEND, now when I try to open with NOTEPAD, I see 格浴㹬格慥㹤琼瑩 964;‾䘼湯⁴挽汯牯∽䙆 7990;䙆㸢潃牲捥慴汢⁥牏 敤獲⼼潦瑮㰾琯瑩 as the data. When I look in the IFS using the WRKLNK I see the same data that I had before. The attributes display indicates code page 819. Coded character set ID . . . . . . . . : 819 What happened? Why am I still getting garbage in my output data (as viewed in the WRKLNK) I must be doing something wrong, but I am out of my depth here. Thanks, Bob Cozzi wrote: You need to add O_APPEND to the set of Open Flags for the second open. -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 11:14 AM To: RPG programming on the AS400 / iSeries Subject: RE: IFS Output problem This is the RPG code I am using to create / open the file. D Code_Page S 10U 0 Inz(819) // Create file with correct code page, in text mode Open_Flag = O_CREAT + O_WRONLY + O_CODEPAGE; Mode_Flag = S_IWUSR + S_IRUSR + S_IRGRP + S_IROTH; fd=open(%TrimR(IFS_File_Name) :Open_Flag : Mode_Flag : Code_Page); // Close file RC=close(fd); // File Created - Open for text output Open_Flag = (O_WRONLY + O_TEXTDATA); fd=open(%TrimR(IFS_File_Name) : Open_Flag); >From what I understand, the initial open should have created the file with code page 819. If not, what am I doing wrong, and why do I have the garbage imbedded in my data? Bob Cozzi wrote: Yes, well I suspect you're problem is related to what I suggested. Opening it directly from Excel or Windows Explore would produce the same results. I may being going out on a limb here, but I'm going to "guess" you open/create the file on the IFS in once step, then write data to it? If so, the system doesn't automatically convert it to the 819 codepage. You have to open/create it, then close it, then reopen it with append before writing to it. At that point the system will automatically translate the EBCDIC to the ASCII codepage. -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 10:42 AM To: RPG programming on the AS400 / iSeries Subject: RE: IFS Output problem Bob, I am accessing the file directly from the IFS. The code page is 819. Bob Cozzi wrote: How are you getting the file from the IFS to the PC? Or aren't you? I find that if you use Windows Explorer to pull down a file, you get the results you experience. If you use FTP to transfer the file from the IFS to the PC, you get good results. This has to do with the CCSID of the IFS file. Make sure it is PC ASCII (I think that's CCSID 819) and it should open fine from Explorer or FTP. -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeffrey Young Sent: Thursday, July 14, 2005 10:03 AM To: midrange-l@xxxxxxxxxxxx; rpg400-l@xxxxxxxxxxxx Subject: IFS Output problem I am creating a file in the IFS in HTML format with a .xls extension to be opened by MS EXCEL. I am getting garbage characters in my output file that my program did not create. When I try to open the file, EXCEL can not determine what type of data it contains. When I view it in NOTEPAD it looks fine. I SAVE the file from NOTEPAD *without any changes*, then EXCEL can open it. When it is displayed, I get weird results as follows: Run Date: 07/14/2005Correctable OrdersRequested by: JEFF repeated 245 times.... The file in NOTEPAD is as follows: êRun Date: 07/14/2005Correctable OrdersRequested by: JEFF width="100%"> The HEX version of the data (from option 5 on WRKLNK is : 20EA3C68 746D6C3E 3C686561 643E3C74 69746C65 653E203C 466F6E74 203D636F 6C6F723D 22464646 46464646 223E436F 72726563 7461626C 65204F72 72646572 733C2F66 6F6E743E 3C2F7469 746C653E 3E3C2F68 6561203F 3C683320 616C6967 6E3D226C 6C656674 223E5275 6E204461 74653A20 30372F31 31342F32 3030353C 2F68333E 3C683220 616C6967 676E3D22 63656E74 6572223E 436F7272 65637461 61626C65 204F7264 6572733C 2F68323E 3C68333E 3E526571 75657374 65642062 793A204A 4546463C 3C2F6801 C83C7461 626C6520 616C6967 6E3D2274 746F7022 20626F72 6465723D 22312220 77696474 74683D22 3130300A 223E3C74 72206267 636F6C6F 723D2223 30304646 What am I doing wrong? Thanks, Jeff Young Sr. Programmer Analyst Dynax Solutions, Inc. IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2 IBM Certified Specialist- e(logo) server i5Series Technical Solutions Designer V5R3 IBM Certified Specialist- e(logo)server i5Series Technical Solutions Implementer V5R3 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.