简体   繁体   English

了解IBM i中的DSPPGM命令

[英]Understanding DSPPGM command in IBM i

I am trying to understand the meaning of the details that are displayed on using the DSPPGM command on a program. 我试图了解在程序上使用DSPPGM命令显示的详细信息的含义。

Suppose command is as below: 假设命令如下:

DSPPGM PGM(SE046R) DETAIL(*ALL) 

The information showed for Detail as *MODULE is as below: 显示为* MODULE的详细信息如下:

Program  . . . . . . . :   SE046R        Library  . . . . . . . :   HGBASQUA   
Owner  . . . . . . . . :   QPGMR                                               
Program attribute  . . :   RPGLE                                               
Detail . . . . . . . . :   *MODULE                                             


Type options, press Enter.                                                     
  5=Display description   6=Print description                                  

                                         Creation  Optimization  Debug         
Opt  Module      Library     Attribute   Date         Level      Data          
     SE046R      QTEMP       RPGLE       06/28/17  *NONE         *YES        

What I don't understand here is why SE046R shows up as a module. 我在这里不明白的是为什么SE046R显示为模块。 as there is no object of this name with type MODULE. 因为没有该名称的对象具有MODULE类型。

Next comes the Service program details. 接下来是服务程序的详细信息。 Are the below ones the list of service programs bound to the program? 以下是与该程序绑定的服务程序列表吗? Apart from SE045RS, everything seem to be some sort of system defined stuff? 除了SE045RS,一切似乎都是某种系统定义的东西?

 Service                                                               
 Program     Library     Activation  Signature                         
 QC2SYS      QSYS        *IMMED      000000000000000000009485A3A2A8A2  
 SE045RS     *LIBL       *IMMED      A584A90E326C57B523D38F7C6803F7C4  
 QRNXIE      QSYS        *IMMED      D8D9D5E7C9C540404040404040404040  
 QRNXUTIL    QSYS        *IMMED      D8D9D5E7E4E3C9D34040404040404040  
 QRNXDUMP    QSYS        *IMMED      D8D9D5E7C4E4D4D74040404040404040  
 QLEAWI      QSYS        *IMMED      44F70FABA08585397BDF0CF195F82EC1  

Also, SE045RS is a service program which on doing a DSPSRVPGM command displays the SE045RM which i guess means that the service program consists of a MODULE by the name SE045RM. 同样,SE045RS是一个服务程序,在执行DSPSRVPGM命令时会显示SE045RM,我想这意味着该服务程序包含一个名为SE045RM的模块。

There are procedure calls in SE046R to procedures defined within SE045RM. SE046R中存在对SE045RM中定义的过程的过程调用。 I undertand that perfectly but would it be possible the other way around? 我完全理解这一点,但是反过来可能吗? That is there is a procedure defined within SE046R, can i use it within a procedure defined inside the SE045RM module? 那就是SE046R中定义了一个过程,我可以在SE045RM模块中定义的过程中使用它吗?

Update - 1: 更新-1:

Okay so the decision has been made to move the the procedure to SE045RM and whatever local variables that were being used within the procedure would now have to be passed as parameters. 好的,因此已经决定将过程移至SE045RM,并且现在必须将过程中使用的任何局部变量作为参数传递。 that would mean pretty much the below: 这几乎意味着以下内容:

LongMsg = 'Program ' + %Trim(P_Program) +                                
 ' encountered a SQL error code ' +                                      
 %Char(P_SQLError01) + ' while trying to ' + %Trim(P_ActText) + ' for ' +
 %char(Input_Company) + ':' + %trim(Input_Int_Hdr)      + ':' +          
 %trim(Input_Order)   + ':' + %char(Input_Line_Itm_Seq) + ':' +          
 %char(Input_Rel_Seq) + ':' + %trim(Input_VIN);                          

All the above fields are local to SE046R and would have worked perfectly inside that but now these would have to be passed as parameters to the Procedure. 以上所有字段对于SE046R都是本地的,在SE046R中可以很好地工作,但是现在这些必须作为参数传递给Procedure。 Question is passing as many parameters as above along with around 4 more a good practice? 问题是传递与上述一样多的参数以及大约4个以上的良好实践吗? That would be around 13 parameters to the the Procedure call of SQLSoftError. 这大约是SQLSoftError的Procedure调用的13个参数。 Is this a good thing to do? 这是一件好事吗?

What I don't understand here is why SE046R shows up as a module. 我在这里不明白的是为什么SE046R显示为模块。 as there is no object of this name with type MODULE. 因为没有该名称的对象具有MODULE类型。

