Author: Bill Woodger
Subject: Reply to: Performing arithmetic on input field
Posted: Thu Dec 08, 2016 10:40 pm (GMT 5.5)
It is not the IFTHEN, it is the BUILD. Each BUILD that is executed creates a "new version" of the current record, from the previous version.
OVERLAY does not create a new version of the current records, but operates on the existing version.
Try those, the output will be different, because of the way BUILD and OVERLAY operate.
If you need to "rearrange" data, BUILD is more convenient. If you need to update data where it is, OVERLAY is 1) clearer and 2) performs better.
Other differences are that although you can specify columns in BUILD, you can only define fields in "ascending" order (the columns will just get space-padded if needed), whereas with OVERLAY you can specify the columns in any order, and even do multiple transformations to the same field in one OVERLAY, by specifying the same column multiple times.
Anyway, I'm assuming that was the confusion (how BUILD works), because it is entirely normal to expect something that has been changed to be available to the next line of code.
Note also that with IFTHEN=(WHEN=(logicalexpression), when one is true, no further IFTHEN=(WHEN=(logicalexpression) are processed for that "record", unless you ask for it, by using HIT=NEXT, and that includes if you want to use WHEN=ANY.
So one or more IFTHEN=(WHEN=(logicalexpression) are like a "case/select" statement (EVALUATE in COBOL).
Subject: Reply to: Performing arithmetic on input field
Posted: Thu Dec 08, 2016 10:40 pm (GMT 5.5)
zh_lad wrote: |
I was amazed to know every IFTHEN picks up amendments done by previous IFTHEN |
It is not the IFTHEN, it is the BUILD. Each BUILD that is executed creates a "new version" of the current record, from the previous version.
OVERLAY does not create a new version of the current records, but operates on the existing version.
Code: |
BUILD=(21,20,1,20) OVERLAY=(21,20,1,20) |
Try those, the output will be different, because of the way BUILD and OVERLAY operate.
If you need to "rearrange" data, BUILD is more convenient. If you need to update data where it is, OVERLAY is 1) clearer and 2) performs better.
Other differences are that although you can specify columns in BUILD, you can only define fields in "ascending" order (the columns will just get space-padded if needed), whereas with OVERLAY you can specify the columns in any order, and even do multiple transformations to the same field in one OVERLAY, by specifying the same column multiple times.
Anyway, I'm assuming that was the confusion (how BUILD works), because it is entirely normal to expect something that has been changed to be available to the next line of code.
Note also that with IFTHEN=(WHEN=(logicalexpression), when one is true, no further IFTHEN=(WHEN=(logicalexpression) are processed for that "record", unless you ask for it, by using HIT=NEXT, and that includes if you want to use WHEN=ANY.
So one or more IFTHEN=(WHEN=(logicalexpression) are like a "case/select" statement (EVALUATE in COBOL).