OPALE - 10.0 - Usage

Repaginating an IBM i spooled file

De MappingDoc
Révision datée du 4 décembre 2019 à 09:04 par Rdal (discussion | contributions) (Page créée avec « =====General Connect project===== »)
Autres langues :
English • ‎français

Introduction

The objective of this use case is to explain how to repaginate an IBM i spooled file.

To do this, two commands need to be used: MAPSORTPAG and MAPRUNRPT (M-Connect). MAPSORTPAG puts the content of the spooled file into a physical file, and then MAPRUNRPT reads the physical file and recreates a spooled file with the desired pagination.
Example: A page break every 20 lines passed as a parameter in MAPRUNRPT.

Commands

MAPSORTPAG

As explained above, MAPSORTPAG is used to put the content of the file into a database file.

As an example, here is a spooled file we want to repaginate:

Spooled file name . . . . . . . > A000000002
Spooled file number . . . . . . > 3
Job name . . . . . . . . . . . . > QPADEV0008
Job number . . . . . . . . . . . > 487312
User . . . . . . . . . . . . . . > JDIEU

Run this command:

MAPSORTPAG SPLF(A000000002) SPLNUM(3) JOB(QPADEV0008) JOBNUM(487312) USER(JDIEU) KEYLINE(1) KEYCOL(1) KEYLGN(1) CREATE(*NO) LIB(MAP$$SORT) NAME(MYPF)

The spooled file content is now added to physical file MAP$$SORT/MYPF in the database

MAPRUNRPT

This command runs a Connect which reads the physical file MYPF and creates a spooled file with the new pagination information.

Connect Project

Creating the Connect project
  1. Create a new Connect project
  2. Change the name of the format. Click on Properties and call it NEWPAG
  3. Click on Insert table (.def)
  4. Browse to the .def file created previously on Opale Server (this will create a Connect table automatically)
  5. Click on the Spooled file button (on the vertical bar on the left)
  6. Click on New Block
  7. Call the block MYBLOCK
  8. Drag and drop the field PRTDTA from the MYPF table on to the block
  9. Create 2 variables in the DB table: LINE# and TOTLINE (TOTLINE should be defined as an Input Parameter)
  10. In the actions of the MYPF table, enter the actions to get the result below:
  11. Click on Preview , enter 10 for the value of DB.TOTLINE and check that the content of the PF is written with the expected number of lines

Preview:

As you can see, the newly generated spooled file has only 10 lines (value specified in parameter TOTLINE when generating the preview)

General Connect project

Fenêtre de la table DB. (ce qui se trouve dans ACTION sera exécuté lors de l'exécution du Connect)


Fenêtre de la table MYPF. (ce qui se trouve dans MYPF sera exécuté lors de l'exécution du Connect au niveau du Execute MYPF)

Le Read MYPF lit la première ligne du fichier physique MYPF. Pour cette ligne en cours, le moteur Connect va :

  1. Ecrire le BLOC MYBLOC via le Write MYPF : MYBLOC (bloc Connect contenant la valeur de l'enregistrement de MYPF en cours)
  2. Incrémenter le compteur de nombre de ligne (Variable DB.LINE# déclaré dans la table DB)
  3. Vérifier sa valeur : Si le numéro de ligne en cours est égale à la valeur passé en paramètre pour le nombre de ligne souhaité alors Connecte fera un saut de page (instruction page break) et ensuite on met ce compteur à 0.
  4. Passer au prochain enregistrement de MYPF grâce à l'instruction Next Read
Exécution du Connect sur le serveur

Une fois le Connect généré et importé sur le serveur Opale, il faut exécuter la commande suivante :

MAPRUNRPT RPTNAM(NEWPAG) SPOOLFILE(MYREPORT) OUTQ(LIBOUTQ/MYOUTQ)PARM('DB.TOTLINE=10')

L'exécution de cette commande a pour effet de lire le contenu du fichier physique MYPF et de créer un nouveau spooled file (MYREPORT) ayant un saut de page toutes les 10 lignes.

Remarque : Pour avoir un spooled file avec un saut de page toutes les 20 lignes, il faut changer la valeur TOTLINE à 20.

Exécution sur le serveur

Afin d'automatiser l'exécution sur le serveur, il est nécessaire de créer une entrée dans les règles appelant une action incluant les 2 commandes vues ci-dessus :

MAPSORTPAG SPLF(&SPLF) SPLNUM(&SPLNUM) JOB(&JOB) JOBNUM(&JOBNUM) USER(&USER) KEYLINE(1) KEYCOL(1) KEYLGN(1) CREATE(*NO) LIB(MAP$$SORT) NAME(MYPF)
MAPRUNRPT RPTNAM(NEWPAG) SPOOLFILE(MYREPORT) OUTQ(LIBOUTQ/MYOUTQ)PARM('DB.TOTLINE=10')