IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query regarding Easytrieve program


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shanudarling
Warnings : 1

New User


Joined: 20 Dec 2006
Posts: 55
Location: noida

PostPosted: Wed Jan 06, 2016 5:33 pm
Reply with quote

HI,

Below is my easytrieve program -

Code:


PARM   DEBUG(FLOW)                 
FILE MERGE  VB(44  4400)           
*   INPUT AREAS  STPACC             
      INREC            1   40   A   
      BSB_ACC          1   4  N     
      BSB_ACC_ACC      1   10 N     
      SGMT_CHK_ACC     11  6  A     
      FILLER_ACC       17  2  B     
      BSB_ACC_HEX_ACC  19  5  U     
*   INPUT AREAS  STPCHQ             
      BSB_ACC_CHQ      1   10 N     
      SGMT_CHK_CHQ     11  6  A     
      FILLER_CHQ       17  2  B     
      SERLNO_CHQ       19  4  P 0   
      AMOUNT_CHQ       23  6  P 2   
      STRTDT_CHQ       29  3  P 3   
      ENDDTE_CHQ       32  3  P 3   
*   INPUT AREAS  STPCTL             
      BSB_CTL          1   4  N     
      ACC_CTL          5   6  N     
      SGMT_CHK_CTL     11  6  A       
      FILLER_CTL       17  2  B       
      ITEM_COUNT       19  5  P 0     
      AMOUNT_CTL       24  7  P 2     
*   INPUT AREAS  CNTLDTE             
      BSB_DTE          1   4  N       
      ACC_DTE          5   6  N       
      SGMT_CHK_DTE     11  7  A       
      FILLER_DTE       18  1  B       
      CNTL_DTE         19  12 N       
      BROSY_DTE        31  3  P 0     
      BROST_DTE        34  3  P 0     
      BRNEW_DTE        37  3  P 0     
FILE OUTPUT VB(255 23476)             
*   OUTPUT AREAS STPACC               
      OUTREC            1  40  A     
      BSB_ACC_O         1   4  N     
      BSB_ACC_ACC_O     1   10 N     
      SGMT_CHK_ACC_O    11  6  A     
      FILLER_ACC_O      17  2  B     
      BSB_ACC_HEX_ACC_O 19  5  U     
*   OUTPUT AREAS STPCHQ               
      BSB_ACC_CHQ_O     1   10 N     
      SGMT_CHK_CHQ_O    11  6  A         
      FILLER_CHQ_O      17  2  B         
      SERLNO_CHQ_O      19  4  P 0       
      AMOUNT_CHQ_O      23  6  P 2       
      STRTDT_CHQ_O      29  3  P 3       
      ENDDTE_CHQ_O      32  3  P 3       
*   OUTPUT AREAS STPCTL                 
      BSB_CTL_O         1   4  N         
      ACC_CTL_O         5   6  N         
      SGMT_CHK_CTL_O    11  6  A         
      FILLER_CTL_O      17  2  B         
      ITEM_COUNT_O      19  5  P 0       
      AMOUNT_CTL_O      24  7  P 2       
*   OUTPUT AREAS CNTLDTE                 
      BSB_DTE_O        1   4  N         
      ACC_DTE_O        5   6  N         
      SGMT_CHK_DTE_O   11  7  A         
      FILLER_DTE_O     18  1  B         
      CNTL_DTE_O       19  12 N         
      BROSY_DTE_O      31  3  P 0       
      BROST_DTE_O      34  3  P 0       
      BRNEW_DTE_O      37  3  P 0       
*   WORK  AREA                           
      PREV_BSB    W   4  N   VALUE(0)                                 
      TOT_STPCHQ  W   7  P 0 VALUE(0)                                 
      TOT_STPAMT  W   8  P 2 VALUE(0)                                 
*                                                                     
*                                                                     
 JOB INPUT  MERGE   FINISH DISP-TOTALS                                 
                                                                       
*                                        FIRST RECORD                 
       DISPLAY  INREC                                                 
   IF  PREV_BSB  =  0                                                 
       OUTREC = INREC                                                 
       PUT  OUTPUT                                                     
   END-IF                                                             
                                                                       
*      WRITE RECORD IF SAME BSB AND SEGEMENT IS STPACC BUT NOT THE     
*      FIRST RECORD                                                   
                                                                       
   IF PREV_BSB = BSB_ACC AND SGMT_CHK_ACC = 'STPACC'  AND PREV_BSB NE 0
       OUTREC = INREC                                                 
       PUT  OUTPUT                                                     
   END-IF                                                             
                                                                       
