Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 6th October 2017, 15:48
pralash pralash is offline
Member
 
Join Date: Feb 2017
Posts: 62
pralash is on a distinguished road
Baan: 9.0 - DB: SQL Server - OS: Windows 2012R2
How to write record one by one into the file
Baan: Other/Unknown
C/S: None/Unknown

Hi....

I'm fresher in LN Programming...I write a data into the file by using seq.puts function. But I want to know that how to write the data one by one into the file... Is there any switch are available in baan like \n or \t to do this task. Can anybody please let me know that about this task.

Regards,
Pralash
Reply With Quote
  #2  
Old 7th October 2017, 06:39
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,287
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi Pralash,

seq.puts() will take care of adding a new line character.

Code:
seq.open(file.name,"w+")
select ...
from ...
selectdo
       seq.puts(...,fp)  |# Insert data in the text file
endselect

seq.close(fp)

So, with every seq.puts() a new line character is added and every record will be added to a new line in the text file.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 8th October 2017, 16:21
pralash pralash is offline
Member
 
Join Date: Feb 2017
Posts: 62
pralash is on a distinguished road
Baan: 9.0 - DB: SQL Server - OS: Windows 2012R2
Thanks for your information.... But how can I apply the new line char in seq.puts() function...
Thanks,
Pralash
Reply With Quote
  #4  
Old 9th October 2017, 07:14
pralash pralash is offline
Member
 
Join Date: Feb 2017
Posts: 62
pralash is on a distinguished road
Baan: 9.0 - DB: SQL Server - OS: Windows 2012R2
How to write a new line char into the file

Hi, I'm new to LN Programming. I have stored some data into the file by using seq.open(). But I don't know how to write the record one by one into the file...
We can write the records one by one in "C" Language by using the switch '\n' char...Similarly is there any characters are available in Bann for seq.put() in order to write the records one by one...
Can anybody assist me how to write the record one by one in with sample script...

Regards,
Senthil
Reply With Quote
  #5  
Old 9th October 2017, 08:25
JaapJD's Avatar
JaapJD JaapJD is offline
Guru
 
Join Date: Sep 2002
Location: Netherlands
Posts: 728
JaapJD will become famous soon enoughJaapJD will become famous soon enough
Baan: BaanIV, BaanERP, ERP LN 6.1 - DB: Oracle, SQL Server - OS: Unix, Windows
seq.puts() writes a new line character. So for each line you need to write call the seq,puts() function with the data to write.
Reply With Quote
  #6  
Old 9th October 2017, 09:01
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Posts: 1,639
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox - DB: tbase, ms-sql7, oracle10gV1, 11g - OS: HP-UX, W2K3, SLES
Double post !

Hello,

avoid double posting, please 1
http://www.baanboard.com/baanboard/s...ad.php?t=70483

Regards
__________________
//Bernd
Reply With Quote
  #7  
Old 9th October 2017, 10:05
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,287
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Please do not create new threads if one already exists. As already said and confirmed by Jaap, seq.puts() will add new line character automatically. You just need to pass the string you want to write to the file.

e.g. Lets write item code and description from tcibd001 to a file.

Code:
string filename(100)
long fp
string str(100)

filename = creat.tmp.file$( bse.tmp.dir$() ) |# Create temp file
fp = seq.open(filename,"w+")                    |# Open temp file

select tcibd001.item, tcibd001.dsca
from tcibd001
selectdo
         str = tcibd001.item & "," & tcibd001.dsca |# Item Code , Description
         seq.puts(str,fp)                                   |# Write to file
endselect

seq.close(fp)         |# Close file

This should create and write the item code and description with comma separator the the output file in bse\temp directory. Each item will be written to a new line.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #8  
Old 9th October 2017, 10:06
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,287
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Please do not create new threads if one already exists. Merged threads now. As already said and confirmed by Jaap, seq.puts() will add new line character automatically. You just need to pass the string you want to write to the file.

e.g. Lets write item code and description from tcibd001 to a file.

Code:
string filename(100)
long fp
string str(100)

filename = creat.tmp.file$( bse.tmp.dir$() ) |# Create temp file
fp = seq.open(filename,"w+")                    |# Open temp file

select tcibd001.item, tcibd001.dsca
from tcibd001
selectdo
         str = tcibd001.item & "," & tcibd001.dsca |# Item Code , Description
         seq.puts(str,fp)                                   |# Write to file
endselect

seq.close(fp)         |# Close file

This should create and write the item code and description with comma separator the the output file in bse\temp directory. Each item will be written to a new line.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #9  
Old 10th October 2017, 14:34
pralash pralash is offline
Member
 
