Ecrire dans un fichier déjà existant par traitement

SOLVED

Bonjour,

Je souhaite à l'aide d'un traitement écrire dans un fichier de sortie de type csv.

Pour cela pas de soucis je créé mon fichier ainsi :

Openo [L]FICHIER2, 0 Using [OUT]
Iomode adxirs chr$(13) + chr$(10) Using [OUT] 
Iomode adxifs ';' Using [OUT] 
Iomode adxium 50 Using [OUT]

Cependant je voudrais que si ce fichier existe déjà écrire à la suite et non pas l'écraser, est-ce possible de faire ça ?

Merci pour votre aide.

  • +1
    verified answer

    Bonjour,

    C'est justement l'utilité du second paramètre dans l'instruction Openo.

    Au lieu de 0, si vous renseignez -1, le prochain Wrseq écrira bien à la fin du fichier.

  • 0 in reply to L.V. Expertise X3

    Bonjour,

    Merci pour votre réponse, cela fonctionne très bien pour moi.

  • 0 in reply to Delph

    Bonjour,
    Pour une future reférence:
    https://online-help.sageerpx3.com/erp/12/staticpost/openo

    The value in the 2nd parameter is used to position the write position (in bytes) in the file:

    • If it is missing or null, the position is at the beginning of the file and the file is truncated. When a truncation to 0 is done, the file is really truncated and never deleted. This means that if other links exist on the file in a Unix file system, they will remain. If the file is deleted first by using Delfile, the other links remain on the file and a new empty file is created by Openo.
    • If negative, the original position is at the end of the file.
    • If positive and if it exceeds the size of the file, the first write at this position will increase the file size by adding null characters at the end of the file to reach the expected size.
    • If positive and if it is smaller than the size of the file, the file is first truncated to the right size. To avoid a file deletion, truncating a file to a size that is not null is done by a preliminary copy of the size to keep in a temporary file, followed by a truncation to 0 of the file, a reverse copy of the temporary file on the origin truncated file, and finally a deletion of the temporary file. This can use temporary space and take time if the size is big.