{"id":59,"date":"2025-08-08T09:10:12","date_gmt":"2025-08-08T09:10:12","guid":{"rendered":"http:\/\/fhix.fr\/?page_id=59"},"modified":"2025-10-13T16:48:39","modified_gmt":"2025-10-13T16:48:39","slug":"tips-as400-ibmi","status":"publish","type":"page","link":"https:\/\/fhix.fr\/index.php\/tips-as400-ibmi\/","title":{"rendered":"TIPS AS400 IBMi"},"content":{"rendered":"<ul class=\"wp-block-latest-posts__list wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2026\/02\/12\/afficher-la-version-de-los400\/\">Afficher la version de l&rsquo;OS400<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>DSPDTAARA QUSRSYS\/QSS1MRI<\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2026\/02\/10\/recherche-de-source-sur-la-machine\/\">Recherche de source sur la machine<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Votre source a \u00e9t\u00e9 supprim\u00e9? <br>Comment v\u00e9rifier si il existe une copie de sauvegarde quelque part sur la machine?<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><code><strong>SELECT<\/strong> * <strong>FROM<\/strong> syspartitionstat <strong>WHERE<\/strong> system_table_member = 'MONSOURCE'<\/code><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/11\/04\/chercher-les-programmes-en-erreur-de-niveau\/\">Chercher les programmes en erreur de niveau<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Permet de rep\u00e9rer les programmes RPG qui vont planter en erreur de niveau suite \u00e0 une \u00e9volution de la base de donn\u00e9es.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\">1) Lister les r\u00e9f\u00e9rences des programmes dans un fichier temporaire :<\/mark><\/strong><br><code>DSPPGMREF PGM(BIBPGM\/*ALL<em>)<\/em> OUTPUT(OUTFILE) OBJTYPE(*PGM) OUTFILE(QTEMP\/LISTEPGM)<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph {\"style\":{\"typography\":{\"fontStyle\":\"normal\",\"fontWeight\":\"300\"}}} -->\n<p style=\"font-style:normal;font-weight:300\"><strong><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\">2) Croiser les \u00ab\u00a0format level ID\u00a0\u00bb entre la liste des r\u00e9f\u00e9rences des programmes et la liste des fichiers<\/mark><\/strong><br><code><strong>SELECT<\/strong> whlib, whpnam, whlnam, whfnam, whrfnm <br><strong>FROM<\/strong> qtemp.listepgm <br><strong>LEFT JOIN<\/strong> sysfiles <strong>ON<\/strong> whfnam=system_table_name <strong>AND<\/strong> whrfnm=format_name <br><strong>WHERE<\/strong> whrfsn <\/code>&lt;&gt;<code> format_level_id <\/code><br><code><strong>AND<\/strong><\/code> <code>system_table_schema <strong>IN<\/strong> ('BIBFICHIER1' , 'BIBFICHIER2')<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>On obtient la liste des programmes de la biblioth\u00e8que BIBPGM en erreur de niveau sur les fichiers des biblioth\u00e8ques BIBFICHIER1 et BIBFICHIER2 :<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":395,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"49\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/11\/image.png\" alt=\"\" class=\"wp-image-395\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/11\/image.png 466w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/11\/image-300x32.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Il n&rsquo;y a plus qu&rsquo;\u00e0 recompiler le ou les programmes trouv\u00e9s (dans l&rsquo;exemple BIBPGM\/ADDCUST). La m\u00e9thode fonctionne aussi pour les PRTF et les DSPF.<\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/10\/11\/comparer-2-tables-en-utilisant-except\/\">Comparer 2 tables en utilisant EXCEPT<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>EXCEPT en SQL permet d&rsquo;extraire les diff\u00e9rences entre 2 tables.<br><br>Exemple :  2 tables article avec des contenus diff\u00e9rents<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":358,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"163\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image.png\" alt=\"\" class=\"wp-image-358\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image.png 346w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image-300x141.png 300w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p><br>1) Extraire les lignes de ARTICLE qui ne sont pas dans ARTICLE2 :<br><code><strong>SELECT<\/strong> * <strong>FROM<\/strong> article<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> * <strong>FROM<\/strong> article2<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"><strong> Casquette jaune<\/strong><\/mark><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>2) Extraire les lignes de ARTICLE2 qui ne sont pas dans ARTICLE :<br><code><strong>SELECT<\/strong> * <strong>FROM<\/strong> article2<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> * <strong>FROM<\/strong> article<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"> <strong>Beret noir<\/strong><\/mark><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>3) Il est possible de comparer sur une ou plusieurs colonnes choisies.<br>Par exemple, extraire les couleurs de ARTICLE2 qui ne sont pas dans ARTICLE :<br><code><strong>SELECT<\/strong> couleur <strong>FROM<\/strong> article2<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> couleur <strong>FROM<\/strong> article<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"> <strong>noir<\/strong><\/mark><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>A noter, il est possible de comparer 2 fichiers source avec EXCEPT :<br>1- OVRDBF FILE(SOURCE1) TOFILE(BIB1\/QRPGSRC) MBR(PGM1)<br>2- OVRDBF FILE(SOURCE2) TOFILE(BIB2\/QRPGSRC) MBR(PGM2)<br>3- <strong>SELECT * FROM<\/strong> source1 <strong><mark class=\"has-inline-color has-accent-color\">EXCEPT<\/mark><\/strong> <strong>SELECT * FROM<\/strong> source2<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><br><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/10\/06\/copier-un-spoule-dans-lifs\/\">Copier un spoule dans l&rsquo;IFS<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:list {\"ordered\":true} -->\n<ol class=\"wp-block-list\"><!-- wp:list-item -->\n<li><code>CRTPF FILE(QTEMP\/SPOULE) RCDLEN(132)<\/code><\/li>\n<!-- \/wp:list-item -->\n\n<!-- wp:list-item -->\n<li><code>CPYSPLF FILE(NOM_SPOULE) TOFILE(QTEMP\/SPOULE) <\/code><\/li>\n<!-- \/wp:list-item -->\n\n<!-- wp:list-item -->\n<li><code>CPYTOSTMF FROMMBR('\/QSYS.LIB\/QTEMP.LIB\/SPOULE.FILE\/SPOULE.MBR') TOSTMF('\/home\/mon_user\/spoule.txt') STMFCCSID(*PCASCII)<\/code><\/li>\n<!-- \/wp:list-item --><\/ol>\n<!-- \/wp:list --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/29\/utiliser-metabase-pour-surveiller-la-machine\/\">Superviser mon AS400 avec Metabase<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Metabase est un outil de visualisation des donn\u00e9es sous forme d&rsquo;un dashboard graphique.<br>Exemple d&rsquo;utilisation :<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":289,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"729\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-9-1024x729.png\" alt=\"\" class=\"wp-image-289\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-9-1024x729.png 1024w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-9-300x214.png 300w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-9-768x547.png 768w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-9.png 1070w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p>Requ\u00eates utilis\u00e9es pour cette exemple :<br>1) <strong>% occupation disque<\/strong><br><code>SELECT SYSTEM_ASP_USED FROM qsys2.system_status_info<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>2) <strong>Nombre de travaux int\u00e9ractifs<\/strong><br>SELECT count(*) FROM TABLE(active_job_info()) where job_type=&rsquo;INT&rsquo;<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>3) <strong>Nombre de travaux en message <\/strong><br><code>SELECT count(*) FROM TABLE(active_job_info()) WHERE job_status='MSGW'<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>4) <strong>Palmar\u00e8s du nombre de spoules par utilisateur<\/strong><br><code>SELECT job_user , count(*) AS nombre FROM TABLE(QSYS2.SPOOLED_FILE_INFO(USER_NAME =&gt;<em>'<\/em>*'))<br>WHERE job_user'QTCP'<br>GROUP BY job_user<br>ORDER BY nombre DESC<br>LIMIT 10<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>5) <strong>Palmar\u00e8s des plus gros fichiers<\/strong><br><code>SELECT objlib concat '\/' concat objname , objsize<br>FROM TABLE(QSYS2.OBJECT_STATISTICS('*ALLUSR<em>', '<\/em>FILE'))<br>WHERE objowner NOT LIKE 'Q%' AND objattribute='PF'<br>ORDER BY objsize DESC LIMIT 15<\/code><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/25\/boucle-de-lecture-en-sqlrpgle\/\">Boucle de lecture en SQLRPGLE<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Exemple : Lecture de la table utilisateur en filtrant les habitants de PARIS <\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code><code>**FREE\n<strong>\/\/ D\u00e9claration des variables<\/strong>\ndcl-s nom char(30);\ndcl-s prenom char(30);\ndcl-s ville char(20) inz('PARIS');\n\n<strong>\/\/ D\u00e9finition du curseur C01<\/strong>\nexec sql\n  declare C01 cursor for\n  select NOM , PRENOM\n  from UTILISATEUR\n  where VILLE = <strong><em>:ville<\/em><\/strong>\n  order by NOM , PRENOM;\n\n<strong>\/\/ Ouverture du curseur <\/strong>\nexec sql\n  open C01;\n\n<strong>\/\/ Boucle de lecture<\/strong>\ndow sqlcode = 0;\n  exec sql\n    fetch C01 into <em><strong>:nom , :prenom<\/strong><\/em> ;\n  if sqlcode = 0;\n    \/\/ lecture r\u00e9ussie, je fais mon traitement ici\n  endif;\nenddo;\n\n<strong>\/\/ Fermeture du curseur<\/strong>\nexec sql\n  close C01;\n\n*inlr = *on;\nreturn;<\/code><\/code><\/pre>\n<!-- \/wp:code --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/25\/copier-un-savf-depuis-lifs\/\">Importer un SAVF depuis l&rsquo;IFS<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p> &#8211; Cr\u00e9ation du savf (par exemple dans qtemp) : <br><code>CRTSAVF FILE(QTEMP\/MONSAVF)<\/code><br> &#8211; Importation du savf depuis l&rsquo;IFS :<code><br>CPYFRMSTMF FROMSTMF('\/home\/monprofil\/monsavf') TOMBR('\/qsys.lib\/qtemp.lib\/monsavf.file') MBROPT(*REPLACE)<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/24\/remplacer-des-caracteres-dans-une-chaine-de-caracteres\/\">Remplacer des caract\u00e8res dans une cha\u00eene de caract\u00e8res<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Utilisation de %SCANRPL( from : to : source { : start } )<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code><code>**FREE\ndcl-s chaine varchar(50);\nchaine = 'AZ500 IBMi AZ500 IBMi AZ500';\nchaine = %SCANRPL('Z5' : 'S4' : chaine); <strong>\/\/ chaine = 'AS400 IBMi AS400 IBMi AS400'<\/strong>\nchaine = %SCANRPL(' IBMi ' : ' ' : chaine); <strong>\/\/ chaine = 'AS400 AS400 AS400'<\/strong><\/code><code>chaine = %SCANRPL(' ' : '' : chaine); <strong>\/\/ chaine = 'AS400AS400AS400'<\/strong><\/code><\/code><\/pre>\n<!-- \/wp:code --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/03\/agregation-de-donnees\/\">Agr\u00e9gation de donn\u00e9es avec LISTAGG<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p><code><strong>SELECT<\/strong> item ,<br><strong>LISTAGG<\/strong>(<strong>TRIM<\/strong>(couleur), ',') <strong>WITHIN GROUP<\/strong>(<strong>ORDER BY<\/strong> couleur)<br><strong>AS<\/strong> couleurs<br><strong>FROM<\/strong> article<br><strong>GROUP BY<\/strong> item<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Explications :<\/strong><br><strong>LISTAGG<\/strong> permet de lister dans une colonne les donn\u00e9es issues de plusieurs lignes.<br><code>LISTAGG(colonne_\u00e0_concat\u00e9ner , 's\u00e9parateur') WITHIN GROUP(ORDER BY colonne_de_tri)<\/code><br><br>Dans l&rsquo;exemple donn\u00e9, le SQL transforme le fichier article suivant<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":240,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"170\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-6.png\" alt=\"\" class=\"wp-image-240\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-6.png 439w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-6-300x116.png 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p>en 2 lignes compos\u00e9es de la colonne item et d&rsquo;une colonne de couleurs s\u00e9par\u00e9es par la virgule<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":241,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"68\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-7.png\" alt=\"\" class=\"wp-image-241\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-7.png 439w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-7-300x46.png 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/09\/02\/agrandir-la-ligne-de-commande\/\">Agrandir la ligne de commande<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Sur une ligne de commande : CALL QCMD<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":159,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"129\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-3-1024x129.png\" alt=\"\" class=\"wp-image-159\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-3-1024x129.png 1024w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-3-300x38.png 300w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-3-768x97.png 768w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-3.png 1040w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p>On obtient 4 lignes :<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":156,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1024x171.png\" alt=\"\" class=\"wp-image-156\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1024x171.png 1024w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-300x50.png 300w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-768x128.png 768w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image.png 1045w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p>Et pour avoir encore plus grand : F11=Plein \u00e9cran<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":157,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"469\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1-1024x469.png\" alt=\"\" class=\"wp-image-157\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1-1024x469.png 1024w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1-300x137.png 300w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1-768x352.png 768w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/09\/image-1.png 1050w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p> <\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/08\/12\/trouver-le-programme-appelant-dans-un-rpg\/\">Trouver le programme appelant dans un RPG<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Permet dans un RPG d&rsquo;identifier son programme appelant. Cela peut servir par exemple pour conditionner certaines actions ou laisser une trace dans un fichier log.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>en SQLRPGLE :<\/strong><br><code>dcl-ds N PSDS;<br>  nom_du_pgm CHAR(10) POS(1);<br>end-ds; <br>dcl-s appelant char(10); <\/code><br><code><br>EXEC SQL <\/code><br>  <code>SELECT program_name INTO :appelant <\/code><br>  <code>FROM TABLE(stack_info('*'))<br> WHERE program_name not in (' ' , :nom_du_pgm)<br> AND ordinal_position &lt;<br> ( SELECT ordinal_position FROM TABLE(stack_info('*')) WHERE<br>   program_name=:nom_du_pgm LIMIT 1)<br> LIMIT 1;<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Explications :<\/strong><br><code>stack_info<\/code> permet de r\u00e9cup\u00e9rer la pile de programme en cours. Le SQL propos\u00e9 identifie dans la pile le programme au dessus du programme en cours.<\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/08\/12\/trouver-le-fqdn-de-la-machine\/\">Trouver le FQDN de la machine<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>CHGTCPDMN + F4<\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/08\/09\/supprimer-les-doublons-dans-un-fichier\/\">Supprimer les doublons dans un fichier<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p><code><strong>DELETE FROM<\/strong> monfichier a<br><strong>WHERE RRN<\/strong>(a) <strong>NOT IN<\/strong> ( <strong>SELECT MAX<\/strong>(<strong>RRN<\/strong>(b)) <strong>FROM<\/strong> monfichier b <br><strong>WHERE<\/strong> (a.cle1, a.cle2) = (b.cle1, b.cle2) )<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Explications :<\/strong><br>La fonction RRN permet de r\u00e9cup\u00e9rer le num\u00e9ro d&rsquo;enregistrement de la ligne. <br>Le SQL supprime donc les doublons (cl\u00e91+cl\u00e92 dans l&rsquo;exemple) qui ne correspondent pas au dernier num\u00e9ro d&rsquo;enregistrement.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":163,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"407\" height=\"146\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-1.png\" alt=\"\" class=\"wp-image-163\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-1.png 407w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-1-300x108.png 300w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Si on veut conserver le premier doublon et non le dernier doublon, il faut remplacer MAX par MIN :<br><code><strong>DELETE FROM<\/strong> monfichier a<br><strong>WHERE RRN<\/strong>(a) <strong>NOT IN<\/strong> ( <strong>SELECT MIN<\/strong>(<strong>RRN<\/strong>(b)) <strong>FROM<\/strong> monfichier b <br><strong>WHERE<\/strong> (a.cle1, a.cle2) = (b.cle1, b.cle2) )<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":164,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"406\" height=\"145\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-2.png\" alt=\"\" class=\"wp-image-164\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-2.png 406w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/08\/image-2-300x107.png 300w\" sizes=\"auto, (max-width: 406px) 100vw, 406px\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Pour simplement chercher les doublons, on peut utiliser :<br><code><strong>SELECT<\/strong> *<strong> FROM<\/strong> monfichier a<br><strong>WHERE RRN<\/strong>(a) <strong>NOT IN<\/strong> ( <strong>SELECT <\/strong><strong>RRN<\/strong>(b) <strong>FROM<\/strong> monfichier b <br><strong>WHERE<\/strong> (a.cle1, a.cle2) = (b.cle1, b.cle2) )<\/code><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/08\/09\/trouver-le-jour-de-la-semaine-du-jour\/\">Trouver le num\u00e9ro du jour de la semaine sans calendrier<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p>Permet d&rsquo;affecter \u00e0 la variable jour le num\u00e9ro du jour de la semaine du jour comme suit :<br>1:Lundi 2:Mardi 3:Mercredi 4:Jeudi 5:Vendredi 6:Samedi 7:Dimanche<br>(et sans s&rsquo;appuyer sur un calendrier!)<br><br><strong>en SQLRPGLE :<\/strong><br><code>EXEC SQL<br>  SET :jour= (CASE WHEN DAYOFWEEK(CURRENT_DATE) = 1 THEN 7 ELSE DAYOFWEEK(CURRENT_DATE)-1 END);<\/code><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Explications : <\/strong>la fonction SQL DAYOFWEEK permet de r\u00e9cup\u00e9rer le num\u00e9ro de jour d&rsquo;une date dans sa num\u00e9rotation anglaise (1:Dimanche 2:Lundi 3:Mardi &#8230;) d&rsquo;o\u00f9 le dayofweek()-1 <\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/fhix.fr\/index.php\/2025\/08\/09\/recuperer-la-date-du-au-format-aaaammjj\/\">R\u00e9cup\u00e9rer la date du au format AAAAMMJJ<\/a><div class=\"wp-block-latest-posts__post-full-content\"><!-- wp:paragraph -->\n<p><strong>Free RPG : <\/strong><br><code>dcl-s dateDuJour char(8);<br>dateDuJour = %char(%date():*ISO0);<\/code><\/p>\n<!-- \/wp:paragraph --><\/div><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-59","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":13,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions"}],"predecessor-version":[{"id":365,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions\/365"}],"wp:attachment":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/media?parent=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}