‎2006 Oct 31 10:21 AM
With transact SQL I can do the following:
SELECT
SUM(CASE WHEN pstyv = 'KEN' THEN newtr) AS KENsales,
SUM(CASE WHEN pstyv <> 'KEN' THEN newtr) AS OTHERsales etcIs there anyway this can be done in ABAP in the same way?
Kind Regards
Carly
‎2006 Oct 31 10:24 AM
Hi,
It would be fine if you describe your requirement in brief in words.
Message was edited by: Palak Limbachiya
‎2006 Oct 31 10:25 AM
data: kensales like vrp-netwr,
OTHERsales like vbrp-netwr.
data: begin of itab occurs 0,
pstyv type pstyv,
netwr type netwr,
end of itab.
select pstyv netwr into table itab from dbtab where cond.
loop at itab.
if itab-pstyv = 'KEN'.
kensales = kensales + itab-netwr.
else.
OTHERsales = OTHERsales + itab-netwr.
endif.
endloop.
‎2006 Oct 31 10:29 AM
Hi Carl,
select sum( pstyv ) as kensales
where pstyv = 'KEN'.
select sum( pstyv ) as othersales
where pstyv ne 'KEN'.
CASE PSTYV.
WHEN KEN.
WRITE:/ KENSALES.
WHEN OTHERS.
WRITE:/OTHERSALES.
ENDCASE.
regards,
VIjay.
‎2006 Oct 31 10:34 AM
Hi,
select pstyv netwr into table it_kensales from <table> where pstyv = 'KEN'.
select pstyv netwr into table it_othersales from <table> where pstyv <> 'KEN'.Regards
vijay
‎2006 Oct 31 10:53 AM
The select statement I currently have is:
SELECT a~kunnr b~vkbur c~pernr a~name1 a~name2 a~name3 a~name4
a~stras a~ort01 a~pstlz
SUM( e~netwr ) AS sa_sales
SUM( e~wavwr ) AS sa_cost
INTO TABLE it_list
FROM kna1 AS a
JOIN knvv AS b
ON a~kunnr = b~kunnr
JOIN knvp AS c
ON a~kunnr = c~kunnr
JOIN vbrk AS d
ON a~kunnr = d~kunag
JOIN vbrp AS e
ON d~vbeln = e~vbeln
UP TO 1000 ROWS
WHERE parvw = 'VE'
AND a~kunnr IN so_cust
AND d~erdat IN so_date
GROUP BY a~kunnr b~vkbur c~pernr a~name1 a~name2 a~name3 a~name4
a~stras a~ort01 a~pstlz.But I want 2 columns for sales & 2 columns for cost, 1 for just KEN and 1 for all others.
Would I have to extract pstyv in my select statement and loop at the internal table to format them in the way I want?
Regards
Carly
‎2006 Oct 31 11:10 AM
Yeah u need to extract PSTYV into ur itab .
once u secure
u can apply the conditions ..
regards
VIjay.