‎2007 May 03 1:26 PM
Hi All,
In the below mentioned code, i am reading an internal table and using the GUID i am fetching values from the database table and populating another internal table.
SELECT BUT000~PARTNER AS RESP_GROUP
FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
FOR ALL ENTRIES IN itab_PartnerGUID
WHERE BUT000~PARTNER_GUID = itab_PartnerGUID-GUID.
This code statement doesn't give any syntax error. But if i have to return values say from the itab as well as database table... then should it be something like...
SELECT itab_PartnerGUID-GUID as GUID
BUT000~PARTNER AS RESP_GROUP
FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
FOR ALL ENTRIES IN itab_PartnerGUID
WHERE BUT000~PARTNER_GUID = itab_PartnerGUID-GUID.
This statement throws an error saying "Unknown column name itab_PartnerGUID-GUID; not determined until runtime' .... what is the issue? can't i use the internal table that way? what is the right syntax to get the results.... please help....
Ramya G
‎2007 May 03 1:42 PM
Hello Ramya,
In the second select statement u r trying to retrieve the data the ITABPARTNERGUID. BUt the select stmt are only used to get data from Database table u can do like this.
loop at itab_PartnerGUID.
" Move the required fields to another internal table based on the required condition
endloop.
Regards,
Vasanth
‎2007 May 03 1:40 PM
Hi Ramya,
SELECT <i>itab_PartnerGUID-GUID</i> as GUID
OK, I think the field's name is PARTNER_GUID,
SELECT <i>PARTNER_GUID</i> as GUID
should do.
Regards,
Clemens
‎2007 May 03 2:52 PM
‎2007 May 03 3:03 PM
when you are equating BUT000~PARTNER_GUID = itab_PartnerGUID-GUID , then PARTNER_GUID is same as GUID , so just select that field from database table instead of internal table which is wrong
SELECT <b>BUT000~PARTNER_GUID</b> as GUID
BUT000~PARTNER AS RESP_GROUP
FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
FOR ALL ENTRIES IN itab_PartnerGUID
WHERE BUT000~PARTNER_GUID = itab_PartnerGUID-GUID.
‎2007 May 04 9:58 AM
Wow.. Chandrashekar.... that was an amazing catch in the code... you are rite.. when i am equating itab_PartnerGUID-GUID to BUT000PARTNER_GUID, i can as well use the BUT000PARTNER_GUID.... makes complete sense.....
but there's a problem, its a mistake in the query.... the query shd actuall be this:
SELECT <b>itab_PartnerGUID-GUID as GUID</b>
BUT000~PARTNER AS RESP_GROUP
FROM BUT000 INTO CORRESPONDING FIELDS OF TABLE itab_Partner
FOR ALL ENTRIES IN itab_PartnerGUID
WHERE BUT000~PARTNER_GUID = <b>itab_PartnerGUID-PARTNER_GUID.</b>
the internal table itab_PartnerGUID has 2 fields GUID and PARTNERGUID... in the where condition of the query i need to use PARTNERGUID, but in select i need to return GUID... how shd i do it? please help...
‎2007 May 03 1:42 PM
Hello Ramya,
In the second select statement u r trying to retrieve the data the ITABPARTNERGUID. BUt the select stmt are only used to get data from Database table u can do like this.
loop at itab_PartnerGUID.
" Move the required fields to another internal table based on the required condition
endloop.
Regards,
Vasanth
‎2007 May 03 2:51 PM
Hi Vasanth.. i was thinking of the same ....
May be i need to use the At Loop here .... but i am not able to see how to read from database table and then assign the filed and the guid from the 1st internal table to another internal table.... it would be grest if you can provide me the code using at loop for the sample code mentioned in first post.... thanks...
‎2007 May 03 2:12 PM
Hi Ramya,
first of all i want to know one thing, y r u using BUT000~PARTNER in ur sdelect statement, u r not using any joins rite.
just try this select in ur case
select partner as resp_group
from but000
into corresponding fields of table itab_partner
for all entries in itab_partnerguid
where partner_guid = itab_partnerguid-guid.
regards
ganesh
‎2007 May 03 2:48 PM
Hi Ganesh u are rite.. that's what my first query says... but what i need is the guid also from the itab_partnerguid table b'coz the structure of the intenal table itab_partner has 2 fields; GUId and partner....
so when i use the internal table's guid in the select it throws error...
select itab_partnerguid-guid as guid partner as resp_group
from but000
into corresponding fields of table itab_partner
for all entries in itab_partnerguid
where partner_guid = itab_partnerguid-guid
‎2007 May 03 3:08 PM
Hi Ramya,
As per my knowledge BUT000 is very large table and using CORRESPONDING FIELDS OF TABLE in Select Query will degrade ur performance.
U can simply do the following.
itab_resp_guid = (RESP_GROUP + GUID)
itab_guid = (GUID)
select partner guid
into table itab_resp_guid
for all entries in itab_guid
from BUT000
where GUID = itab_guid-guid.
U can check this out in ABAP Performance(SE30) also.
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>