Application Development 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: 

Problem in adding one condition in where clause

Former Member
0 Kudos
208

Hi,

I am populating this internal table t_bkpf for all entries in gt_covp_ext

select bukrs belnr gjahr

bldat budat cpudt

xblnr waers awtyp awkey

from bkpf

into corresponding fields of table t_bkpf

for all entries in gt_covp_ext

where bukrs eq gt_covp_ext-bukrs and

awtyp eq 'MKPF'.

Here i have to add one more condition in where clause

AWKEY = ( Concatenated string of gt_covp_ext-REFBN + gt_covp_ext-REFGJ )

As i am not using loop at gt_covp_ext.How to implement this condition in Where clause.

Please help.If you did not understood the requirement reply this post.

Mukesh Kumar

Message was edited by:

mukesh kumar

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos
164

Hi Mukesh,

YOu have to have anothe fild to hold the concatenation of the fields REFBN and REFGJ , say AWKEY

loop at gt_covp_ext.
concatenate gt_covp_ext-refbn gt_covp_ext-refgj into gt_covp_ext-awkey.
modify gt_covp_ext index sy-tabix.
endloop.

select bukrs belnr gjahr
bldat budat cpudt
xblnr waers awtyp awkey
from bkpf
into corresponding fields of table t_bkpf
for all entries in gt_covp_ext
where bukrs eq gt_covp_ext-bukrs and
awtyp eq 'MKPF' and
<b>awkey = gt_covp_ext-awkey.</b>

Regards,

Ravi

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos
165

Hi Mukesh,

YOu have to have anothe fild to hold the concatenation of the fields REFBN and REFGJ , say AWKEY

loop at gt_covp_ext.
concatenate gt_covp_ext-refbn gt_covp_ext-refgj into gt_covp_ext-awkey.
modify gt_covp_ext index sy-tabix.
endloop.

select bukrs belnr gjahr
bldat budat cpudt
xblnr waers awtyp awkey
from bkpf
into corresponding fields of table t_bkpf
for all entries in gt_covp_ext
where bukrs eq gt_covp_ext-bukrs and
awtyp eq 'MKPF' and
<b>awkey = gt_covp_ext-awkey.</b>

Regards,

Ravi

Former Member
0 Kudos
164

maintain one more field in that internal table like AWKEY

get the data

then

loop at itab.

concatenate itab1 itab1 into itab-awkey.

modify itab.

endloop.

second select.

Regards

prabhu

Former Member
0 Kudos
164
Ad one more add one more field to table  gt_covp_ext

data : begin of gt_covp_ext occurs 0,
          ....
          AWKEY(25),
         end of gt_covp_ext.

loop at gt_covp_ext into wa_gt_covp_ext.
   concatenate gt_covp_ext-REFBN  gt_covp_ext-REFGJ into wa_gt_covp_ext-AWKEY.
  modify gt_covp_ext from wa_gt_covp_ext.
endloop.

if not gt_covp_ext[] is initial.

select bukrs belnr gjahr

bldat budat cpudt

xblnr waers awtyp awkey

from bkpf

into corresponding fields of table t_bkpf

for all entries in gt_covp_ext

where bukrs eq gt_covp_ext-bukrs and

<b> AWKEY = gt_covp_ext-AWKEY</b>

awtyp eq 'MKPF' .

endif.

Former Member
0 Kudos
164

Hi

U have to do that before doing the query on BKPF, so add the field AWKEY in gt_covp_ext.

LOOP AT gt_covp_ext.

  CONCATENATE gt_covp_ext-REFBN  gt_covp_ext-REFGJ INTO gt_covp_ext-AWKEY.
  MODIFY gt_covp_ext.
ENDLOOP. 

select bukrs belnr gjahr bldat budat cpudt xblnr waers awtyp awkey
   from bkpf into corresponding fields of table t_bkpf
                                        for all entries in gt_covp_ext
                                                where awtyp eq 'MKPF'
                                                  AND AWKEY EQ  gt_covp_ext-AWKEY.

<b>U don't need to use BUKRS in where condition, because there's an index using AWTYP and AWKEY only.</b>

Max

Former Member
0 Kudos
164

Hi,

Create a new internal table gt_covp_ext_new with the same structure as gt_covp_ext. Include an extra field in gt_covp_ext_new-concat, to store the concatenated value.

Copy all entries from gt_covp_ext to gt_covp_ext_new.

Loop at gt_covp_ext.

move-corresponding gt_covp_ext to gt_covp_ext_new.

gt_covp_ext_new-concat = gt_covp_ext-REFBN + gt_covp_ext-REFGJ .

append gt_covp_ext_new.

endloop.

Now use this new internal table in the query.

select bukrs belnr gjahr

bldat budat cpudt

xblnr waers awtyp awkey

from bkpf

into corresponding fields of table t_bkpf

for all entries in gt_covp_ext_new

where bukrs eq gt_covp_ext_new-bukrs and

awkey eq gt_covp_ext_new-concat and

awtyp eq 'MKPF'.

Hope this answers your qn.

Regards,

Divya

Former Member
0 Kudos
164

hi

good

as far as i got the knowledge from your post ,you want to add the next condition with your first select statement.

I dont think there is any statement in sap like "Concatenated string of " as you have mentione din your second statement,so try to use the CONCATENATE statement outside the select query and than try to use that particular value in your existing select statement.

thanks

mrutyun^