Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

writing alias query with casting

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.