04-27-2009 2:14 PM
Dear Experts,
i want to excute a query which have a condition that needs some casting. the table is MSEG the users are entering the reffrencing article document in the item text field. now all i need is to excute a query which have the mseg aliased and the joining condition should be mblnr with sgtxt
i imagine it should be something like this
select * from recmseg,supmseg where supmseg.mblnr=cast(recmseg.sgtxt as blnr)
recmseg is alias mseg for the recieving site
supmseg is alias Mseg for suplying site
so please can you tell me where i can write it and how to excute it and correct the syntax also
04-27-2009 2:38 PM
Hi Ebrahime ,
Please try this code ---
DATA : t_itab LIKE TABLE OF mseg.
SELECT mblnr sgtxt FROM mseg
INTO CORRESPONDING FIELDS
OF TABLE t_itab.
Regards
Pinaki
04-27-2009 2:47 PM
thank you for your immediate reply. can you tell me where i can excute this query also i am not finding the joining condition in the query i want to join sgtxt with mblnr
04-27-2009 2:52 PM
Hi,
I have modified the previous code a bit to join that by CONCATENATE statement.
Check the changes -
DATA : t_itab LIKE TABLE OF mseg,
fs_itab TYPE mseg.
DATA : w_string TYPE string.
SELECT mblnr sgtxt FROM mseg
INTO CORRESPONDING FIELDS
OF TABLE t_itab.
LOOP AT t_itab INTO fs_itab.
CONCATENATE fs_itab-mblnr fs_itab-sgtxt INTO w_string.
WRITE : / w_string.
ENDLOOP.
Thanks and regards
Pinaki
04-28-2009 12:05 PM
hi,
let me explain more i want to write a join condition statement the condition is mblnr=sgtxt thats all not to concatenate the 2 fields. in other words to make copy of the table mseg 2 times and compare sgtxt in the first copy with mblnr in the second copy and if a match happen select that.
04-28-2009 12:57 PM
i found it
REPORT ZMM_TRANSFER.
DATA :
fs_itab TYPE mseg,rs_itab LIKE TABLE OF mseg.
select MSEG2~mblnr MSEG1~sgtxt
INTO CORRESPONDING FIELDS
OF TABLE rs_itab
from MSEG as MSeg1
inner JOIN
MSEG as mseg2
on
mseg2~MBLNR = MSEG1~sgtxt.
LOOP AT rs_itab into fs_itab.
WRITE : / fs_itab-sgtxt,fs_itab-mblnr.
ENDLOOP.