Join Date: Feb 2017
Posts: 62
pralash is on a distinguished road
Baan: 9.0 - DB: SQL Server - OS: Windows 2012R2
Thanks for your information...
Actually I read record from the table and also store a particular field in the text file...
But some additional value is automatically added with the end of the file as shown in the attachment... Also the records are not added one by one if I using the seq.put function...
Here is my script as follows.

function extern control.users.function()
{
file.name="c:\erpln\proj\users.txt"
file.pointer = seq.open(file.name, "w")

if file.pointer < 0 then
message("Can not find the file")
e = seq.close(file.pointer)
exit(1)
endif

select tccom200.user
from tccom200
where tccom200.stus="inactive"
selectdo
user.name=tccom200.user
seq.puts(strip$(shiftl$(user.name)),file.pointer)

selectempty

endselect
}
Can you please assist me to resolving this problem...
Thanks,
Pralash
Attached Images
File Type: png doubt-3.PNG (13.5 KB, 6 views)
Reply With Quote
  #10  
Old 10th October 2017, 14:37
JaapJD's Avatar
JaapJD JaapJD is offline
Guru
 
Join Date: Sep 2002
Location: Netherlands
Posts: 728
JaapJD will become famous soon enoughJaapJD will become famous soon enough
Baan: BaanIV, BaanERP, ERP LN 6.1 - DB: Oracle, SQL Server - OS: Unix, Windows
You need to do this:
Code:
file.pointer = seq.open(file.name, "wt")
Reply With Quote
  #11  
Old 11th October 2017, 07:25
pralash pralash is offline
Member
 
Join Date: Feb 2017
Posts: 62
pralash is on a distinguished road
Baan: 9.0 - DB: SQL Server - OS: Windows 2012R2
The issue is resolved right now...
Thanks a lot Jaapjd....
Regards,
Pralash
Reply With Quote
Sponsored Links
  #12  
Old 11th October 2017, 09:08
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Posts: 1,639
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox - DB: tbase, ms-sql7, oracle10gV1, 11g - OS: HP-UX, W2K3, SLES
seq.open flags

Hello,
Code:
seq.open()
Syntax:

function long  seq.open  (string file, string openmode, ref string pathnm)

Description

This opens a specified file. It uses the file $BSE/lib/fd ver.pack_combination to find the file. ver refers to a particular release of the software; pack_combination refers to a particular package combination (see pathname() ).

Arguments

string file The file name.
 
string openmode The mode in which the file must be opened. This can be one of the following options:

"r" Open for reading. The current file position is placed at the start of the file. 
"w" Open for writing. The file is created if it does not already exist. The current file position is placed at the start of the file. 
"a" Open for writing. The file is created if it does not already exist. The current file position is placed at the end of the file.

The file position is placed at end of the file before every write statement, even if the previous file action was a seq.seek().
 
"x" Open for writing. This is the same as "w", except that the function fails if the file already exists. 
"r+" Same as "r", but the file can also be written to. 
"w+" Same as "w", but the file can also be read. 
"a+" Same as "a", but the file can also be read. 
"x+" Same as "x", but the file can also be read. 
Use the following modes to indicate whether the file is a binary or a text file. You can combine one of these modes with any one of the previous modes (for example, "rt+"). 
"b" Use for binary files. This is the default mode and need not be specified. 
"t" The line separator(s) for text-files are different on Windows NT and UNIX systems. CRLF on the former; LF only on the latter. In addition, a Windows NT text file can include an EOF-character (^Z) that indicates the end of the file. This character should not be returned to a program reading the file.

So, you must specify the "t" option when reading from or writing to a text file on Windows NT systems (for example, "at+".) This ensures that line separators and EOF characters are handled correctly. Never use the "t" option when opening a binary file; on Windows NT systems this will corrupt the file data. The "t" option has no effect on UNIX systems.
 
 
 
ref string pathnm This returns the full path to the file.
 
 
Return values

>= 1 Success; File pointer returned for use in subsequent operations. 
<1 Error; that is, the negative value of the system error (for example, for a permission error, the system returns 13 and the function returns -13, or if the internal table is full, the function returns -EAGAIN).
Regards
__________________
//Bernd
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any permission or header file needed while read a server file from client pralash Tools Development 6 23rd March 2017 11:59
This function is not supported in th LN UI: seq.open.dialog.local showstuff11 Tools Development 13 16th February 2017 15:34
Peek at next record in Report Seq File ben.kansas Tools Development 3 12th November 2014 00:14
Error in reading sort file record becks22 Tools Development 11 15th November 2010 15:05
write file macoxy Tools Development 5 21st October 2005 16:17


All times are GMT +2. The time now is 06:51.


©2001-2017 - Baanboard.com - Baanforums.com