WS-VAR-VALUE PIC X(10)
TEMP1 REDEFINES WS-VAR-VALUE PIC 9(10)
MOVE WS-VAR-VALUE to TEMP1
MOVE TEMP1 TO WS-VAR-MON-DAY
Sandhya, I always found it a good idea to take breaks from concentrating on one problem. Often, when returning to the problem, I would see straight away something which would lead to the solution. We have an expression "can't see the woods for the trees".
Looking further at your code snippets, I have a couple of further comments. Above, where you have done the redefine, you end up moving the same piece of storage to itself
. If you do the redefine, you don't need to do the move of MS-VAR-VALUE to TEMP1, just the move of TEMP1. I don't think that is your problem anyway.
Next, in the following, you have "unbalanced parentheses". Where this is possible, it is more "left" than "right" that work (say, REXX). But you have more "right" parenthesis than "left".
Finally, as I previously mentioned, you should use the business date from your database. You seem to be using some "timestamp", which smacks of some actual date/time not some business date. If you use an actual date, you program might behave differently if run before midnight and after midnight. That is not a good thing. Even if, as here, you were using a system date to just (maybe, still not clear to me) get the 2nd day of the month, it is not good enough. What about the circumstance where you have to "re-run" a previous day's run? Using the system date, you can (and eventually will for sure) calculate an inccorrect date.
You can use the system date for reporting/tracking and things like that, alongside the business date. In my book, you should never use it for data selection of any sort.
dick scherrer wrote:Suggest you add a bit of code and show the values in all of these WS fields and make sure the content is what you want.
I think, Sandhya, you should take this advice. You don't understand the value 10245. It is a computer. If you understand the inputs and the process you understand the output. I think you'll find one of the inputs has a value that is not what you think before you use it to get 10245. Or your "process" is wrong. Putting in the displays will tell you which, and from there you might be able to make further progress.