2006 Feb 05 7:28 PM
I need to pass this code if the statement is true:
But the program dont respect the statement.
Thanks for the help.
IF T_ITAB-BSTAT1 NE 'S' OR T_ITAB-BSTAT1 NE 'V'
OR T_ITAB-BSTAT1 NE 'W' OR T_ITAB-BSTAT1 NE 'Z'
OR T_ITAB-BSTAT1 NE 'D'.
wa_msgdetails-company = t_itab-bukrs.
wa_msgdetails-account = t_itab-hkont.
wa_msgdetails-center = t_itab-prctr .
wa_msgdetails-posting_date = t_itab-cpudt .
wa_msgdetails-efective_date = t_itab-budat .
wa_msgdetails-source_code = t_itab-sgtxt.
wa_msgdetails-description1 = t_itab-sgtxt.
wa_msgdetails-description2 = t_itab-zuonr .
wa_msgdetails-description3 = t_itab-ltext .
wa_msgdetails-amount = t_itab-wrbtr.
wa_msgdetails-sign = t_itab-shkzg.
msghead-posting_date = sy-datum.
msghead-effective_date = sy-datum.
msghead-counter_rec = t_acum.
endif.
2006 Feb 05 9:51 PM
Hi Carlos
Your code respect your control, because you're using OR statament so you're checking if a variable isn't equal to value OR other value and this control is always true.
Infact: A = 2.
IF A <> 1 or A <> 2.
This control is true because A <> 1.
A = 1.
IF A <> 1 or A <> 2.
This control is true because A <> 2.
You have to use AND statament, if you want the data isn't equal to several values at the same time.
A = 1.
IF A <> 1 AND A <> 2.
This control is false, because A isn't equal 2 but it's 1.
So your code have to be:
IF T_ITAB-BSTAT1 NE 'S' AND T_ITAB-BSTAT1 NE 'V'
AND T_ITAB-BSTAT1 NE 'W' AND T_ITAB-BSTAT1 NE 'Z'
AND T_ITAB-BSTAT1 NE 'D'.
wa_msgdetails-company = t_itab-bukrs.
wa_msgdetails-account = t_itab-hkont.
wa_msgdetails-center = t_itab-prctr .
wa_msgdetails-posting_date = t_itab-cpudt .
wa_msgdetails-efective_date = t_itab-budat .
wa_msgdetails-source_code = t_itab-sgtxt.
wa_msgdetails-description1 = t_itab-sgtxt.
wa_msgdetails-description2 = t_itab-zuonr .
wa_msgdetails-description3 = t_itab-ltext .
wa_msgdetails-amount = t_itab-wrbtr.
wa_msgdetails-sign = t_itab-shkzg.
msghead-posting_date = sy-datum.
msghead-effective_date = sy-datum.
msghead-counter_rec = t_acum.
endif.
Max
I need to pass this code if the statement is true:
But the program dont respect the statement.
Thanks for the help.
IF T_ITAB-BSTAT1 NE 'S' OR T_ITAB-BSTAT1 NE 'V'
OR T_ITAB-BSTAT1 NE 'W' OR T_ITAB-BSTAT1 NE 'Z'
OR T_ITAB-BSTAT1 NE 'D'.
wa_msgdetails-company = t_itab-bukrs.
wa_msgdetails-account = t_itab-hkont.
wa_msgdetails-center = t_itab-prctr .
wa_msgdetails-posting_date = t_itab-cpudt .
wa_msgdetails-efective_date = t_itab-budat .
wa_msgdetails-source_code = t_itab-sgtxt.
wa_msgdetails-description1 = t_itab-sgtxt.
wa_msgdetails-description2 = t_itab-zuonr .
wa_msgdetails-description3 = t_itab-ltext .
wa_msgdetails-amount = t_itab-wrbtr.
wa_msgdetails-sign = t_itab-shkzg.
msghead-posting_date = sy-datum.
msghead-effective_date = sy-datum.
msghead-counter_rec = t_acum.
endif.
2006 Feb 05 7:34 PM
2006 Feb 05 9:51 PM
Hi Carlos
Your code respect your control, because you're using OR statament so you're checking if a variable isn't equal to value OR other value and this control is always true.
Infact: A = 2.
IF A <> 1 or A <> 2.
This control is true because A <> 1.
A = 1.
IF A <> 1 or A <> 2.
This control is true because A <> 2.
You have to use AND statament, if you want the data isn't equal to several values at the same time.
A = 1.
IF A <> 1 AND A <> 2.
This control is false, because A isn't equal 2 but it's 1.
So your code have to be:
IF T_ITAB-BSTAT1 NE 'S' AND T_ITAB-BSTAT1 NE 'V'
AND T_ITAB-BSTAT1 NE 'W' AND T_ITAB-BSTAT1 NE 'Z'
AND T_ITAB-BSTAT1 NE 'D'.
wa_msgdetails-company = t_itab-bukrs.
wa_msgdetails-account = t_itab-hkont.
wa_msgdetails-center = t_itab-prctr .
wa_msgdetails-posting_date = t_itab-cpudt .
wa_msgdetails-efective_date = t_itab-budat .
wa_msgdetails-source_code = t_itab-sgtxt.
wa_msgdetails-description1 = t_itab-sgtxt.
wa_msgdetails-description2 = t_itab-zuonr .
wa_msgdetails-description3 = t_itab-ltext .
wa_msgdetails-amount = t_itab-wrbtr.
wa_msgdetails-sign = t_itab-shkzg.
msghead-posting_date = sy-datum.
msghead-effective_date = sy-datum.
msghead-counter_rec = t_acum.
endif.
Max
2006 Feb 06 1:42 AM
hi ,
as per your code,
say if the value of T_ITAB-BSTAT1 is 'V',
it will satisfy your first condition in if,
i.e
if T_ITAB-BSTAT1 NE 'S'
and the loop would not go for the 'OR' condition, so here your purpose is lost.
hence you could do one thing ,
use 'AND' instead of 'OR'.
hope it was helpful.
cheers,
Aditya.
2006 Feb 06 4:07 AM
AS IT IS A NEGATION STATEMENT,
CHANGE ALL UR ORs to AND s
because
A OR B = NOT A and NOT B
I HOPE U UNDERSTOOD.
regs
hyma
2006 Feb 06 5:01 AM
Hi Carlos,
When you use conditions for equalling to a certain value then you have to use OR & when you go for non-quality to values then you have to go for AND .Furthermore as you have so many conditions to be checked use simple braces too.
Thanx
Rk