Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9190

Re: union in a select

$
0
0

If you want to get the output using multiple queries, you can apply the following logic.

 

Tables sapsr3.

data s_matnr type range of matnr WITHHEADERLINE.
data : beginof i_matnr OCCURS0,
       matnr type matnr,
     endof i_matnr.
data i_tab typetableof
sapsr3.


selectDISTINCT matnr  into CORRESPONDING FIELDSOFTABLE i_matnr  from
sapsr3

CLIENTSPECIFIEDwhere mandt = 300 AND werks = '1100' AND stlan = '1' AND stlal = '01'.


  loopat i_matnr.
    s_matnr-sign = 'E'.
    s_matnr-option = 'EQ'.
    s_matnr-low = i_matnr-matnr.
    append s_matnr.
endloop.

select * from
sapsr3 CLIENTSPECIFIEDintotable i_tab

            WHERE mandt = 300 AND werks = '1100'  AND stlan = '1' AND stlal = '02'


delete i_tab where matnr in s_matnr.

select * from
sapsr3 CLIENTSPECIFIEDappendingtable i_tab

          where mandt = 300 AND werks = '1100' AND stlan = '1' AND stlal = '01'.

 

I do not think trim function would be required as matnr will always be in the internal format.

Let me know if its working fine.


Viewing all articles
Browse latest Browse all 9190

Trending Articles