set schema <SCHEMANAME>; -- SET SCHEMA NAME HERE WITHOUT <>
set 'CDS_CLIENT' = ''; -- SET YOUR CLIENT HERE
set 'APPLICATIONUSER' = ''; --SET YOUR APPLUCATION USER HERE
DO
BEGIN
SELECT
BSET.BUKRS,
BSET.GJAHR,
BSET.BELNR,
BSET.HWBAS,
BSET.HWSTE,
T007K.MWSKZ,
T007K.KTOSL,
T007K.BASGRUNO,
CASE
WHEN BASGRUNO = '3'
THEN BSET.HWBAS
ELSE 0.00
END AS ZERORATETAX,
CASE
WHEN BASGRUNO = '4'
THEN BSET.HWBAS
ELSE 0.00
END AS ZERORATEONLYEXPORTEDGOODS
FROM T007K
LEFT OUTER JOIN BSET ON BSET.MANDT = T007K.MANDT
AND BSET.MWSKZ = T007K.MWSKZ
AND BSET.KTOSL = T007K.KTOSL
WHERE T007K.MANDT = '500'
AND T007K.LAND1 = 'ZA'
AND T007K.VERSION = 'ZA01';
END
set schema <SCHEMANAME>; -- SET SCHEMA NAME HERE WITHOUT <>
set 'CDS_CLIENT' = ''; -- SET YOUR CLIENT HERE
set 'APPLICATIONUSER' = ''; --SET YOUR APPLUCATION USER HERE
do
begin
lt_t007k = (
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A1' AS MWSKZ, 'MWS' AS KTOSL, '3' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A2' AS MWSKZ, 'MWS' AS KTOSL, '4' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A3' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA02' AS VERSION, 'A4' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
);
select * from :lt_t007k;
end
set schema <SCHEMANAME>; -- SET SCHEMA NAME HERE WITHOUT <>
set 'CDS_CLIENT' = ''; -- SET YOUR CLIENT HERE
set 'APPLICATIONUSER' = ''; --SET YOUR APPLUCATION USER HERE
do
begin
lt_t007k = (
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A1' AS MWSKZ, 'MWS' AS KTOSL, '3' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A2' AS MWSKZ, 'MWS' AS KTOSL, '4' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A3' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA02' AS VERSION, 'A4' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
);
select * from :lt_t007k;
lt_bset = (
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D1' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A1' AS MWSKZ, 'MWS' AS KTOSL, 1000.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D2' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A1' AS MWSKZ, 'MWS' AS KTOSL, 1100.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D3' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A2' AS MWSKZ, 'MWS' AS KTOSL, 1500.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D4' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A3' AS MWSKZ, 'MWS' AS KTOSL, 2000.00 AS HWBAS, 50.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D5' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A2' AS MWSKZ, 'MWS' AS KTOSL, 3000.00 AS HWBAS, 0.00 AS HWSTE from dummy )
);
SELECT * FROM :LT_BSET;
end
set schema <SCHEMANAME>; -- SET SCHEMA NAME HERE WITHOUT <>
set 'CDS_CLIENT' = ''; -- SET YOUR CLIENT HERE
set 'APPLICATIONUSER' = ''; --SET YOUR APPLUCATION USER HERE
do
begin
lt_t007k = (
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A1' AS MWSKZ, 'MWS' AS KTOSL, '3' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A2' AS MWSKZ, 'MWS' AS KTOSL, '4' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA01' AS VERSION, 'A3' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA' AS LAND1, 'ZA02' AS VERSION, 'A4' AS MWSKZ, 'MWS' AS KTOSL, '5' BASGRUNO from dummy )
);
select * from :lt_t007k;
lt_bset = (
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D1' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A1' AS MWSKZ, 'MWS' AS KTOSL, 1000.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D2' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A1' AS MWSKZ, 'MWS' AS KTOSL, 1100.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D3' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A2' AS MWSKZ, 'MWS' AS KTOSL, 1500.00 AS HWBAS, 0.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D4' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A3' AS MWSKZ, 'MWS' AS KTOSL, 2000.00 AS HWBAS, 50.00 AS HWSTE from dummy )
UNION ALL
( select '500' AS MANDT, 'ZA01' AS BUKRS, 'D5' AS BELNR, '2022' AS GJAHR, '001' AS BUZEI, 'A2' AS MWSKZ, 'MWS' AS KTOSL, 3000.00 AS HWBAS, 0.00 AS HWSTE from dummy )
);
SELECT * FROM :LT_BSET;
lt_output = SELECT
BSET.BUKRS,
BSET.GJAHR,
BSET.BELNR,
BSET.HWBAS,
BSET.HWSTE,
T007K.MWSKZ,
T007K.KTOSL,
T007K.BASGRUNO,
CASE
WHEN BASGRUNO = '3'
THEN BSET.HWBAS
ELSE 0.00
END AS ZERORATETAX,
CASE
WHEN BASGRUNO = '4'
THEN BSET.HWBAS
ELSE 0.00
END AS ZERORATEONLYEXPORTEDGOODS
FROM :lt_t007k as T007K
LEFT OUTER JOIN :lt_bset as BSET
ON BSET.MANDT = T007K.MANDT
AND BSET.MWSKZ = T007K.MWSKZ
AND BSET.KTOSL = T007K.KTOSL
WHERE T007K.MANDT = '500'
AND T007K.LAND1 = 'ZA'
AND T007K.VERSION = 'ZA01';
select * from :lt_output;
end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
25 | |
21 | |
12 | |
8 | |
8 | |
8 | |
8 | |
8 | |
8 |