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

Doubt in internal table

Former Member
0 Likes
525

Hi all.

I need to pass one field to local variable from internal table.

SELECT * FROM vbkd into CORRESPONDING FIELDS OF table it_vbkd WHERE vbkd~mandt = sy-mandt AND

vbeln = komp-aubel.

pls help me with this code.

To be reward all helpfull answers,

Jay

3 REPLIES 3
Read only

vinod_vemuru2
Active Contributor
0 Likes
502

Hi Jay,

U cant pass the content of internal table directly to variables.

Either u have to use Read table or Loop INTO work area.

Also if u r not using Joins then vbkd~ Is not required.

Let me know how u r getting data into internal table komp

(If it is). If u declared it in TABLES: komp then U can directly refer to it as u are doing now.

check below code.

Code1:

CHECK NOT komp[] IS INITIAL.

SELECT * FROM vbkd

into CORRESPONDING FIELDS OF table it_vbkd

FOR ALL ENTRIES IN komp

WHERE mandt = sy-mandt

AND vbeln = komp-aubel.

This select will fetch all the records in vbkd

where vbeln = all aubel values in komp.

Code2:

CLEAR wa.

READ TABLE komp INTO wa WITH KEY (ur keys).

CHECK sy-subrc IS INITIAL.

SELECT * FROM vbkd into CORRESPONDING FIELDS OF table it_vbkd WHERE mandt = sy-mandt AND

vbeln = wa-aubel.

This select will fetch all the records in vbkd

where vbeln = wa-aubel.(One value here)

*Also let me know how u r getting into internal table komp(If it is)

Thanks,

Vinod.

Edited by: Vinod Kumar Vemuru on Apr 27, 2008 7:33 PM

Read only

Former Member
0 Likes
502

Hi,

You just read the internal table which you have filled into a work area and assign the required field to a variable..OR loop at it_vbkd if it has multiple entries.

and better avoid using into corresponding fields..you can modify the code as,

pls revert if you need further help,

cheers.

Read only

Former Member
0 Likes
502

Hye Jay,


SELECT * FROM vbkd into CORRESPONDING FIELDS OF table it_vbkd WHERE vbkd~mandt = sy-mandt AND
vbeln = komp-aubel.            
* This select will return all the rows into an internal table it_vbkd.
* now you want to read a value frm it_vbkd into local variable lv.
data: wa_vbkd like line of it_vbkd " work area with same structure as internal table.
read table it_vbkd into wa_vbkd 
       with key vbeln = '100'.   
* i have table for example vbeln. you can use any number of keys as selection cretira by just seperating with space.

* now send the particular field of work area into local variable.

lv = wa_vbkd-jay.

* local variable will have the content.

hope this helps u.

Thanks.

Imran.