<< Back to man.ChinaUnix.net   CU网友原创,转载请注明出处ChinaUnix.net及作者

返回总目录

 

7     经验共享-- 26

7.1系统部分    26

7.2程序开发部分... 26

7.2.1       有关RPGLE中日期型数据的用法       *from code400.com- 26

7.2.2       让程序摆脱指示器-- 26

7.2.2.1        内置函数BIF- 26

7.2.2.2        P-fields驯服你的DDS- 26

7.2.2.3        定位光标-- 26

7.2.2.4        判断用户按下了什么键-- 26

7.2.2.5        显示出错消息-- 26

7.2.2.6        总结-- 26

7.2.3       基本的SUBFILE的使用-- 26

7.2.4       如何在AS400写进度条?-- 26

7.3             如何检测及分析系统性能?... 26

7.4             如何在应用程序中校验用户密码?... 26

7.5             如何知道ODBC的真正使用者?... 26

7.6            如何将报表(Spooled File)使用e-mail传输至使用者... 26

7.7             报表设计工具RLU... 26

7.8             利用RLU设计打印文件... 26

7.9             如何监控以及控制ODBC的数据传输?. 47

7.9.1       可以通过Exit Program来监控-- 47

7.9.2       通过导航器限制ODBC以及FTP数据传输-- 47

7.9.3       OS/400主要的系统作业的用途-- 47

7.9.4       Code Pages and Character Sets for the CCSIDs 47

7.经验共享

7.1系统部分

7.2程序开发部分

7.2.1   有关RPGLE中日期型数据的用法
     
*from code400.com

     H*-----------------------------------------

     H* %MSeconds %Seconds, %Minutes, %Hours,

     H* %Days, %Months, and %Years.

     H* %Date, %Time, and %TimeStamp

     H*

     H*

     H*

     H*

     H*-----------------------------------------

     D*-----------------------------------------

     D* Program Info

     D*-----------------------------------------

     D                SDS

     D  @PGM                 001    010

     D  @PARMS               037    039  0

     D  @JOB                 244    253

     D  @USER                254    263

     D  @JOB#                264    269  0

     D*

     D*  Field Definitions.

     D*

     D ISOdate         S               D

     D USAdate         S               D   DatFmt(*USA)

     D XMASDate        S               D   Inz(D'2003-12-25')

     D LogonDate       S               D

     D Date_Start      S             15

     D MonthNames      S             12    Dim(12) CtData

     D Date_String     S             40

 

      *

      * Time Stamp

      *

     DTimeStamp        S               Z

      *

     D WorkISO         S               D

     D Month           S              2  0

     D Day             S              2  0

     D Year            S              4  0

     D Decimal8        S              8  0

     D LogMonth        S              2  0

     D LogDay          S              2

     D LogYear         S              4  0

     D NextMonth       S               D

     D EndOfMonth      S               D

      *

      * Variables for free RPG example + some above

      *

     D DateIn          S               D

     D FromISO         S               D

     D ToISO           S               D

     D DiffDays        S              3  0

     D WorkField       S              5  0

     D Name            S              9    Based(NamePtr)

     D Name2           S              9

     D NamePtr         S               *   Inz(%ADDR(Names))

     D Names           S             63    Inz('Sunday   Monday   Tuesday  Wedn+

     D                                     esdayThursday Friday   Saturday ')

     D*

     D* RPG-defined date formats and separators for Date data type

     D*

      * 2-Digit Year Formats

      * *MDY  Month/Day/Year  mm/dd/yy  8  09/26/03

      * *DMY  Day/Month/Year  dd/mm/yy  8  26/09/03

      * *YMD  Year/Month/Day  yy/mm/dd  8  03/09/26

      * *JUL  Julian          yy/ddd    6  03/926

     C*=====

      * 4-Digit Year Formats

      * *ISO  Int Standards Org yyyy-mm-dd  10  2003-09-26

      * *USA  IBM USA Standard  mm/dd/yyyy  10  09/26/2003

      * *EUR  IBM European Std  dd.mm.yyyy  10  26.09.2003

      * *JIS  Japan Indst Std   yyyy-mm-dd  10  2003-09-26

      *

      *

     C*

      *

      * Okay first lets get todays date

      * For display purposes the date is now

      *      Friday September 26th 2003

      *  so date now looks like this 2003-09-26

      *  because the default date type is *ISO

      *

     C                   Eval      ISOdate = %Date()

      *

      *  Now that I have the date in a date format

      *  (*ISO) I can do stuff to it.

      *  Once I move this date to a decimal 8,0 field

      *  the date is now in format 20030926

      *  Not very exciting..yet

      *

     C                   Move      ISODate       Decimal8

      *

      *  Now back to the *ISO date  lets add

      *  1 month to the date.

      *  date after will equal 2003-10-26

      *  %days and % years works the same as %months

      *

     C                   Eval      WorkISO  = ISODate + %Months(1)

      *

      *  Logon date is set equal to today then the month is extracted

      *  the "*M" is the same as "*Months"  LogMonth = 09.

      *                                     LogDay   = 26.

      *

     C                   Eval      LogonDate =  %Date()

     C                   Extrct    LogonDate:*Y  LogYear

     C                   Extrct    LogonDate:*M  LogMonth

     C                   Extrct    LogonDate:*D  LogDay

      *

      *  Build the date string - Later we will add the day name

      *

     C                   Eval      Date_String =

     C                              %Trim(MonthNames(LogMonth))

     C                              + %trim('@') + %Trim(LogDay)

     C                              + %trim(',@') + %Char(LogYear)

      *

      *  convert the "@" back to *Blanks

      *  Date_String = 'September 26, 2003'

      *

     C     '@':' '       Xlate     Date_String   Date_String

      *

      * TimeStamp = yyyy-mm-dd-hh.mm.ss.mmmmmm (length 26).

      * TimeStamp = '2003-09-26-15.16.26.531000'

      *

     C                   Eval      TimeStamp = %TimeStamp()

      *

      *  Free Format date stuff   By the way Name2 = 'Friday'

      *

      /Free

        DateIn   = %Date()                     ;

        ISODate  = %Date()                     ;

        ISODate  = DateIn                      ;

        Year     = %Subdt(ISODate:*Y)          ;

        Month    = %Subdt(ISODate:*M)          ;

        Day      = %Subdt(ISODate:*D)          ;

        FromISO  = ISODate - %YEARS(1)         ;

        ToISO    = ISODate                     ;

        DiffDays = %Diff(ToISO:FromISO:*DAYS)  ;

        ISODate  = DateIn                      ;

 

        WorkField = %Diff(ISODate:D'1899-12-31':*DAYS);

        WorkField = %REM(WorkField:7);

 

        NamePtr = NamePtr + (WorkField * 9);

        Name2 = Name;

      /End-Free

      *

      *  Build the date string - With The Day Name

      *  DATE_STRING = 'Friday  September 26, 2003              '

      *

     C                   Eval      Date_String =

     C                              %trim(Name) + %Trim('@@')

     C                              + %trim(MonthNames(LogMonth))

     C                              + %trim('@') + %Trim(LogDay)

     C                              + %trim(',@') + %Char(LogYear)

     C                   Eval      Date_String = %Xlate('@':' ':Date_String)

      *

      * Calculate the last day of the month

      * ENDOFMONTH = '2003-09-30'

      *

     C     ISODate       AddDur    1:*Months     NextMonth

     C                   Extrct    NextMonth:*D  DiffDays

     C     NextMonth     SubDur    DiffDays:*D   EndOfMonth

 

 

     C                   Eval      *INLR = *On

     C*----------------------------------------------------

** CTDATA MonthNames

January

February

March

April

May

June

July

August

September

October

November

December

 

 

7.2.2           程序摆脱指示器

 
   
* reference:<go indicatorless in RPG> By Paul Ladouceur

一直以来,指示器(indicators)都是rpg程序中很重要的一部分。但是,我们应该认识到,属于指示器的编程时代已经过去了,我们应该用21世纪的编程方式。

为什么被淘汰?

    指示器最大的缺点就是只能有99个的限制。然而实际上,我们的程序逻辑,文件的I/O如果全部都靠指示器控制的话,复杂些的程序就会显得不够用了。
    另外,一大堆数字指示器混杂在程序中,看起来实在是一件很辛苦的事情。也许你会知道03表示F3,F3表示用户要退出当前程序,可是你怎么知道*IN23,*IN24,*IN25分别表示什么呢?

7.2.2.1           内置函数BIF

首先我们要开始摆脱指示器的地方就是C-Specs.通常,当对文件进行I/O操作的时候,需要一个或者多个只是起来表示该操作的状态,在RPG IV中,可以用%EOF,%FOUND,%EQUAL,%OPEN等等这些内置函数来实现这些功能。他们返回一个类似指示器的逻辑值true(*on) 或者false(*off).

下面是一些内值函数的例子以及等效的指示器用法。***************************************************

   Traditional Way of Handling I/O

C CusKey Setll Customer 5350
C If *IN50
C Do *Hival
C CusKey Reade CustomerR 5351
C If *IN51
C Leave
C Endif
C If *IN53
C Message1 Dsply
C Leave
C Endif
C CrdKey Chain CreditCdR 5253
C If *IN52 = *On or *IN53
C Message2 Dsply
C Leave
C Endif
C Enddo
C Endif

   Indicatorless Way


 

C CusKey Setll(e) Customer
C If %Equal(Customer)
C Do *Hival
C CusKey Reade(e) CustomerR
C If %Eof
C Leave
C Endif
C If %Error
C Message1 Dsply
C Leave
C Endif
C CrdKey Chain (e) CreditCDR
C If Not %Found(CreditCD) or %Error
C Message2 Dsply
C Leave
C Endif
C Enddo
C Endif

另外,值得一提的是%Error这个内置函数。你必须在输入/输出操作后面带上扩展符(e)。当I/O发生错误的时候,它返回true.比如在读数据库文件的时候,%Error的值为true,那么可能是因为记录被锁住。为了找到问题所在,你可以用%Status来返回错误代码。

7.2.2.2           P-fields驯服你的DDS

显示文件(DSPF)一般都会用到很多指示器。下面的代码中,定义了各种显示文件中用到的关键字的指示器:

F CUSTD CF E  WORKSTN  INFDS(Indicators)
 
  Declare Named Indicators

DIndicators DS Based(IndicatorP)
D SFLNXTCHG 8 8
D SFLCLR 40 40
D SFLCTLDSP 41 41
D SFLDSP 42 42
D SFLINZ 43 43
DIndicatorP S * Inz(%Addr(*In))

或者我们可以这样:

F CUSTD CF E  WORKSTN  INFDS(Indicators)

  Declare Named Indicators

DIndicators DS
D SFLNXTCHG 8 8N

D SFLCLR 40 40N
D SFLCTLDSP 41 41N
D SFLDSP 42 42N
D SFLINZ 43 43N

语句EVAL SFLNXTCHG = *On就使*IN08的状态变为*on.是用字段名代替指示器,能使你的程序更自由易懂。可以看出,这种方法实际上相当于为指示器取了个好听易懂的名字。我们在编程过程中就能把它们作为普通的逻辑变量来使用了(这里说他们是逻辑变量实际上是表示他们的值只有10两种状态,相当于逻辑值true /false)。

    同理,我们如果在程序里面要把每个功能键很容易的份清楚,可以定义:
D F03 03 03N
D F05 05 05N
D F12 12 12N
   
在这之前,我们还是需要在DSPF里面把CA03*In03关联,这样当我们就可以在程序里面使用这样的描述:
IF  F03
EVAL INLR=*ON
ENDIF

你可以用program-to-system fieldsP-fields)来代替指示器控制一个栏位在画面上的显示。
    P-fields
