2011 Feb 07 10:11 AM
Hi experts,
I have a subquery which has to be written in ABAP.
select single TARIF_TYPE from table ZTARIFF where (TARIFTYP = xxx and ANLART = mn)
Where xxx = select TARIFTYP from table EANLH where (ANLAGE = select ANLAGE from table EVER where VKONTO = Contract account Number)
Where mn = select ANLART from EANL where where (ANLAGE = select ANLAGE from table EVER where VKONTO = Contract account Number)
Can anyone give me the corresponding ABAP code for this?
Thanks
Ayan
<MOVED FROM PI FORUMS>
Edited by: Prateek Raj Srivastava on Feb 8, 2011 2:33 AM
Hi experts,
I have a subquery which has to be written in ABAP.
select single TARIF_TYPE from table ZTARIFF where (TARIFTYP = xxx and ANLART = mn)
Where xxx = select TARIFTYP from table EANLH where (ANLAGE = select ANLAGE from table EVER where VKONTO = Contract account Number)
Where mn = select ANLART from EANL where where (ANLAGE = select ANLAGE from table EVER where VKONTO = Contract account Number)
Can anyone give me the corresponding ABAP code for this?
Thanks
Ayan
<MOVED FROM PI FORUMS>
Edited by: Prateek Raj Srivastava on Feb 8, 2011 2:33 AM
2011 Feb 07 10:19 AM
Hi Ayan,
you should ask that in an ABAP forum.
Regards,
Udo
2011 Feb 07 11:01 AM
use internal tables & work area for this requirement
select ANLAGE from table EVER INTO <Internal table IT1> where VKONTO = Contract account Number.
select ANLART from EANL INTO <Internal table IT2>
For all entries in IT1 where ANLAGE = IT1-ANLAGE.
select ANLAGE from table EVER INTO <Internal table IT3> where VKONTO = Contract account Number.
select TARIFTYP from table EANLH INTO <Internal table IT4>
For all entries in IT4 where ANLAGE = IT3-ANLAGE.
select single TARIF_TYPE from table ZTARIFF INTO <IT5>
for all entries in table IT4
where TARIFTYP = IT4-xxx.
loop at it3 into wa_it3.
Read table IT5 into WA_IT5 with key ANLART = wa_it3-mn.
if sy-subrc is initial.
TARIF_TYPE = wa_it5-TARIF_TYPE .
Endif.
Endloop.
2011 Feb 07 11:26 PM
I'd say it's doable in one select.
Read documentation on subqueries [http://help.sap.com/saphelp_NW04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm|http://help.sap.com/saphelp_NW04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm]
and this syntax
SELECT SINGLE city latitude longitude
INTO (city, lati, longi)
FROM sgeocity
WHERE city IN ( select cityfrom
FROM spfli
WHERE carrid = carr_id AND
connid = conn_id ).
2011 Feb 08 12:47 AM
sorry i have no means of testing this, but you could try this one.
select single TARIF_TYPE from ZTARIFF where
TARIFTYP = ( select single TARIFTYP from EANLH where ANLAGE = ( select single ANLAGE from EVER where VKONTO = Contract_account_Number ) )
and ANLART = ( select single ANLART from EANL where ANLAGE = ( select single ANLAGE from EVER where VKONTO = Contract_account_Number ) ).
2011 Feb 08 3:07 AM
I think you can joins for this:
select ztariff~tarif_type
from ever
join eanlh on eanlanlage = everanlage
join eanl on eanlanlage = everanlage
join ztariff on ztarifftariftyp = eanlhtariftyp
and ztariffanlart = eanlanlart
where ever~vkonto in s_vkonto.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |