pjohns
10th December 2013, 10:33
Hello,

We have a report which generates a Bank payment file which has worked fine up to now.

The bank has just changed their online payment system which no longer recognises the LF character at the end of every line. I need to get the report script to put a CRLF at the end of every line. How can I do this?

The payment file is created on a Samba share and the finance user will take the file from this location and upload to the bank payment system. I don't really want to have to introduce a manual step where somebody has to run unix2dos or run the file through awk or sed.

Any advice you can give will be appreciated.

Thanks

This is my print string.

print.string = shiftl$(strip$(tfcmg001.bano)) & "," & shiftl$(strip$(sprintf$("%D(%02y%02m%02d)",tfcmg101.plan))) & ",Tokyo Elec Euro,DOMESTIC," & shiftl$(strip$(tfcmg103.ccur)) & "," & shiftl$(strip$(sprintf$("%A005", tfcmg103.amnt))) & ",,,,," & chr$(67) & chr$(58) & shiftl$(strip$(tccom025.swft)) & "," & "," & shiftl$(strip$(tccom025.bano)) & "," & shiftl$(strip$(tccom020.nama)) & ",,,,SHA,"

mark_h
10th December 2013, 15:02
Can you just use run.prog or the shell command to run unix2dos?

mark_h
10th December 2013, 15:06
Straight from some of my code:

cmd = "unix2dos " & strip$(spool.fileout) & " " & strip$(spool.fileout)
rc = shell(cmd, SHELL_NO_OUTPUT)

pjohns
10th December 2013, 15:10
Thanks Mark,

Would this not go in the session script? If so the payment file is generated using the standard sessions in the Baan Finance CMG module.

mark_h
10th December 2013, 15:16
Sorry - but yes it would need to go into a script. But then again if you run it in batch mode, you could create another session to change the file. Do the users run it manually?

pjohns
10th December 2013, 15:19
Users will run the process manually and then collect the file from the Samba share.

mark_h
10th December 2013, 15:34
Well worst case scenario you could add another session to the process that the users have to run before getting the file from the samba share. Not a good solution in my opinion and hopefully someone has a better solution. This is one of the reasons I like qkey - I can almost always find a place in the script extend the source code to do something like this.

george7a
10th December 2013, 18:14
You can add chr$(13) at the end of the string variable.

pjohns
17th December 2013, 11:21
Hi,

As suggested I added chr$(13) at the end of my print string but it didn't make any difference. I check my file using Notepadd++ and could only see LF

print.string = shiftl$(strip$(tfcmg001.bano)) & "," & shiftl$(strip$(sprintf$("%D(%02y%02m%02d)",tfcmg101.plan))) & ",Tokyo Elec Euro,DOMESTIC," & shiftl$(strip$(tfcmg103.ccur)) & "," & shiftl$(strip$(sprintf$("%A005", tfcmg103.amnt))) & ",,,,," & chr$(67) & chr$(58) & shiftl$(strip$(tccom025.swft)) & "," & "," & shiftl$(strip$(tccom025.bano)) & "," & shiftl$(strip$(tccom020.nama)) & ",,,,SHA," & chr$(13)

If I put chr$(13) in the middle of my string I do not get a carriage return. It's gives the impression that chr$(13) is not supported ?

Han Brinkman
17th December 2013, 13:45
If I create a simple text file on linux and convert it to dos format with unix2dos than the od command shows me that the lines are ending with \r\n meaning you have to add chr$(10) before your linefeed (chr$(13)).


~/tmp> od -c thb
0000000 r e g e l 1 \n r e g e l 2 \n
0000016
~/tmp> unix2dos < thb > thb.dos
~/tmp> od -c thb.dos
0000000 r e g e l 1 \r \n r e g e l 2 \r \n
0000020
~/tmp> od -x thb.dos
0000000 6572 6567 316c 0a0d 6572 6567 326c 0a0d
0000020

george7a
17th December 2013, 18:11
Hi,

As suggested I added chr$(13) at the end of my print string but it didn't make any difference. I check my file using Notepadd++ and could only see LF

print.string = shiftl$(strip$(tfcmg001.bano)) & "," & shiftl$(strip$(sprintf$("%D(%02y%02m%02d)",tfcmg101.plan))) & ",Tokyo Elec Euro,DOMESTIC," & shiftl$(strip$(tfcmg103.ccur)) & "," & shiftl$(strip$(sprintf$("%A005", tfcmg103.amnt))) & ",,,,," & chr$(67) & chr$(58) & shiftl$(strip$(tccom025.swft)) & "," & "," & shiftl$(strip$(tccom025.bano)) & "," & shiftl$(strip$(tccom020.nama)) & ",,,,SHA," & chr$(13)

If I put chr$(13) in the middle of my string I do not get a carriage return. It's gives the impression that chr$(13) is not supported ?
That is strange! It works for me every time!
If you open the file in notepad++ or wscite or any other advanced editor, and try to show the "end of line characters", what would you see?