Showing posts from January, 2024

Efficient WRKSPLF with WSF: How to Search string into spooled files, Sort, and Generate PDFs on IBMi

Searching Spooled Files Made Easy: A Unique Solution Managing spooled files efficiently is crucial for users dealing with numerous rows of print data. IBM's WRKSPLF command provides a standard way to interact with spooled files, but it lacks certain features that can significantly enhance user experience. In this article, we'll delve into a powerful functionality that IBM doesn't offer — the ability to search among spooled file lists. Our goal is to highlight the advantages of this capability and introduce a practical solution. The Limitations of Standard WRKSPLF While the WRKSPLF command is a handy tool for working with spooled files, it falls short in certain aspects. One prominent limitation is the inability to search efficiently through the list of spooled file rows. Users often find it challenging to quickly locate specific files based on criteria like creation date, status, or content. Introducing a Unique Solution: WSF (WorkSpooledFiles) To address the limitations of

Extracting Data from DB2 to Excel with ODBC

Configuring ODBC is the first crucial step to enable data transmission between your PC and the IBMi server (AS400). In my example, I am using the Windows 10 operating system and want to extract data from the public IBMi server PUB400.COM. However, make sure to configure ODBC to point to your specific IBMi environment. ODBC Configuration on Windows: 1. Open "ODBC Data Sources" in either 32-bit or 64-bit (in my case, 64-bit). 2. Select "iSeries Access ODBC Driver" and click "Add". **Data Source:** Specify the data source name. 3. Fill in the nine configuration tabs: - **Server:** Indicate the address of your IBMi server.     -  **Libraries:** List the libraries containing the files you want to access. 4. Once the tabs are filled, click "Apply" and "OK". Extracting Data to Excel: 1. Open Excel. 2. Go to "Data" and then "Get Data". 3. Select "From Other Sources" and choose "From Microsoft Query". 4. S

IBMi (AS400) fans only ' SQLCODE values: Dear readers, unleash your suggestions!

This RPG code uses a DOU loop to fetch data from a cursor named C1 until the SQLCODE is not equal to 0, indicating the end of the recordset. Inside the loop, it clears a data structure (RecordDsC1), fetches data into it, and then checks if the fetch was successful. If successful, it assigns values and writes to an output file. After the loop, it checks if the SQLCODE is not 100, indicating unexpected termination, and displays a warning message if needed. // Loop until SQLCODE is not equal to 0 dow sqlCode = 0 ;   // Clear the data structure RecordDsC1   clear RecordDsC1;   // Fetch data into RecordDsC1 using cursor C1   exec sql fetch C1 into :RecordDsC1;   // If fetch was successful (SQLCODE = 0)   if sqlcode = 0 ;     // Assign values and write to output     W1QUEU = rDsW1QUEU;     write W1SF1;   endif; enddo; // Check if SQLCODE is not 100 (indicating unexpected termination) if sqlCode <> 100;   // Build a warning message   wMsg='Warning: +    The selection has terminated