cpytostmf - how to get rid of last blank line
Last Post 28 Feb 2013 09:43 AM by y2krush. 17 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
cat5ive
New Member
New Member
Posts:45

--
13 Feb 2013 05:46 PM

Hi,

CPYTOSTMF FROMMBR('QSYS.LIB/DTALIB.LIB/FLAT.FILE/MYMBR.MBR') TOSTMF('QDLS/MYFOLDER/DOC.TXT') STMFOPT(*REPLACE) STMFCODPAG(*PCASCII) 

 

I use above command to copy flat file to text file in as400 folder. My flat file does not have any blank line but after copy my 

file DOC.TXT contain 1 blank line after last record. How can I get rid of this blank line.

Thanks in advance.

 

Carel Teijgeler
Basic Member
Basic Member
Posts:141

--
14 Feb 2013 01:49 AM
First, you copy it to the old QDLS-environment (good old DOS), but the IFS is much opener.

The last line could be the End of File-marker (^Z in DOS).

Try copying it to /home/mydoc.txt and see what the result is then.

Regards,
Carel Teijgeler
cat5ive
New Member
New Member
Posts:45

--
14 Feb 2013 01:19 PM

Hi Carel,

 

I did copy  it to QDLS

TOSTMF('QDLS/MYFOLDER/DOC.TXT')

 

What I just try was copy it to root directory first. I checked the result, it did not have blank line at the end. But after I copy it to qdls, it has blank line at the end.

CPYTOSTMF FROMMBR('QSYS.LIB/DTALIB.LIB/FLAT.FILE/MYMBR.MBR') TOSTMF(
'home/text/book.TXT') STMFOPT(*REPLACE) STMFCODPAG(*PCASCII)   

strqsh cmd('mv home/text/book.txt qdls/myfolder/')                   

 

Ringer
Veteran Member
Veteran Member
Posts:1758
Avatar

--
14 Feb 2013 05:05 PM
Using QDLS is the equivalent of using MS DOS. It's old, antiquated. But then again, some of our code is 25+ years old. If this new code, consider not using QDLS.

Chris Ringer
cat5ive
New Member
New Member
Posts:45

--
14 Feb 2013 08:06 PM

I tried ftp directly from database file to another server (not as400) with below command, still has blank line.

append DTALIB/FLATF.MYMBR BOOK.TXT

 

Emmanuel
Veteran Member
Veteran Member
Posts:813

--
15 Feb 2013 07:53 AM

This may be of interest:

http://archive.midrange.com/midrang...01140.html

Cheers,

Emmanuel

cat5ive
New Member
New Member
Posts:45

--
15 Feb 2013 05:12 PM
Thank Emmanuel but that's a manual process. I'm looking for a way to copy my flat file to .txt file without a blank line at the end.
Gary Lavery
New Member
New Member
Posts:8

--
17 Feb 2013 06:14 AM
Just a guess...if you are using FTP, try switching to binary mode.
Gary
cat5ive
New Member
New Member
Posts:45

--
17 Feb 2013 09:07 AM
Gary, just try FTP using binary mode. My text file became unreadable. I had tried FTP before without binary mode, my text file was ok except that it had blank line at the end.

My purpose is to copy PF (flat file) to .txt file. I'm using cmd cpytostmf. When I open .txt file, I see a blank line inserted after my last record. I opened the file with note pad and wordPad, I got the same result. When I display the file form wrklnk, I don't see that blank line though.
This blank line causes the problem. When I send out the file to my client, they said their software (SAP) could not process the file because it has blank line in the last record.

I'm open to other command. I had already tried FTP directly from my PF to other pc server. It still produce same result.
Katty
New Member
New Member
Posts:11

--
18 Feb 2013 09:53 AM
Hi, I had the same problem, and couldn't fix it. The only solution I had found is executing a transfer file (*.DTF) on PC, using STRPCCMD command.
Scott Klement
Editorial Staff Member
Editorial Staff Member
Posts:16354
Avatar

--
18 Feb 2013 04:32 PM

What is causing the blank line?    Can you post the last 10 bytes of your file in hex, so we can see what the ending characters are?

Without even looking for information about what the cause is, we're playing the "pick some random tip and try it without understanding it" game, which I've never found to be especially effective.

cat5ive
New Member
New Member
Posts:45

--
18 Feb 2013 05:21 PM
Hi Scott,

>>Can you post the last 10 bytes of your file in hex

How do I do that? My PF doesn't doesn't have blank line. Only the .txt file has it. I'm pretty sure if you run below cmd against any of your flat file you will get the same result. Or you can show me how to post the last 10 bytes in hex, I will post it.

CPYTOSTMF FROMMBR('QSYS.LIB/DTALIB.LIB/FLAT.FILE/MYMBR.MBR') TOSTMF('QDLS/MYFOLDER/DOC.TXT') STMFOPT(*REPLACE) STMFCODPAG(*PCASCII) 

Thanks
Scott Mildenberger
New Member
New Member
Posts:66

--
19 Feb 2013 12:23 PM

To get the last 10 bytes in hex you can use WRKLNK - option 5 to display and then F10 to display hex.  Copy the hex of the lat 10 bytes.

 

 

cat5ive
New Member
New Member
Posts:45

--
19 Feb 2013 01:26 PM
40404040 40404040 40400D0A

This hex is shown on the same line that display '*****End of Data********' in the wrklnk. Not sure if it's what you're looking for.
Scott Klement
Editorial Staff Member
Editorial Staff Member
Posts:16354
Avatar

--
20 Feb 2013 04:45 PM
If your data is ASCII, that should not show up as blanks -- x'40' is EBCDIC blank, but in ASCII it's the @ character.
cat5ive
New Member
New Member
Posts:45

--
23 Feb 2013 12:40 AM
Hi Scott,

How do I get rid of the blank line?

Scott Klement
Editorial Staff Member
Editorial Staff Member
Posts:16354
Avatar

--
25 Feb 2013 09:13 AM

There's something very strange and unexplained going on here... since, according to what you posted, you should not have a blank line, you should have a line of @@@@@@@.   So there's more going on here than meets the eye.

The best way to eliminate that line is to find out where it's coming from.  When I use CPYTOSTMF, I don't get a blank line -- why do you?

y2krush
New Member
New Member
Posts:2

--
28 Feb 2013 09:43 AM

CPYTOSTMF has another parameter ENDLINFMT

which defaults to *CRLF

*CRLF                                                              
    Carriage-return followed by line-feed is appended to the end of
    each line.

You are not authorized to post a reply.

Acceptable Use Policy