*      WRITE RECORD IF SAME BSB AND SEGEMENT IS STPCHQ                 
*      WRITE RECORD IF SAME BSB AND SEGEMENT IS STPCHQ         
                                                               
   IF PREV_BSB  = BSB_ACC  AND SGMT_CHK_CHQ = 'STPCHQ'         
       OUTREC = INREC                                         
       PUT  OUTPUT                                             
       TOT_STPCHQ  =  TOT_STPCHQ  +  1                         
       TOT_STPAMT  =  TOT_STPAMT  +  AMOUNT_CHQ               
   END-IF                                                     
*                         WRITE CONTROL SEGMENT ON END OF BSB 
   IF PREV_BSB NE BSB_ACC  AND PREV_BSB NE  0  AND  +         
        SGMT_CHK_CTL   NE  'CNTLDTE'                           
       BSB_CTL_O      =  PREV_BSB                             
       ACC_CTL_O      =  999999                               
       SGMT_CHK_CTL_O = 'STPCTL'                               
       ITEM_COUNT_O = TOT_STPCHQ                               
       AMOUNT_CTL_O = TOT_STPAMT                               
       PUT  OUTPUT                                             
       TOT_STPCHQ =  0                                         
       TOT_STPAMT =  0                                         
       BSB_ACC_ACC_O  =  BSB_ACC_ACC                           
       SGMT_CHK_ACC_O =  'STPACC'                             
       BSB_ACC_HEX_ACC_O =  BSB_ACC_HEX_ACC                   
       FILLER_ACC_O   =  FILLER_ACC                           
       PUT  OUTPUT                                             
   END-IF                                                       
   IF PREV_BSB NE BSB_ACC  AND PREV_BSB NE  0  AND   +         
        SGMT_CHK_CTL   =   'CNTLDTE'                           
        BSB_DTE_O      =    BSB_DTE                             
        ACC_DTE_O      =    ACC_DTE                             
        SGMT_CHK_DTE_O =    SGMT_CHK_DTE                       
        FILLER_DTE_O   =    FILLER_DTE                         
        CNTL_DTE_O     =    CNTL_DTE                           
        BROSY_DTE_O    =    BROSY_DTE                           
        BROST_DTE_O    =    BROST_DTE                           
        BRNEW_DTE_O    =    BRNEW_DTE                           
        PUT  OUTPUT                                             
   END-IF                                                       
       PREV_BSB =  BSB_ACC                                     
  DISP-TOTALS. PROC                                             
       BSB_CTL_O      =  PREV_BSB                               
       ACC_CTL_O      =  999999                                 
       SGMT_CHK_CTL_O = 'STPCTL'                               
       ITEM_COUNT_O = TOT_STPCHQ                               
       AMOUNT_CTL_O = TOT_STPAMT                               
       PUT  OUTPUT                                             
   END-PROC                                                     
                                                         






This program reads a variable block input file and writes the data to an output file. The problem that I am facing is that when the read statement gets executed, it reads the first & second record.
The input file is given below -
Code:

----+----1----+----2----+----3----
**********************************
4121100046STPACC   ...ã           
4121100046STPCHQ  ..c.....Ì%......
4121106288STPACC   ..Âh           
4121106288STPCHQ  ..ä@........<..<
**********************************



Input file properties -
Organization . . . : PS
Record format . . . : VB
Record length . . . : 255

WHen we put display in our program after reading the input file, it shows the below -
Code:


4121100046STPACC           4121100046STP         
4121100046STPCHQ    c      %          41         
4121106288STPACC      h    4121106288STP         
4121106288STPCHQ     @        <  <               



The data from the second line is also coming in the display.

Please help.

Thanks in advance.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 06, 2016 5:50 pm
Reply with quote

Why code record-length and blocksize in the program?

You are DISPLAYing a fixed amount of data, no matter what the record-length. Have a look at DISPLAY filename.

Also, don't use the assignment for copying input to output, use MOVE filename TO filename.

You use = for assignment and for equality, even lining up the two different uses in the same position. Use EQ for equality.

You could also make the code clearer, rather than repeating conditions with only a NE/EQ different.
Back to top
View user's profile Send private message
shanudarling
Warnings : 1

New User


Joined: 20 Dec 2006
Posts: 55
Location: noida

PostPosted: Thu Jan 07, 2016 10:46 am
Reply with quote

HI , I have changed my code as per the comments .




Code:

