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 typetableofsapsr3.
selectDISTINCT matnr into CORRESPONDING FIELDSOFTABLE i_matnr fromsapsr3
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 * fromsapsr3 CLIENTSPECIFIEDintotable i_tab
WHERE mandt = 300 AND werks = '1100' AND stlan = '1' AND stlal = '02'
delete i_tab where matnr in s_matnr.
select * fromsapsr3 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.