midrange.com code scratchpad
Name:
Command PRTLMTCMD
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
07/18/2008 07:11:30 am
IP:
Logged
Description:
Print Allow Limit User Command with API list object QUSLOBJ, Retrieve command information QCDRCMDI
Code:
  1. <pre>
  2. <b>
  3. File   : QRPGLESRC
  4. Member : PRTLMTCMD
  5. Type   : RPGLE
  6. Usage  : CRTBNDRPG PGM(PRTLMTCMD) TGTRLS(V5R1M0)
  7. </b>
  8.      **
  9.      **  Program . . : PrtLmtCmd
  10.      **  Description : Print Allow Limit User Command
  11.      **  Author  . . : Vengoal Chang
  12.      **
  13.      **  Input parameters
  14.      **   Description        Type  Size    How Used
  15.      **   -----------        ----  ----    --------
  16.      **   InLibary           Char  10      Library to search for objects
  17.      **
  18.      **
  19.      **  Compile options:
  20.      **
  21.      **    CrtBndRpg  Pgm( PrtLmtCmd )
  22.      **               DbgView( *LIST ) TgtRls(V5R1M0)
  23.      **
  24.      **
  25.      **-- Header Specifications:  --------------------------------------------**
  26.      H DEBUG  OPTION(*SRCSTMT:*NODEBUGIO) DFTACTGRP(*NO) ACTGRP(*NEW)
  27.      FQSYSPRT   O    F  132        Printer
  28.       *
  29.       * Program Info
  30.       *
  31.      d                SDS
  32.      d  @PGM                   1     10
  33.      d  @PARMS                37     39  0
  34.      d  @JOB                 244    253
  35.      d  @USER                254    263
  36.      d  @JOB#                264    269  0
  37.       *
  38.       *  Field Definitions.
  39.       *
  40.      d AllText         s             10    Inz('*ALL')
  41.      d CmdString       s            256
  42.      d CmdLength       s             15  5
  43.      d Count           s              4  0
  44.      d Format          s              8
  45.      d GenLen          s              8
  46.      d InLibrary       s             10
  47.      d InType          s             10    inz('*CMD')
  48.      d ObjectLib       s             20
  49.      d SpaceVal        s              1    inz(*BLANKS)
  50.      d SpaceAuth       s             10    inz('*CHANGE')
  51.      d SpaceText       s             50    inz(*BLANKS)
  52.      d SpaceRepl       s             10    inz('*YES')
  53.      d SpaceAttr       s             10    inz(*BLANKS)
  54.      d UserSpaceOut    s             20
  55. ?    *                                                                                            ?
  56. ?    *  Data structures                                                                           ?
  57. ?    *                                                                                            ?
  58.      d GENDS           ds
  59.      d  OffsetHdr              1      4i 0
  60.      d  NbrInList              9     12i 0
  61.      d  SizeEntry             13     16i 0
  62.       *
  63.       * Create userspace datastructure
  64.       *
  65.      d                 DS
  66.      d  StartPosit                   10i 0
  67.      d  StartLen                     10i 0
  68.      d  SpaceLen                     10i 0
  69.       *
  70.       * Date structure for retriving userspace info
  71.       *
  72.      d InputDs         DS
  73.      d  UserSpace              1     20
  74.      d  SpaceName              1     10
  75.      d  SpaceLib              11     20
  76.      d  InpFileLib            29     48
  77.      d  InpFFilNam            29     38
  78.      d  InpFFilLib            39     48
  79.      d  InpRcdFmt             49     58
  80.       *
  81.      d ObjectDs        ds
  82.      d  Object                       10
  83.      d  Library                      10
  84.      d  ObjectType                   10
  85.      d  InfoStatus                    1
  86.      d  ExtObjAttrib                 10
  87.      d  Description                  50
  88.  
  89.      **-- API Error Data Structure:
  90.      D ERRC0100        Ds                  Qualified  Inz
  91.      D  BytPrv                       10i 0 Inz( %Size( ERRC0100 ))
  92.      D  BytAvl                       10i 0
  93.      D  MsgId                         7a
  94.      D                                1a
  95.      D  MsgDta                     1024a
  96.  
  97.      **-- Global constants:
  98.      D OFS_MSGDTA      c                   16
  99.  
  100.      **-- Command information:
  101.      D CMDI0100        Ds         10240    Qualified  Inz
  102.      D  BytRtn                       10i 0
  103.      D  BytAvl                       10i 0
  104.      D  CmdNam_q                     20a
  105.      D   CmdNam                      10a   Overlay( CmdNam_q:  1 )
  106.      D   CmdLib                      10a   Overlay( CmdNam_q: 11 )
  107.      D  CmdPgm_q                     20a
  108.      D   PgmNam                      10a   Overlay( CmdPgm_q:  1 )
  109.      D   PgmLib                      10a   Overlay( CmdPgm_q: 11 )
  110.      D  SrcFil                       10a
  111.      D  SrcLib                       10a
  112.      D  SrcMbr                       10a
  113.      D  VcpNam                       10a
  114.      D  VcpLib                       10a
  115.      D  ModeInf                      10a
  116.      D  AlwInf                       15a
  117.      D  AlwLmtUsr                     1a
  118.      D  MaxPos                       10i 0
  119.      D  PmtMsfNam                    10a
  120.      D  PmtMsfLib                    10a
  121.      D  MsgFilNam                    10a
  122.      D  MsgFilLib                    10a
  123.      D  HlpPngNam                    10a
  124.      D  HlpPngLib                    10a
  125.      D  HlpId                        10a
  126.      D  SchIdxNam                    10a
  127.      D  SchIdxLib                    10a
  128.      D  CurLib                       10a
  129.      D  PrdLib                       10a
  130.      D  PopNam                       10a
  131.      D  PopLib                       10a
  132.      D  RstTgtRls                     6a
  133.      D  TxtDsc                       50a
  134.      D  CppCalStt                     2a
  135.      D  VcpCalStt                     2a
  136.      D  PopCalStt                     2a
  137.      D  OfsHlpBks                    10i 0
  138.      D  LenHlpBks                    10i 0
  139.      D  CcsId                        10i 0
  140.      D  EnbGui                        1a
  141.      D  ThdSafInd                     1a
  142.      D  MltJobAcn                     1a
  143.      D  PxyCmdInd                     1a
  144.      D                               14a
  145.  
  146.      **-- Retrieve command information:
  147.      D RtvCmdInf       Pr                  ExtPgm( 'QCDRCMDI' )
  148.      D  RcvVar                    65535a          Options( *VarSize )
  149.      D  RcvVarLen                    10i 0 Const
  150.      D  FmtNam                       10a   Const
  151.      D  CmdNam_q                     20a   Const
  152.      D  Error                     32767a          Options( *VarSize )
  153.  
  154.      **-- Send program message:
  155.      D SndPgmMsg       Pr                  ExtPgm( 'QMHSNDPM' )
  156.      D  MsgId                         7a   Const
  157.      D  MsgFil_q                     20a   Const
  158.      D  MsgDta                      128a   Const
  159.      D  MsgDtaLen                    10i 0 Const
  160.      D  MsgTyp                       10a   Const
  161.      D  CalStkE                      10a   Const  Options( *VarSize )
  162.      D  CalStkCtr                    10i 0 Const
  163.      D  MsgKey                        4a
  164.      D  Error                     32767a          Options( *VarSize )
  165.  
  166.      **-- Send completion message:
  167.      D SndCmpMsg       Pr            10i 0
  168.      D  PxMsgId                       7a   Const
  169.      D  PxMsgFil                     10a   Const
  170.      D  PxMsgDta                    512a   Const  Varying
  171.  
  172.      **-- Parameter definitions:
  173.      D ObjNam_q        Ds                  Qualified
  174.      D  ObjNam                       10a
  175.      D  ObjLib                       10a
  176.  
  177.      D ERRMSGID        S              7a
  178.      D firstRcd        S               N   INZ('1')
  179.      D matchRcd        S               N
  180. ?    *                                                                                            ?
  181.       *  Create a userspace
  182.       *
  183.      c                   exsr      $QUSCRTUS
  184.       *
  185.      c                   eval      ObjectLib =  AllText + InLibrary
  186.       *
  187.       * List all the objects to the user space
  188.       *
  189.      c                   eval      Format = 'OBJL0200'
  190.       *
  191.      c                   call(e)   'QUSLOBJ'
  192.      c                   parm      Userspace     UserSpaceOut
  193.      c                   parm                    Format
  194.      c                   parm                    ObjectLib
  195.      c                   parm      '*CMD'        InType
  196.       *
  197.       * Retrive header entry and process the user space
  198.       *
  199.      c                   eval      StartPosit = 125
  200.      c                   eval      StartLen   = 16
  201.       *
  202.       * Retrive header entry and process the user space
  203.       *
  204.      c                   call      'QUSRTVUS'
  205.      c                   parm      UserSpace     UserSpaceOut
  206.      c                   parm                    StartPosit
  207.      c                   parm                    StartLen
  208.      c                   parm                    GENDS
  209.       *
  210.      c                   eval      StartPosit = OffsetHdr + 1
  211.      c                   eval      StartLen = %size(ObjectDS)
  212.       *
  213.       *
  214. ?    *  Do for number of fields                                                                   ?
  215.       *
  216.      c                   if        NbrInList > 0
  217.  
  218. B1   c                   Do        NbrInList
  219.       *
  220.      c                   call(e)   'QUSRTVUS'
  221.      c                   parm      UserSpace     UserSpaceOut
  222.      c                   parm                    StartPosit
  223.      c                   parm                    StartLen
  224.      c                   parm                    ObjectDs
  225.       *
  226.      c                   eval      ObjNam_q.ObjLib = Library
  227.      c                   eval      ObjNam_q.ObjNam = Object
  228.      c
  229.      c                   callp     RtvCmdInf( CMDI0100
  230.      c                                       : %Size( CMDI0100 )
  231.      c                                       : 'CMDI0100'
  232.      c                                       : ObjNam_q
  233.      c                                       : ERRC0100
  234.      c                                      )
  235.      c                   If        ERRC0100.BytAvl > *Zero
  236.      c
  237.      c                   If        ERRC0100.BytAvl < OFS_MSGDTA
  238.      c                   eval      ERRC0100.BytAvl = OFS_MSGDTA
  239.      c                   EndIf
  240.      c                   eval      ErrMsgId = ERRC0100.MsgId
  241.      c                   If        ErrMsgId <> 'CPF6250'
  242.      c                   except    error
  243.      c                   EndIf
  244.      c                   Else
  245.      c                   If        (CMDI0100.AlwLmtUsr = '1')
  246.      c                   If        firstRcd
  247.      c                   except    head
  248.      c                   eval      firstRcd = *Off
  249.      c                   eval      matchRcd = *On
  250.      c                   EndIf
  251.      c                   except    detail
  252.      c                   EndIf
  253.      c                   EndIf
  254.  
  255.      c                   eval      StartPosit = StartPosit + SizeEntry
  256.      c                   EndDo
  257.  
  258.      c                   EndIf
  259.  
  260.      c                   If        matchRcd
  261.      c                   callp     SndCmpMsg( 'CPF9898'
  262.      c                                       :'QCPFMSG'
  263.      c                                       :'Print allow limit user command' +
  264.      c                                        ' on library ' + %trim(InLibrary)+
  265.      c                                        ' completed'
  266.      c                                       )
  267.      c                   Else
  268.      c                   callp     SndCmpMsg( 'CPF9898'
  269.      c                                       :'QCPFMSG'
  270.      c                                       :'Library ' + %trim(InLibrary)    +
  271.      c                                        ' no any allow limit user command'
  272.      c                                       )
  273.      c                   EndIf
  274.       *
  275.      c                   eval      *Inlr = *On
  276.       *===============================================
  277.       * $QUSCRTUS - API to create user space
  278.       *===============================================
  279.      c     $QUSCRTUS     begsr
  280.       *
  281.       * Create a user space named ListObjects in QTEMP.
  282.       *
  283.      c                   movel(p)  'LISTOBJECTS' SpaceName
  284.      c                   movel(p)  'QTEMP'       SpaceLib
  285.       *
  286.       * Create the user space
  287.       *
  288.      c                   call(e)   'QUSCRTUS'
  289.      c                   parm      UserSpace     UserSpaceOut
  290.      c                   parm                    SpaceAttr
  291.      c                   parm      4096          SpaceLen
  292.      c                   parm                    SpaceVal
  293.      c                   parm                    SpaceAuth
  294.      c                   parm                    SpaceText
  295.      c                   parm                    SpaceRepl
  296.      c                   parm                    ERRC0100
  297.       *
  298.      c                   endsr
  299.       *=================================================
  300.       *    *Inzsr - One time run House keeping subroutine
  301.       *=================================================
  302.      c     *Inzsr        begsr
  303.       *
  304.      c     *entry        plist
  305.      c                   parm                    InLibrary
  306.       *
  307.      c                   endsr
  308.       *==============================================
  309.      OQSYSPRT   E            HEAD           1
  310.      O                                           28 'Allow Limit User Command'
  311.      O          E            HEAD           1
  312.      O                                           12 'Library'
  313.      O                                           24 'Command'
  314.      O          E            detail         1
  315.      O                       Library        B    15
  316.      O                       Object         B    27
  317.      O          E            error          1
  318.      O                       Library        B    15
  319.      O                       Object         B    27
  320.      O                       ERRMSGID       B    37
  321. 
  322.      **-- Send completion message:
  323.      P SndCmpMsg       B
  324.      D                 Pi            10i 0
  325.      D  PxMsgId                       7a   Const
  326.      D  PxMsgFil                     10a   Const
  327.      D  PxMsgDta                    512a   Const  Varying
  328.      **
  329.      D MsgKey          s              4a
  330.  
  331.       /Free
  332.  
  333.         SndPgmMsg( PxMsgId
  334.                  : PxMsgFil + '*LIBL'
  335.                  : PxMsgDta
  336.                  : %Len( PxMsgDta )
  337.                  : '*COMP'
  338.                  : '*PGMBDY'
  339.                  : 1
  340.                  : MsgKey
  341.                  : ERRC0100
  342.                  );
  343.  
  344.         If  ERRC0100.BytAvl > *Zero;
  345.           Return  -1;
  346.  
  347.         Else;
  348.           Return   0;
  349.         EndIf;
  350.  
  351.       /End-Free
  352.  
  353.      P SndCmpMsg       E
  354.  
  355. <b>
  356. File   : QCMDSRC
  357. Member : PRTLMTCMD
  358. Type   : CMD
  359. Usage  : CRTCMD CMD(PRTLMTCMD) PGM(PRTLMTCMD)
  360. </b>
  361. /*  ===============================================================  */
  362. /*  = Command....... PrtLmtCmd                                    =  */
  363. /*  = CPP........... PrtLmtCmd                                    =  */
  364. /*  = Description... Print allow limit user command               =  */
  365. /*  =                                                             =  */
  366. /*  = CrtCmd      Cmd( PrtLmtCmd )                                =  */
  367. /*  =             Pgm( PrtLmtCmd )                                =  */
  368. /*  =             SrcFile( YourSourceFile )                       =  */
  369. /*  =                                                             =  */
  370. /*  ===============================================================  */
  371. /*  = Date  : 2008/07/18                                          =  */
  372. /*  = Author: Vengoal Chang                                       =  */
  373. /*  ===============================================================  */
  374.  
  375.           Cmd      Prompt( 'Print Allow Limit User Command' )
  376.  
  377.              PARM       KWD(LIB) TYPE(*CHAR) LEN(10) MIN(1) +
  378.                           EXPR(*YES) PROMPT('Library')
  379. </pre>
© 2004-2019 by midrange.com generated in 0.007s valid xhtml & css