Ich mache das (seit V5R2) so:

Code:
 * --------------------------------------------------------
 * API-Definitionen CALLSTACK                              
 * --------------------------------------------------------
DGetStack         pr                  extpgm('QWVRCSTK')   
d                             2000                         
d                               10I 0 const                
d                                8    const                
d                               56                         
d                                8    const                
d                               16                         
                                                          
dStackInfo        ds          2000                          
d ByteAvail                     10I 0 inz(%size(StackInfo)) 
d ByteReturn                    10I 0                       
d Entries                       10I 0                       
d Offset                        10I 0                       
d Count                         10I 0                       
                                                            
dApiErr           ds                                        
d ErrAvail                      10I 0 inz(16)               
d ErrReturn                     10I 0                       
d ErrReserv                      1                          
d ErrMsg                         7                          
                                                            
dStackID          ds                                        
d IdInfo                        26    inz('*')              
d IdInt                         16    inz                   
d IdRes                          2    inz(*loval)           
d IdThread                      10I 0 inz(1)                
d IdThId                         8    inz(*loval)           
                                                           
dStackPtr         s               *                   
dStackEntry       ds                  based(StackPtr) 
d EntryLen                      10I 0                 
d EntryDispSt                   10I 0                 
d EntryStmtNo                   10I 0                 
d EntryDispPr                   10I 0                 
d EntryProcLen                  10I 0                 
d EntryReqLvl                   10I 0                 
d EntryPgm                      10                    
d EntryLib                      10                    
                                                      
d StackAct        s             10I 0                 
d FirstQ          s              1                    
                                                     
c/free
         callp GetStack(StackInfo:%size(StackInfo):'CSTK0100' 
                        :StackId:'JIDF0100':ApiErr);          
         if ErrReturn = *zero;                                
            StackPtr = %addr(StackInfo) + Offset;             
            FirstQ = *off;                                    
            for StackAct = 0 to Entries - 1;                  
                if FirstQ = *off;                             
                   if %subst(EntryPgm:1:1) = 'Q';             
                      FirstQ = *on;                           
                   endif;                                     
                else;                                         
                   if %subst(EntryPgm:1:1) <> 'Q'             
                   or EntryLib <> 'QSYS';                     
                      LEPROG = EntryPgm;   // gefundenes Programm
                      LEPLIB = EntryLib;       // in Lib
                      leave;                                  
                   endif;                                     
                endif;                                        
                StackPtr += EntryLen;                         
            endfor;                                          
 /endfree