Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

If condition help.....

Former Member
0 Likes
638

in the below code i need to check whether the claim-brand doesnt contain any car,bry,pay if it contains any one then it need to take wa_claim-brand else if wa_claim-brand doenst contain any car, bry,pay then it should read kna1 and check the wa_kna1-katr8 not equal to car, bry, pay if the kna1-katr8 doesnt contain the above then it should pick the brand as car else it should use kna1-katr8 , but the code below is not working.

IF ( wa_claim-brand NE c_car OR

wa_claim-brand NE c_bry OR

wa_claim-brand NE c_pay ) .

READ TABLE i_kna1 into wa_kna1 WITH KEY kunnr = wa_claim-sapcustomer.

IF ( wa_kna1-katr8 NE c_car OR

wa_kna1-katr8 NE c_bry OR

wa_kna1-katr8 NE c_pay ).

IF SY-SUBRC = 0.

wa_cust_mvmt-brand = c_car.

ELSE.

wa_cust_mvmt-brand = wa_kna1-katr8.

ENDIF.

ENDIF.

ELSE.

wa_cust_mvmt-brand = wa_claim-brand.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

Hi Rocky,

IF ( wa_claim-brand EQ c_car OR

wa_claim-brand EQ c_bry OR

wa_claim-brand EQ c_pay ) .

wa_cust_mvmt-brand = wa_claim-brand.

else.

READ TABLE i_kna1 into wa_kna1 WITH KEY kunnr = wa_claim-sapcustomer.

IF SY-SUBRC = 0.

IF ( wa_kna1-katr8 EQ c_car OR

wa_kna1-katr8 EQ c_bry OR

wa_kna1-katr8 EQ c_pay ).

wa_cust_mvmt-brand = wa_kna1-katr8.

ELSE.

wa_cust_mvmt-brand = c_car.

ENDIF.

ENDIF.

ENDIF.

It should work.

Regards,

Subbu

5 REPLIES 5
Read only

JozsefSzikszai
Active Contributor
0 Likes
605

hi Rocky,

in the conditions replace all ORs with ANDs.

hope this helps

ec

Read only

0 Likes
605

hi eric first condition is working but for kna1 the condition is not working its going to this else if record is there or not there

Read only

0 Likes
605

after the READ TABLE, I think you have to check if any record was found: CHECK sy-subrc EQ 0.

Read only

Former Member
0 Likes
605

hi populate variables.. into the ranges.....and use it in the if

r_brand-low = c_car.

r_brand-sign = 'E'.

r_brand-option = EQ'.

append r_brand .

r_brand-low = c_bry .

r_brand-sign = 'E'.

r_brand-option = EQ'.

append r_brand .

r_brand-low = c_pay .

r_brand-sign = 'E'.

r_brand-option = EQ'.

append r_brand .

IF wa_claim-brand in r_brand .

do some thing..

do the same thing for the katr8

ELSE.

wa_cust_mvmt-brand = wa_claim-brand.

ENDIF.

Read only

Former Member
0 Likes
606

Hi Rocky,

IF ( wa_claim-brand EQ c_car OR

wa_claim-brand EQ c_bry OR

wa_claim-brand EQ c_pay ) .

wa_cust_mvmt-brand = wa_claim-brand.

else.

READ TABLE i_kna1 into wa_kna1 WITH KEY kunnr = wa_claim-sapcustomer.

IF SY-SUBRC = 0.

IF ( wa_kna1-katr8 EQ c_car OR

wa_kna1-katr8 EQ c_bry OR

wa_kna1-katr8 EQ c_pay ).

wa_cust_mvmt-brand = wa_kna1-katr8.

ELSE.

wa_cust_mvmt-brand = c_car.

ENDIF.

ENDIF.

ENDIF.

It should work.

Regards,

Subbu