Application Development and Automation 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: 
Read only

select quirey

Former Member
0 Likes
1,046

Hi experts ,

plz help me how to write code for below given technical description

Retrieve

• LIKP.VSTEL (shipping point)

WHERE

• LIKP.VBELN = Delivery Note Number.

Retrieve

• TVST.ADNR (address number)

WHERE

• TVST.VSTEL = LIKP.VSTEL

Retrieve

• ADRC.NAME1 (name)

• ADRC.STREET (address)

• ADRC.CITY (city)

• ADRC.REGION (state)

• ADRC.POST_CODE1 (zip)

WHERE

• ADRC.ADNR = TVST.ADNR

DEA ADRC.NAME2 from address record selected for ‘Header – From’ (DEA number stored in NAME2 field only for shipping points)

regards

siri

Hi experts ,

plz help me how to write code for below given technical description

Retrieve

• LIKP.VSTEL (shipping point)

WHERE

• LIKP.VBELN = Delivery Note Number.

Retrieve

• TVST.ADNR (address number)

WHERE

• TVST.VSTEL = LIKP.VSTEL

Retrieve

• ADRC.NAME1 (name)

• ADRC.STREET (address)

• ADRC.CITY (city)

• ADRC.REGION (state)

• ADRC.POST_CODE1 (zip)

WHERE

• ADRC.ADNR = TVST.ADNR

DEA ADRC.NAME2 from address record selected for ‘Header – From’ (DEA number stored in NAME2 field only for shipping points)

regards

siri

7 REPLIES 7
Read only

Former Member
0 Likes
1,011

Hi,

l_del_no = 432423. --> The delivery no.

SELECT VBELN

VSTEL

FROM LIKP

into table it_vstel

WHERE VBELN = l_del_no.

sort it_vstel by vbeln vstel.

if not it_vstel is initial.

select vstel

adnr

from TVST

for all entries in it_vstel

into table it_adnr

where vstel = it_vstel-vstel.

endif.

sort it_adnr by vstel adnr.

if not it_adnr is initial.

select vstel

name1

street

city

region

post_code1

for all entries in it_adnr

into table it_address

from ADRC

where adnr = it_adnr-adnr.

endif.

Best regards,

Prashant

Read only

Former Member
0 Likes
1,011

Hi,

select vstel from LIKP into table LIKP_IT where vbeln = <Delivery note number>.

SORT LIKP_IT by VSTEL.

select ADRNR from TVST into table TVST_IT for all entries in LIKP_IT where VSTEL= LIKP_IT-VSTEL.

SORT TVST_IT by ADRNR.

select name1 street city1 region post_code1 from ADRC into table ADRC_IT for all entries in TVST_IT where ADRNR = TVST_IT-ADRNR.

Thanks.

If this helps you reward with points.

Read only

Former Member
0 Likes
1,011

select likpvstel tvstadnr

into table itab

from likp inner join tvst

on likpvstel = tvstvstel

where likp~vbeln = l_vbeln.

Loop at itab.

select name1 street city region post_code1

from adrc where adnr = itab-adnr.

endloop.

Note 100% sure of your last requirement about DEA but it seems that you just need to include name2 in the above query.

Message was edited by: Anurag Bankley

Read only

Former Member
0 Likes
1,011

hi,

     select vstel from likp into v_vstel up to 1 row
           
            where vbeln = (deilery note number or parameter).
 
if sy-subrc = 0.
    
     select adrnr from tvst into v_adrnr up to 1 row
             where vstel = v_vstel.

if sy-subrc = 0.
  select name1 
         street
         city 
         region
         post_code1
          into table wa_adrc
        where adrnr = v_adrnr.

endif.
endif.

Regards

Ashok P

Read only

Former Member
0 Likes
1,011

Hi,

Written code for 3 selects from 3 tables

<b>can you be more clear for the last line</b>

tables: likp.

select-options:s_vbeln for likp-vbeln.

data:begin of itab1 occurs 0,

vbeln like likp-vbeln,

vstel like likp-vstel,

end of itab1.

data:begin of itab2 occurs 0,

adrnr like tvst-adrnr,

vstel like tvst-vstel,

end of itab2.

data:begin of itab3 occurs 0,

name1 like adrc-name1,

street like adrc-street,

city1 like adrc-city1,

region like adrc-region,

post_code1 like adrc-post_code1,

ADDRNUMBER like adrc-ADDRNUMBER,

end of itab3.

select vbeln vstel from likp into table itab1 where vbeln in s_vbeln.

select adrnr vstel from tvst into table itab2

for all entries in itab1

where vstel = itab1-vstel.

select name1 street city1 region post_code1 from adrc into table itab3

for all entries in itab2

where ADDRNUMBER = itab2-adrnr.

Read only

Former Member
0 Likes
1,011

Hi,

Find the belowsaid code :

Reward points if helpful.

DATA : BEGIN OF str_addr,
        vstel LIKE likp-vstel,
        vbeln LIKE likp-vbeln,
        adnr LIKE tvst-adrnr,
        name1 LIKE adrc-name1,
        street LIKE adrc-street,
        city LIKE adrc-city1,
        region LIKE adrc-region,
        END OF str_addr.

DATA : it_adr LIKE TABLE OF str_addr WITH HEADER LINE.

SELECT l~vstel l~vbeln t~adrnr a~name1
       a~street a~city1 a~region
       INTO CORRESPONDING FIELDS OF TABLE it_adr
       FROM  likp AS l INNER JOIN
       tvst AS t ON l~vstel = t~vstel
       INNER JOIN
       adrc AS a
       ON a~addrnumber = t~adrnr.
       WHERE l~vbeln = 'XXXXXXXXX'.

check sy-subrc = 0.

Regards

Read only

Former Member
0 Likes
1,011

Hi,

You can write the select statment as...

select vstel from likp into v_vstel up to 1 row where vbeln = (deilery note number or parameter).

if sy-subrc = 0.
     select adrnr from tvst into v_adrnr up to 1 row  where vstel = v_vstel.
     if sy-subrc = 0.
        select name1  street
               city   region
               post_code1
           nto table wa_adrc
          where adrnr = v_adrnr.
     endif.
endif.

Hope this code solves the issue

Regards,

Richa