PARM   DEBUG(FLOW)                 
FILE MERGE                         
*   INPUT AREAS  STPACC             
      INREC            1   40   A   
      BSB_ACC          1   4  N     
      BSB_ACC_ACC      1   10 N     
      SGMT_CHK_ACC     11  6  A     
      FILLER_ACC       17  2  B     
      BSB_ACC_HEX_ACC  19  5  U     
      FILLER1          24  232 A   
*   INPUT AREAS  STPCHQ             
      BSB_ACC_CHQ      1   10 N     
      SGMT_CHK_CHQ     11  6  A     
      FILLER_CHQ       17  2  B     
      SERLNO_CHQ       19  4  P 0   
      AMOUNT_CHQ       23  6  P 2   
      STRTDT_CHQ       29  3  P 3   
      ENDDTE_CHQ       32  3  P 3   
      FILLER2          35  221 A   
*   INPUT AREAS  STPCTL             
      BSB_CTL          1   4  N     
       ACC_CTL          5   6  N             
       SGMT_CHK_CTL     11  6  A             
       FILLER_CTL       17  2  B             
       ITEM_COUNT       19  5  P 0           
       AMOUNT_CTL       24  7  P 2           
       FILLER3          31  225 A             
 *   INPUT AREAS  CNTLDTE                     
       BSB_DTE          1   4  N             
       ACC_DTE          5   6  N             
       SGMT_CHK_DTE     11  7  A             
       FILLER_DTE       18  1  B             
       CNTL_DTE         19  12 N             
       BROSY_DTE        31  3  P 0           
       BROST_DTE        34  3  P 0           
       BRNEW_DTE        37  3  P 0           
       FILLER4          40  216 A             
 FILE OUTPUT                                 
 *   OUTPUT AREAS STPACC                     
       OUTREC            1  40  A             
       BSB_ACC_O         1   4  N             
       BSB_ACC_ACC_O     1   10 N             
       SGMT_CHK_ACC_O    11  6  A             
       FILLER_ACC_O      17  2  B             

      BSB_ACC_HEX_ACC_O 19  5  U           
      FILLER5          24  232 A           
*   OUTPUT AREAS STPCHQ                     
      BSB_ACC_CHQ_O     1   10 N           
      SGMT_CHK_CHQ_O    11  6  A           
      FILLER_CHQ_O      17  2  B           
      SERLNO_CHQ_O      19  4  P 0         
      AMOUNT_CHQ_O      23  6  P 2         
      STRTDT_CHQ_O      29  3  P 3         
      ENDDTE_CHQ_O      32  3  P 3         
      FILLER6          35  221 A           
*   OUTPUT AREAS STPCTL                     
      BSB_CTL_O         1   4  N           
      ACC_CTL_O         5   6  N           
      SGMT_CHK_CTL_O    11  6  A           
      FILLER_CTL_O      17  2  B           
      ITEM_COUNT_O      19  5  P 0         
      AMOUNT_CTL_O      24  7  P 2         
      FILLER7          31  225 A           
*   OUTPUT AREAS CNTLDTE                   
      BSB_DTE_O        1   4  N             
      ACC_DTE_O        5   6  N             
      SGMT_CHK_DTE_O   11  7  A             

      FILLER_DTE_O     18  1  B                         
      CNTL_DTE_O       19  12 N                         
      BROSY_DTE_O      31  3  P 0                       
      BROST_DTE_O      34  3  P 0                       
      BRNEW_DTE_O      37  3  P 0                       
      FILLER8          40  216 A                       
*   WORK  AREA                                         
      PREV_BSB    W   4  N   VALUE(0)                   
      TOT_STPCHQ  W   7  P 0 VALUE(0)                   
      TOT_STPAMT  W   8  P 2 VALUE(0)                   
*                                                       
*                                                       
 JOB INPUT  MERGE   FINISH DISP-TOTALS                 
                                                       
*                                        FIRST RECORD   
       DISPLAY 'READ1' INREC                           
       MOVE INREC TO OUTREC                             
       PUT  OUTPUT                                     
  DISP-TOTALS. PROC                                     
    DISPLAY  '  CODE COMPLETE'                         
   END-PROC                                             

                                 



and here is the output

Code:

READ14121100046STPACC           4121100046STP   
READ14121100046STPCHQ    c      %          41   
READ14121106288STPACC      h    4121106288STP   
READ14121106288STPCHQ     @        <  <         
  CODE COMPLETE                                 


Can you please advise why records from the second line being read always .

Thanks.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts RC query -Time column CA Products 3
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top