MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Easy-Trieve logic coding help
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Fri Sep 23, 2005 4:45 pm    Post subject: Easy-Trieve logic coding help Reply with quote

I am trying to change a style by a 8 digit customer class and a 5 character style. I can get easy-trieve to make changes just by the style but don't know how to code the change for customer class as well. I am trying to use an outside file to build two tables to match for the change. Here is the part that I need the help with the logic:
Code:

       SEARCH W-STYLES WITH STYLE GIVING WS-STYLE       
             IF W-STYLES                               
                RPT-STYLE EQ STYLE                     
                STYLE EQ WS-STYLE                       
                PRINT STYLE-SUMMARY                     
             END-IF                                     
       MOVE SPACES TO NEW701                           
       PUT O701 FROM I701                               

Complete jcl step is:

//CHGSYTL  EXEC PGM=EZTPA00                           
//STEPLIB  DD  DSN=CAI.EZTP.LOAD,DISP=SHR             
//PDS      DD DSN=LMF004.PROD.MACEZT,DISP=SHR         
//SYSPRINT DD  SYSOUT=*                               
//EZTVFM   DD  UNIT=SYSDA,SPACE=(0,(5000,1000))       
//ZSTYLES  DD  DSN=DSV.DSV000.NSTYLES.@01DEL,DISP=SHR
//I701     DD  DSN=INPUT 701 FILE HERE,DISP=SHR       
//O701     DD  DSN=DSV.DSV000.NTEST.@01DEL,           
//*            DISP=(,CATLG),                         
//             DISP=OLD,                             
//             SPACE=(CYL,(150,50),RLSE),             
//             DCB=(RECFM=FB,LRECL=1360,DSORG=PS)     
//PRINTER1 DD  SYSOUT=*                               
//PRINTER2 DD  SYSOUT=*                               
//SYSIN    DD  *                                     
PARM DEBUG (FLOW FLOWSIZ (200))                       
FILE PRINTER1 PRINTER                                 
FILE PRINTER2 PRINTER                                 
FILE O701                                             
   NEW701         1 1360  A                           
FILE I701                                             
   CUSTCODE         1  8  A                           
   STYLE           44  6  A                           
   VOIDED         125  1  A                           
   PLANT          237  4  A                           
   CUT            545 12  A OCCURS 3                 
   BRANCH         433  5  A                             
   RPT-CUSTCODE     W  8  A                             
   RPT-STYLE        W  6  A                             
   I701-KEY            W 13  A                           
     BC-KEY I701-KEY      8  A                           
     BR-KEY I701-KEY  +8  5  A                           
                                                         
FILE ZSTYLES                                             
FILE W-STYLES FB(80 27920) VIRTUAL RETAIN TABLE 500     
  ARG                   1        6   A                   
  DESC                 22        6   A                   
  WS-STYLE              W        6   A                   
                                                         
FILE X-STYLES FB(80 27920) VIRTUAL RETAIN TABLE 500     
  ARG                   1        8   A                   
  DESC                 34        8   A                   
  XS-STYLE              W        8   A                   
                                                         
JOB INPUT ZSTYLES.                                       
  PUT W-STYLES FROM ZSTYLES                             
  PUT X-STYLES FROM ZSTYLES                             
                                                         
JOB INPUT I701                                           
                                                         
       SEARCH W-STYLES WITH STYLE GIVING WS-STYLE       
             IF W-STYLES                                 
                RPT-STYLE EQ STYLE                           
                STYLE EQ WS-STYLE                             
                PRINT STYLE-SUMMARY                           
             END-IF                                           
       MOVE SPACES TO NEW701                                 
       PUT O701 FROM I701                                     
                                                             
REPORT STYLE-SUMMARY PRINTER PRINTER2 SUMMARY NOADJUST +     
                     NOHEADING NOPAGE NODATE                 
SEQUENCE RPT-STYLE STYLE                                     
CONTROL  FINAL NOPRINT  RPT-STYLE NOPRINT  STYLE             
LINE  01  RPT-STYLE STYLE TALLY                               

Here is the file that builds the tables:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
Old Style CodeAOE Binding       Cust Code           Product Desc.
B            DUP         XXXXX       01100234             AMERICAN MON
AT          DUP         ZZZZZ       01100234             AMERICAN MON

Any ideas would be greatly appreciated. Thank you.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sat Sep 24, 2005 7:29 am    Post subject: Reply with quote

Mkelly7,

