‎2008 Feb 11 9:18 AM
Please see the Query below:
Part 1
select
vbeln posnr meins matnr werks netwr
kwmeng vrkme matwa charg pstyv
posar prodh grkor antlf kztlf lprio
vstel route umvkz umvkn abgru untto
awahr erdat erzet fixmg prctr vpmat
vpwrk mvgr1 mvgr2 mvgr3 mvgr4 mvgr5
bedae cuobj mtvfp
into corresponding fields of table t_vbap
from vbap
where
( ( erdat > pre_dat ) and ( erdat <= w_date ) ) and
( ( ( erdat > pre_dat and erdat < p_syndt ) or
( erdat = p_syndt and erzet <= p_syntm ) ) ) and
matnr in s_matnr and
pstyv in s_itmcat and
lfrel in s_lfrel and
abgru = ' ' and
kwmeng > 0 and
mtvfp in w_mtvfp.
Part 1
if sy-subrc is initial.
select etenr wmeng bmeng ettyp wepos abart edatu
tddat mbdat lddat wadat abruf etart ezeit
into corresponding fields of table t_vbap
from vbep
for all entries in t_vbap
where
vbeln = t_vbap-vbeln and
posnr = t_vbap-posnr and
ettyp in w_ettyp and
bdart in s_req_tp and
plart in s_pln_tp and
etart in s_etart and
abart in s_abart and
( ( lifsp in s_lifsp ) or ( lifsp = ' ' ) ).
endif.
Part 1 of the Query is executed and populates values into a few fields of the record into internal table.*
Part 2 of the Query has the duty to populate the values into the rest of the fields (which are empty) of the same internal table.*
But, when Part 2 of the Query is executed immediate to the Part 1, the internbal table looses values of those fields which are populated by Query Part 1.
My requirement is like this:
Query Part 1 should do:
Field1 Field2 Field3 Field4 Field5
100 abc 1425
Query Part 2 should do:
Field1 Field2 Field3 Field4 Field5
100 abc 1425 1100 4578
It should not erase Field1, Field2 & Field3 values.
Plz suggest!
‎2008 Feb 11 9:24 AM
Hi,
use append statement in the second select query...now u will get next records appended..
select ....appending table..
Regards,
nagaraj
‎2008 Feb 11 9:35 AM
Do U mean like below.....??
if sy-subrc is initial.
select etenr wmeng bmeng ettyp wepos abart edatu
tddat mbdat lddat wadat abruf etart ezeit
appending table t_vbap
from vbep
for all entries in t_vbap
where
vbeln = t_vbap-vbeln and
posnr = t_vbap-posnr and
ettyp in w_ettyp and
bdart in s_req_tp and
plart in s_pln_tp and
etart in s_etart and
abart in s_abart and
( ( lifsp in s_lifsp ) or ( lifsp = ' ' ) ).
endif.
‎2008 Feb 11 9:53 AM
Hi Dude,
In the second query,it should be like this,
appending corresponding fields of table tvbap_ instead of
into " " " ".
Regards,
Lakshmanan
‎2008 Feb 11 10:14 AM
Hi dude,
First of all check your t_vbap internal table declaration.
See to that whether all of the fields to be diaplayed in the report are included in the internal table.
Also tell me whether the appending addition to the second select meets your requirement.
Regards,
Lakshmanan
‎2008 Feb 11 9:50 AM
Hi
Ur first query is correct, problem with second one
in this even if u use append , it will not solve ur problem,
Bcz it will add new rows for those fields which are empty earlier.
now solution fo this is
in second part store the data in t_vbap1 in stead of t_vbap.
at the end od this query.
loop at t_vbap
read t_vbap1 with vblnr = t_vbap-vblnr.
move t_vbap content to t_vbap_final.
move t_vbap1 contents to t_vbap_ final.
append t_vbap_final.
endloop.
this will help u.
Rewards points please.good point if possible
‎2008 Feb 22 5:33 AM