如何识别和使用使用QTCP用户的其他用户的假脱机文件(COMMAND PROMPT)? [英] How to identify and use spooled files of other user using QTCP user(COMMAND PROMPT)?

查看:146
本文介绍了如何识别和使用使用QTCP用户的其他用户的假脱机文件(COMMAND PROMPT)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我使用(FTP Servername)命令从命令提示符连接到AS400机器。

我使用命令提示符执行的每个操作都是在后台使用 QTCP 用户提交的。



以下是主要关心的问题:




  • 我有一个命令生成名为i的假脱机文件用于从命令提示符登录。

  • 我想使用该假脱机文件内容并将其复制到我的一个库中,所有这些都可以使用CPYSPLF命令完成,但是如何做同样的事情使用 QTCP 用户。

  • 我的主要要求是使用命令提示符而不是AS400终端执行CL命令操作。

      解决方案

      @ user2338816对于使用QSPRILSP API很有帮助。但是,如果这不能提供你所需要的,这里是你如何使用List Spooled Files(QUSLSPL)API来找到它。



      在开始之前,请查看我的从这篇文章中回答:在C#中编写IBM iSeries API QUSLSPL
      尽管使用C#进行会话,但它对使用QUSLSPL API和用户空间有很好的启示。所以下面是你如何在RPG IV中使用这个API:



      首先,你需要对调用API的原型进行原型开发。



      列表后台文件

        DQUSLSPL PR EXTPGM('QUSLSPL')
      D用户空间喜欢(用户空间)CONST
      D格式名称8 CONST
      D用户名10 CONST
      D QualOutQName 20 CONST
      D FormType 10 CONST
      D UsrDta 10 CONST
      D ErrorCode Like(APIError)
      D QualJobName 26 CONST
      D KeyFields 1 CONST
      D KeyFieldsNum 10i 0 CONST
      D ASP 10i 0 CONST
      D JobSyste mName 8 CONST
      D StartCRDate 7 CONST
      D StartCRTime 6 CONST
      D EndCRDate 7 CONST
      D EndCRTime 6 CONST

      创建用户空间

        DCreateUserSpace PR ExtPgm('QUSCRTUS')
      D Name Like(用户空间)CONST
      D ExtendedAttrib 10 CONST
      D InitialSize 10i 0 CONST
      D InitialValue 1 CONST
      D PublicAuth 10 CONST
      D Text 50 CONST
      D替换10 CONST
      D ErrorCode Like(APIError)

      从用户空间检索数据

        DRtvUserSpace PR ExtPgm('QUSRTVUS')
      D UserSpaceName Like(用户空间)CONST
      D StartingPos 10i 0 CONST
      D LengthToReturn 10i 0 CONST
      D ReceiverVar像(SPLF0300)
      D ErrorCode Like(APIError)

      删除用户空间

        DDeleteUserSpace PR ExtPgm('QUSDLTUS')
      D名称(UserSpace)CONST
      D ErrorCode Like(APIError)

      我喜欢创建一个字段来存储用户空间名称,所以我不用不必继续输入:

        DUserSpace S 20 INZ('SPLFSPACE QTEMP )

      在调用API时,您需要以下API错误数据结构:

        DAPIError DS合格
      D AEBytesProv 10i 0 Inz(117)
      D AEBytesAvail 10i 0 Inz(0)
      D AEExceptionID 7
      D AEReserved 1
      D AEExceptData 80

      最后,这里是一个包含每个假脱机文件返回信息的数据结构:

      pre $ code DSPLF0300 DS合格的
      D JobName 10
      D UserName 10
      D JobNumber 6
      D SplfName 10
      D SplfNumber 10i 0
      D SplfStatus 10i 0
      D DateCreated 7
      D TimeCreated 6
      D SplfSchedule 1
      D SplfSystemName 10
      D UserData 10
      D FormType 10
      D OutQName 10
      D OutQLib 10
      D ASP 10i 0
      D SplfSize 10i 0
      D SplfSizeMult 10i 0
      D TotalPages 10i 0
      D CopiesLeft 10i 0
      D Priority 1
      D保留3
      D Internalppji 10i 0

      List Spooled Files API的参数多于在其他答案中需要什么,我在上面的原型中使用了它们。因为您不能指定假脱机文件名作为搜索参数,所以我们可以指定创建日期和时间范围来帮助限制返回的结果。



      因此,实际的编码很简单。例如,最后5分钟列出QTCP拥有的所有假脱机文件。查看列表并查看哪些被命名为QPJOBLOG。抓住最近的一个。

        DCounter S 10i 0 
      DStartPoint S 10i 0
      DFiveMinutesAgo SZ
      DDateStart S 7
      DTimeStart S 6

      DLastSPLF DS合格
      D工作26
      D SplfName 10
      D SplfNumber 10i 0
      D日期7
      D时间6

      /免费
      FiveMinutesAgo =%TimeStamp() - %分钟(5);
      DateStart =%Char(%日期(FiveMinutesAgo):* CYMD0);
      TimeStart =%Char(%Time(FiveMinutesAgo):* HMS0);
      CreateUserSpace(用户空间:*空白:1:x'00':'* ALL':*空白:'* YES':APIError);
      QUSLSPL(UserSpace:'SPLF0300':'QTCP':'* ALL':'* ALL':'* ALL':APIError:
      *空格:*空格:0:0:'* CURRENT ':DateStart:TimeStart:'* LAST':
      * Blanks);
      RtvUserSpace(用户空间:1:%Len(ListInfo):ListInfo:APIError);
      Counter = 0;
      StartPoint = ListInfo.ListDataOfs + 1;

      DoW计数器< ListInfo.ListEntryCount;
      RtvUserSpace(用户空间:StartPoint:%Len(SPLF0300):SPLF0300:APIError);
      如果SPLF0300.SplfName ='QPJOBLOG'和
      SPLF0300.DateCreated> = LastSplf.Date和
      SPLF0300.TimeCreated> = LastSplf.Time;
      LastSplf.Job = SPLF0300.JobName +
      SPLF0300.UserName +
      SPLF0300.JobNumber;
      LastSplf.SplfName = SPLF0300.SplfName;
      LastSplf.SplfNumber = SPLF0300.SplfNumber;
      LastSplf.Date = SPLF0300.DateCreated;
      LastSplf.Time = SPLF0300.TimeCreated;
      EndIf;
      StartPoint = StartPoint + ListInfo.EntrySize;
      Counter = Counter + 1;
      EndDo;

      DeleteUserSpace(UserSpace:APIError);

      我的例子使用了5分钟,但这可能太大。试验一下,看看你有什么用。



      所有这些都需要进入一个新程序,然后返回CPYSPLF命令所需的信息。事实上,你可以建立这个程序并为你执行一个CPYSPLF命令,这样你的FTP脚本就简单了。


      Here i am connecting to an AS400 machine from command prompt using (FTP Servername) command.
      Every action that i do using command prompt is being submitted with QTCP user in the background.

      Here is the main concern:

      • I have a command that generates spool file with the name i used to login from command prompt.
      • I want to use that spool file content and copy to one of my library , and all these can be done with CPYSPLF command but how to do the same thing using QTCP user.
      • My main requirement here is to perform CL command operations using command prompt rather than AS400 terminal.

      解决方案

      @user2338816 makes a good point about using the QSPRILSP API. But if that doesn't provide what you need, here is how you can use the List Spooled Files (QUSLSPL) API to find it.

      Before beginning, please review my answer from this post: Programming IBM iSeries API QUSLSPL in C# That has a good primer on using the QUSLSPL API and user spaces, although it talks in C#. So here is how you use that API in RPG IV:

      To start with, you need to prototype out the calls to the APIs.

      List Spooled Files

      DQUSLSPL          PR                  EXTPGM('QUSLSPL')    
      D UserSpaceName                       Like(UserSpace) CONST
      D FormatName                     8    CONST                
      D UserName                      10    CONST                
      D QualOutQName                  20    CONST                
      D FormType                      10    CONST                
      D UsrDta                        10    CONST                
      D ErrorCode                           Like(APIError)       
      D QualJobName                   26    CONST                
      D KeyFields                      1    CONST                
      D KeyFieldsNum                  10i 0 CONST                
      D ASP                           10i 0 CONST                
      D JobSystemName                  8    CONST                
      D StartCRDate                    7    CONST                
      D StartCRTime                    6    CONST                
      D EndCRDate                      7    CONST                
      D EndCRTime                      6    CONST                
      

      Create User Space

      DCreateUserSpace  PR                  ExtPgm('QUSCRTUS')   
      D Name                                Like(UserSpace) CONST
      D ExtendedAttrib                10    CONST                
      D InitialSize                   10i 0 CONST                
      D InitialValue                   1    CONST                
      D PublicAuth                    10    CONST                
      D Text                          50    CONST                
      D Replace                       10    CONST                
      D ErrorCode                           Like(APIError)       
      

      Retrieve data from the user space

      DRtvUserSpace     PR                  ExtPgm('QUSRTVUS')   
      D UserSpaceName                       Like(UserSpace) CONST
      D StartingPos                   10i 0 CONST                
      D LengthToReturn                10i 0 CONST                
      D ReceiverVar                         Like(SPLF0300)       
      D ErrorCode                           Like(APIError)       
      

      Delete User Space

      DDeleteUserSpace  PR                  ExtPgm('QUSDLTUS')   
      D Name                                Like(UserSpace) CONST
      D ErrorCode                           Like(APIError)       
      

      I like to make a field to store the user space name so I don't have to keep typing it in:

      DUserSpace        S             20    INZ('SPLFSPACE QTEMP     ')
      

      When calling APIs, you'll need the following API error data structure:

      DAPIError         DS                  Qualified
      D AEBytesProv                   10i 0 Inz(117) 
      D AEBytesAvail                  10i 0 Inz(0)   
      D AEExceptionID                  7             
      D AEReserved                     1             
      D AEExceptData                  80             
      

      Finally, here is a data structure with the information for each spooled file returned:

      DSPLF0300         DS                  Qualified
      D JobName                       10             
      D UserName                      10             
      D JobNumber                      6             
      D SplfName                      10             
      D SplfNumber                    10i 0          
      D SplfStatus                    10i 0          
      D DateCreated                    7             
      D TimeCreated                    6             
      D SplfSchedule                   1             
      D SplfSystemName                10             
      D UserData                      10             
      D FormType                      10             
      D OutQName                      10             
      D OutQLib                       10             
      D ASP                           10i 0          
      D SplfSize                      10i 0          
      D SplfSizeMult                  10i 0          
      D TotalPages                    10i 0          
      D CopiesLeft                    10i 0          
      D Priority                       1             
      D Reserved                       3             
      D Internalppji                  10i 0          
      

      The List Spooled Files API has more parameters than what was needed in that other answer and I used them in the prototype above. Because you can't specify the spooled file name as a parameter to search on, we can specify a creation date and time range to help limit the returned results.

      So the actual coding is simple. You list all spooled files owned by QTCP for, say, the last 5 minutes. Look through the list and see which ones are named QPJOBLOG. Grab the most recent one.

      DCounter          S             10i 0                                     
      DStartPoint       S             10i 0                                     
      DFiveMinutesAgo   S               Z                                       
      DDateStart        S              7                                        
      DTimeStart        S              6                                        
      
      DLastSPLF         DS                  Qualified                           
      D Job                           26                                        
      D SplfName                      10                                        
      D SplfNumber                    10i 0                                     
      D Date                           7                                        
      D Time                           6                                        
      
       /free                                                                    
        FiveMinutesAgo = %TimeStamp()-%Minutes(5);                              
        DateStart=%Char(%Date(FiveMinutesAgo):*CYMD0);                          
        TimeStart=%Char(%Time(FiveMinutesAgo):*HMS0);                           
        CreateUserSpace(UserSpace:*Blank:1:x'00':'*ALL':*Blank:'*YES':APIError);
        QUSLSPL(UserSpace:'SPLF0300':'QTCP':'*ALL':'*ALL':'*ALL':APIError:  
                *Blanks:*Blank:0:0:'*CURRENT':DateStart:TimeStart:'*LAST':      
                *Blanks);                                                       
        RtvUserSpace(UserSpace:1:%Len(ListInfo):ListInfo:APIError);             
        Counter = 0;                                                          
        StartPoint = ListInfo.ListDataOfs+1;                                  
      
        DoW Counter<ListInfo.ListEntryCount;                                  
          RtvUserSpace(UserSpace:StartPoint:%Len(SPLF0300):SPLF0300:APIError);
          If SPLF0300.SplfName='QPJOBLOG' And                                 
             SPLF0300.DateCreated>=LastSplf.Date And                          
             SPLF0300.TimeCreated>=LastSplf.Time;                             
            LastSplf.Job = SPLF0300.JobName +                                 
                           SPLF0300.UserName +                                
                           SPLF0300.JobNumber;                                
            LastSplf.SplfName = SPLF0300.SplfName;                            
            LastSplf.SplfNumber = SPLF0300.SplfNumber;                        
            LastSplf.Date = SPLF0300.DateCreated;                             
            LastSplf.Time = SPLF0300.TimeCreated;                             
          EndIf;                                                              
          StartPoint=StartPoint+ListInfo.EntrySize;                           
          Counter=Counter+1;                                                  
        EndDo;                                                                
      
        DeleteUserSpace(UserSpace:APIError);                                  
      

      My example uses 5 minutes, but that's probably too large of a timespan. Experiment to see what works for you.

      All of this will have to go into a new program that will then return the information needed for the a CPYSPLF command. In fact, you can have this program build and execute a CPYSPLF command for you so your FTP script is simpler.

      这篇关于如何识别和使用使用QTCP用户的其他用户的假脱机文件(COMMAND PROMPT)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