‎2007 Nov 15 7:11 AM
Hi Experts,
here i want to select data based on the following steps..
The logic is
1. Take a minimum date for every currency from TCURR.
2. Loop through all records (for the number range) in /msg/rabr table.
3. Select the record and match with the TCURR.FCURR Equals RABR.OW_WHGNR.
4. And check if the bil_dat is less the the minimum date.
5. If it is, write the output. else ignore.
i ve done code for this its working, according to my rewuirement it should give output records in hundrends but its giving thousands.
but logic is not giving any error.
pls any one check the below logic for above steps,
SELECT kurst
fcurr
gdatu
from <b>tcurr</b> into table it_tcurr
where kurst EQ 'M'.
SORT it_tcurr by fcurr GDATU DESCENDING.
delete adjacent duplicates from it_tcurr comparing fcurr.
SELECT * FROM <b>/msg/rabr</b> into CORRESPONDING FIELDS OF TABLE it_rabr
WHERE abrnr BETWEEN '00000000000000800251' AND '00000000000000800500'.
SORT it_rabr BY OW_WHGNR bil_dat abrnr.
LOOP AT it_rabr.
READ TABLE it_tcurr with key fcurr = it_rabr-OW_WHGNR.
IF it_tcurr-kurst EQ 'M' AND it_tcurr-gdatu GT it_rabr-bil_dat AND it_rabr-abrnr BETWEEN '00000000000000800251' AND '00000000000000800500'.
IF SY-SUBRC EQ 0.
MOVE it_tcurr-kurst TO it_output-kurst.
MOVE it_tcurr-gdatu TO it_output-gdatu.
MOVE it_rabr-bil_dat TO it_output-bil_dat.
MOVE it_rabr-VTGNR TO it_output-VTGNR.
MOVE it_rabr-BESTNR TO it_output-BESTNR.
MOVE it_rabr-OW_WHGNR TO it_output-OW_WHGNR.
MOVE it_rabr-abrnr TO it_output-abrnr.
APPEND it_output.
ENDIF.
ENDIF.
ENDLOOP.
Thanks and Regards,
sudha.
‎2007 Nov 15 8:12 AM
Hey try this..
SELECT kurst
fcurr
gdatu
from tcurr into table it_tcurr
where kurst EQ 'M'.
SORT it_tcurr by fcurr GDATU DESCENDING.
delete adjacent duplicates from it_tcurr comparing fcurr.
SELECT * FROM /msg/rabr into CORRESPONDING FIELDS OF TABLE it_rabr
WHERE abrnr BETWEEN '00000000000000800251' AND '00000000000000800500'.
SORT it_rabr BY OW_WHGNR bil_dat abrnr.
LOOP AT it_rabr.
clear it_tcurr.
READ TABLE it_tcurr with key fcurr = it_rabr-OW_WHGNR.
IF sy-subrc eq 0.
IF it_tcurr-gdatu GT it_rabr-bil_dat .
MOVE it_tcurr-kurst TO it_output-kurst.
MOVE it_tcurr-gdatu TO it_output-gdatu.
MOVE it_rabr-bil_dat TO it_output-bil_dat.
MOVE it_rabr-VTGNR TO it_output-VTGNR.
MOVE it_rabr-BESTNR TO it_output-BESTNR.
MOVE it_rabr-OW_WHGNR TO it_output-OW_WHGNR.
MOVE it_rabr-abrnr TO it_output-abrnr.
APPEND it_output.
ENDIF.
ENDIF.
ENDLOOP.
My doubt is if it_tcurr record is there or not the code is executing. because of no subrc check. It must work now.
‎2007 Nov 15 8:12 AM
Hey try this..
SELECT kurst
fcurr
gdatu
from tcurr into table it_tcurr
where kurst EQ 'M'.
SORT it_tcurr by fcurr GDATU DESCENDING.
delete adjacent duplicates from it_tcurr comparing fcurr.
SELECT * FROM /msg/rabr into CORRESPONDING FIELDS OF TABLE it_rabr
WHERE abrnr BETWEEN '00000000000000800251' AND '00000000000000800500'.
SORT it_rabr BY OW_WHGNR bil_dat abrnr.
LOOP AT it_rabr.
clear it_tcurr.
READ TABLE it_tcurr with key fcurr = it_rabr-OW_WHGNR.
IF sy-subrc eq 0.
IF it_tcurr-gdatu GT it_rabr-bil_dat .
MOVE it_tcurr-kurst TO it_output-kurst.
MOVE it_tcurr-gdatu TO it_output-gdatu.
MOVE it_rabr-bil_dat TO it_output-bil_dat.
MOVE it_rabr-VTGNR TO it_output-VTGNR.
MOVE it_rabr-BESTNR TO it_output-BESTNR.
MOVE it_rabr-OW_WHGNR TO it_output-OW_WHGNR.
MOVE it_rabr-abrnr TO it_output-abrnr.
APPEND it_output.
ENDIF.
ENDIF.
ENDLOOP.
My doubt is if it_tcurr record is there or not the code is executing. because of no subrc check. It must work now.
‎2007 Nov 15 8:39 AM
Hi Jyothi Thank u verymuch for ur replay,
Previously i ve checked what u told and i ve checked sy-subrc also,
and here the problem is , from 1st table( it_tcurr ) am getting and only 77 records are there, but in 2nd tale( it_rabr ) getting 287 records. from their respective tables.
but in output its giving 287 records. but here we r checking on 1st table, so it should display 77 records, but its displayong 287 records.
pls just check once again.
Regards,
sudha.
‎2007 Nov 15 8:43 AM
loop at 1st itab and read the table contents of the second table...
this should solve the problem
‎2007 Nov 15 9:17 AM
Hi Sharayu,
Thanks for u r help.
i ve given rewards.
Regards,
sudha.