Chinaunix首页 | 论坛 | 博客
  • 博客访问: 347166
  • 博文数量: 90
  • 博客积分: 847
  • 博客等级: 准尉
  • 技术积分: 1373
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-02 10:54
个人简介

跌打滚爬中的小菜鸟...

文章分类

全部博文(90)

文章存档

2015年(5)

2013年(47)

2012年(38)

我的朋友

分类: 其他UNIX

2012-10-20 15:54:47

1. Printer File的定义       
这也就是所谓的'画报表',可以通过RLU来实现. 其实这一步的用途就是定义报表格式.

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+
        *************** Beginning of data *******************************
0001.00       *                                                          
0002.00      A          R TITLE                                          
0003.00      A                                      SPACEA(001)          
0004.00      A                                    61                     
0005.00      A                                      'EMPLOYEE LIST'      
0006.00      A                                                           
0007.00      A          R DHEAD                                          
0008.00      A                                      SPACEA(001)          
0009.00      A                                     4                     
0010.00      A                                      'NAME'               
0011.00      A                                      HIGHLIGHT            
0012.00      A                                      UNDERLINE            
0013.00      A                                                           
0014.00      A                                    15                     
0015.00      A                                      'SERIAL'             
0016.00      A                                      HIGHLIGHT            
0017.00      A                                      UNDERLINE            
0018.00      A                                                           
0019.00      A                                    25                     
0020.00      A                                      'SALARY'         
0021.00      A                                      HIGHLIGHT        
0022.00      A                                      UNDERLINE        
0023.00      A                                                       
0024.00      A                                    36                 
0025.00      A                                      'FLAG'           
0026.00      A                                      HIGHLIGHT        
0027.00      A                                      UNDERLINE        
0028.00      A                                                       
0029.00      A                                    41                 
0030.00      A                                      'TIMESTAMP'      
0031.00      A                                      HIGHLIGHT        
0032.00      A                                      UNDERLINE        
0033.00      A                                                       
0034.00      A          R EMPEE                                      
0035.00      A                                      SPACEA(002)      
0036.00      A            NAME          10A        4                 
0037.00      A            SERIAL         6A       15                 
0038.00      A            SALARY        10S 2     25                 
0039.00      A            FLAG           1A       36     
0040.00      A            TS              Z       41     
        ****************** End of data ******************


2. RPG程序

这一步就是所谓的'打印报表',准备打印数据,然后将内容打印到Spooled File中. 其实这一步就准备并发送打印数据.

 FMT F  FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++
        *************** Beginning of data *********************
0001.00 FDDS01     O    E             PRINTER OFLIND(*IN99)    
0002.00  *                                                     
0003.00 C                   WRITE     TITLE                    
0004.00 C                   WRITE     DHEAD                    
0005.00 C     1             DO        100                      
0006.00 C                   EVAL      NAME = 'ZHANG SAN'       
0007.00 C                   EVAL      SERIAL='600001'          
0008.00 C                   EVAL      SALARY=100.02            
0009.00 C                   EVAL      FLAG='1'                 
0010.00 C                   TIME                    TS         
0011.00 C                   WRITE     EMPEE                    
0012.00 C                   ENDDO                              
0013.00 C                   CLOSE     DDS01                    
0014.00  *                                                     
0015.00 C                   OPEN      DDS01                    
0016.00 C                   WRITE     TITLE                    
0017.00 C                   WRITE     DHEAD                    
0018.00 C                   EVAL      NAME = 'ZHANG SAN'       
0019.00 C                   EVAL      SERIAL='600001'          
0020.00 C                   EVAL      SALARY=100.02                          
0021.00 C                   EVAL      FLAG='1'                               
0022.00 C                   TIME                    TS                       
0023.00 C                   WRITE     EMPEE                                  
0024.00 C                   CLOSE     DDS01                                  
0025.00  *                                                                   
0026.00 C*    'DONE'        DSPLY                                            
0027.00 C                   SETON                                        LR  
0028.00 C                   RETURN                                           
        ****************** End of data **************************************

几点说明:
1.对于RPG打印报表的理解: Printer File就是定义打印的具体格式,RPG就是准备要打印的数据并将这些数据发送给Printer File(Write操作),这就如同我们平时打印文件一样, Word,jpg什么的决定打印格式,然后我们往word中写入文档,或者制作jpg,然后我们将数据发送给打印机.   最后打印机自己将东西打印出来.

