• 在Application Engine 中调用 Crystal Report时,如何为 Crystal Report 传递参数?


      最近在项目中遇到一个问题,在一个Application Engine中,当执行一系列的操作后,需要调用2个Crystal Report。如果纯粹的调用Crystal Report, 那很简单,其实直接调用Crystal Report 和直接调用SQR的做法是完全一样的,直接使用 processrequest即可。但是,如果你的Crystal Report 需要参数的话,那就行不通了。

      为什么行不通呢?这还得从Crystal Report 和Application Engine的运行机制说起。

        

      通常,在PeopleSoft中,Crystal Report的数据源是Query,Query的交互性比较强,可以含有参数,如果这个Query含有参数,那很自然的调用他的Crystal Report也需要参数(这句话似乎是废话)。我们假设这个Query需要2个参数, Business_unit, Pay_Cycle. 为了传参数给这个Crystal Report,我们需要修改他的process definition,在parameterlist中append如下命令行:-ORIENTP :RUN_CNTL_AP.PABUSINESS_UNIT :RUN_CNTL_AP.PAY_CYCLE. 此时通过page调用这个Crystal Report, 可以执行成功。 但是,如果是通过Application Engine触发,则会出错,原因是Crystal Report没有得到相应的参数。

      那么为什么Crystal Report没有得到他需要的参数呢? 那是因为Crystal Report的命令行是从Component Buffer中取数据,而Application Engine是不支持Component Buffer的,因此通过Application Engine调用的Crystal Report自然取不到参数了。

      那么,有没有办法取得参数呢? 方法是有的,那就是利用Component interface。在PeopleSoft中,Component Interface的作用很大,他通常可以用来做一些batch job的工作,也可以完成和其他系统的数据交互。在Application Engine中,利用Component Interfaace触发Crystal Report,则可以成功传递参数。

      以下是具体步骤:具体步骤可以查看PeopleBook,PeopleSoft Process Scheduler > Using Process Request APIs -> Using a Component Interface to Schedule a Request

    1. Create a new page based on the PRCSRQSTBC page.

    a. Make a copy of the page PRCSRQSTBC into a new definition. When Application Designer prompting you to copy the associated PeopleCode, reply yes.

    b. Insert new edit box for the field referenced in the Parameter List. Select Insert->Edit box. When the cursor icon changes, click the mouse where you want to position the new field in the page. Double click on the new field to open the box to select the field for this new box. Perform this step for each field found in the Parameter List.

    c. Save the new definition.

    2. Create a new component based on the PRCSRQSTBC component.

    a. Make a copy of the component PRCSRQSTBC. When Application Designer prompting you to copy the associated PeopleCode, reply yes.

    b. Insert the new page you created from the previous step by selecting Insert->Page Into Component from the menu.

    c. Remove the page PRCSRQSTBC from the component, so the only page referenced in this Component is the new page.

    d. Save the component

    3. Create a new Component Interface from the Application Designer by selecting File->New. When prompted for the new component, provide the component created from the previous step. Save the new Component Interface. Do not close the definition of the new Component Interface as additional edit will be done in the subsequent step.

    4. Copy the existing PeopleCode found in the Component Interface PROCESSREQUEST.

    a. From the Application Designer, open the definition for the Component Interface PROCESSREQUEST.

    b. In the METHODS section of the Component Interface, click your mouse to the Create method and right-click to select the View PeopleCode option.

    c. Highlight the PeopleCode, then right-click to select the Copy option

    d. In the new Component Interface, highlight the method Create and right click your mouse to select the View PeopleCode

    e. Paste the PeopleCode by right clicking your mouse and select the Paste option.

    f. Save the component interface. After saving, you should see two additional methods Schedule() and Update() inserted in the METHODS section.

    5. In the new component interface, add the new field(s) added in the new page from step 1

    a. Click on the Scroll ? Level 0 folder to display all the records.

    b. Expand on the record folder for the field added in the new page. Highlight the field with your mouse and drag the field in the PROPERTIES section of the Component Interface.

    c. Perform this step for any additional fields added to the page.

    d. Save the Component Interface definition.

    6. Modify the Application Engine program to include the PeopleCode to schedule the request using the new Component Interface. The PeopleCode will be copied from the sample PRCSMULTI component.

    a. Open the Component PRCSMULTI from Application Designer.

    b. View the PeopleCode found in RUNCNTLCOMPINTF.FieldChange.

    c. Copy the entire PeopleCode found in the FieldChange by highlighting the PeopleCode and right click your mouse to select Copy.

    d. Open the Application Engine program where the request will be scheduled. In the step where the request will be copied, paste the PeopleCode copied from the PRCSMULTI component.

    e. In the pasted PeopleCode, perform the following edits.

    1. Remove the DoSave() function. This function is not allowed within an Application Engine program.

    2. In the function GetCompIntfc(), replace the Component Interface PROCESSREQUEST with the new Component Interface created in step 2.

    3. In all attributes of ProcessRequest class, modify these fields for the process request you will schedule. For additional information pertaining to these attributes, please refer to the discussion of ProcessRequest class found in the PeopleCode manual.

    4. For the new field(s) added to the Properties of the Component Interface, modify the code to assign value to this field(s). This is the value that will be assigned to the Parameter list.

    5. Save your changes.

      走到这一步的时候,看上去是已经完了,但是运行,发现有错,提示没有访问权限。原因是因为Component Interface是一个独立的结构,就如page一样,所以需要给他指定permissionlist。 进入peopletool--》security-》permission & rols, 选择一个permissionlist, 通常可以选择allpages, 在component interface中添加刚才创建的那个component interface, 点击Edit,选择access。保存之后即可运行。

      有一点需要说明的是,Component 和Component Interface之间并没有对应关系,也就是说一个Component Interface可以被任意的一个Component使用。刚开始的时候很容易被Component Interface中的那个component迷惑,以为是一一对应,其实不然。

      

  • 相关阅读:
    redis远程连接超时
    GNU LIBC源代码学习之strcmp
    计算最小生成树
    域名和空间的绑定问题
    Spring MVC 基于Method的映射规则(注解版)
    Spring MVC 基于URL的映射规则(注解版)
    手把手教你编写Logstash插件
    Ruby中如何识别13位的时间戳
    [logstash-input-http] 插件使用详解
    Java直接(堆外)内存使用详解
  • 原文地址:https://www.cnblogs.com/darcyhu/p/1705792.html
Copyright © 2020-2023  润新知