10-20-2007 9:28 AM
Hi Experts,
I have written two select statement shown below. In it_vbap the whole data is comming apart from auart = 'ZBEO' or auart = 'ZBOR' or auart = 'ZOLD' or auart = 'ZOEO' . In it_vbak it is comming O.K. I want to delete records apart from ZBEO,ZBOR,ZOLD, & ZBEO comparing from it_vbap without loop comparing it_vbap and it_vbak. How to write ? Pl. help me.
SELECT * FROM vbap client specified
INTO CORRESPONDING FIELDS OF TABLE it_vbap
WHERE mandt = sy-mandt and
erdat IN dt1 AND
matnr IN matnr1 AND
gsber = 'HIP' AND
vstel = 'BSP'.
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE it_vbak
FOR ALL ENTRIES IN it_vbap WHERE vbeln = it_vbap-vbeln
and ( auart = 'ZBEO' or auart = 'ZBOR'
or auart = 'ZOLD' or auart = 'ZOEO' ) .
Yusuf
10-20-2007 10:00 AM
Instead of writing different queries on VBAP and VBAK .. you can use JOIN On the two tables.
Other Option is loop at the interal table VBAK and prepare a range ra_vbeln for the Document Number (VBELN). Then you can use the statement
delete it_vbap where vbeln in ra_vbeln.
Reward if useful
Regards,
Abhishek
10-21-2007 6:39 AM
Hi,
Delete it_vabk where auart NE 'ZBEO' or auart NE 'ZBOR' or auart NE 'ZOLD' or auart NE 'ZOEO'.
Delete it_vabk where auart NE 'ZBEO' or auart NE 'ZBOR' or auart NE 'ZOLD' or auart NE 'ZOEO'.
Or best one is :
SELECT * FROM vbap client specified
INTO CORRESPONDING FIELDS OF TABLE it_vbap
WHERE mandt = sy-mandt and
erdat IN dt1 AND
matnr IN matnr1 AND
gsber = 'HIP' AND
vstel = 'BSP' and
AUART = 'ZBEO' and auart = 'ZBOR' and auart = 'ZOLD' and auart = 'ZOEO'.
Regards,
Vijay Mekala.
10-21-2007 9:51 AM
Hello Vijay,
The document type is not present in VBAP.
Regards,
Abhishek
10-21-2007 5:40 PM
> Delete it_vabk where auart NE 'ZBEO' or auart NE
> 'ZBOR' or auart NE 'ZOLD' or auart NE 'ZOEO'.
Just a small annotation. This code would result in deleting the compete table. If you want to delete all entries with keys other than the 4 stated you have to use AND insteat of OR.
NOT ( a OR b OR c OR d) is becomming NOT a AND NOT b AND NOT c AND NOT d when elimination the ( ) .
Rgds.
Roman