Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Open SQL to Native SQL

Author  Topic 

Chaitanya_MYK
Starting Member

1 Post

Posted - 2014-05-21 : 04:05:00
Hello All

I have an open SQL code for Customer Invoice Statement which I need to convert into native SQL code
(http://wiki.scn.sap.com/wiki/display/Snippets/Customer+Invoice+Statement)
This is what I made of it so far. I'm stuck as it is going into an unending loop.
------------------------
<code>
with t_kna1
as
(
select * from KNA1
)

,t_knvk
as
(
select KUNNR,NAME1,NAMEV from KNVK
)

,t_bsid
as
(

select KUNNR,BUKRS,BLART,BELNR,BLDAT,GJAHR,
case when SHKZG='H' then (WRBTR*-1) else WRBTR end
WRBTR,WAERS,DMBTR,ZBD1T,ZBD2T,ZBD3T,AUGBL,AUGDT,

SHKZG from BSID where BLART in ('ab','dg','dh','ds','dr','dc','rz','db','rx')
)

,t_bsad
as
(
select KUNNR,BUKRS,BLART,BELNR,BLDAT,GJAHR,WRBTR,WAERS,DMBTR,ZBD1T,ZBD2T,ZBD3T,AUGBL,AUGDT,SHKZG from BSAD
)

,t_vbrk
as
(
select VBELN,ERDAT,NETWR from VBRK v
full join t_bsid t on t.BELNR=v.VBELN
--where t.BLART not in ('DC','AB','DB')
)

,t_final
as
(

select KUNNR,BUKRS,BLART,BELNR,BLDAT,GJAHR,
case when BLART not in ('ab','db','dc')
THEN CASE WHEN B.SHKZG='H'
THEN (v.NETWR*-1)
else v.NETWR end else WRBTR
end
WRBTR,WRBTR b,WAERS,DMBTR,ZBD1T,ZBD2T,ZBD3T,AUGBL,AUGDT

from t_bsid b
left join t_vbrk v on v.VBELN=b.BELNR


)

select *,isnull(WRBTR,0)-isnull(b,0) from t_final order by BLDAT desc

</code>

Please help.





GouravSaxena1987
Starting Member

23 Posts

Posted - 2014-05-21 : 07:41:16
Are you looking for converting code into SQL-Server?
Please give some detaild lie what error are you getting into SQL Server execution.


Regards,
Gourav Saxena
Data Warehouse Counsultant
GouravSaxena1987@gmail.com
Go to Top of Page
   

- Advertisement -