‎2007 Aug 27 8:45 AM
Hi Friends,
Is any thing wrong with the statement, inv_date and invr_date is type date, trans and trans-high is NUMC and usname is char.
IF NOT ( ( zinv_reg-inv_date IS INITIAL
AND zinv_reg-invr_date IS INITIAL )
OR ( zinv_mov-trans IS INITIAL
AND trans-high IS INITIAL )
OR usname IS INITIAL ).
IF sy-subrc = 0.
SELECT trans lifnr xblnr usnam appdate status
FROM zinv_mov INTO TABLE lt_mov
WHERE ( appdate GE zinv_reg-inv_date
AND appdate LE zinv_reg-invr_date )
OR ( trans GE zinv_mov-trans
AND trans LE trans-high )
OR usnam EQ name.
Regards,
Line
‎2007 Aug 27 8:49 AM
Hi Turbin,
No need of checking subrc value in this case.
IF NOT ( zinv_reg-inv_date IS INITIAL AND zinv_reg-invr_date IS INITIAL )
OR ( zinv_mov-trans IS INITIAL AND trans-high IS INITIAL )
OR usname IS INITIAL .
SELECT trans lifnr xblnr usnam appdate status
FROM zinv_mov INTO TABLE lt_mov
WHERE ( appdate GE zinv_reg-inv_date
AND appdate LE zinv_reg-invr_date )
OR ( trans GE zinv_mov-trans
AND trans LE trans-high )
OR usnam EQ name.
Award points if this helpful.
Regards,
Ravi G
‎2007 Aug 27 8:49 AM
Hi Turbin,
No need of checking subrc value in this case.
IF NOT ( zinv_reg-inv_date IS INITIAL AND zinv_reg-invr_date IS INITIAL )
OR ( zinv_mov-trans IS INITIAL AND trans-high IS INITIAL )
OR usname IS INITIAL .
SELECT trans lifnr xblnr usnam appdate status
FROM zinv_mov INTO TABLE lt_mov
WHERE ( appdate GE zinv_reg-inv_date
AND appdate LE zinv_reg-invr_date )
OR ( trans GE zinv_mov-trans
AND trans LE trans-high )
OR usnam EQ name.
Award points if this helpful.
Regards,
Ravi G
‎2007 Aug 27 8:51 AM
Hi,
Your IF condition checks
1) IF both zinv_reg-inv_date and zinv_reg-invr_date are not INITIAL. So if this condition is true ,that is if both these dates are not initial your other conditions(Checking of TRANS HIGH and USNAME) will never be checked since you are using OR and in the case of OR the second condition will be checked only of First condition is FALSE.
Is this what you want or something else just find out.
<b>also could not understand why you are using IF sy-subrc = 0.?</b> First IF itself is enough..
Regards,
Sesh
‎2007 Aug 27 8:56 AM
Hi Sesh,
Actually my condition is that if inv_date and invr_date is initial or trans and trans-high is initial or usnam is intial then the select querry should execute.
Regards,
Line
‎2007 Aug 27 8:59 AM
Hi,
Following if should be enough
IF ( zinv_reg-inv_date IS INITIAL
AND zinv_reg-invr_date IS INITIAL ) " Check if these two or inittial
OR ( zinv_mov-trans IS INITIAL " Else check if these two or initial, this will be checked only if first condition is false that is one of the dates are not initial.
AND trans-high IS INITIAL )
OR usname IS INITIAL . " Else check if usname is initial
* execute select query here
ENDIF.
‎2007 Aug 27 9:10 AM
Hi,
But the select querry is picking all the records from the database it is not selecting based on the condition.
Regards,
Line
‎2007 Aug 27 9:23 AM
Hi,
As said I changed the code in the if condition but what is wrong with my select querry it is picking all the records from the data base.
Regards,
Line
‎2007 Aug 27 9:27 AM
Hi,
Try this query
SELECT trans lifnr xblnr usnam appdate status
FROM zinv_mov INTO TABLE lt_mov
WHERE appdate <b>between</b> zinv_reg-inv_date AND zinv_reg-invr_date OR trans <b>between</b> zinv_mov-trans and trans-high OR usnam EQ name.
Also in your if condition you are checking if they are INITIAL, you want to check if they are initial or NOT initial?
Regards,
Sesh
‎2007 Aug 27 9:00 AM
IF (zinv_reg-INV_DATE IS INITIAL
AND zinv_reg-INVR_DATE IS INITIAL) OR
( zinv_mov-TRANS IS INITIAL AND
zinv_mov-TRANS_HIGH IS INITIAL) OR
USNAM IS INITIAL.