I am using below mentioned query to get the multiplied value of three columns and then I will doing the order by on the multiplied value.
Columns from table used for multiplication are as mentioned below.
10 LAGERVARDERING-PRS PIC S9(6)V9(2) USAGE COMP-3.
10 LEVERERAD-BPK PIC S9(5)V USAGE COMP-3.
10 GM-KBPAK PIC S9(5)V USAGE COMP-3.
10 LEVERERAD-BPK PIC S9(5)V USAGE COMP-3.
10 GM-KBPAK PIC S9(5)V USAGE COMP-3.
Working store variable to receive the multiplied value.
05 SECB-BELLOP PIC 9(18)V9(9).
Query used:
SELECT TERM,DEPA,GM_VGR,CAST(BELLOP AS DECIMAL(18,9)) FROM
(SELECT
'505' AS TERM,
'01' AS DEPA,
GM_VGR,
SUM(CASE WHEN LEVERERAD_VKT>0
THEN(LAGERVARDERING_PRS *LEVERERAD_BPK*GM_KBPAK)
ELSE(DPRIS_TOT*LAGERVARDERING_PRS/DEBITERINGS_PRS)
END) AS BELLOP
FROM T_TABEL1 U,T_TABLE2 R )
(SELECT
'505' AS TERM,
'01' AS DEPA,
GM_VGR,
SUM(CASE WHEN LEVERERAD_VKT>0
THEN(LAGERVARDERING_PRS *LEVERERAD_BPK*GM_KBPAK)
ELSE(DPRIS_TOT*LAGERVARDERING_PRS/DEBITERINGS_PRS)
END) AS BELLOP
FROM T_TABEL1 U,T_TABLE2 R )
I am getting below mentioned issue with the variable defined.
0DSNH312I E DSNHSMUD LINE 2006 COL 31 UNDEFINED OR UNUSABLE HOST VARIABLE "SECB-BELLOP"
Thankful if someone could help me in fixing the issue.