‎2008 Apr 27 2:41 PM
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
‎2008 Apr 27 3:01 PM
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
‎2008 Apr 27 5:32 PM
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.
‎2008 Apr 27 6:49 PM
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.