‎2006 Aug 29 6:13 AM
I have a task this way:
I need to fetch some records based on a logic from CATSDB table. After applying a series of conditions, I have the final data. For this data, I need to fetch the name, personnel number, payroll area (SNAME, WERKS, ABKRS) from infotype 1. I am using the following logic:
select PERNR
BEGDA
SNAME
WERKS
ABKRS
from PA0001 into corresponding fields of table GT_PA0001
for all entries in GT_FINAL
where PERNR = GT_FINAL-pernr AND
BEGDA <= SP_ENDDA AND
ENDDA >= SP_BEGDA.
LOOP AT GT_FINAL.
read table gt_pa0001 with key pernr = gt_final-pernr
binary search.
if sy-subrc = 0.
GT_FINAL-SNAME = GT_PA0001-SNAME.
GT_FINAL-WERKS = GT_PA0001-WERKS.
GT_FINAL-ABKRS = GT_PA0001-ABKRS.
MODIFY GT_FINAL.
endif.
ENDLOOP.
Here, GT_FINAL is the final output to be displayed. It has the following fields:
PERNR
COUNTER
WORKDATE
CATSHOURS
AWART
PRAKN
ZZPSPNR
RNPLNR
RKOSTL
ZZALTC1
ERNAM
ERSDA
AENAM
LAEDA
SNAME
WERKS
ABKRS.
Now, I am not getting the correct logic to append the employee personnel area/payroll area depending upon the begda and endda of selection screen.
Secondly, how to update the gt_final internal table with the data of gt_pa0001? i also want performance.
Can anyone help. It is very urgent.
Thanks.
‎2006 Aug 29 6:23 AM
HI,
why are you filling 'GT_PA0001' can can get values directly from table pa0001 into gt_final. in this way you can save an Extra loop.
like this.
<b>
LOOP AT gt_final.
select
SNAME
WERKS
ABKRS
from PA0001 into corresponding fields of GT_final
where PERNR = GT_FINAL-pernr AND
BEGDA <= SP_ENDDA AND
ENDDA >= SP_BEGDA.
MODIFY gt_final.
ENDOOP.</b>
Regards,
‎2006 Aug 29 6:23 AM
Hi,
use SORT gt_pa0001 by PERNR, since you are using binary search..
Check if the internal table is not initial before using the FOR ALL ENTRIES..
IF NOT GT_FINAL[] IS INITIAL.
SELECT...FROM ..PA0001.
ENDIF.
Regards
Naren