2010 Apr 16 3:18 PM
Hi,
I want to fetch all entries for year and period less than entered in parameters as below.
SELECT rprctr racct matnr hsl
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ( ryear LE p_gjahr )
AND poper <= p_perio
AND racct = p_hkont2
AND rprctr IN s_prctr2.
Suppose user entered period as 6 and year 2010 then if there are entries with 2009 it will take from period 6 but it should take all periods of 2009 and less than or equal to 6 for 2009.
Kindly advice.
Rgds
2010 Apr 16 3:43 PM
Hi Sanjay,
If I understand correctly, if user enters period = 6 and year = 2010, you must fetch Jan 2009, Feb 2009, also July 2009, Aug 2009, but not July 2010, Aug 2010.
For this write the code as follows:
SELECT rprctr
racct
matnr
hsl
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ( ryear < p_gjahr OR ( ryear = p_gjahr AND
poper <= p_perio ) )
AND racct = p_hkont2
AND rprctr IN s_prctr2[].
Let me know if this works! If you have any further queries, please do reply back.
On a separate note, I would advise you to avoid such a confusing query. If you are not very very stringent on performance issues, you can also code as follows:
SELECT rprctr
racct
matnr
hsl
ryear
poper
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ryear < p_gjahr
AND racct = p_hkont2
AND rprctr IN s_prctr2[].
LOOP AT git_glpca_2 INTO gwa_glpca.
IF gwa_glpca-ryear = p_gjahr and gwa_glpca-poper > p_perio.
delete git_glpca.
ENDIF.
ENDLOOP.
Cheers,
Shailesh.
Hi,
I want to fetch all entries for year and period less than entered in parameters as below.
SELECT rprctr racct matnr hsl
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ( ryear LE p_gjahr )
AND poper <= p_perio
AND racct = p_hkont2
AND rprctr IN s_prctr2.
Suppose user entered period as 6 and year 2010 then if there are entries with 2009 it will take from period 6 but it should take all periods of 2009 and less than or equal to 6 for 2009.
Kindly advice.
Rgds
2010 Apr 16 3:32 PM
>
> Suppose user entered period as 6 and year 2010 then if there are entries with 2009 it will take from period 6 but it should take all periods of 2009 and less than or equal to 6 for 2009.
Is that correct??
Rob
2010 Apr 16 3:43 PM
Hi Sanjay,
If I understand correctly, if user enters period = 6 and year = 2010, you must fetch Jan 2009, Feb 2009, also July 2009, Aug 2009, but not July 2010, Aug 2010.
For this write the code as follows:
SELECT rprctr
racct
matnr
hsl
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ( ryear < p_gjahr OR ( ryear = p_gjahr AND
poper <= p_perio ) )
AND racct = p_hkont2
AND rprctr IN s_prctr2[].
Let me know if this works! If you have any further queries, please do reply back.
On a separate note, I would advise you to avoid such a confusing query. If you are not very very stringent on performance issues, you can also code as follows:
SELECT rprctr
racct
matnr
hsl
ryear
poper
FROM glpca
INTO TABLE git_glpca_2
WHERE rbukrs = p_bukrs
AND ryear < p_gjahr
AND racct = p_hkont2
AND rprctr IN s_prctr2[].
LOOP AT git_glpca_2 INTO gwa_glpca.
IF gwa_glpca-ryear = p_gjahr and gwa_glpca-poper > p_perio.
delete git_glpca.
ENDIF.
ENDLOOP.
Cheers,
Shailesh.