用来控制显示的栏位的属性。首先,为你要控制的栏位另外再定义一个栏位,如,你要控制的栏位是CUST#,那么你再建一个P-field @CUST#,当然你可以用其它你喜欢的名字。你可以用这个栏位来控制PRRI,BL等所有的属性。

下面是程序中对P-fields的一些定义,基本上包含了所有的显示属性。

  RI=Reverse Image, HI=Hi Intensity, BL=blink, UL=Underline
  ND=Non Display
  NON Protect fields
d Normal c const(x’20’)
d RI c const(x’21’)
d HI c const(x’22’)
d HIRI c const(x’23’)
d UL c const(x’24’)
d ULRI c const(x’25’)
d ULHI c const(x’26’)
d ND c const(x’27’)
d BL c const(x’28’)
d BLRI c const(x’29’)
d BLHI c const(x’2A’)
d BLHIRI c const(x’2B’)
d BLUL c const(x’2C’)
d BLULRI c const(x’2D’)
d BLULHI c const(x’2E’)

  Protect field

d PRNormal c const(x’A0’)
d PRRI c const(x’A1’)
d PRHI c const(x’A2’)
d PRHIRI c const(x’A3’)
d PRUL c const(x’A4’)
d PRULRI c const(x’A5’)
d PRULHI c const(x’A6’)
d PRND c const(x’A7’)
d PRBL c const(x’A8’)
d PRBLRI c const(x’A9’)
d PRBLHI c const(x’AA’)
d PRBLHIRI c const(x’AB’)
d PRBLUL c const(x’AC’)
d PRBLULRI c const(x’AD’)

d PRBLULHI c const(x’AE’)