This is a simple task but you have made it complicated. But before I show you the code let me clarify a couple of questions.

You have a input file which has style field in it and there is another which has the style description for every style.

Now all you want is to pick that style description from the 2nd file and write it out in the output file ?

Am I Right?

If I am wrong just explain your requirements

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Sat Sep 24, 2005 11:05 am    Post subject: Reply with quote

Thank you for your reply. I will try to make this clearer. Forgive me if I fail. I have an incoming file that has a list of customer accounts, the customer type (level of service) and the product style along with some other info. I have another file (i'll call it a parm) that contains a list of the customer type and the product style as well as a style to convert to. My intention is for the easy-trieve to compare the incoming file to the parm. If both the customer type and product style match the parm, I want it to convert the style. The jcl as I posted it (the 2nd table is not necessary for this) will only compare product style and convert that. Now I need it to compare both. I would prefer to remain using one easy-trieve step if possible. I am just learning about tables and I think I need a sort step for the 2nd table as well. The documentation I find on tables is very limited and slow learners like me can use examples. Thank you.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sun Sep 25, 2005 8:32 am    Post subject: Reply with quote

Mkelly7,

You actually don't need a Table processing for your specs. It can be achieved using syncronised file processing (SFP) method. However I will show you both(SFP and table processing)

SFP method: (This assumes that your both files are sorted on customer type and product style)

Code:

  FILE I701                                             
   OLD701           1  1360 A
   CUSTCODE         1  8  A                           
   STYLE           44  6  A                           
   VOIDED         125  1  A                           
   PLANT          237  4  A                           
   CUT            545 12  A OCCURS 3                 
   BRANCH         433  5  A                             

  FILE ZSTYLES                                             
    PARM-CUSTCODE        1   6   A                   
    PARM-STYLE          22   6   A                   
    PARM-CHNG-STYLE     34   8   A                   

                                                                         
  FILE O701 FB(0 0)                                                   
       NEW701         1 1360  A 
       O-CHNG-STYLE   500  8  A
         
*********************************************************************** 
* MAINLINE                                                            * 
*********************************************************************** 
                                                                         
 JOB INPUT (I701    KEY (CUSTCODE, STYLE)  +                                 
            ZSTYLES KEY (PARM-CUSTCODE, PARM-STYLE))

   IF MATCHED                   
      NEW701         = OLD701
      O-CHNG-STYLE   = PARM-CHNG-STYLE
      PUT O701
   ELSE-IF I701
      NEW701         = OLD701
      O-CHNG-STYLE   = ' '
      PUT O701
   END-IF                       
                                 
/*


if the above code is confusing then here is a simpler version.

Code:

    IF MATCHED                   
       NEW701         = OLD701
       O-CHNG-STYLE   = PARM-CHNG-STYLE
       PUT O701
    ELSE
      IF I701
         NEW701         = OLD701
         O-CHNG-STYLE   = ' '
         PUT O701
       END-IF               
    END-IF


Basically , if the input file and the ztyles files match on the custcode and style we change the o-chng-style in the input file at pos 500 to the value of parm-chng-style. if it did not match then we simply move spaces.

Note: If your Files are not sorted then you need to add the following statments before your JOB statement in the easytrieve program.

Code:

SORT I701 TO I701 USING (CUSTCODE, STYLE)
SORT ZSTYLES TO ZSTYLES USING (PARM-CUSTCODE, PARM-STYLE)


Table processing:

Code:

  FILE I701                                             
   OLD701           1  1360 A
   CUSTCODE         1  8  A                           
   STYLE           44  6  A                           
   VOIDED         125  1  A                           
   PLANT          237  4  A                           
   CUT            545 12  A OCCURS 3                 
   BRANCH         433  5  A                             

  FILE ZSTYLES TABLE 500                                     
      ARG           01 06  A                 
      DESC          22 20  A 
                                                                         
  FILE O701 FB(0 0)                                                   
       NEW701         1 1360  A 
       O-CHNG-STYLE   500  8  A
 
 W-SRCH-CUST-CODE       W  06 A
                                   
 W-PARM-DESC                  W   20 A           
   W-PARM-STYLE  W-PARM-DESC      06 A
   FILLER1       W-PARM-DESC  +6  06 A
   W-CHNG-STYLE  W-PARM-DESC  +12 08 A

*********************************************************************** 
* MAINLINE                                                            * 
*********************************************************************** 
                                                                         
 JOB INPUT I701
   
     W-SRCH-CUST-CODE   = CUSTCODE                                       
     W-PARM-DESC        = ' '                                             
     SEARCH ZSTYLES WITH W-SRCH-CUST-CODE, GIVING W-PARM-DESC

     IF W-PARM-STYLE    = STYLE
        NEW701          = OLD701
        O-CHANG-STYLE   = W-CHNG-STYLE                   
     ELSE
        NEW701          = OLD701
        O-CHANG-STYLE   = ' '
     END-IF

     PUT O701
/*



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Mon Sep 26, 2005 8:39 pm    Post subject: Reply with quote

I think I am well on my way but I still get an error saying

B039 Qualification required - new701
B039 Qualification required - o-chng-file

I looked up the error code and found it to be "The required name cannot be uniquely identified. Qualify the field or record."

Sorry but they lost me on that one.
Back to top
View user's profile Send private message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Mon Sep 26, 2005 9:11 pm    Post subject: Reply with quote

I have made some other changes and now have a b062/b063 error. Field referenced in unavailable file - new701 and field referenced was --chg-style. I am not sure if that is progress or regresssion... haha... Thank you for your time.
Back to top
View user's profile Send private message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Mon Sep 26, 2005 10:14 pm    Post subject: Reply with quote

Kolusu,

I decided you were right and used the synchronized file method. Here is what I ran:
Code:

FILE I701                                                   
   OLD701              1 1360  A                             
   CUSTCODE            1    8  A                             
   STYLE              44    6  A                             
                                                             
FILE ZSTYLES                                                 
  PARM-STYLE           1    6  A                             
  PARM-CHNG-STYLE     22    6  A                             
  PARM-CUSTCODE       34    8  A                             
                                                             
FILE NEW701 FB(0 0)                                         
   OLD701              1 1360  A                             
   CUSTCODE            1    8  A                             
   O-CHNG-STYLE      500    8  A                             
                                                             
*************************************************************
* MAINLINE                                                   
*************************************************************
                                                             
JOB INPUT (I701    KEY (CUSTCODE, STYLE)  +                 
       ZSTYLES KEY (PARM-CUSTCODE, PARM-CHNG-STYLE))         
   IF MATCHED                                               
      NEW701         = OLD701                               
      O-CHNG-STYLE   =   PARM-CHNG-STYLE                     
      PUT O701                                               
   ELSE-IF I701                                             
      NEW701         = OLD701                               
      O-CHNG-STYLE   = ' '                   
      PUT O701                               
   END-IF                                     
                                             
/*                                           

I received the following message:

*******B062 FIELD REFERENCED IN UNAVAILABLE FILE - NEW701
*******B063 FIELD REFERENCED WAS - O-CHNG-STYLE

In a manual it gives the following info:
B062 FIELD REFERENCED IN UNAVAILABLE FILE - file-name
One or more fields were referenced in the identified file, but the file is not used within the job activity. This is a deferred message which is generated at the end of each job activity. This message is always accompanied by one or more B063 messages that identify which fields were referenced in the unavailable file.

B063 FIELD REFERENCED WAS - field name
This message always accompanies the B062 message and identifies which fields were referenced in the unavailable file.

I don't understand why the file isn't available Thanks.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Sep 27, 2005 12:19 am    Post subject: Reply with quote

mkelley7,

Couple of things. Check the following declarations.

Code:

FILE I701
OLD701 1 1360 A
CUSTCODE 1 8 A
STYLE 44 6 A


Code:

FILE NEW701 FB(0 0)
OLD701 1 1360 A
CUSTCODE 1 8 A
O-CHNG-STYLE 500 8 A


There are two fields by the same name OLD701 - one in input and one in output. Correct this.

Also, in kolusu's note the output file is declared as O701 and the group variable underneath is NEW701. But you seem to have changed this altogether. Did you make corresponding changes in the JCL ? Have you declared the file NEW701 in the JCL ?

Code:

FILE O701 FB(0 0)                                                   
       NEW701         1 1360  A 
       O-CHNG-STYLE   500  8  A


If you have everthing corrected and if you still get a problem, post your JCL as well as the Eazytrieve code.

Also, please use the BB Tags {code} & {/code} to paste your code (Remember to replace '{' by '[' and '}' by ']'). That makes it more legible.

Thanks,
Phantom
Back to top
View user's profile Send private message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Tue Sep 27, 2005 12:52 pm    Post subject: Reply with quote

Thanks a bunch, Phantom and Kolusu. The duplicate 701 file definition and the foolish code changes I made were my downfall. Thank you for having the patience to help me out.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Sep 27, 2005 12:57 pm    Post subject: Reply with quote

You are welcome - mkelley7. This is the typical mistake that we all do. Take it easy Wink

Thanks,
Phantom
Back to top
View user's profile Send private message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Tue Sep 27, 2005 6:56 pm    Post subject: Reply with quote

Sorry to be a pest but I still have a problem. The coding works great except that it only changes the first match it finds. The original jcl (which I cannot take credit for) changes all of the records. Is that possibly why they used a table instead of sequential files? I did some searching on the forums here and someone said that using match with one to many records would require coded logic. I am not sure how I would set that up. I am working with files about 300,000 records where about 50,000 would match. There could be several hundred entries to match against several hundred thousand. Any suggestions would be greatly appreciated. Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Sep 27, 2005 7:30 pm    Post subject: Reply with quote

Quote:

The original jcl (which I cannot take credit for) changes all of the records.


mkelly7,

All you need to do is flip the files in the JOB statement like shown below.

Code:

JOB INPUT (ZSTYLES KEY (PARM-CUSTCODE, PARM-CHNG-STYLE) +
           I701    KEY (CUSTCODE, STYLE))


You only need a custom logic when you are doing a MANY to MANY match. ONE to MANY and MANY to ONE logic is already built in easytrieve.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Tue Sep 27, 2005 7:49 pm    Post subject: Reply with quote

That was it. Thanks again.
Back to top
View user's profile Send private message
mkelley7
Beginner


Joined: 21 Sep 2005
Posts: 13
Topics: 1

PostPosted: Tue Oct 04, 2005 9:20 pm    Post subject: Reply with quote

I am trying to run the jcl provided by Kolusu that uses a table and I am getting a message

A007 TABLE INPUT IS NOT IN SEQUENCE - ZSTYLES.

I have tried
SORT FIELDS=[1,6,CH,A]
SORT FIELDS=[34,8,CH,A]
SORT FIELDS=[34,8,CH,A,1,6,CH,A] and
SORT FIELDS=[1,6,CH,A,34,8,CH,A]

Using the logic provided by Kolusu

Code:
 JOB INPUT I701                                               
                                                             
     W-SRCH-CUST-CODE   = CUSTCODE                           
     W-PARM-DESC        = ' '                                 
     SEARCH ZSTYLES WITH W-SRCH-CUST-CODE, GIVING W-PARM-DESC
     IF W-PARM-STYLE    = STYLE                               
        NEW701          = OLD701                             
        O-CHNG-STYLE    = W-CHNG-STYLE                       
     ELSE                                                     
        NEW701          = OLD701                             
        O-CHNG-STYLE    = ' '                                 
     END-IF                                                   
     PUT O701                                                 


what sort order should I be using or am I just climbing the wrong tree?

Here is the what the input file that becomes zstyles looks like:

Code:
Old Design           New Design  Cust Code       
B                    AAXXX       91100124         
VP5                  BBXXX       91100197         
AT                   CCXXX       91100235         
DHB                  DDXXX       91100235         
B                    CCXXX       91100235         
B                    EEXXX       91107516         


This job changes the Old Design to the New Design when the Cust Code and the Old Design both match. Here is what the file that is to be changed looks like

Code:
91100124  000001                           B   
91100124  000225                           AT   
91100124  000303                           VP5 
91100124  004125                           AW   
91100124  033516                           B   
91100197  000006                           B   
91100197  000225                           B   
91100235  001125                           AT   
91100235  002125                           B   


This file should look like this after processing:
Code:
91100124  000001                           AAXXX
91100124  000225                           AT   
91100124  000303                           VP5   
91100124  004125                           AW   
91100124  033516                           AAXXX
91100197  000006                           B     
91100197  000225                           B     
91100235  001125                           CCXXX
91100235  002125                           CCXXX


Thank you.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Oct 05, 2005 12:15 am    Post subject: Reply with quote

mkelley7,

If you notice Kolusu's message, he said
Quote:

Note: If your Files are not sorted then you need to add the following statments before your JOB statement in the easytrieve program.



Code:

SORT I701 TO I701 USING (CUSTCODE, STYLE)
SORT ZSTYLES TO ZSTYLES USING (PARM-CUSTCODE, PARM-STYLE)


Did you try his suggestion ? If not, try and let us know if you still face any problem.

Thanks,
Phantom
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group