2.定义报表格式时很多人用RLU.  用DDS最根本.

3.DDS定义报表格式时要注意的几个Function Keyword
SKIPA:  Skip After    在Write时,写该字段后,自动换页
SKIPB:  Skip Before   在Write时,写该字段前,自动换页
SPACEA: Space After   写该字段后,再打印空格s
SPACEB: Space Before  写该字段前,打印空格s

4.报表自动换页问题.      OFLIND(*IN99)表示该报表文件换页指示器(overflow indicator)是*IN99,当写满1页时,*IN99自动变为1,然后报表自动换页,*IN99再自动变回0. 如果不指定该keyword,如果打印的报表多余1页,则程序在执行过程中会报错.
手动换页不讨论了...(有人用SKIPA实现换页)

5.关于打印多份报表.       
首先,PRTF不用声明USROPN就可以多次OPEN,但这时一定要注意了,由于系统在执行第一条C表时就自动OPEN了所有File,所以不能再OPEN了,否则是要出错滴.
第二,PRTF每OPEN,CLOSE一次算是打印一份报表,即在Spooled File是能看到多份的(名字一般是重复的).
第三,PRTF中含有多条Record,每条Record相当于一个DS,并且一个Record实际上是可以占多行的.要想打印哪个Record你就需要Write这个Record,否则是不会被打印出来的.

6.打印报表时会自动忽略空行!!!!这情况比较复杂...

7.DDS定义Printer File时用到的一些Function Keywords

Name

Level

Description

ALIAS

F

to specify an alternative name for a field

BARCODE

F

to print a field as a user-specified bar code

BLKFOLD

F

BOX

R

to print a rectangle

CDEFNT

B

to specify the coded font

CHRID

F

CHRSIZ

B

to expand the width and height of a record or field

COLOR

F

to specify the color for a field

CPI

B

CVTDTA

F

DATE

F

to display the current date or the current system
date as a constant field 6 or 8 bytes long

DATFMT

F

to specify the format of a date field

DATSEP

F

to specify the separator character for a date field

DFNCHR

R

File

to define characters of your own design

DFT

F

to specify a constant value for constant (unnamed) fields

DLTEDT

F

DOCIDXTAG

R

DRAWER

F

DTASTMCMD

B

DUPLEX

R

to specify whether output is printed on one side or two
sides of the paper

EDTCDE

EDTWRD

ENDPAGE

R

to eject the current page after the record is printed

ENDPAGGRP

R

FLTFIXDEC

F

FLTPCN

F

FNTCHRSET

B

File

FONT

B

to specify the font ID for printing a named

FONTNAME

B

File

FORCE

R

GDF

R

HIGHLIGHT

B

to indicate that a field should be printed in bold letters.

INDARA

File

INDTXT

B

File

INVDTAMAP

R

INVMMAP

R

LINE

R

to print a horizontal or vertical line

LPI

R

MSGCON

F

OUTBIN 

R

OVERLAY

R

to print an overlay

PAGNBR

F

to specify the location of an unnamed, 4-digit, zoned decimal field to contain the page number

PAGRTT

R

PAGSEG

R

to print a page segment

POSITION

F

to define the location of a named field on the page

PRTQLTY

B

to vary the print quality within the file

REF

File

to specify the name of a file from which field descriptions are to be retrieved

REFFLD

F

referring to a field

SKIPA

B

File

to specify that the printer device is to skip to a 
specific line number after it prints one or more lines

SKIPB

B

File

to specify that the printer device is to skip to a specific line number before it prints the next line(s)

SPACEA

B

to specify that the printer device is to space some number
of lines after it prints one or more lines

SPACEB

B

to specify that the printer device is to space some number
of lines before it prints the next line or lines

STAPLE

R

STRPAGGRP

R

TEXT

B

to supply a text description (or comment) for the record 
format or field that is used for program documentation

TIME

F

prints the current system time as a constant field 6 bytes long

TIMFMT

F

to specify the format of a time field

TIMSEP

F

to specify separator characters for time fields

TRNSPY

F

TXTRTT

F

UNDERLINE

F

to specify that the OS/400 program is to underline the field

ZFOLD

R




阅读(1337) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~