2010 Oct 07 7:40 AM
Hello all.
I've encountered a problem which i cannot explain:
When i write a query which look like this:
types: begin of ty_vbfa,
vbelv type vbelv,
posnv type posnr_von,
vbeln type vbeln_nach,
posnn type posnr_nach,
rfwrt type rfwrt,
end of ty_vbfa.
types: begin of ty_vbrp,
vbeln type vbeln_vf,
vgbel type vgbel,
netwr type netwr_fp,
ntgew type ntgew_15,
end of ty_vbrp.
data: gt_vbfa type table of ty_vbfa.
data: gt_vbrp type table of vbrp.
and then:
select vbelv vbeln
into corresponding fields of table lt_vbfa
from vbfa
where vbtyp_n in (lv_vbtyp_n_m, lv_vbtyp_n_n, lv_vbtyp_n_o, lv_vbtyp_n_s).
sort lt_vbfa by vbeln.
delete adjacent duplicates from lt_vbfa comparing vbeln.
select *
into corresponding fields of table gt_vbrp
from vbrp
for all entries in lt_vbfa
where vbeln = lt_vbfa-vbeln.
I get 52000 results from vbrp.
but if i define the itabs like that:
data: gt_vbfa type table of ty_vbfa.
data: gt_vbrp type table of vbrp.
i get 67000 results which matches the number of results if i make the same query through se16.
What is the reason for that? is it something connected to the way those records are written in the DB (DB2)?
Kind regards.
Motty.
Edited by: Thomas Zloch on Oct 7, 2010 9:02 AM - please use code tags
2010 Oct 07 8:14 AM
I don't see any change in the definition. Hope you are using
data: gt_vbrp type table of ty_vbrp.in the first case. In this case only distinct records (comparing the fields vbeln,vgbel,netwr,ntgew of type TY_VBRP) will be updated in internal table. If you define table as TYPE TABLE OF VBRP, all the records(comparing all the fields of type VBRP) will be copied to internal table.
Hello all.
I've encountered a problem which i cannot explain:
When i write a query which look like this:
types: begin of ty_vbfa,
vbelv type vbelv,
posnv type posnr_von,
vbeln type vbeln_nach,
posnn type posnr_nach,
rfwrt type rfwrt,
end of ty_vbfa.
types: begin of ty_vbrp,
vbeln type vbeln_vf,
vgbel type vgbel,
netwr type netwr_fp,
ntgew type ntgew_15,
end of ty_vbrp.
data: gt_vbfa type table of ty_vbfa.
data: gt_vbrp type table of vbrp.
and then:
select vbelv vbeln
into corresponding fields of table lt_vbfa
from vbfa
where vbtyp_n in (lv_vbtyp_n_m, lv_vbtyp_n_n, lv_vbtyp_n_o, lv_vbtyp_n_s).
sort lt_vbfa by vbeln.
delete adjacent duplicates from lt_vbfa comparing vbeln.
select *
into corresponding fields of table gt_vbrp
from vbrp
for all entries in lt_vbfa
where vbeln = lt_vbfa-vbeln.
I get 52000 results from vbrp.
but if i define the itabs like that:
data: gt_vbfa type table of ty_vbfa.
data: gt_vbrp type table of vbrp.
i get 67000 results which matches the number of results if i make the same query through se16.
What is the reason for that? is it something connected to the way those records are written in the DB (DB2)?
Kind regards.
Motty.
Edited by: Thomas Zloch on Oct 7, 2010 9:02 AM - please use code tags
2010 Oct 07 7:53 AM
Hi Motty,
I am new to SAP, but I tried to solve or understand your issue.
1st: You are saying that when you are defining internal tables other way.....
BUT both of the definitions are same in internal table declarations.
2nd: You are declaring .. gt_vbfa
data: gt_vbfa type table of ty_vbfa.
but using lt_vbfa
select *
into corresponding fields of table gt_vbrp
from vbrp
for all entries in lt_vbfa
where vbeln = lt_vbfa-vbeln.
please check it if you are mis-spelling or if the codes are correct, then please explain it in easier way.
Hope it'll help you.
Thanks and regards,
Sachin Bhatt.
2010 Oct 07 8:13 AM
Hi Sachin.
the misspelling is just some manipulation i did to gt_vbfa into lt_vbfa(same type) - just for Performance accelaration.
hence gt_vbfa = lt_vbfa.
Kind Regards.
Motty.
2010 Oct 07 8:14 AM
I don't see any change in the definition. Hope you are using
data: gt_vbrp type table of ty_vbrp.in the first case. In this case only distinct records (comparing the fields vbeln,vgbel,netwr,ntgew of type TY_VBRP) will be updated in internal table. If you define table as TYPE TABLE OF VBRP, all the records(comparing all the fields of type VBRP) will be copied to internal table.
2010 Oct 07 8:18 AM
Hi Vinod.
I i understand you correctly, the APPl. performs an auto-distinct in an implicit type?
Is there an official SAP documentation about it?
Motty.
2010 Oct 07 9:36 AM
Yes. But i couldn't able to location the official document from SAP.
Refer to this : [Table types |http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb366d358411d1829f0000e829fbfe/content.htm]
Edited by: Vinod Kumar on Oct 7, 2010 2:09 PM
2010 Oct 07 10:21 AM
2010 Oct 07 10:08 AM
Hi Motty
I beleive you are fetching the records from VBRP for the entries present in table it_vbfa.
did you check whether the table lt_vbfa has values or not?
before using for all entires always chech the table whether it is empty or not And use all the primary keys fot vbrp
define the other primary keys as constants and use them in where condition with greater value to their initial value.
like: suppose you have fld1 fld2 fld3 as primary key in table it_vbfa,
define them in constants statement as:
Constants: c_fld1 type vbrp-fld1 value initial,
c_fld2 type vbrp-fld1 value initial,
c_fld3 type vbrp-fld1 value initial.
check not lt_vbfa is initial.
sort lt_vbfa.
select * into corresponding fields of table gt_vbrp
from vbrp
for all entries in lt_vbfa
where vbeln = lt_vbfa-vbeln and
fld1 gt c_fld1 and
fld2 gt c_fld2 and
fld3 gt c_fld3 .
It might be possible because you are selecting data in gt_vbrp for all entries present in it_vbfa thats why you are getting diffrent number of recordds.
I hope you will figure it out now.
thanks
Lalit Gupta
2010 Oct 07 10:13 AM
Hi,
This question is being asked several times. When you use for all entries you have to provide all the primary keys.
So, in the ty_vbrp add POSNR also.
Hope it helps.
Sujay