‎2009 Feb 27 4:03 PM
Hi,
I am trying to query data from some tables and tyring to figure what is the best way to do it.
types: begin of ty_test,
field1 type num08 ,
field2 type char30,
end of ty_test,
tt_test type standard table of ty_test.
data: t_inp type standard table of tt_test,
t_tbla type standard table of tt_test.lets consider the table t_inp has 10 entries and based on entries from t_inp I need to get related data from table A
select objid sobid from A
into table t_tbla
for all entries in table t_inp
where field1 = t_inp-field2.If I do this I get an error saying that to use for all entries it needs to be of the same type and length
I will have to do something similar atleast 3 to 4 times.
Note:- << Removed>> I am trying to avoid using select end select statement.
Thanks
Vick
Added code tags.
Please do not offer rewards
And please use a meaningful subject. Everyone needs programming help.
Edited by: Rob Burbank on Feb 27, 2009 11:08 AM
‎2009 Feb 27 4:13 PM
Hi Vick,
types: begin of t_source,
field1 type tab1-field1,
field2 type tab1-field2,
field_tmp type tab1-field2, "declare one more filed in first internatable with the type of second internal table filed --->ccheck 1.
eend of t_source
data: it_inpt type table of t_source.
data:wa_inpt like line of it_inpt.
loop at it_inp into wa_iinp
wa_inpt-field_tmp = wa_iinp-field1
modify it_inp from wa_inpt index sy-tabix tranporting field_tmp ----- >> check 2
clear wa_inpt.
endloop.
select objid sobid from A
into table t_tbla
for all entries in table t_inp
where field1 = t_inp-field_tmp. " here you have to do the type of field1 and field2 should be equal. --->check 3Note: if you are using the For all entries you must note that fields which you are comparing that must be equal.
hope it helps you.
Regards
‎2009 Feb 27 4:13 PM
Hi Vick,
types: begin of t_source,
field1 type tab1-field1,
field2 type tab1-field2,
field_tmp type tab1-field2, "declare one more filed in first internatable with the type of second internal table filed --->ccheck 1.
eend of t_source
data: it_inpt type table of t_source.
data:wa_inpt like line of it_inpt.
loop at it_inp into wa_iinp
wa_inpt-field_tmp = wa_iinp-field1
modify it_inp from wa_inpt index sy-tabix tranporting field_tmp ----- >> check 2
clear wa_inpt.
endloop.
select objid sobid from A
into table t_tbla
for all entries in table t_inp
where field1 = t_inp-field_tmp. " here you have to do the type of field1 and field2 should be equal. --->check 3Note: if you are using the For all entries you must note that fields which you are comparing that must be equal.
hope it helps you.
Regards
‎2009 Feb 27 4:13 PM
loop at t_inp.
posted by mistake.
Edited by: kartik tarla on Feb 27, 2009 9:46 PM
‎2009 Feb 27 4:13 PM
‎2009 Feb 27 4:15 PM
loop at t_inp.
wa-field = t_inp-field2."where wa field is of type num08
append wa to t_temp.
endloop.
now use t_temp in for all entries instead of t_inp
‎2009 Feb 27 4:15 PM
I dont want to use the loop statement because I have to do the similar process 3 to 4 more times.
‎2009 Feb 27 4:17 PM
then modify the structure of t_inp or else u have to use loop
‎2009 Feb 27 4:28 PM
I cannot modiy the t_inp structure, is there any way I can utilize field symbols or equivalent to modify the structure dynamically with the data in them, may be assign to another fieldsymbol with a different structure ??? just a thought, you guys are the experts you wud know it better.
Thanks
Vick
‎2009 Feb 27 4:34 PM
Vick - analyze your problem.
You want to use FOR ALL ENTRIES.
You have a table that has the correct data, but in a format that can't be used by FOR ALL ENTRIES.
So, one way or another, you need a table with the correct entries in the correct format.
Rob
‎2009 Feb 27 4:43 PM
Rob,
I know that what I am trying to do sounds dumb but I feel that the language shud have been a little bit more flexible.
I need to retreive data from HRP1001 table based on certain condition and as u know how the data is stored in the HRP1001 table. I will be retreiving the data based on a certain realtionship and the resulting id will be in the sobid field so based on the sobids from ur query1 I need to read the same table again but with a different realtionship and retrieve the data. I need to repeat this process for 4 times and every time I will end up looping so I thought may be I will pose this question to the experts, as some of you guys know to trick the system really well.
It looks like there is no easy way out other than looping so I guees I will stick to this.
I appreciate for your time and effort in trying to solve my query.
Thanks
Vick
‎2009 Feb 27 5:15 PM
>
> I know that what I am trying to do sounds dumb but I feel that the language shud have been a little bit more flexible.
Nope - not dumb at all. But it has come up before and I don't know of another solution.
Rob
‎2009 Feb 27 4:16 PM
1) Add a field to table t_inp with the same characteristics as t_tbla-field1.
2) After populating t_inp, loop through it and assign field2 to the new field.
3) Use the new field in the SELECT.
Rob
‎2009 Feb 27 4:31 PM
If you can't change the structure, then a loop and a variable of the same type as a-field1 are your only way.