ILE programs are always created from modules in a two step process. ILE程序总是通过两步过程从模块创建的。

  1. CRTxxxMOD CRTxxxMOD
  2. CRTPGM 通用汽车

CRTBNDxxx, used to create a *PGM object from a single source of the same name, is simply a shortcut that does both steps for you automagically. CRTBNDxxx用于从同名的单个来源创建* PGM对象,它只是一种快捷方式,可以自动为您完成两个步骤。

Next comes the Service program details. 接下来是服务程序的详细信息。 Are the below ones the list of service programs bound to the program? 以下是与该程序绑定的服务程序列表吗? Apart from SE045RS, everything seem to be some sort of system defined stuff? 除了SE045RS,一切似乎都是某种系统定义的东西?

Correct, the Qxxxx service programs in QSYS are system objects and are automatically bound in. 正确,QSYS中的Qxxxx服务程序是系统对象,并且会自动绑定到其中。

There are procedure calls in SE046R to procedures defined within SE045RM. SE046R中存在对SE045RM中定义的过程的过程调用。 I undertand that perfectly but would it be possible the other way around? 我完全理解这一点,但是反过来可能吗? That is there is a procedure defined within SE046R, can i use it within a procedure defined inside the SE045RM module? 那就是SE046R中定义了一个过程,我可以在SE045RM模块中定义的过程中使用它吗?

Generally, no. 通常,不会。 If you want a procedure to be shared, it belongs in a *SRVPGM. 如果要共享过程,则该过程属于* SRVPGM。

I just want to make one addendum to Charles' answer. 我只想对查尔斯的答案做一个补充。

There are procedure calls in SE046R to procedures defined within SE045RM. SE046R中存在对SE045RM中定义的过程的过程调用。 I undertand that perfectly but would it be possible the other way around? 我完全理解这一点,但是反过来可能吗? That is there is a procedure defined within SE046R, can i use it within a procedure defined inside the SE045RM module? 那就是SE046R中定义了一个过程,我可以在SE045RM模块中定义的过程中使用它吗?

Generally, no. 通常,不会。 If you want a procedure to be shared, it belongs in a *SRVPGM. 如果要共享过程,则该过程属于* SRVPGM。

Generally because you can do it, but not with a bound call. 通常是因为您可以执行此操作,但不能使用绑定调用。 You need to use a technique called a callback. 您需要使用一种称为回调的技术。 In this case SE046R defines a procedure that is needed by a procedure in SE045RS. 在这种情况下,SE046R定义了SE045RS中的过程所需的过程。 The procedure in SE046R is the callback procedure. SE046R中的过程是回调过程。 SE046R would define a procedure pointer to the callback, and then would pass that procedure pointer to the procedure in SE045RS that needs to 'call back' into SE046R. SE046R将定义一个指向回调的过程指针,然后将该过程指针传递给SE045RS中需要“回调”到SE046R中的过程。 One commonly used example of this is the qsort function in C. Qsort can sort any array because it uses a callback to tell it if two elements are equal or one is greater than the other. 一个常用的例子是C中的qsort函数。Qsort可以对任何数组进行排序,因为它使用回调来告诉它两个元素相等还是一个大于另一个。 Qsort itself doesn't know the difference, and can't compare two pieces of the array, but the program that defined the array can know that information, and can do the comparison based on that knowledge. Qsort本身不知道区别,也无法比较数组的两个部分,但是定义数组的程序可以知道该信息,并可以基于该知识进行比较。 Ok I am rambling now. 好吧,我现在正在漫步。 This is what calling a procedure by procedure pointer might look like: 这是通过过程指针调用过程的样子:

dcl-s procptr      Pointer(*proc);

dcl-pr MyProc;
  parm1     ...
  parm2     ...
end-pr;

dcl-pr proc     ExtProc(procptr);
  parm1     ...
  parm2     ...
end-pr;

...
procptr = %paddr(MyProc);
...
proc(parm1: parm2);

The nice thing about a procedure pointer is that it can be passed as a parameter just like any other pointer, and on the other side used to call the procedure. 关于过程指针的好处是,它可以像其他任何指针一样作为参数传递,并在另一侧用于调用过程。 An advantage that procedure pointers have over pointers in other languages is that they can only be used to reference procedures, not data, and vice versa. 过程指针优于其他语言中的指针的一个优点是,它们只能用于引用过程,而不能用于引用数据,反之亦然。 You can't take a procedure pointer and pass it to a data pointer and attempt to modify it like data. 您不能采用过程指针并将其传递给数据指针并尝试像数据一样对其进行修改。 IBM i knows the difference and will throw an error. IBM i知道它们之间的区别,并且会抛出错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM