假设每个语句我有2个,没有2个相关表第一个是
对于每个表-1 disp table-1.col1 表1.col2。结束。
对于每个表-2 disp table-2.col1 …
如果指定两个帧的宽度和col(umn),则可以控制它们应该彼此相邻显示。
for each Salesrep: display salesrep.salesrep salesrep.repname with down frame frm-salesrep width 40. end. for each Item: display item.ItemNum item.ItemName with down frame frm-item col 41. end.
由于表格不相关,您必须进行一些数据操作才能获得您正在寻找的并排图表输出。您可以创建一个“行”临时表,其中包含要在每个输出行中显示的四个字段。浏览每个表,将记录数据添加到每一行。然后浏览行临时表并输出行数据。
DEFINE VARIABLE linecnt AS INTEGER NO-UNDO. DEFINE TEMP-TABLE ttLine FIELD linenum AS INTEGER FIELD tbl1col1 AS CHARACTER FIELD tbl1col2 AS CHARACTER FIELD tbl2col1 AS CHARACTER FIELD tbl2col2 AS CHARACTER INDEX Idx1 IS PRIMARY linenum. linecnt = 1. /* Initialize the line counter. */ /* Go thru table-1, creating a ttLine for each record. */ FOR EACH table-1 NO-LOCK: CREATE ttLine. ASSIGN ttLine.linenum = linecnt ttLine.tbl1col1 = table-1.col1 ttLine.tbl1col2 = table-1.col2 linecnt = linecnt + 1. END. linecnt = 1. /* Reset the line counter. */ /* Go thru table-2, adding data to ttLine and creating new records if necessary. */ FOR EACH table-2 NO-LOCK: FIND FIRST ttLine WHERE ttLine.linenum = linecnt NO-ERROR. IF NOT AVAILABLE(ttLine) THEN DO: CREATE ttLine. ttLine.linenum = linecnt. END. ASSIGN ttLine.tbl2col1 = table-2.col1 ttLine.tbl2col2 = table-2.col2 linecnt = linecnt + 1. END. /* Go thru ttLine, output data. */ OUTPUT TO VALUE("output.txt"). PUT UNFORMATTED "---------- Table 1 --------- ---------- Table 2 --------" SKIP. FOR EACH ttLine: PUT UNFORMATTED "|" + STRING(ttLine.tbl1col1, "X(12)") + " " + STRING(ttLine.tbl1col2, "X(12)") + " | |" + STRING(ttLine.tbl2col1, "X(12)") + " " + STRING(ttLine.tbl2col2, "X(12)") + "|" SKIP. END. OUTPUT CLOSE.
上面的例子应该为您提供您正在寻找的输出。它还将处理每个表中没有相同数量记录的情况。它将留下没有数据的空白区域。