Blog Pro de Jean-Baptiste HEREN

Notes d'un consultant Freelance en Informatique

To content | To menu | To search

Ecrire un fichier plat en sqr

Voici les trois étapes nécessaires pour l'écriture d'un fichier plat en sqr:

  1. Ouverture : Instruction OPEN
  2. Ecriture: Instruction WRITE
  3. Fermeture : Instruction CLOSE

Dans cet exemple, Nous créons un fichier text.txt dans le dossier /temp, et y écrivons deux chaines de caractères, en précisant pour chaque 'colonne', sa taille fixe.

!  Init FileName and File Number
let $File_name = '/temp/text.txt'
move 1 to  #FILE_NO

! Put Something to $values
let $value1 = 'foo1'
let $value2 = 'foo2'

! 1- Create the File and attach it to the specified File Number
OPEN $File_name as #FILE_NO for-writing record=20000:VARY
                                       status=#filestat                                                      
! 2- Write one line (aka record)
write #FILE_NO from             
     $Value1:16 ! fixed zize to 16 chars
     $Value2:4  ! fixed zize to 4 chars
    
! 3 - close File
Close #FILE_NO

Biensûr, ils est courant de placer une boucle de type BEGIN-SQL/END-SQL autour de l'étape 2, sachant que chaque appel à la commande WRITE crée une nouvelle ligne dans le fichier.

Jean-Baptiste Heren

Author: Jean-Baptiste Heren

Stay in touch with the latest news and subscribe to the RSS Feed about this category

Comments are closed


no attachment



You Might Also Like

Finding one component location in the peoplesoft portal

Just replace the 'MY_COMPONENT_GBL' parameter in the following sql script. This works for MS SQl Server. You can add more levels by adding Outer Joins. [SQL] /* Where is my component in the portal */...

Continue reading

02_-_new_component_interface.png

Peoplesoft Component interface HOWTO

Here is a tutorial explaining how you can create a function containing one Component INterface, and make use of it from any peolplecode. Following example takes the PO Receipt Component to make...

Continue reading