Skip to content

Instantly share code, notes, and snippets.

View BirgittaHauser's full-sized avatar

Birgitta Hauser BirgittaHauser

View GitHub Profile
@BirgittaHauser
BirgittaHauser / ListSrcCode.sql
Last active August 26, 2024 13:54
List all Source Code Lines - for Scan
Select System_Table_Schema, System_Table_Name, System_Table_Member, Line_Number, Line
from Qsys2.SysPartitionStat cross join
Lateral(Select Line_Number, Cast(Line as VarChar(256)) Line
from Table(QSYS2.IFS_READ(Path_Name => '/QSYS.Lib/'
concat Trim(System_Table_Schema) concat '.lib/' concat
Trim(System_Table_Name) concat '.file/' concat
Trim(System_Table_Member) concat '.mbr'))) x
Where System_Table_Schema = 'YOURSCHEMA'
and System_Table_Name = 'YOURSRCF'
-- Order By System_Table_Schema, System_Table_Name, System_Table_Member, Line_Number
@BirgittaHauser
BirgittaHauser / BLOBPDF.SQLRPGLE
Last active August 30, 2023 10:08
Access a PDF document (with RPG) and pass the PDF document as Parameter to another Program/Procedure
//*********************************************************************************************
// I recently get asked how to read a small PDF document into a BLOB and pass it as parameter
// to another function or procedure
// 1. When working with embedded SQL character host variables can only be used up to 32k
// Larger data (up to 16 MB - RPG restriction)
// can be read into a LOB-Variable defined with the SQLTYPE keyword
// 2. Unfortunately the SQLTYPE Keyword cannot be used in a Prototype or Procedure Interface
// 3. But the SQL precompiler generates for the LOB variable a data structure with an
// UNS(4) Subfield _LEN and
// CHAR(xxx) Subfield _DATA
@BirgittaHauser
BirgittaHauser / RtvDspfFldPos
Created December 15, 2023 07:02
List Display File Information
Create Or Replace Function RtvDspFFldPos
(ParDspF VarChar(10),
ParDSpFLib VarChar(10) Default '*LIBL')
Returns Table (DSPF CHAR(10) ,
DSPFLIB CHAR(10) ,
Format Char(10) ,
ExtFldName CHAR(10) ,
Row SmallInt ,
Column SmallInt ,
LengthByte Integer ,
@BirgittaHauser
BirgittaHauser / CONDSPATR.rpgle
Created September 25, 2025 15:23
Display Attributes - Hex for DisplayFiles
//******************************************************************************************
// Display File - Display Attributes Hex
//********************************************************************************************
/IF NOT DEFINED(DSColorHex)
/DEFINE DSColorHex
DCL-DS DSColorHex Qualified; //Display-Attributes
DSColAll;
DSColHexFree Overlay(DSColAll);
DDSGRN VarChar(10) Overlay(DSColHexFree) inz('GRN'); //DDS Attr. Green