Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Record Selection Problem

Former Member
0 Likes
760

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!

6 REPLIES 6
Read only

former_member404244
Active Contributor
0 Likes
736

Hi,

use append statement in the second select query...now u will get next records appended..

select ....appending table..

Regards,

nagaraj

Read only

0 Likes
736

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.

Read only

0 Likes
736

Hi Dude,

In the second query,it should be like this,

appending corresponding fields of table tvbap_ instead of

into " " " ".

Regards,

Lakshmanan

Read only

0 Likes
736

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

Read only

Former Member
0 Likes
736

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

Read only

Former Member
0 Likes
736

k