ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

QUSLOBJ example in free-format?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • QUSLOBJ example in free-format?

    Does anyone have any example code using QUSLOBJ in free-format code? Google hasn't been helping me much.

    I've looked through Jamief's examples, but I'm rubbish at reading fixed format, having been working with RPG almost exclusively in free format.

  • #2
    Re: QUSLOBJ example in free-format?

    cant someone using that new fangled gui editor thing convert one for him?
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: QUSLOBJ example in free-format?

      I already ran it through the latest version of RDI's fixed to free format converter, but it left the majority of the code in fixed format. Sadly, this has been my experience with it most times I've tried it.

      Comment


      • #4
        Re: QUSLOBJ example in free-format?

        edit: nevermind, wrong api
        Last edited by MichaelCatalani; July 29, 2010, 02:29 PM.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: QUSLOBJ example in free-format?

          An example working with QGYOLOBJ would work too - I can't even find a good fixed-format on that one, much less a free format one.

          I really just need a good way to make a list of all objects in a library available to my code.

          Comment


          • #6
            Re: QUSLOBJ example in free-format?

            Hi vitaemachina:

            Craig Rutledge has some nice utilities
            Have a look here:


            In addition to qulsobjd (JCRLOBJ)
            Some of them assist in the conversion of fixed to free
            He has really done a great job but you have to download the entire package not just one utility

            Best of Luck
            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: QUSLOBJ example in free-format?

              or.... ignore the binary (Tom I love u)

              PHP Code:
                   H Option(*SrcStmt: *NoDebugIODftActGRP(*No)
                   
              À*
                   
              À*  Field Definitions.
                   
              À* ~~~~~~~~~~~~~~~~~~~~~~~~
                   
              D ObjNam          s             10a
                   D ObjLib          s             10a
                   D ObjTyp          s             10a
                   
              **-- Api error data structure:  ----------------------------------
                   
              D ApiError        Ds
                   D  AeBytPro                     10i 0 Inz
              ( %SizeApiError ))
                   
              D  AeBytAvl                     10i 0 Inz
                   D  AeMsgId                       7a
                   D                                1a
                   D  AeMsgDta                    128a
                   
              **-- Object description structure OBJD0200:  ---------------------
                   
              D RoData          Ds
                   D  RoBytRtn                     10i 0
                   D  RoBytAvl                     10i 0
                   D  RoObjNam                     10a
                   D  RoObjLib                     10a
                   D  RoObjTypRt                   10a
                   D  RoObjLibRt                   10a
                   D  RoObjASP                     10i 0
                   D  RoObjOwn                     10a
                   D  RoObjDmn                      2a
                   D  RoObjCrtDts                  13a
                   D  RoObjChgDts                  13a
                   D  RoExtAtr                     10a
                   D  RoTxtDsc                     50a
                   D  RoSrcF                       10a
                   D  RoSrcLib                     10a
                   D  RoSrcMbr                     10a

                   dTheData          DS
                   d QUSBR05                 1      4B 0
                   d QUSBA05                 5      8B 0
                   d QUSJN08                 9     18
                   d QUSUN07                19     28
                   d QUSJNBR07              29     34
                   d QUSIJID05              35     50
                   d QUSJS14                51     60
                   d QUSJT08                61     61
                   d QUSJS15                62     62
                   d QUSJS16                63     70
                   d QUSES00                71     71
                   d QUSSN00                72     81
                   d QUSSL06                82     91
                   d QUSCUN                 92    101
                   d QUSDE                 102    102
                   d QUSEK                 103    103
                   d QUSCK00               104    104
                   d QUSPRC                105    108B 0
                   d QUSURC                109    112B 0
                   d QUSPGMRC              113    116B 0
                   d QUSSE02               117    126
                   d QUSDN                 127    136
                   d QUSGPN                137    146
                   d QUSGRP                        10    DIM
              (00015)
                   
              d  QUSGN00                      10    OVERLAY(QUSGRP:00001)
                   
              d QUSJUID               297    306
                   d QUSJUIDS              307    307
                    
              *
                    *  
              Field Definitions.
                    *
                   
              d AllText         s             10    Inz('*ALL')
                   
              d CmdString       s            256
                   d CmdLength       s             15  5
                   d Count           s              4  0
                   d Format          s              8
                   d GenLen          s              8
                   d InLibrary       s             10
                   d InType          s             10
                   d ObjectLib       s             20
                   d SpaceVal        s              1    inz
              (*BLANKS)
                   
              d SpaceAuth       s             10    inz('*CHANGE')
                   
              d SpaceText       s             50    inz(*BLANKS)
                   
              d SpaceRepl       s             10    inz('*YES')
                   
              d SpaceAttr       s             10    inz(*BLANKS)
                   
              d UserSpaceOut    s             20
                   d Worktype        s             10    inz
              ('*OUTQ')
              À     *                                                                                            Ã„
              À     
              GenHdr                                                                                     Ã„
              À     
              *                                                                                            Ã„
                   d GenHdr          ds                  inz
                   d  OffSet                 1      4B 0
                   d  NumEnt                 9     12B 0
                   d  Lstsiz                13     16B 0
              À     
              *                                                                                            Ã„
              À     
              *  Data structures                                                                           Ã„
              À     
              *                                                                                            Ã„
                   d GENDS           ds
                   d  OffsetHdr              1      4B 0
                   d  NbrInList              9     12B 0
                   d  SizeEntry             13     16B 0
                    
              *
                   
              d HeaderDs        ds
                   d  OutFileNam             1     10
                   d  OutLibName            11     20
                   d  OutType               21     25
                   d  OutFormat             31     40
                   d  RecordLen             41     44B 0
                    
              *
                    * 
              API Error Data Structure
                    
              *
                   
              d ErrorDs         DS                  INZ
                   d  BytesPrv               1      4B 0
                   d  BytesAvl               5      8B 0
                   d  MessageId              9     15
                   d  ERR
              ###                16     16
                   
              d  MessageDta            17    116
                    
              *
                   
              d                 DS
                   d  StartPosit             1      4B 0
                   d  StartLen               5      8B 0
                   d  SpaceLen               9     12B 0
                   d  ReceiveLen            13     16B 0
                   d  MessageKey            17     20B 0
                   d  MsgDtaLen             21     24B 0
                   d  MsgQueNbr             25     28B 0
                    
              *
                    * 
              Date structure for retriving userspace info
                    
              *
                   
              d InputDs         DS
                   d  UserSpace              1     20
                   d  SpaceName              1     10
                   d  SpaceLib              11     20
                   d  InpFileLib            29     48
                   d  InpFFilNam            29     38
                   d  InpFFilLib            39     48
                   d  InpRcdFmt             49     58
                    
              *
                   
              d ObjectDs        ds
                   d  Object                       10
                   d  Library                      10
                   d  ObjectType                   10
                   d  InfoStatus                    1
                   d  ExtObjAttrib                 10
                   d  Description                  50

                   
              **-- Retrieve object description:  -------------------------------
                   
              d RtvObjD         Pr                  ExtPgm'QUSROBJD' )
                   
              d  RoRcvVar                  32767a         Options( *VarSize )
                   
              d  RoRcvVarLen                  10i 0 Const
                   
              d  RoFmtNam                      8a   Const
                   
              d  RoObjNamQ                    20a   Const
                   
              d  RoObjTyp                     10a   Const
                   
              d  RoError                   32767a         Options( *VarSize )
                   **-- List 
              objects:   ---------------------------------------------
                   
              d $ListObjects    Pr                  ExtPgm'QUSLOBJ' )
                   
              d  userspace                    20a   Const
                   
              d  format                        8a   Const
                   
              d  objectlib                    20a   Const
                   
              d  type                         10a   Const
                   **-- 
              Userspace pointer: ------------------------------------------
                   
              d $Userspace      Pr                  ExtPgm'QUSRTVUS' )
                   
              d  userspace                    20a   Const
                   
              d  start                        10i 0 Const
                   
              d  Length                       10i 0 Const
                   
              d  Returned                  32767a         Options( *VarSize )
                   **-- 
              Create Space:   ---------------------------------------------
                   
              d $CreateSpace    Pr                  ExtPgm'QUSCRTUS' )
                   
              d  UserSpaceOut                 20a   Const
                   
              d  SpaceAttr                    10    Const
                   
              d  SpaceLen                     10i 0 Const
                   
              d  SpaceVal                      1a   Const
                   
              d  SpaceAuth                    10a   Const
                   
              d  SpaceText                    50a   Const
                   
              d  SpaceRepl                    10a   Const
                   
              d  ErrorDs                   32767a         Options( *VarSize )

                    /
              free
                               exsr $QUSCRTUS
              ;
                               
              ObjectLib =  '*ALL      ' '*LIBL';
                       
              //
                       // List all the outqueues to the user space
                       //
                               
              Format 'OBJL0200';
                               
              $ListObjectsUserspace Format ObjectLib WorkType);
                       
              //
                       // Retrive header entry and process the user space
                       //
                               
              StartPosit 125;
                               
              StartLen   16;
                               
              $UserSpaceUserspace StartPosit StartLen GENDS);

                               
              StartPosit OffsetHdr 1;
                               
              StartLen = %size(ObjectDS);
                       
              //
              À        // Do for number of outqueues in the userspace                            Ã„
                       //

              B1               for count 1 to  NbrInList;
                                
              $UserSpaceUserspace StartPosit StartLen ObjectDs);
                                
              StartPosit += SizeEntry;
                               endfor;
                               *
              INLR = *On;

                      
              //--------------------------------------------------------
                      // $QUSCRTUS - create userspace
                      //--------------------------------------------------------
                               
              begsr $QUSCRTUS;

                                
              BytesPrv 116;
                                
              Spacename 'LISTOUTQS';
                                
              SpaceLib 'QTEMP';

                             
              //
                             // Create the user space
                             //
                                
              $CreateSpaceUserspace SpaceAttr 4096 :
                                              
              SpaceVal SpaceAuth SpaceText SpaceRepl:
                                              
              ErrorDs);
                               
              endsr;
                    /
              End-Free 
              Attached Files
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: QUSLOBJ example in free-format?

                Sheesh, so much for me thinking I'd be able to decipher it in free format any better.

                How do I actually work with the data retrieved? Like, for example if I just wanted to use dsply to list the object names?

                Comment


                • #9
                  Re: QUSLOBJ example in free-format?

                  put it in debug....


                  Code:
                  d Worktype        s             10    inz('*OUTQ')
                  The above could include, but is not limited to
                  *ALL *CSI
                  *ALRTBL *CSPMAP
                  *AUTL *CSPTBL
                  *BNDDIR *CTLD
                  *CFGL *DEVD
                  *CHTFMT *DOC
                  *CLD *DTAARA
                  *CLS *DTADCT
                  *CMD *DTAQ
                  *CNNL *EDTD
                  *COSD *EXITRG
                  *CRG *FCT
                  *CRQD *FILE
                  This is the loop that reads (in this case) all the outq's
                  PHP Code:
                   for count 1 to  NbrInList;
                                    
                  $UserSpaceUserspace StartPosit StartLen ObjectDs);
                                    
                  StartPosit += SizeEntry;
                                   endfor; 
                  NbrInList = total number of items in list...

                  place cursor on ObjectDs this is the data structure with all the data in it....




                  jamie
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: QUSLOBJ example in free-format?

                    Originally posted by vitaemachina View Post
                    Sheesh, so much for me thinking I'd be able to decipher it in free format any better.

                    How do I actually work with the data retrieved? Like, for example if I just wanted to use dsply to list the object names?
                    List api's are good candidates for using call back procedures. Create a wrapper for the api, and send it a procedure address to call each time it retrieves an item from the user space. This way, you can isolate the api into a service program, and not have to deal with mounds of code inside the actual program.
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: QUSLOBJ example in free-format?

                      I made a couple of changes to Jamie's / Tom's program to separate the api into a subprocedure. You can then move this into it's own service program and bind to it from the program, but for simplicity, I kept it in the program.

                      Code:
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]H Option(*SrcStmt: *NoDebugIO) DftActGRP(*No)               [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]d CallBackPTR     S               *   ProcPtr               [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]d ObjectDs        ds                  Qualified             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  Object                       10                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  Library                      10                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  ObjectType                   10                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  InfoStatus                    1                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  ExtObjAttrib                 10                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  Description                  50                          [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]d ProcessList     pr              n                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   Data                              LikeDS( ObjectDS )    [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]d RetrieveObjectList...                                     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d                 pr                                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   ObjectName                  10a   Const                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   LibraryName                 10a   Const                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   TypeObject                  10a   Const                               [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   CallBackPTR                   *   ProcPtr Const                       [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/free                                                                    [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]RetrieveObjectList( '*ALL' : 'QGPL' : '*FILE' : %paddr(ProcessList));[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*inlr = *on;                                                            [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/end-free                                                                [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]p ProcessList     b                                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d ProcessList     pi              n                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   Data                              LikeDS( ObjectDS )                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]/free                                                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]dsply Data.Object;                                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]return *on;                                                           [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]/end-free                                                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]P                 E                                                       [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]p RetrieveObjectList...                                                   [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]p                 b                                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d RetrieveObjectList...                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d                 pi                                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   ObjectName                  10a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   LibraryName                 10a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   TypeObject                  10a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   CallBackPTR                   *   ProcPtr  Const                [/COLOR][/SIZE]
                       
                       
                      [SIZE=2][COLOR=#ff0000]D CallBack        pr              n   ExtProc( CallBackPTR )        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   Data                              LikeDS( ObjectDS )            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]À*                                                                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]À*  Field Definitions.                                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]À* ~~~~~~~~~~~~~~~~~~~~~~~~                                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D ObjNam          s             10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D ObjLib          s             10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D ObjTyp          s             10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]**-- Api error data structure:  ----------------------------------  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D ApiError        Ds                                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  AeBytPro                     10i 0 Inz( %Size( ApiError )) [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]D  AeBytAvl                     10i 0 Inz                           [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  AeMsgId                       7a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D                                1a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  AeMsgDta                    128a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]**-- Object description structure OBJD0200:  ---------------------  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D RoData          Ds                                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoBytRtn                     10i 0                               [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoBytAvl                     10i 0                               [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjNam                     10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjLib                     10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjTypRt                   10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjLibRt                   10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjASP                     10i 0                               [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjOwn                     10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjDmn                      2a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjCrtDts                  13a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoObjChgDts                  13a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoExtAtr                     10a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoTxtDsc                     50a                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoSrcF                       10a  [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]D  RoSrcLib                     10a     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]D  RoSrcMbr                     10a     [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]dTheData          DS                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSBR05                 1      4B 0   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSBA05                 5      8B 0   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJN08                 9     18      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSUN07                19     28      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJNBR07              29     34      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSIJID05              35     50      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJS14                51     60      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJT08                61     61      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJS15                62     62      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJS16                63     70      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSES00                71     71      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSSN00                72     81      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSSL06                82     91      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSCUN                 92    101      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSDE                 102    102      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSEK                 103    103      d QUSCK00               104    104                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSPRC                105    108B 0                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSURC                109    112B 0                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSPGMRC              113    116B 0                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSSE02               117    126                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSDN                 127    136                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSGPN                137    146                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSGRP                        10    DIM(00015)                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  QUSGN00                      10    OVERLAY(QUSGRP:00001)        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJUID               297    306                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d QUSJUIDS              307    307                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*  Field Definitions.                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d AllText         s             10    Inz('*ALL')                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d CmdString       s            256                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d CmdLength       s             15  5                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d Count           s              4  0                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d Format          s              8                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d GenLen          s              8                                 d InLibrary       s             10                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d InType          s             10                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d ObjectLib       s             20                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d SpaceVal        s              1    inz(*BLANKS)    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d SpaceAuth       s             10    inz('*CHANGE')  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d SpaceText       s             50    inz(*BLANKS)    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d SpaceRepl       s             10    inz('*YES')     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d SpaceAttr       s             10    inz(*BLANKS)    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d UserSpaceOut    s             20                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d Worktype        s             10    inz('*OUTQ')    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]* GenHdr                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d GenHdr          ds                  inz             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OffSet                 1      4B 0                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  NumEnt                 9     12B 0                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  Lstsiz                13     16B 0                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*  Data structures                                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                        [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]d GENDS           ds                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OffsetHdr              1      4B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  NbrInList              9     12B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SizeEntry             13     16B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d HeaderDs        ds                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OutFileNam             1     10            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OutLibName            11     20            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OutType               21     25            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  OutFormat             31     40            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RecordLen             41     44B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]* API Error Data Structure                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d ErrorDs         DS                  INZ     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  BytesPrv               1      4B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  BytesAvl               5      8B 0         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  MessageId              9     15            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  ERR###                16     16            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  MessageDta            17    116                                                           [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]*                                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d                 DS                                     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  StartPosit             1      4B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  StartLen               5      8B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceLen               9     12B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  ReceiveLen            13     16B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  MessageKey            17     20B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  MsgDtaLen             21     24B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  MsgQueNbr             25     28B 0                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]* Date structure for retriving userspace info           [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*                                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d InputDs         DS                                     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  UserSpace              1     20                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceName              1     10                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceLib              11     20                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  InpFileLib            29     48                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  InpFFilNam            29     38                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  InpFFilLib            39     48                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  InpRcdFmt             49     58                       [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]*                                                                 [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]**-- Retrieve object description:  ------------------------------- [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d RtvObjD         Pr                  ExtPgm( 'QUSROBJD' )         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoRcvVar                  32767a         Options( *VarSize )    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoRcvVarLen                  10i 0 Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoFmtNam                      8a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoObjNamQ                    20a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoObjTyp                     10a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  RoError                   32767a         Options( *VarSize )    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]**-- List objects:   --------------------------------------------- [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d $ListObjects    Pr                  ExtPgm( 'QUSLOBJ' )          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  userspace                    20a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  format                        8a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  objectlib                    20a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  type                         10a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]**-- Userspace pointer: ------------------------------------------ [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d $Userspace      Pr                  ExtPgm( 'QUSRTVUS' )         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  userspace                    20a   Const                        [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  start                        10i 0 Const                        [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]d  Length                       10i 0 Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  Returned                  32767a         Options( *VarSize )     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]**-- Create Space:   ---------------------------------------------  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d $CreateSpace    Pr                  ExtPgm( 'QUSCRTUS' )          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  UserSpaceOut                 20a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceAttr                    10    Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceLen                     10i 0 Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceVal                      1a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceAuth                    10a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceText                    50a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  SpaceRepl                    10a   Const                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d  ErrorDs                   32767a         Options( *VarSize )     [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/free                                                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        exsr $QUSCRTUS;                                         [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        ObjectLib =  ObjectName + LibraryName;                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]// List all the outqueues to the user space                     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                              [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        Format = 'OBJL0200';                                    [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]        $ListObjects( Userspace : Format : ObjectLib : TypeObject);  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]// Retrive header entry and process the user space                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        StartPosit = 125;                                            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        StartLen   = 16;                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        $UserSpace( Userspace : StartPosit : StartLen : GENDS);      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        StartPosit = OffsetHdr + 1;                                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        StartLen = %size(ObjectDS);                                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                                   [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]// Do for number of outqueues in the userspace                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//                                                                   [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]        for count = 1 to  NbrInList;                                 [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         $UserSpace( Userspace : StartPosit : StartLen : ObjectDs);  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         if NOT CallBack( ObjectDS );                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         return;                                                     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         endif;                                                      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         StartPosit += SizeEntry;                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        endfor;                                                      [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]        return;                                                      [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]//--------------------------------------------------------            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]// $QUSCRTUS - create userspace                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]//--------------------------------------------------------            [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]        begsr $QUSCRTUS;                                             [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]         BytesPrv = 116;                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         Spacename = 'LISTOUTQS';                                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]         SpaceLib = 'QTEMP';                                         [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]      //                                                             [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]      // Create the user space                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]      //                                                             [/COLOR][/SIZE]
                       
                       
                      [SIZE=2][COLOR=#ff0000]                   $CreateSpace( Userspace : SpaceAttr : 4096 :      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]                                 SpaceVal : SpaceAuth : SpaceText :  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000] SpaceRepl:                                                          [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]                                 ErrorDs);                           [/COLOR][/SIZE][/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]                  endsr;                    [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]/End-Free                                      [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]p                 e                                                                                           [/COLOR][/SIZE]
                      [/COLOR][/SIZE]

                      Wrapping the api with a callback procedure can greatly simplifiy the program by isolating the ugly api code stuff outside of our program.


                      Some changes need to be made to this subprocedure to make it better. Instead of the ObjectDS data structure, we should be passing the Format Data Structure to ensure all of the fields in the format can be accessed.

                      The callback procedure passes back a logical return value. This is so that we can stop the list api at any point. So if the list api returns a few thousand items, but we get what we need on the 5th item, we can return an *off to the subprocedure, and it will terminate looping thru the entries.

                      If we encapsulated the subprocedure into a service program, and utilizzed copy members for the prototype and format data structure, then any program that utilized this api could be simplified down to the following:


                      Code:
                      [SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#000000]H Option(*SrcStmt: *NoDebugIO) DftActGRP(*No)               [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]d CallBackPTR     S               *   ProcPtr               [/COLOR][/SIZE]
                       /copy The format data structure[SIZE=2][COLOR=#ff0000] ProcessList     pr              n                         [/COLOR][/SIZE]
                       /copy The prototype for the subprocedure that contains the QUSRLOBJ api
                       
                      [SIZE=2][COLOR=#ff0000]d   Data                              LikeDS( Format Data Structure )    [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/free                                                                    [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]RetrieveObjectList( '*ALL' : 'QGPL' : '*FILE' : %paddr(ProcessList));[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]*inlr = *on;                                                            [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/end-free                                                                [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]p ProcessList     b                                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d ProcessList     pi              n                                       [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]d   Data                              LikeDS( Format Data Structure )                  [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]/free     [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]// ******* Do stuff with the list entries                                                               [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]if we are done;                                               [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]  return *off; [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]else;[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]  return *on;[/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]endif;                   [/COLOR][/SIZE]
                       
                      [SIZE=2][COLOR=#ff0000]/end-free                                                                [/COLOR][/SIZE]
                      [SIZE=2][COLOR=#ff0000]P                 E    [/COLOR][/SIZE]
                      [/COLOR][/SIZE]
                      Last edited by MichaelCatalani; July 29, 2010, 06:02 PM.
                      Michael Catalani
                      IS Director, eCommerce & Web Development
                      Acceptance Insurance Corporation
                      www.AcceptanceInsurance.com
                      www.ProvatoSys.com

                      Comment


                      • #12
                        Re: QUSLOBJ example in free-format?

                        it's not my code...that's all Jamie's. he was mentioning me simply because i always give him a hard time about using the "B" data type instead of integer.

                        for all list APIs that return data in a user space i use a service program designed specifically for the user space API's. that service program can be downloaded from my website (in the downloads section of course) http://tommyholden.com and there's no "B" data types used
                        I'm not anti-social, I just don't like people -Tommy Holden

                        Comment


                        • #13
                          Re: QUSLOBJ example in free-format?

                          I really appreciate the help, Michael.

                          On this same subject - how would I list the members inside source files? I would assume a different API would be required, but a quick romp through the info center isn't turning up any likely candidates.

                          Comment


                          • #14
                            Re: QUSLOBJ example in free-format?

                            QUSLMBR API is what you are looking for. http://publib.boulder.ibm.com/infoce...is/quslmbr.htm
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: QUSLOBJ example in free-format?

                              So it is! I got thrown by how it was described. Looks like Scott Klement has a bit of code that uses it amidst his pointer tutorial, so off I go to see if I can integrate them.

                              Comment

                              Working...
                              X