‎2008 Aug 05 8:33 PM
I have a itab of input file and I have seperated header records intogt_header internal table.
Data : begin of gt_header
Rec_type(2) TYPE c,
Contol_no(50) TYPE c,
Report_flag(1),
Edi_tp(16) TYPE c,
Cust_no(10) TYPE c,
Brand_id(4) TYPE c,
Po_no(18) TYPE c,
Store_no(17) Type c,
END of gt_header.
LOOP AT gt_header
I have one zcustable is thereu2026
SELECT cust_no from zcustable
Where edi_tp = gt_header-edi_tp.
I will get muitple cust_nos here. How to put them in gt_header ?
Because I have to select for these multiple entries below KNVP table.
Again I have to fetch
1 FETCH ( kunnr ) into itab_shipto by Reading KNA1 table
using ( kna1-name2+7(5) = Store Number OR J_3ASTCU = Store Number ).
Again I have to fetch
2 FETCH ship to ( kunn2 ) into internal_tablef
from KNVP table
using knvp-kunnr = multiple cust_no (header(10) record sold tos ) and knvp u2013vkorg equal to 869_INPUT_REC_final -brand identifier
and knvp-spart equal to u201802u2019
and knvp-parvw equal to u2018DEu2019
and knvp-knn2 IN itab_shipto .
ENDLOOP.
how to write the logic? Is it better to go for inner join - if so kindly help me in writing join.
I am not that comfortable in writing joins ?
THANKS IN ADVANCE
‎2008 Aug 06 11:04 AM
Hi,
Try this.
Instead of using loop at & endloop.
Try using for all entries.
If gt_header[] is not initial.
SELECT cust_no
from zcustable
into ita1
for all entries in gt_header
Where edi_tp = gt_header-edi_tp.
select from other tables also as per your requirement.
endif.
Am giving the inner join example, use as per your requirement bcoz am not able to get a clear view of your tables.
Ex:
select af1 af2
bf3 bf4
cf5 cf6
into table itab
from <table1> as a inner join <table2> as b
on afield eq bfield
inner join <table3> as c
on bfield eq cfield
where a~field eq <some value to be checked>.
Sharin.
‎2008 Aug 06 11:04 AM
Hi,
Try this.
Instead of using loop at & endloop.
Try using for all entries.
If gt_header[] is not initial.
SELECT cust_no
from zcustable
into ita1
for all entries in gt_header
Where edi_tp = gt_header-edi_tp.
select from other tables also as per your requirement.
endif.
Am giving the inner join example, use as per your requirement bcoz am not able to get a clear view of your tables.
Ex:
select af1 af2
bf3 bf4
cf5 cf6
into table itab
from <table1> as a inner join <table2> as b
on afield eq bfield
inner join <table3> as c
on bfield eq cfield
where a~field eq <some value to be checked>.
Sharin.
‎2008 Aug 06 11:24 AM
hi ,
u can use the inner join.
use the sub queries in where cindition like WHERE field IN ( sub query)
pradeep.
‎2008 Aug 06 11:59 AM
Hi,
try this below code
IFgt_header[] is not initial.
SELECT cust_no
from zcustable
into i_zcustable
for all entries in gt_header
Where edi_tp = gt_header-edi_tp.
SELECT kunnr
land1
name2
INTO TABLE itab_shipto
for all entries in gt_header
WHERE kna1-name2 = gt_header-Store_no.
ENDIF.
IF not itab_shipto[] is initial.
SELECT kunnr
vkorg
vtweg
spart
parvw
knn2
INTO TABLE i_knvp
for all entries in itab_shipto
WHERE knvp-kunnr = itab_shipto-kunnr
AND spart = u201802u2019
AND PARVW = 'DE'.
endif.
if helpful rewards points.
regards,
bhupal.