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

solve this logic

Former Member
0 Likes
760

Here for single field iam taking internal table , for this i need just

one variable to store this internal table field instead of internal table.

Please send me that variable logic for following shown logic.

Tables LTAP.

DATA: BEGIN OF it_vbeln occurs 0,

wdno like ltap-vbeln,

END OF it_vbeln.

SELECT SINGLE vbeln INTO it_vbeln

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

After that iam passing that internal table (now i need that defined variable pased here)to retrieve data in this loop.

by See 'WHERE vbeln = it_vbeln-wdno'.

Here i need that defined variable. Please do this , remaining part is ok.

LOOP AT it_vbeln.

SELECT SINGLE kunnr "$05

INTO it_behdr-kunnr

FROM VBPA

WHERE vbeln = it_vbeln-wdno

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = it_behdr-kunnr. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

ENDLOOP.

*********************

Please change my logic as i mentioned.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
720

Hi....

i think here there is no need of internal table because you are retrieving a single value in select statement..

and remove loop statement..

write like this.....

Tables LTAP.

DATA: BEGIN OF it_vbeln, <b>"occurs 0,</b>

wdno like ltap-vbeln,

END OF it_vbeln.

SELECT SINGLE vbeln INTO <b>it_vbeln-wdno</b>

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

********************************************

After that iam passing that internal table (now i need that defined variable pased here)to retrieve data in this loop.

by See 'WHERE vbeln = it_vbeln-wdno'.

Here i need that defined variable. Please do this , remaining part is ok.

****************************

<b>*LOOP AT it_vbeln.</b>

SELECT SINGLE kunnr "$05

INTO it_behdr-kunnr

FROM VBPA

WHERE vbeln = it_vbeln-wdno

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = it_behdr-kunnr. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

<b>*ENDLOOP.</b>

Hope it helps you...

Let me know if u have any more doubt...

Reward points if useful......

Suresh.......

Here for single field iam taking internal table , for this i need just

one variable to store this internal table field instead of internal table.

Please send me that variable logic for following shown logic.

Tables LTAP.

DATA: BEGIN OF it_vbeln occurs 0,

wdno like ltap-vbeln,

END OF it_vbeln.

SELECT SINGLE vbeln INTO it_vbeln

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

After that iam passing that internal table (now i need that defined variable pased here)to retrieve data in this loop.

by See 'WHERE vbeln = it_vbeln-wdno'.

Here i need that defined variable. Please do this , remaining part is ok.

LOOP AT it_vbeln.

SELECT SINGLE kunnr "$05

INTO it_behdr-kunnr

FROM VBPA

WHERE vbeln = it_vbeln-wdno

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = it_behdr-kunnr. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

ENDLOOP.

*********************

Please change my logic as i mentioned.

Thanks

4 REPLIES 4
Read only

Former Member
0 Likes
721

Hi....

i think here there is no need of internal table because you are retrieving a single value in select statement..

and remove loop statement..

write like this.....

Tables LTAP.

DATA: BEGIN OF it_vbeln, <b>"occurs 0,</b>

wdno like ltap-vbeln,

END OF it_vbeln.

SELECT SINGLE vbeln INTO <b>it_vbeln-wdno</b>

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

********************************************

After that iam passing that internal table (now i need that defined variable pased here)to retrieve data in this loop.

by See 'WHERE vbeln = it_vbeln-wdno'.

Here i need that defined variable. Please do this , remaining part is ok.

****************************

<b>*LOOP AT it_vbeln.</b>

SELECT SINGLE kunnr "$05

INTO it_behdr-kunnr

FROM VBPA

WHERE vbeln = it_vbeln-wdno

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = it_behdr-kunnr. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

<b>*ENDLOOP.</b>

Hope it helps you...

Let me know if u have any more doubt...

Reward points if useful......

Suresh.......

Read only

Former Member
0 Likes
720

Hi,

Check the changes marked in bold..

Tables LTAP.

DATA: BEGIN OF it_vbeln, <b>" Removed the occurs 0.</b>

wdno like ltap-vbeln,

END OF it_vbeln.

SELECT SINGLE vbeln INTO it_vbeln

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

After that iam passing that internal table (now i need that defined variable pased here)to retrieve data in this loop.

by See 'WHERE vbeln = it_vbeln-wdno'.

Here i need that defined variable. Please do this , remaining part is ok.

<b>* Removed the LOOP AT</b>

SELECT SINGLE kunnr "$05

INTO it_behdr-kunnr

FROM VBPA

WHERE vbeln = it_vbeln-wdno

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = it_behdr-kunnr. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

<b>

  • REmoved the ENDLOOP.</b>

Thanks,

Naren

Read only

Former Member
0 Likes
720

Hi,

data: v_vbeln like vbap-vbeln, v_kunnr(10).

SELECT SINGLE vbeln INTO v_vbeln

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

<b>remove the LOOP..endloop</b>

SELECT SINGLE kunnr "$05

INTO <b>v_kunnr</b>FROM VBPA

WHERE <b>vbeln = v_vbeln</b>

AND PARVW = 'AG'. "$05

SELECT SINGLE adrnr "$05

INTO addr FROM Kna1

WHERE kunnr = <b>v_kunnr</b>. "$05

SELECT SINGLE name1 name2 name3 street house_num1 str_suppl1 "$05

str_suppl2 city1 post_code1

INTO (w_cname4, w_cname5, w_cname6, w_cstreet1,w_chouse_num2,

w_cstr_suppl3, w_cstr_suppl4, w_ccity2, w_cpost_code2)

FROM adrc

WHERE addrnumber = addr.

Dear Ali, You have asked this question so many times. but have you awarded points for the answers.

reward points for useful

answers

regards,

Anji

Read only

Former Member
0 Likes
720

Hi ali..

<b>SELECT SINGLE</b> vbeln INTO it_vbeln

FROM LTAP

WHERE tanum = tonumber

AND lgnum = w_lgnum.

it will fetch u only one record...so save it in a single field ..

why r u going for loop <b>LOOP AT it_vbeln</b>.??

it will run only once as it has only one record...

is it clear???

ram