RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Blog - Content Section Layout
Changing the CCSID of an IFS File
User Rating: / 0
Written by Chamara Withanachchi   

From time to time, you'll find a stream file in your IFS that's marked with the wrong CCSID. I recently had a problem where a file in my IFS was full of ASCII data but was marked as CCSID 37 (US EBCDIC). This was a problem because the IBM-supplied commands didn't convert the data, since they thought it was already in EBCDIC.

The CHGATR command can be used to change the CCSID of a stream file. Here's an example:

CHGATR OBJ('/path/to/myfile.txt') ATR(*CCSID) VALUE(819)

Another way to do the same thing is with the SETCCSID command in QShell. Here's an example of that command:

STRQSH CMD('setccsid 819 /path/to/myfile.txt')

If the data in the stream file also needs to be converted, you can use QShell's ICONV command to convert it. This does not set the CCSID of the resulting file properly, but we already know how to fix that!

The following command converts the data in MYFILE.TXT from CCSID 37 to CCSID 819 and writes the output to YOURFILE.TXT:

STRQSH CMD('iconv -f 37 -t 819 /path/to/myfile.txt > /path/to/yourfile.txt 
&& setccsid 819 /path/to/yourfile.txt')
Another way to convert the data in the file is with the CPY CL command. Here's an example of that: [code] CPY OBJ('/path/to/myfile.txt') TOOBJ('/path/to/yourfile.txt') + FROMCCSID(37) TOCCSID(819) DTAFMT(*TEXT) [/code]Write Comment (0 comments)
User Rating: / 0
Written by Chamara Withanachchi   

The Process Commands (QCAPCMD) API is used to perform command analyzer processing on command strings. You can check or run CL commands from HLLs as well as check syntax for specific source definition types.

You can use the QCAPCMD API to:

Check the syntax of a command string prior to running it

Prompt the command and receive the changed command string

Run a command from an HLL

Sample codes are from www.code400.com, Jamie Flanary

     dchangedCmd       s            512    inz                                                      
     dcmdstring        s            512    inz                                                      
     dcmdlength        s             10i 0 inz                                                      
     dcmdAvailLen      s             10i 0 inz                                                      
     dcmdChangeLen     s             10i 0 inz                                                      
     docbDS            ds                  Qualified                                                
     d type                          10i 0 inz                                                      
     d DBCSdh                         1    inz('0')                                                 
     d prompt                         1    inz('0')                                                 
     d cmdsyntax                      1    inz('0')                                                 
     d msgrtvkey                      4    inz(x'00000000')                                         
     d reserve1                       9    inz(x'000000000000000000')                               
     d ocblength                     10i 0 inz                                                      
     d formatName                     8    inz('CPOP0100')                                          
     d chgcmd                         1    inz                                                      
     d lngchgcmd                     10i 0 inz                                                      
     d lngchgrtn                     10i 0 inz                                                      
     d $command        pr                  extpgm('QCAPCMD')                                        
     d   cmdstring                  512    const                                                    
     d   cmdlength                   10i 0 const                                                    
     d   ocb                               likeds(ocbDS)                                            
     d   ocblength                   10i 0 const                                                    
     d   FormatName                   8    const                                                    
     d   ChangedCmd                 512    const                                                    
     d   LenAvailChgd                10i 0 const                                                    
     d   LenChgdCmd                  10i 0 const                                                    
     d   ApiError                          likeds(APIErrorDS)                                         
     d APIErrorDS      ds                  Qualified                                                
     d  BytesP                       10I 0 inz(%size(apiErrorDS))                                   
     d  BytesA                       10I 0 inz(0)                                                   
     d  Messageid                     7                                                             
     d  Reserved                      1                                                             
     d  messagedta                  240                                                             
      *  Program Information                                                                        
     d progstatus     sds                                                                           
     d  parms            *parms                                                                     
     d  progname         *proc                                                                      
     d  errmsgID                      7    overlay(ProgStatus:40)                                   
     d  errmsg                       80    overlay(ProgStatus:91)                                   
     d  jobname                      10    overlay(ProgStatus:244)                                  
     d  userid                       10    overlay(ProgStatus:254)                                  
     d  Jobnumber                     7    overlay(ProgStatus:264)                                  
                 // --------------------- QCAPCMD  ------------------------                         
                cmdstring = 'ADDLIBLE NOLIBRARY';                                                   
                cmdlength = %len(%trim(cmdstring));                                                 
                $command(cmdstring    :                                                             
                         cmdlength    :                                                             
                         ocbds        :                                                             
                         %len(ocbDS)  :                                                             
                         'CPOP0100'   :                                                             
                         changedCmd   :                                                             
                         cmdAvailLen  :                                                             
                         cmdChangeLen :                                                             
Build, Add entries to DATQ
User Rating: / 0
Written by Chamara Withanachchi   

Originally from www.code400.com

     d TimeStamp       s               Z                                                            
     d IsOdate         s               D                                                            
     d Count           s              4  0                                                          
     d Count2          s              4  0                                                          
     d CmdString       s            256                                                             
     d CmdLength       s             15  5                                                          
     d Reply           s              1                                                             
     d Chr26           s             26                                                             
      * The defined fields for the QRCVDTAQ                                                         
     d   DtaqName      s             10A   inz('TEST')                                              
     d   DtaqLib       s             10A   inz('JAMIELIB')                                          
     d   DtaqLen       s              5P 0 inz(1000)                                                
     d   Data          s             40A                                                            
     d   WaitTime      s              5P 0 inz(-1)                                                  
     d   KeyOrder      s              2A                                                            
     d   KeyLen        s              3P 0                                                          
     d   KeyData       s          32766A                                                            
     d   SenderLen     s              3P 0                                                          
     d   SenderInfo    s          32766A                                                            
     d   RmvMsg        s             10A   inz('*YES')                                              
     d   RcvVarSize    s              5P 0                                                          
     d   ErrorCode     s          32766A                                                            
     d   Receiver      s           2322                                                             
     d   ReceiverLen   s              4B 0 inz(2322)                                                
     d   ReceiverFmt   s              8    inz('RDQM0100')                                          
     d   DataQName     s             20    inz('TEST      JAMIELIB')                                
     d   MessageSel    s            272                                                             
     d   MessageSelLn  s              4B 0 inz(32)                                                  
     d   MessageFmt    s              8    inz('RDQS0200')                                          
     d   Error         s              4B 0 inz(0)                                                   
      * constants                                                                                   
     d Q               c                   const('''')                                              
     ** Delete the message queue                                                                    
     c                   eval      cmdstring = 'DLTDTAQ TESTLIB/TEST'                              
     c                   eval      cmdlength = %len(%trim(cmdstring))                               
     c                   call(e)   'QCMDEXC'                                                        
     c                   parm                    cmdstring                                          
     c                   parm                    cmdlength                                          
     ** CRTDTAQ DTAQ(QTEMP/TEST) MAXLEN(1000) SEQ(*KEYED)                                           
     ** KEYLEN(05) SENDERID(*YES)                                                                   
     c                   eval      cmdstring = 'CRTDTAQ DTAQ(TESTLIB/TEST) '  +                    
     c                             'MAXLEN(1000) SENDERID(*YES)'              +                     
     c                             ' TEXT(' + Q + 'test dataq'+ Q + ')'                             
     c                   eval      cmdlength = %len(%trim(cmdstring))                               
     c                   call(e)   'QCMDEXC'                                                        
     c                   parm                    cmdstring                                          
     c                   parm                    cmdlength                                          
     ** Clear data queue                                                                            
     c                   call(e)   'QCLRDTAQ'                                                       
     c                   parm                    DtaqName                                           
     c                   parm                    DtaqLib                                            
     c                   for       Count = 1 to 5                                                   
     c                   eval      Data = 'Test entry' + %char(Count) +                             
     c                                     '-' + %char(%time())                                     
     c                   call(e)   'QSNDDTAQ'                                                       
     c                   parm                    DtaqName                     Data queue name       
     c                   parm                    DtaqLib                      Data queue library    
     c                   parm                    DtaqLen                      Data queue length     
     c                   parm                    Data                         Queued data           
     c                   endfor                                                                     
     c                   eval      *INLR = *on     

Write Comment (0 comments)
Using C function STRTOK to read .csv table
User Rating: / 4
Written by Chamara Withanachchi   

Originaly from Jamie Flanary, Code400.com

     h dftactgrp(*no) actgrp(*caller) option(*srcstmt)
     h bnddir('QC2LE')

     d counter         s              3s 0
     d displayme       s             20
     d isodate         s               d   inz
     d n12             s             12s 0
     d pointer         s               *
     d reply           s              1
     d response        s           4096a
     d rundte          s              6s 0
     d  token          S            160A   varying
     d                 DS

     dstrtok           PR              *   ExtProc('strtok')
     d string                          *   value options(*string)
     d delim                           *   Value Options(*string)


         response  =  'tree,dog,bird,,cow,horse,flower';
         response = %scanrpl(',,' : ', ,' : response);
         reset counter;
         pointer = strtok(response: ',');

         dow (pointer <> *null);
          token = %trim(%str(pointer));
          pointer = strtok(*null: ',');
          displayme = %trim(token);
          dsply displayme reply;

         *inlr = *on; 


Write Comment (1 comments)
V6R1 Upgrade Check List
User Rating: / 0
Written by Chamara Withanachchi   

By Steve Pitcher

Given that you'll be up to your neck in lengthy IBM manuals, webcasts and white papers while planning a move to V6R1, I've compiled a handy list of points to consider when preparing for the upgrade.

The major caveat with this upgrade is the object conversion, which is similar to the CISC to RISC conversion when moving from the 48 to the 64-bit address space introduced in the PowerPC RISC processor about 15 years ago. This conversion, however, promises to be much easier and faster.


  • Review the manual "Install, upgrade, or delete i5/OS and related software" at the V6R1 Information Center. This is your bible, and it couldn't hurt to have a printed copy handy.

  • If you're not already on a supported release of i5/OS, bring your server up to V5R3 or V5R4 in order to upgrade to V6R1.

  • Review current system software that isn't supported on V6R1. Get the V5R4 software product and its V6R1 suggested replacement, if available.

  • Ensure that your current server supports the new operating system. The following models are supported: 60X, 61X, M15, M25, M50, E4A, E8A, EMA, MMA, FHA, 515, 520, 525, 550, 570, 595, 800, 810, 825, 870, and 890.

  • Ensure your programs will function in V6R1. You should run the Analyze Object Conversion (ANZOBJCVN) tool to make sure your programs have observability. If they don't, they will not convert and, therefore, not function in the new release. This tool is available by PTF. It's best to run it a couple of months in advance, in case some programs do not make the grade.

  • If using third-party applications, check with your ISVs to ensure their currently installed product will be supported after the upgrade. If not, check if your vendor has a V6R1-ready version that you must upgrade to in advance. Even so, run the ANZOBJCVN tool on anything the vendor certifies on V6R1 just in case. In the end, you're responsible for the applications to successfully run on your server post upgrade and you have the tools to prove they will.

  • Install mandatory PTFs for upgrading to V6R1.

  • Order the most recent cumulative, HIPER, group and application specific PTFs to install as part of the upgrade.

  • Review "PSP i5/OS memo to users V6R1." There are plenty of gold nuggets in there, many specific to your current configuration, that I couldn't cover in a quick checklist.

  • Review "PSP software installation information for V6R1."

  • If you run Lotus Domino and subsequent Quickr, Quickplace, Sametime or related servers, be sure to read "i5/OS V6R1 upgrade roadmap for Lotus Domino and related products." You'll want to ensure that you're on a supported Lotus release. Also, be sure to disable Domino auto-start and run the appropriate product conversion programs before you start your Domino servers. You would not want product conversion to take place as you're bringing your Domino servers up the first time. It's best to get this done out of the way in advance.

  • If you have old SPD hardware on V5R3, you must have a plan to move off this hardware before moving to V5R4 or V6R1. SPD support is nonexistent after V5R3.

  • Before upgrading, you have the opportunity to permanently apply temporarily applied PTFs. This is a space saver and isn't a bad idea.

  • Order your license keys and prepare to install them via the Web. Don't waste your time typing them in.

  • Ensure you have some backup media. We've all spent time looking for a couple of before/after tapes a few hours before a big upgrade.

  • Make sure you know your SST and DST passwords. Test them.

  • Use image catalogs to do the install. It's much faster than loading CDs or DVDs.

This is not an all inclusive list by any means, but it's a start. Do your due diligence, ask questions of people who've done the upgrade, talk to your business partner, read your manuals and get re-acquainted with your server room. All you need then is a deck of cards.

<< Start < Previous 1 2 3 4 5 6 7 8 9 10 Next > End >>

Results 61 - 70 of 626