{"id":367,"date":"2025-10-13T16:45:43","date_gmt":"2025-10-13T16:45:43","guid":{"rendered":"https:\/\/fhix.fr\/?page_id=367"},"modified":"2025-10-13T16:45:43","modified_gmt":"2025-10-13T16:45:43","slug":"tips-as400-ibmi-rpg","status":"publish","type":"page","link":"https:\/\/fhix.fr\/index.php\/tips-as400-ibmi-rpg\/","title":{"rendered":"TIPS AS400 IBMi RPG"},"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\/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\/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\/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\/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\/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-367","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/367","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=367"}],"version-history":[{"count":1,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/367\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/pages\/367\/revisions\/368"}],"wp:attachment":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/media?parent=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}