2007 Jun 06 2:06 AM
i have a scenario,
where i have a itab inprofpost which has
besides other fields kostl aufnr lstar as key fields,
now for each entry in inprofpost
i have to pick up all the entries from bseg which match
kostl aufnr lstar
into another itab final_tab along with inprofpost entries.
am i clear, the final_tab must have entries
which are join of this itab and also bseg. ie. it should have
a total of ( # of itab * # of bseg ) entries.
2007 Jun 06 3:36 AM
thank you all of you.
we can use select inside loop with condition, thats ok,
but wat about the other fields in itab1 which have to be copied into final_itab.
like i said itab1 has 5 fields and ztable has 5 fields.
the final_itab should have all the 10 entries including 3 common fields.
i have a scenario,
where i have a itab inprofpost which has
besides other fields kostl aufnr lstar as key fields,
now for each entry in inprofpost
i have to pick up all the entries from bseg which match
kostl aufnr lstar
into another itab final_tab along with inprofpost entries.
am i clear, the final_tab must have entries
which are join of this itab and also bseg. ie. it should have
a total of ( # of itab * # of bseg ) entries.
2007 Jun 06 2:14 AM
Hi Saritha,
Can you please be more specific. I am not clear as what exactly you want :(.
Regards,
Atish
2007 Jun 06 2:25 AM
data is there in itab1 and ztable.
now final_itab is empty.
for every entry in itab1, all the entries in ztable should be copied to final_itab along with itab1 values.
if for entry in itab1 there are 5 entries in ztable, and if itab1 has 2 entries.
then final_itab should have a total of 10 entries.
am i clear, if not i will try to be more clear.
thankyou for the response.
2007 Jun 06 2:26 AM
2007 Jun 06 2:35 AM
Or just use loop , like
loop at itab.
select ... from bseg into itab2 where ... = itab-col
endloop.
Then you'll have itab2 as result you wanted .
2007 Jun 06 2:27 AM
there are 3 fields common in between itab1 and ztable, which should match before picking.
2007 Jun 06 2:30 AM
Hi Saritha,
try something like this,
select field1 field 2... from ztable into final_itab for all entries in itab
where ....(three common field condition)
Revert back if further query.
Regards,
Atish
2007 Jun 06 3:13 AM
Hi,
Use the three common fields in condition for select statement.
2007 Jun 06 2:53 AM
use this select query
if inprofpost[] is not intial.
select * from bseg
into table final_tab
for all entiries in inprofpost
where lstar = inprofpost-lstar
and aufnr = inprofpost-aufnr
and kostl = inprofpost-kostl.
endif.
Please reward ponts if helpful
2007 Jun 06 3:36 AM
thank you all of you.
we can use select inside loop with condition, thats ok,
but wat about the other fields in itab1 which have to be copied into final_itab.
like i said itab1 has 5 fields and ztable has 5 fields.
the final_itab should have all the 10 entries including 3 common fields.
2007 Jun 06 3:39 AM
Hi Saritha,
First select 5 fields in final_itab as mentioned above.
now use below code.
LOOP AT final_itab.
Read table itab1 with key ...(use common fields as key between itab and final_itab)
final_itab-field6 = itab-field1.
..like this move all fields.
Modify final_itab.
ENDLOOP.
Hope it is clear.
Regards,
Atish
2007 Jun 06 3:47 AM
Hi,
If you decided to use select inside loop, then your logic should be,
loop at itab1 into wa1.
select f1 f2 f3 f4 f5 into corresponding fields of wa_ztable
where f1 = wa1-f1 and f2 = wa1-f2 and f3 = wa1-f3.
move-corresponding wa_ztable to wa_final.
move-corresponding wa1 to wa_final.
append wa_final to itab_final.
endselect.
endloop.
Otherwise, you can use for all entries.
if not itab[] is initial.
select f1 f2 f3 f4 f5 from bseg into table itab_ztable for all entries in itab
where f1 = itab-f1 and f2 = itab-f2 and f3 = itab-f3.
endif.
loop at itab into wa.
read table itab_ztable into wa_ztable with key f1 = wa-f1
f2 = wa-f2 f3 = wa-f3.
if sy-subrc eq 0.
move-corresponding wa_ztable to wa_final.
move-corresponding wa1 to wa_final.
append wa_final to itab_final.
endif.
endloop.
Kindly reward points by clicking the star on the left of reply,if it helps.
2007 Jun 06 4:06 AM
thanks jayanthi,
thank you very much.
i couldnot assign more points because i already gave those to thers.
i appreciate your help.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |