在JCL的SORT parm中使用的REXX代码

时间:2013-12-09 22:09:06

标签: sorting rexx

我在使用一些REXX代码创建的JCL中有一个sort parm,如下所示:

/* REXX */                                                           
'EXECIO * DISKR ZEROGDT (STEM ZGD.'                                  
S21='                     '                                          
OUTVAR1=' SORT FIELDS=COPY'                                          
'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'                                
DO I=1 TO ZGD.0                                                      
   ACCTNBR=SUBSTR(ZGD.I,33,16)                                       
   IF I=1 THEN DO                                                    
     OUTVAR1=" OMIT FORMAT=CH,COND=(33,16,EQ,C'"||ACCTNBR||"',OR,"   
   END                                                               
   ELSE DO                                                           
      IF I=ZGD.0 THEN OUTVAR1=S21||" 33,16,EQ,C'"||ACCTNBR||"')"     
      ELSE OUTVAR1=S21||" 33,16,EQ,C'"||ACCTNBR||"',OR,"              
   END                                                               
   'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'                             
END                                                                  
'EXECIO 0 DISKW ACCOUNT (FINIS'                                      

我知道上面的REXX代码创建了一个sort parm,如下所示:

SORT FIELDS=COPY                                     
OMIT FORMAT=CH,COND=(33,16,EQ,C'8257310018808572',OR,
                     33,16,EQ,C'8257310018076428',OR,
                     33,16,EQ,C'8257310017959681',OR,
                     33,16,EQ,C'8257310016504835',OR,
                     33,16,EQ,C'8257310016059467',OR)

但是,它无法处理输入文件中的单个记录。我试图修改REXX代码来处理单个记录,但一直无法。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

下面的代码允许第一行也是最后一行,即原始代码 由于IF语句的嵌套方式,无法解释这一点。

/* REXX */                                                           
'EXECIO * DISKR ZEROGDT (STEM ZGD.'                                  
OUTVAR=' SORT FIELDS=COPY'                                          
'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'                                
DO I=1 TO ZGD.0                                                      

   IF I = 1 THEN  
      OUTVAR = " OMIT FORMAT=CH,COND=(33,16,EQ,C'" || SUBSTR(ZGD.I,33,16)
   ELSE
      OUTVAR = COPIES(' ', 21) || " 33,16,EQ,C'" || SUBSTR(ZGD.I,33,16)

   IF I = ZGD.0 THEN
      OUTVAR = OUTVAR || ")" /* This is the last line, close paren. */
   ELSE
      OUTVAR = OUTVAR || ",OR," /* Another line to follow, continue */

   'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'                             
END                                                                  
'EXECIO 0 DISKW ACCOUNT (FINIS'                                      

对于单行输入,这应该产生:

SORT FIELDS=COPY                                     
OMIT FORMAT=CH,COND=(33,16,EQ,C'8257310018808572')

对于多行,它应该产生:

SORT FIELDS=COPY                                     
OMIT FORMAT=CH,COND=(33,16,EQ,C'8257310018808572',OR,
                     33,16,EQ,C'8257310018076428',OR,
                     33,16,EQ,C'8257310017959681')