I haven't seen this posted anywhere on this site. I had no clue this could be done until I came across this article by chance. Basically in cl you can define a variable as being based on part of another variable.
DCL VAR(&CustData) TYPE(*CHAR) LEN(77)
DCL VAR(&AmtDue) TYPE(*DEC) LEN(9 2) STG(*DEFINED) DEFVAR(&CustData 1)
In this sample &AMTDUE basically will have the value from position 1-9 of &CUSTDATA.
The key to this is the STG parameter and the DEFVAR parameter when defining &AMTDUE.
Article in the link can explain it in more detail.
DCL VAR(&CustData) TYPE(*CHAR) LEN(77)
DCL VAR(&AmtDue) TYPE(*DEC) LEN(9 2) STG(*DEFINED) DEFVAR(&CustData 1)
In this sample &AMTDUE basically will have the value from position 1-9 of &CUSTDATA.
The key to this is the STG parameter and the DEFVAR parameter when defining &AMTDUE.
Article in the link can explain it in more detail.
Comment