注意每个缩写的常量名字都有一个相应的十六进制的值。从常量的名字我们可以看出来它所控制的显示属性。假如你有一个可输入的栏位,当出错的时候反色显示(riverse),当要提示用户一些东西的时候让它闪烁(blink,通常你会用到3个指示器来控制。但是现在我们只要一个控制栏位就可以了。我们现在可以花更多时间在程序的逻辑上,而不用为管理一大堆的指示器大费脑筋了。
例如:当用户输入一个不正确的客户代号的时候,我们要让CUST#反色显示,我们要做的是:EVAL @CUST# = RI. 这里,RI是一个代表十六进制X21的常量.上面的代码中我们可以看到,这里有两组常量的定义,一组可以控制栏位的保护属性(PR头),另一组控制未保护的栏位。你如果只想从把栏位从可输入变成只能输出的状态,那就选择PR头的常量栏控制。反过来,用没有PR开头的常量。

继续上面客户代码栏位的例子,DSPF中我们对控制CUST#栏位的P-field的定义如下:

A**** For the full source code see MNTCUSFM ****

A DSPSIZ(24 80 *DS3)
A PRINT
A CF
01
A CF02

. . . . Other Functions keys DECLARED . . .
A
A CF
24
A PAGEDOWN
A PAGEUP
A*A R PANEL
A*A RTNCSRLOC(&RCD &FLD &POS)
A CLRL(10)
A CSRLOC(ROW# COL#)
A OVERLAY
A RCD 10A H
A FLD 10A H
A POS 4S 0H
A ROW# 3S 0H
A COL# 3S 0H
A @CUST# 1A P
A @CUST#TX 1A P
. . . . Other P Fields Declared . . .
A @CREDLM 1A P
A @CREDLMTX 1A P
A TITLE 30A O 1 25DSPATR(HI)
A 1 60DATE
A EDTCDE(Y)
A 1 70TIME
A 3 2’Customer Number :’
A DSPATR(&@CUST#TX)
A CUST# R B 3 20REFFLD(CUSTOMERR/CUST# CUSTOMER)
A DSPATR(&@CUST#)
A 3 30’Credit Code:’
A DSPATR(&@CREDCDTX)
A CREDCD R B 3 44REFFLD(CUSTOMERR/CREDCD *LIBL/CUSTOA MER)
A DSPATR(&@CREDCD)
A DESC R O 3 47REFFLD(CREDITCDR/DESC *LIBL/CREDITCA D)
A DSPATR(&@DESC)
A 5 2’Customer Name :’
A DSPATR(&@CNAMETX)
A CNAME R B 5 20REFFLD(CUSTOMERR/CNAME *LIBL/CUSTOMA ER)
A DSPATR(&@CNAME)
A 7 2’Address :’
A DSPATR(&@CADD1TX)
A CADD1 R B 7 20REFFLD(CUSTOMERR/CADD1 *LIBL/CUSTOMA ER)
A DSPATR(&@CADD1)
A 8 3’City/State/Zip’

A DSPATR(&@CADD1TX)
A CCITY R B 8 20REFFLD(CUSTOMERR/CCITY *LIBL/CUSTOMA ER)
A DSPATR(&@CCITY)
A CSTATE R B 8 37REFFLD(CUSTOMERR/CSTATE *LIBL/CUSTOA MER)
A DSPATR(&@CSTATE)
A CZIP R B 8 40REFFLD(CUSTOMERR/CZIP *LIBL/CUSTOMEA R)
A DSPATR(&@CZIP)
A 11 2’Credit Limit:’
A DSPATR(&@CREDLMTX)
A CREDLM R B 11 16REFFLD(CUSTOMERR/CREDLM *LIBL/CUSTOA MER)
A DSPATR(&@CREDLM)
A EDTCDE(Z)
A 23 3’F3=Exit’
A 23 23’Enter=Continue’
A 23 41’F12=Cancel’

A*A R MSFL
A*A SFL
A SFLMSGRCD(24)
A MSGKEY SFLMSGKEY
A PGMNAM SFLPGMQ(10)
A R MSFLC
A SFLCTL(MSFL)
A LOCK
A OVERLAY
A SFLSIZ(50)
A SFLPAG(1)
A N26 SFLEND
A SFLDSP
A SFLDSPCTL
A SFLINZ
A PGMNAM SFLPGMQ

@CUST# 定义为一个字节长,位置38我们用P,表示这是一个program-to –system field., 关键字DSPATR用到@CUST#的时候,必须使用符号&作为前缀,程序将根据@CUST#的值控制客户代码栏位显示的属性。
如:
    EVAL   @CUST#=UL
    EXFMT  PANEL
*    If cust# exits
    EVAL   @CUST#=PR
*    If cust# not exits
    EVAL   @CUST#=RI
那么,下次显示画面的时候,栏位CUST#就会按照@CUST#所代表的相应属性来显示了。

另外一点就是:P-fields 也可以用来控制常量.上面的DSPF代码中,@CREDLMTX用来作为@CREDLM的显示控制。

7.2.2.3           定位光标

我们怎样才能不通过指示器来定位光标所在的栏位呢?DDS中有一个关键字CRSLOC,如上面的DDS定义:
A ROW# 3S 0H
A COL# 3S 0H
A CSRLOC(ROW# COL#)
要系统自动返回光标的位置,使用RTNCSRLOC关键字。

* 我们也可以调用API QDFRTVFD来返回光标位置的,具体的用法可以参考IBM information centre的详细说明。

7.2.2.4           判断用户按下了什么键

也许你在想怎么才知道用户按下了ENTER键还是其他什么键呢?DDS并不支持把ENTER键同指示器关联,但是我们可以在程序中判断。方法就是通过用在WORKSTN文件的关键字INFDS.首先,你要在DDS定义你要用到的所有功能键如CA03,CA12等等,如:
A PRINT
A CF
01
A
CF02
A
CF24
RPG程序中,我们通过INFDSWORKSTN文件关联了一个information data structure,369位就叫做AID (Attention Indicator).我们直接把它和F3常量(关于各功能键对应得常量值见附表)相比较,就知道用户有没有按下F3.

7.2.2.5           显示出错消息

我们可以用subfile来显示给用户一些出错信息。这样可以避免为每个信息指定一个指示器。Message subfiles 显示在画面的最下面,同时出错的栏位会被反亮显示

定义一个message subfile ,需要在sflctl定义SFLPAG, SFLDSP, SFLDSPCTL, SFLSIZ这些关键字。SFLEND是必须要有一个指示器控制的关键字。它在画面右下角上显示一个‘+’或者‘More’来提示尚有更多的信息。Subfile 里面,必须要定义的关键字有:SFLMSGRCD, SFLMSGKEY, SFLPGMQ. SFLMSGRCD 指定显示消息的行数, SFLMSGKEY可以让你在程序中为消息指定一个关键字段。SFLPGMQ是程序消息队列的名字。你的程序从这个消息队列中接收错误消息,或者发送错误消息到消息队列中。SFLPGMQ (10)生成一个10-byte 的栏位。10是默认值,你只能指定它为10或者276
我们可以用API QMHSNDPM发送消息到消息队列中。
SFLMESSAGE
包含了两个模块, SendSFLMSG ClearSFLMsg. ClearSFLMsg 从消息队列中移除消息,SendSFLMSG 往消息队列中写入消息。当输入到一个栏位的值有错的时候,我们不仅可以反亮显示该栏位,也同时往消息队列中写入一条消息。使用消息队列可以避免使用硬代码(hard code)定义指示器。你可以从程序直接发送消息文本到subfile,或者发送消息标识(message ID,消息文件或者库。我觉得把错误消息存储在一个array中,然后从中取出来传递给画面十分好用。

7.2.2.6        总结

现在,我们可以让我们的程序彻底摆脱指示器了。下面是应用的基本逻辑:

1. 显示画面

2. 按下ENTER或者其他功能键。画面上包含有可输入栏位,我们用一个P-fieldprogram-to-system)来控制它的显示属性。3. Clear the subfile message queue.

4. 程序中检查AID 的值,判断是按下了ENTER键或者是什么功能键。程序中检查其有效性。

5. 重置用P-field控制的所有栏位属性到默认设置,比如可输入栏位初始会有一个UL属性。

6. 开放被控制的输入/输出栏位,将光标放在出错的第一个栏位,并反亮显示出错的栏位。程序中可以用到%FOUND 或者其他的内置函数。

7. 为每个栏位的错误发送一个信息到SFL消息队列中。

8. 重新显示画面,再次开始。或者更新文件,退出程序。

7.2.3           基本的SUBFILE的使用

显示文件中关于SFL部分的定义:

A*****************************************************************   

A          R SFL10                     SFL                           

A                                      KEEP                          

A            SFFLD1        11A  O  7  5TEXT('   ')                   

A            SFFLD2        20O  O  7 18TEXT('   ')                   

A*****************************************************************   

A          R CTL10                     SFLCTL(SFL10)                 

A                                      CSRLOC(D1ROW D1COL)           

A                                      RTNCSRLOC(&D1RCD &D1HELP)     

A                                      RTNCSRLOC(*MOUSE &D2ROW &D2COL)

A                                                                    

A                                      SFLCSRRRN(&D1RRN)              

A                                      SFLPAG(16) SFLSIZ(32)         

A  22                                  SFLDSPCTL                      

A  23                                  SFLDSP                        

A  24                                  SFLCLR                        

A*                                                    

A            DSPSF1         4S 0H      SFLRCDNBR      

A*                                                    

RPG中关于显示文件调用声明:

FDSPFILE CF  E                    WORKSTN                 

F                                        XRRN1 KSFILE SFL10

其中XRRN1为SubFile的纪录号

SubFile纪录的写入:

C                     ADD  1         XRRN1           

C                     WRITESFL10                     

如果对于同一个纪录号,重复使用了两次WRITE操作的话,系统就会出错。所以每次写的时候XRRN1是必须加1的。

SubFile的显示:

C                     MOVE ON        *IN22              

C                     MOVE ON        *IN23              

C                     Z-ADD1         DSPSF1                   

C                     EXFMTCTL10                               

C                     MOVE OFF       *IN22              

C                     MOVE OFF       *IN23              

其中DSPSF1为显示文件的纪录号,一般设置为1,使光标位置出现在第一条纪录,当然也可以根据需要来定位。

SubFile纪录的定位和更新:

C           X         CHAINSFL10                80      

C*纪录字段值及状态更新操作

C                     UPDATSFL10                         

其中X等同于XRRN1,为SubFile的纪录号。

SubFile纪录的整体删除:

C                     Z-ADD*ZERO     XRRN1              

C                     MOVE ON        *IN24              

C                     WRITECTL10                        

C                     MOVE OFF       *IN24              

 

 

 

7.2.4           如何在AS400写进度条?

The RPG to generate a Progress Bar for source files

 

     FUtl4020D  cf   e             WorkStn                                      

      *---------------------------------------------------------------------   

     D TimeStart       S               T                                       

     D TimeNow         S               T                                       

     D TimeHMS         S               T   TimFmt(*HMS)                        

     D TotalSecs       S              9S 0                                     

     D TimeHMSa        S              8                                        

      *                                                                         

     D CurrentRec      S              7S 0                                     

     D TotalRecs       S              7S 0                                     

     D PCT             S              3S 0                                     

                                                                                         

      *                                                                                  

      * play stuff                                                                        

     C                   Eval      TotalRecs = 2000                                      

     C                   Time                    TimeStart                               

                                                                                          

     C                   dow       CurrentRec < TotalRecs                                

     C                   Eval      CurrentRec = CurrentRec + 1                            

                                                                                         

      * Set the xx% value                                                                

     C                   EVAL      pct = CurrentRec * 100 / TotalRecs                    

     C                   EVAL      PRGBAR = '     ' +                                    

     C                             %Triml(%EditC(CurrentRec:'3')) +                      

     C                             ' records of ' +                                      

     C                             %Triml(%EditC(TotalRecs:'3')) + ' read.   ' +         

     C                             %EditW(PCT:'   %')                                    

      * Estimated time to completion: 

      *  (Below 5% the estimated time is probably badly misleading)

     C                   If        Pct > 5                                               

     C                   Time                    TimeNow                                  

      * Time elapsed so far:?                                                            

     C     TimeNow       SubDur    TimeStart     TotalSecs:*S                  

     C                   Eval      TotalSecs = TotalSecs/pct * (100 - pct)     

     C     T'00.00.00'   AddDur    TotalSecs:*S  TimeHMS                       

     C                   MoveL     TimeHMS       Tmp20            20           

     C                   Move      'remaining  ' Tmp20                         

     C                   Move      Tmp20         PrgBar                        

     C                   End                                                   

                                                                               

      * Set the RI placement                                                   

     C*                  EVAL      pct = (CurrentRec * %size(PRGBAR))/TotalRecs

     C                   EVAL      pct = (CurrentRec * 74)/TotalRecs           

                                                                                

     C                   If        Pct > 0                                     

     C                   EVAL      %subst(PRGBAR:pct:1) = x'21'                

     C                   Write     FMT01                                        

     C                   End                                                   

                                                                               

     C                   EndDo                                                  

                                                                               

     C                   EVAL      %subst(PRGBAR:74:1) = ' '                   

     C                   Exfmt     FMT01                                        

                                                                               

     C                   eval      *inLR = *on                                 

1.    ---------------------------------------------------------------------

 

The DDS for the screen format

 

 

        

     A******************************************************************      

     A*%%EC                                                                   

     A                                      DSPSIZ(24 80 *DS3)                 

     A                                      ERRSFL                            

     A          R FMT01                                                       

     A                                      TEXT('A displayable Progress bar')

     A                                      OVERLAY                           

     A                                      WINDOW(22 2 1 74 *NOMSGLIN)       

     A            PRGBAR        74   O  1  1DSPATR(RI)                        

     A                                      COLOR(RED)                        

     A          R DUMMY                                                         

     A                                      TEXT('PREVENTS PREVIOUS SCREEN FROM-

     A                                       BEING CLEARED')                    

     A                                      ASSUME                              

     A                                  1  9' '                                 

 

 

 

 

 

 

7.3         如何检测及分析系统性能?

a)       利用导航器的中央管理—监控器—系统

参照样本创建一个就可以了

 

b)       利用PM400

c)       利用ACCOUNTING JOURNAL

创建QACGJRN即可检测JOB的资源使用情况

在分析QACGJRN的时候,需要套用系统已有的文件格式

拷贝系统现有的文件格式----QSYS/QAJBACG4

DSPJRN JRN(QACGJRN)             

       OUTPUT(*OUTFILE)         

       OUTFILFMT(*TYPE4)        

       OUTFILE(YOURLIB/QAJBACG4)

 

7.4         如何在应用程序中校验用户密码?

DDS:

 

    A                                      DSPSIZ(24 80 *DS3)      

    A                                      CA03(03 'EXIT')         

    A          R SCRN01                                             

    A                                  4  6'ENTER YOUR PASSWORD TO -

    A                                      CONTINUE:'              

    A            PWD           10A  I  4 40                        

    A                                      DSPATR(ND)              

    A                                 23  2'F3 = EXIT'             

A            MSG           78     24  2                        

 

 

CL:

PGM                                                           

                                                             

  DCLF       FILE(CHKPWDD)                                   

                                                             

RETRY:                                                        

  SNDRCVF                                                    

  CHGVAR &MSG ' '                                            

  IF (&IN03 = '1') GOTO END                                  

                                                              

  CHKPWD PASSWORD(&PWD)                                      

            MONMSG     MSGID(CPF2362 CPF2363 CPF2364) EXEC(DO)

            RCVMSG     MSGTYPE(*LAST) RMV(*NO) MSG(&MSG)     

      GOTO RETRY                                             

  ENDDO                                                      

                                                             

END:                                                          

ENDPGM

 

7.5         如何知道ODBC真正使用者?

1.     查看QUSRWRK子系统下名为QZRCSRVS的JOB,查看JOBLOG就可以知道使用者

2.     通过CLP可以实现

pgm

 

/*                                                           */

/* *Usrspc variables...                                      */

/*                                                           */

  dcl   &usrspc        *char      20   /* Space name/lib    */

 

  dcl   &offslst       *char       4   /* Offset to list    */

  dcl   &sizlste       *char       4   /* Size list entries */

  dcl   &nbrlste       *dec   (  7 0 ) /* Number of entries */

 

  dcl   &us_hdr        *char     150   /* Space header      */

 

  dcl   &us_jobe       *char     512   /* A single entry    */

 

/*                                                           */

/* Job selection variables...                                */

/*                                                           */

  dcl   &jobname       *char      26   /* Select job name   */

  dcl   &dftuser       *char      10   value( 'QUSER     ' )

                                       /* Prestart user     */

/* Variable keys to select                                   */

  dcl   &nbrkeys       *char       4   value( x'00000002' )

                                       /* bin(   2 )        */

  dcl   &rtvcurusr     *char       4   value( x'00000131' )

                                       /* bin( 305 )        */

  dcl   &rtvsts        *char       4   value( x'00000065' )

                                       /* bin( 101 )        */

/* Variable key list...                                      */

  dcl   &varkeylst     *char     400

 

/*                                                           */

/* Retrieved values from job list...                         */

/*                                                           */

  dcl   &job           *char      10

  dcl   &user          *char      10

  dcl   &nbr           *char       6

 

  dcl   &curuser       *char      10   /* Current user      */

  dcl   &sts           *char       4   /* Job status        */

 

 

/*                                                           */

/* Global message monitor...                                 */

/*                                                           */

 

  monmsg   ( cpf0000 mch0000 )  exec( goto  Std_Err )

 

/*                                                           */

/* Create a *usrspc to work with...                          */

/*                                                           */

 

  chgvar    &usrspc       ( 'ODBCJOB   ' *cat 'QTEMP     ' )

 

  call  QUSCRTUS         ( +

                           &usrspc                 +

                           'TMPLST    '            +

                           x'00001000'             +

                           X'00'                   +

                           '*ALL      '            +

                           'Temp list ODBC jobs    ' +

                           '*YES      '            +

                           x'0000000000000000'     +

                         )

 

 

/*                                                           */

/* This sets up selection criteria for list jobs API...      */

/*                                                           */

 

/* The jobname we're after...                                */

 

  chgvar    &jobname      ( 'QZDASOINIT' *cat +

                            &dftuser     *cat +

                            '*ALL   '         +

                          )

 

/* Include current job user and active job status...         */

 

  chgvar    &varkeylst    ( &rtvcurusr *cat &rtvsts )

 

/*                                                           */

/* This lists active jobs with the job name specified.       */

/*                                                           */

 

  call  QUSLJOB          ( +

                           &usrspc                 +

                           'JOBL0200'              +

                           &jobname                +

                           '*ACTIVE   '            +

                           x'0000000000000000'     +

                           'B'                     +

                           &nbrkeys                +

                           &varkeylst              +

                         )

 

 

/*                                                           */

/* Get the *usrspc header for the list attributes...         */

/*                                                           */

 

  call  QUSRTVUS         ( +

                           &usrspc                 +

                           x'00000001'             +

                           x'00000096'             +

                           &us_hdr                 +

                         )

 

/*                                                           */

/* Get the offset to the list within the space, the number   */

/*   of list entries and size of each entry from the header. */

/*                                                           */

  chgvar    &offslst        %sst( &us_hdr    125 4 )

  chgvar    &nbrlste        %bin( &us_hdr    133 4 )

  chgvar    &sizlste        %sst( &us_hdr    137 4 )

 

/* If no entries, then get out of here...                    */

 

  if  ( &nbrlste *eq 0 )     do

     sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +

                  msgdta( 'No ODBC jobs found.' )

     goto   Clean_up

  enddo

 

 

/* Set the offset to the list within the space...            */

 

  chgvar    %bin( &offslst ) ( %bin( &offslst ) + 1 )

 

 

Nxt_JobE:

 

/* Get an entry from the list...                             */

 

  call  QUSRTVUS         ( +

                           &usrspc                 +

                           &offslst                +

                           &sizlste                +

                           &us_jobe                +

                         )

 

/* Extract job info from list entry...                       */

 

  chgvar    &job            %sst( &us_jobe     1  10 )

  chgvar    &user           %sst( &us_jobe    11  10 )

  chgvar    &nbr            %sst( &us_jobe    21   6 )

 

  chgvar    &curuser        %sst( &us_jobe    81  10 )

  if  ( &curuser *eq &dftuser )     do

     chgvar    &curuser        '*DEFAULT'

  enddo

 

  chgvar    &sts            %sst( &us_jobe   109   4 )

 

 

/* Display the result...                                     */

 

  sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +

               msgdta( 'Job<' *cat &nbr *tcat +

               '/' *cat &user *tcat +

               '/' *cat &job  *tcat +

               '> Current user<' *cat &curuser *tcat +

               '> Status<' *cat &sts *tcat '>')

 

 

/* Perform loop testing...                                   */

 

  chgvar    &nbrlste      ( &nbrlste - 1 )

 

  if  ( &nbrlste *gt 0 )     do

 

     chgvar    %bin( &offslst ) ( %bin( &offslst ) + +

                                  %bin( &sizlste ) )

     goto      Nxt_JobE

 

  enddo

 

 

/*                                                           */

/* Exit processing...                                        */

/*                                                           */

 

 

Clean_up:

 

  dltusrspc   %sst( &usrspc 11 10 )/%sst( &usrspc 1 10 )

 

  return

 

Std_Err:

 

  /* Move any *DIAG messages up the stack...        */

 

  Qsys/call  pgm( QSYS/QMHMOVPM ) parm( +

                                        '    '          +

                                        '*DIAG     '    +

                                        x'00000001'     +

                                        '*         '    +

                                        x'00000001'     +

                                        x'00000000'     +

                                      )

  Qsys/monmsg     ( CPF0000 MCH0000 )

 

  /* Resend any *ESCAPE messages up the stack...     */

 

  Qsys/call  pgm( QSYS/QMHRSNEM ) parm( +

                                        '    '          +

                                        x'00000000'     +

                                      )

  Qsys/monmsg     ( CPF0000 MCH0000 )

 

  return

 

endpgm

 

7.6      如何将报表(Spooled File)使用e-mail传输至使用者

 

由于E-mail的普及,所以常会有 AS/400报表下载到PC,并经常要利用outlook传输,很是麻烦,所以我们之整合至 AS/400 中,直接利用 AS/400 SMTP 功能即可直接传送报表。SMTP设置方法请参考ESPLF的说明文档。

 

下面的程序默认设置是转换繁体中文 "*BG5",如果是简体中文,请将 ESPLFC 指令 CPYTOPC参数 TRNIGC 值改为 "*SCGS",即可转换为简体。

 

File  : QCLSRC

Member: ESPLFC

Type  : CLP

Usage : CRTCLPGM  ESPLFC

OS Version: V4R1()

/**================================================================**/

/* ESPLF ** EMAIL SPOOL FILE                                        */

/* Compile: CRTCLPGM PGM(QGPL/ESPLFC)                               */

/**================================================================**/

             PGM        PARM(&FILE &EMAIL &QJOB &SPLNBRD)

             DCL        VAR(&QJOB) TYPE(*CHAR) LEN(26) /* job name */

             DCL        VAR(&FILE) TYPE(*CHAR) LEN(10) /* spool file +

                          name */

             DCL        VAR(&SPLNBRD) TYPE(*DEC) LEN(5 0) /* spool +

                          file number */

             DCL        VAR(&EMAIL) TYPE(*CHAR) LEN(40) /* to email +

                          address */

             DCL        VAR(&JOB)  TYPE(*CHAR) LEN(10)

             DCL        VAR(&USER) TYPE(*CHAR) LEN(10)

             DCL        VAR(&NBR)  TYPE(*CHAR) LEN(6)

             DCL        VAR(&SPLNBR) TYPE(*CHAR) LEN(6) /* spool +

                          file number */

             DCL        VAR(&FNAME)  TYPE(*CHAR) LEN(12)

             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))

/**================================================================**/

/* Translate JOB special values                                     */

/**================================================================**/

             IF         COND(&QJOB = '*') THEN(RTVJOBA JOB(&JOB) +

                          USER(&USER) NBR(&NBR))

             ELSE       CMD(DO)

               CHGVAR     VAR(&JOB)  value(%SST(&QJOB 1 10))

               CHGVAR     VAR(&USER) value(%SST(&QJOB 11 10))

               CHGVAR     VAR(&NBR)  value(%SST(&QJOB 21 6))

             ENDDO

/**================================================================**/

/* Translate SPLNBR special values                                  */

/**================================================================**/

             IF         COND(&SPLNBRD = -1) THEN(CHGVAR VAR(&SPLNBR) +

                          value('*ONLY'))

             ELSE       CMD(IF COND(&SPLNBRD = -2) THEN(CHGVAR +

                          VAR(&SPLNBR) value('*LAST')))

             ELSE       CMD(CHGVAR VAR(&SPLNBR) value(&SPLNBRD))

/**================================================================**/

/* E-mail                                                           */

/**================================================================**/

             CHKOBJ     OBJ(QTEMP/ESPLF) OBJTYPE(*FILE)

             MONMSG     MSGID(CPF9801) EXEC(CRTPF FILE(QTEMP/ESPLF) +

                          RCDLEN(198) IGCDTA(*YES) SIZE(*NOMAX))

             CPYSPLF    FILE(&FILE) TOFILE(QTEMP/ESPLF) +

                          JOB(&NBR/&USER/&JOB) SPLNBR(&SPLNBR) +

                          MBROPT(*REPLACE)

             CHGVAR   VAR(&FNAME) value(%SST(&FILE 1 8) *TCAT '.TXT')

             CPYTOPCD   FROMFILE(QTEMP/ESPLF) TOFLR('temp') +

                          TODOC(&FNAME) REPLACE(*YES) +

                          TRNTBL(*NONE) TRNIGC(*BG5)

             SNDDST     TYPE(*DOC) TOINTNET((&EMAIL)) DSTD(&FILE) +

                        LONGMSG(&FILE) DOC(&FNAME) FLR('temp') +

                        SUBJECT(&FILE *BCAT 'TESTED' )

             DLTDLO     DLO(&FNAME) FLR('temp')

             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Spooled +

                          file' |> &FILE |> 'sent to' |> &EMAIL)

             RETURN

/**================================================================**/

/* Global exception handler                                         */

/**================================================================**/

 ERROR:      CALL       PGM(QMHRSNEM) PARM('    ' X'00000000')

             MONMSG     MSGID(CPF0000)

             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +

                          MSGDTA('Error(s) occured, see previously +

                          listed messages') MSGTYPE(*ESCAPE)

             ENDPGM

 

 

File  : QCMDSRC

Member: ESPLF

Type  : CMD

Usage : CRTCMD CMD(ESPLFC) PGM(ESPLFC)

OS Version: V4R1()

 

/* sample: ESPLF FILE(QPJOBLOG) EMAIL(support@yahoo.com) */

/* V4R1 or later is required.   */

/*You must create a temporary folder using the command CRTFLR FLR(TEMP) */

/* 1.Using CFGTCP, Option 10=Work with TCP/IP host table entries,   */

/*  verify your mail server name is in the table (add if necessary). */

/*  ADD TWN6CPD  145.172.2.11  MAIL SERVER                           */

/*  ADD WTWNAS01 145.172.1.1   LOCAL AS/400 HOST                     */

/* 2. Ping mail server                                               */

/* 3. CHGSMTPA, verify AUTOSTART(*YES) and MAILROUTER(mail-svr-name) */

/* 4. ADDDIRE USRID(INTERNET SMTPRTE)   +                          */

/*       USRD('Internet SMTP gateway') SYSNAME(INTERNET)   +       */

/*       PREFADR(NETUSRID *IBM ATCONTXT)                           */

/*    CHGDSTA SMTPRTE(INTERNET SMTPRTE)                            */

/* 5. STRTCPSVR *SMTP                                              */

/*    If you changed the mail server address, you need restart SMTP*/

/* 6. Test : SNDDST TYPE(*LMSG) TOINTNET(E-mail address)    +      */

/*                  DSTD('Test message') LMSG('Test message')      */

/*    use the Work with Directory Entries (WRKDIRE) command to     */

/*    enroll you in the system directory.                          */

/*                                                                   */

/* preventing large e-mail messages from splitting                   */

/*           CHGPOPA MSGSPLIT(*NOMAX)                               */

/*                            *DFT size is 128k                     */

             CMD        PROMPT('E-mail Spooled File')

             PARM       KWD(FILE) TYPE(*NAME) MIN(1) PROMPT('Spooled +

                          file')

             PARM       KWD(EMAIL) TYPE(*CHAR) LEN(40) MIN(1) +

                          PROMPT('To e-mail address')

             PARM       KWD(JOB) TYPE(JOB) DFT(*) SNGVAL((*)) +

                          PROMPT('Job name')

             PARM       KWD(SPLNBR) TYPE(*DEC) LEN(4) DFT(*ONLY) +

                          SPCVAL((*ONLY -1) (*LAST -2)) +

                          PROMPT('Spooled file number')

 JOB:        QUAL       TYPE(*NAME) DFT(*)

             QUAL       TYPE(*NAME) PROMPT('User')

             QUAL       TYPE(*CHAR) LEN(6) RANGE(000000 999999) +

                          PROMPT('Number')

 

 

 

 

7.7    报表设计工具RLU

RLU的意思为Report Layout Utility(报表设计工具)

 

RPG程序设计的初衷就是为了设计报表以供系统打印。随着技术的改进和OS/400版本的不断升级,现在的许多输出设备都已经改变了传统报表的用法,原来使用程序定义定义文件设计报表,目前则经常采用报表设计工具RLU来设计打印文件PRTF,然后再通过RPGIV+PRTF组合来编制程序。

 

下面将以OS/400 V5R2M0为基准,循序渐进地讲解RLU的使用方法,下面以RLU设计一个A3纸型(11×12 inch、链式打印纸)为例。

 

一、PF文件说明:

 

1EDISYSTEM/QDDSSRC(REFILE)为数据公共字典PF

 

代码:

 

     A* CREATE BY TRF.LIUYUANYAO  2004.12.12

     A* DATA DICTIONARY REFERENCE FILE

     A*----------------------------------------------------

     A          R REFMT

     **

     A* CHARACTER SET

     A            CODE           5A

     A            ID             7A

     **

     A* DBCS-OPEN SET

     A            NAME1         12O

     A            NAME2         12O

     A            DESCRPT       30O

     **

     A** NUMERIAL SET

     A            AMOUNT        15  2

     A            PRICE         11  2

     A            QUATITY        7  0

     **

     A** DATE SET

     A            DATE1           L

 

 

2EDISYSTEM/QDDSSRC(EMPLOYEES)为参照数据公共字典的其中一个PF

 

代码:

 

     A* PROGRAMER    : TRF.LIUYUANYAO 2004.12.14

     A* PROGRAM NAME : EMPLOYEES

     A*****************************************************************

     A                                      REF(*LIBL/REFILE)

     A                                      UNIQUE

     A          R EMPLOY

     A            EYCODE    R               REFFLD(ID)

     A                                      COLHDG('雇员码')

     A            DPCODE    R               REFFLD(CODE)

     A                                      COLHDG('部门码')

     A            EYNAME    R               REFFLD(NAME2)

     A                                      COLHDG('雇员名')

     A            SUBTOTAL  R               REFFLD(AMOUNT)

     A                                      COLHDG('小计')

     A*

     A          K EYCODE

     A          K DPCODE

 

 

二、使用RLU的具体操作步骤:

 

2.1 为打印文件选择数据库:

 

1、在OS/400命令行敲入STRRLU+F4,分别在Source fileLibrarySource member输入对应内容,并且定义Page width...198

 

代码:

 

                      Start Report Layout Utility (STRRLU)                     

                                                                               

Type choices, press Enter.                                                      

                                                                               

Source file  . . . . . . . . . . > QDDSSRC       Name, *PRV                   

   Library  . . . . . . . . . . . >   EDISYSTEM   Name, *LIBL, *CURLIB, *PRV   

Source member  . . . . . . . . . > LPRTF01       Name, *PRV                   

Option . . . . . . . . . . . . .   2             2, 6                         

Page width . . . . . . . . . . . > 198           1-378, *SAME                 

Text 'description' . . . . . . . > 'DEMO for Design Report'                   

                                                                               

 

2、执行后出现如下效果,RLU展示出报表设计屏面。

我们可以使用SEU对其进行编辑:左边的'''''''为功能定义区域,空白区为设计编辑显示区域;左侧开始BASE显示了打印时出标尺;...+... 1 ...+... 2 最大可以定义378个字符位置。

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

        --------------------------- End of Report -----------------------------

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                  

F22=Alternative keys         F24=More keys                                     

Record length of source file greater than 92.                                 +    

 

3、按F10,输入LibraryFileRecord,将光标停在Field栏按F4

 

代码:

 

                           Work with Database Fields                           

                                                                               

Type options, press Enter.                                                     

   1=Add field   4=Remove   8=Display field description                         

                                                                               

Option     Field          Library        File           Record                 

   1                       EDISYSTEM      EMPLOYEES      EMPLOY                 

                                                                               

   (No database fields selected)                                               

                                                                                

 

 

 

                                                                         Bottom

F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F16=Delete all fields         

                                                     

 

 

 

4、出现如下界面后再在Field栏按F4

 

代码:

 

                              Add Database Fields                               

                                                                               

Type choices, press Enter.                                                      

                                                                               

   File . . . . . . . . . . .   EMPLOYEES       Name, F4 for list               

     Library  . . . . . . . .     EDISYSTEM     Name, *LIBL, *CURLIB            

   Record format  . . . . . .   EMPLOY          Name, F4 for list               

   Field  . . . . . . . . . .                   Name, F4 for list               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

F4=Prompt   F5=Refresh   F12=Cancel                                           

Specify field name.                                                               

 

 

 

 

5、执行后可见下图,键入1=Select,选择数据库所有的字段;然后连续键入3次执行:

 

代码:

 

                             Select Database Fields                             

                                                                               

File . . . . . . . . :   EMPLOYEES       Record . . . . . . . :   EMPLOY       

   Library  . . . . . :     EDISYSTEM                                           

                                                                               

Position to  . . . . .                Field                                    

Subset . . . . . . . .   *ALL         *ALL, name, *generic*                   

                                                                               

Type options, press Enter.                                                      

   1=Select   8=Display field description                                       

                                                                               

                                                          Column               

Opt     Field       Length  Type                         Heading               

  1       DPCODE           5  Character                    DPCODE               

  1       EYCODE           7  Character                    EYCODE               

  1       EYNAME          12  Bracketed DBCS               EYNAME               

  1       SUBTOTAL      15,2  Zoned decimal                SUBTOTAL             

                                                                               

                                                                         Bottom

F5=Refresh   F11=Display unsorted   F12=Cancel                                 

DBCS characters in field DPCODE column heading. Heading defaults to field... +    

 

6、我们可以发现刚才所选择的数据库字段已经放置在设计界面底端。

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

        --------------------------- End of Report -----------------------------

                                                                                

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys       

 

2.2 定义记录格式:

 

打印过程是通过RPGIV程序使用写语句将记录输出写至打印文件。写语句后面所调用的是记录格式,每执行一次RPGIV写程序,就调用一次RLU文件中的记录格式,因此我们首先需要定义记录格式。

 

1、在左侧定义键入DR(Define Record Format):

 

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

DR                                                                              

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

'''''''                                                                         

'''''''                                                                         

'''''''                                                                          

        --------------------------- End of Report -----------------------------

                                                                               

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

 

 

 

2、键入执行后,可以看见DR定义自动生成的名为RCD001记录格式。

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

RCD001                                                                         

        --------------------------- End of Report -----------------------------

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                  

F22=Alternative keys         F24=More keys                                     

                                                                         

 

 

 

3、不够规范吧,那就改名。键入F18,选择记录关键字。

 

代码:

 

                           Work with Record Keywords                           

                                                                               

Record format  . . . . :   RCD001                                              

                                                                               

Type options, press Enter.                                                     

   2=Specify   4=Remove                                                          

                                                                               

Opt     Keyword            Opt     Keyword            Opt     Keyword         

         CDEFNT                     LPI                                         

         CHRSIZ                     PAGRTT                                     

         CPI                        PRTQLTY                                     

         DFNCHR                     SKIPA                                       

         DFNLIN                     SKIPB                                       

         DRAWER                     SPACEA                                     

         FNTCHRSET                  SPACEB                                     

         FONT                       TEXT                                       

         HIGHLIGHT                                                             

         IGCCDEFNT                                                             

         IGCCHRRTT                                                              

         INDTXT                                                                 

                                                                         Bottom

F3=Exit      F5=Refresh   F9=Input keyword parameters   F10=Rename record     

F12=Cancel   F16=Remove all keywords                                           

                                                                     

 

4、再按F10=Rename record,将记录格式名改为:DETAIL

 

代码:

                              Rename Record Format                             

                                                                               

Number of keywords . . . . . . . . . :   0                                     

                                                                                

Type choice, press Enter.                                                     

                                                                               

   Record format  . . . . . . . . . . .   DETAIL       Name                     

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                               

F3=Exit   F5=Refresh   F12=Cancel                                             

                                                                   

 

5、连续2次执行键后,记录格式名已经改为了DETAIL

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

DETAIL                                                                         

        --------------------------- End of Report -----------------------------

                                                                               

                                                                                

                                                                               

                                                                              

                                                                                

                                                                               

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys         

 

2.3 放置数据库字段:

 

1、在DETAIL键入VF(View Field)插入字段观察命令:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

VF                                                                              

        --------------------------- End of Report -----------------------------

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                   

2、键入执行,可见左侧显示生成一个FLD1字段区准备放置F10所选择的数据库文件字段:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                                                                            

DETAIL                                                                         

        --------------------------- End of Report -----------------------------

                                                                                

                                                                               

                                                                              

                                                                               

                                                                               

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                               

 

3、将编辑屏幕下方的数据库文件字段序号按字段比例键入对应位置,c表示将字段表头放在上方。

注意:一定要放置与FLD1同一行上;同时要预先估算一下留出的每个字段长度与下个字段长度的间隔,防止字段相互覆盖。

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1       1c         2c               3c                 4c                   

DETAIL                                                                         

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

                                                                                

                                                                               

1:DPCODE   2:EYCODE   3:EYNAME   4:SUBTOTAL                                   

F3=Exit   F11=Define field   F16=Delete field                                  

F22=Alternative keys         F24=More keys                                     

                                                                               

 

4、键入执行,将数据库字段放置在设计报告上。

假设出现了字段间互相覆盖,可以使用F13消除字段区,F15移动字段区,F16字段删除,以调整各个字段间隔。

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                                

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                               

5、在DETAIL命令行键入样本数据命令SD5(Sample Data),执行后参见下图,可见已经生成5行样本数据:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00003 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                                

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                

 

 

 

2.4 定义表头:

 

1、在左侧命令行键入I插入一行,并键入DR定义一个记录格式,执行:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

DR                                                                             

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00003 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999        

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                                

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                   

 2、然后在刚刚生成的记录格式上键入DF,并且在同一编辑行居中位置键入“hhhhhhhhhh”,定义一个常数字段:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

DF                            hhhhhhhhhh                                       

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                   

 3、键入执行,生成新的记录格式名RCD004以及表头字段:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                                       

RCD004                       hhhhhhhhhh                                        

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

DF created 1 fields in record format RCD004.                                       

 

4、使用F18然后再F10,跟上面同样方法改变RCD004记录格式名为:HEADER

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                                       

HEADER                       hhhhhhhhhh                                        

FLD1       <....>     <....>              <....>             <......>           

RCD002    DPCODE     EYCODE              EYNAME             SUBTOTAL           

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                   

5、将光标移至常数字段hhhhhhhhhh上,键入F23进行编辑字段:

 

代码:

 

                            Work with Field Keywords                           

                                                                               

Field  . . . . . . . . :   FLD001        Record format  . . . . :   HEADER     

                                                                               

Type options, press Enter.                                                     

   2=Specify   4=Remove                                                          

                                                                               

Opt     Keyword            Opt     Keyword            Opt     Keyword         

         ALIAS                      DFT                        IGCCHRRTT        

         BARCODE                    DLTEDT                     INDTXT           

         BLKFOLD                    EDTCDE                     MSGCON           

         CDEFNT                     EDTWRD                     PAGNBR           

         CHRID                      FLTFIXDEC                  PRTQLTY         

         CHRSIZ                     FLTPCN                     REFFLD           

         COLOR                      FNTCHRSET                  SKIPA           

         CPI                        FONT                       SKIPB           

         CVTDTA                     HIGHLIGHT                  SPACEA           

         DATE                       IGCALTTYP                  SPACEB           

         DATFMT                     IGCANKCNV                  TEXT             

         DATSEP                     IGCCDEFNT                  TIME             

                                                                        More...

F3=Exit   F5=Refresh   F9=Input keyword parameters   F10=Specify information   

F12=Cancel   F16=Remove all keywords                                           

                                                                             

6、在DFT选项上键入2编辑常数项,执行,键入' 职工信息 ' ,此处定义的是本报表的表头,然后再键入2次执行:

 

代码:

 

                                Specify Default                                 

                                                                               

Keyword  . . . . . . . :   DFT                                                 

Field  . . . . . . . . :   FLD001                                             

Record format  . . . . :   HEADER                                             

                                                                               

Type text of constant, press Enter.                                           

                                                                               

   ' 职工信息 '                                                                 

                                                                               

                                                                               

F3=Exit   F5=Refresh   F12=Cancel   F16=Remove keyword                         

                                                                                             

 

 

7、键入F10,然后再键入F11将其转换为常数项:

 

代码:

 

                           Specify Field Information                            

                                                                               

Edited length . . . . . . . . . . . . :   10                                   

Record format . . . . . . . . . . . . :   HEADER                                

Number of keywords  . . . . . . . . . :   1                                   

Number of indicators  . . . . . . . . :   0                                   

Constant keyword  . . . . . . . . . . :   ' 职工信息 '                         

                                                                               

                                                                               

Type choices, press Enter.                                                     

                                                                               

   Option indicators . . . . . . . . . .                 01-99, N01-N99         

     More indicators . . . . . . . . . .     N           Y=Yes, N=No           

   Starting line . . . . . . . . . . . .                 1-255                 

   Starting position . . . . . . . . . .    23           1-255, +nn             

                                                                                

F3=Exit   F5=Refresh   F11=Convert to named field   F12=Cancel                                                                                                 

                                                                  

8、按2次执行键退出编辑。

Work with Field Keywords同样的定义方法,可以对表头字体进行编辑,下图显示了定义字形CHRSIZ2×2时的编辑状态。

注意:只有当打印以后才能看见实际字形,而在5250终端上显示仅仅是普通尺寸字体。

 

代码:

 

                             Specify Character Size                             

                                                                                

Keyword  . . . . . . . . . . . . . . :   CHRSIZ                               

Field  . . . . . . . . . . . . . . . :   FLD005                               

Record format  . . . . . . . . . . . :   HEADER                                

                                                                               

Type choices, press Enter.                                                     

                                                                                

   Expand character size:                                                       

                                                                               

    Width multiplier  . . . . . . . . .   2            1.0-20.0                  

                                                                               

    Height multiplier . . . . . . . . .   2            1.0-20.0                 

                                                                               

                                                                                

                                                                               

F3=Exit   F5=Refresh   F12=Cancel   F16=Remove keyword                         

                                                                                

9、同时定义表头跳页关键字SKIPB

代码:

                            Work with Field Keywords                           

                                                                               

Field  . . . . . . . . :   FLD005        Record format  . . . . :   HEADER     

                                                                               

Type options, press Enter.                                                     

   2=Specify   4=Remove                                                         

                                                                               

Opt     Keyword            Opt     Keyword            Opt     Keyword         

         ALIAS                      DFT                        IGCCHRRTT       

         BARCODE                    DLTEDT                     INDTXT           

         BLKFOLD                    EDTCDE                     MSGCON           

         CDEFNT                     EDTWRD                     PAGNBR           

         CHRID                      FLTFIXDEC                  PRTQLTY         

      >  CHRSIZ                     FLTPCN                     REFFLD           

         COLOR                      FNTCHRSET                  SKIPA           

         CPI                        FONT                2      SKIPB           

         CVTDTA                     HIGHLIGHT                  SPACEA           

         DATE                       IGCALTTYP                  SPACEB           

         DATFMT                     IGCANKCNV                  TEXT             

         DATSEP                     IGCCDEFNT                  TIME             

                                                                        More...

F3=Exit   F5=Refresh   F9=Input keyword parameters   F10=Specify information   

F12=Cancel   F16=Remove all keywords                                           

                                                                                   

 

10、为什么要定义SKIPB呢?对于链式打印纸来说,每次换页时,应该跳过纸缝再打印表头,SKIPB就是完成这个功能的。

键入执行,完成对表头的关键字的设计。

在表头设计我们共定义了CHRSIZSKIPBDFT3个关键字。

代码:

 

 

                              Specify Skip Before                               

                                                                               

Keyword  . . . . . . . . . . . . . . :   SKIPB                                 

Field  . . . . . . . . . . . . . . . :   FLD005                               

Record format  . . . . . . . . . . . :   HEADER                               

Number of indicators . . . . . . . . :   0                                      

                                                                               

Type choices, press Enter.                                                     

                                                                                

   Line number to skip to before                                               

     printing . . . . . . . . . . . . .     1           1-255                   

                                                                                

   Option indicators  . . . . . . . . .                 01-99, N01-N99         

                                                                               

     More indicators  . . . . . . . . .     N           Y=Yes, N=No             

                                                                                

                                                                               

                                                                               

                                                                                

F3=Exit   F5=Refresh   F12=Cancel   F16=Remove keyword                         

 

11、键入执行返回设计报告:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                                       

HEADER                        职工信息                                         

FLD1       <.......>     <.......>              <.......>             <.....>   

RCD002     雇员码        部门码                 雇员名                小计     

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                   

12、定义表头页号,使得每打印1页,表头页号自动加1。将光标移动至表头的右上侧,键入F11定义一个页号字段:

 

代码:

 

                            Define Field Information                           

                                                                               

Edited length . . . . . . . . . . . . :   1                                   

Record format . . . . . . . . . . . . :   HEADER                               

Number of keywords  . . . . . . . . . :   0                                   

Number of indicators  . . . . . . . . :   0                                   

                                                                                

Type choices, press Enter.                                                     

                                                                               

   Field . . . . . . . . . . . . . . . .   FLD009        Name                    

   Option indicators . . . . . . . . . .                 01-99, N01-N99         

     More indicators . . . . . . . . . .     N           Y=Yes, N=No           

   Starting line . . . . . . . . . . . .                 1-255                  

   Starting position . . . . . . . . . .   +31           1-255, +nn             

   Length of data  . . . . . . . . . . .     1           1-378, +nn, -nn       

                                                                               

                                                                                

                                                                        More...

F3=Exit   F5=Refresh   F10=Work with keywords   F11=Convert to constant field 

F12=Cancel                                                                      

                                                                       

13、再键入F10,在关键字PAGNBR选项键入2

 

代码:

 

                            Work with Field Keywords                           

                                                                                

Field  . . . . . . . . :   FLD009        Record format  . . . . :   HEADER     

                                                                               

Type options, press Enter.                                                     

   2=Specify   4=Remove                                                         

                                                                               

Opt     Keyword            Opt     Keyword            Opt     Keyword         

         ALIAS                      DFT                        IGCCHRRTT       

         BARCODE                    DLTEDT                     INDTXT           

         BLKFOLD                    EDTCDE                     MSGCON           

         CDEFNT                     EDTWRD              2      PAGNBR           

         CHRID                      FLTFIXDEC                  PRTQLTY         

         CHRSIZ                     FLTPCN                     REFFLD           

         COLOR                      FNTCHRSET                  SKIPA           

         CPI                        FONT                       SKIPB           

         CVTDTA                     HIGHLIGHT                  SPACEA            

         DATE                       IGCALTTYP                  SPACEB           

         DATFMT                     IGCANKCNV                  TEXT             

         DATSEP                     IGCCDEFNT                  TIME             

                                                                        More...

F3=Exit   F5=Refresh   F9=Input keyword parameters   F12=Cancel               

F16=Remove all keywords                                                       

Field FLD009 created in record format HEADER.                                     

 

14、键入4次执行,定义页号关键字PAGNBR,在定义过程中按执行不必理睬在提示行出现的ERROR信息;返回到Specify Field Information界面:

 

代码:

 

                           Specify Field Information                           

                                                                               

Edited length . . . . . . . . . . . . :   1                                   

Record format . . . . . . . . . . . . :   HEADER                               

Number of keywords  . . . . . . . . . :   1                                   

Number of indicators  . . . . . . . . :   0                                   

                                                                               

Type choices, press Enter.                                                     

                                                                                

   Field . . . . . . . . . . . . . . . .   FLD009        Name                   

   Option indicators . . . . . . . . . .                 01-99, N01-N99         

     More indicators . . . . . . . . . .     N           Y=Yes, N=No           

   Starting line . . . . . . . . . . . .                 1-255                 

   Starting position . . . . . . . . . .   +31           1-255, +nn             

   Length of data  . . . . . . . . . . .     1           1-378, +nn, -nn       

                                                                               

                                                                               

                                                                        More...

F3=Exit   F5=Refresh   F10=Work with keywords   F11=Convert to constant field 

F12=Cancel                                                                     

 

15、键入F11将其转换为常数字段。键入执行,可见PAGNBR字段定义在表头右侧:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                               <..>     

HEADER                        职工信息                                9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

RCD002     雇员码        部门码             雇员名                小计         

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

 

16、在左侧命令行上HEADER记录格式上键入DF(Define Field),同时在PAGNBR字段左侧相应位置键入Page:,执行后在页号字段左侧生成常数字段Page

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                               <..>     

DF                            职工信息                           Page:9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

RCD002     雇员码        部门码             雇员名                小计         

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                                

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

 

17、键入执行,现在报表设计完成如下:

 

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                          <...><..>     

HEADER                        职工信息                           Page:9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

RCD002     雇员码        部门码             雇员名                小计         

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                      

 

2.5 合并记录格式:

 

我们见到记录格式一共有三个:HEADERDETAILRCD002,需要将HEADERRCD002合并在一起。

 

1、在左侧命令行RCD002上键入CLC(Change Line Format and Combine):

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                          <...><..>     

HEADER                        职工信息                           Page:9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

CLC        雇员码        部门码             雇员名                小计         

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                                

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                      

 

2、键入执行,可见RCD002被合并到HEADER记录格式中,在其行最左侧显示+表示此行为HEADER的记录格式续行:

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                          <...><..>     

HEADER                        职工信息                           Page:9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

00002 +     雇员码        部门码             雇员名                小计         

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00004 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

                                                                               

                                                                                

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

                                                                                    

3、进一步使用DR(定义一个记录格式)、DF(定义虚线字段)、CLC(合并记录格式至表头)生成按字段宽度分割虚线,即每一个字段与标题之间生成‘------’修饰报表。

代码:

 

Columns . . . :    1  71        Design Report                EDISYSTEM/QDDSSRC

RLU==>                                                                 LPRTF01

BASE    ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        ------------------------- Start of Page 001 ---------------------------

FLD1                          <........>                          <...><..>     

HEADER                        职工信息                           Page:9999     

FLD1       <.......>     <.......>              <.......>             <.....>   

00002 +     雇员码        部门码             雇员名                小计         

FLD1      <........>   <.........>     <...........>      <.............>       

00003 +   ----------   -----------     -------------      ---------------       

FLD1       <...>      <.....>          <..........>       <.............>       

DETAIL    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00005 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00006 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00007 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00008 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

00009 S    XXXXX      XXXXXXX          XXXXXXXXXXXX       999999999999999       

        --------------------------- End of Report -----------------------------

                                                                               

F3=Exit   F11=Define field   F16=Delete field                                 

F22=Alternative keys         F24=More keys                                     

 

2.6 建立变量型字段:

 

1、首先使用DRDF以及重命名功能定义一个记录格式TOTALN。将光标移至小计字段SUBTOTAL下方,键入F11定义一个汇总字段。

字段名我们定义为TOTALX,字段长度17,数据类型为2

 

代码:

 

                            Define Field Information                           

                                                                                

Edited length . . . . . . . . . . . . :   1                                   

Record format . . . . . . . . . . . . :   TOTALN                               

Number of keywords  . . . . . . . . . :   0                                    

Number of indicators  . . . . . . . . :   0                                   

                                                                               

Type choices, press Enter.                                                     

                                                                               

   Field . . . . . . . . . . . . . . . .   TOTALX        Name