Skip to Content
0
Apr 03, 2013 at 12:19 PM

how to code ..simple if loop statement ?

26 Views

HI ABAP gurus,

I need to determine the category field based on these conditions. can anyone suggest the code for the same ?

category = C1 if EKPO-PSTYP is equal to 1 and EKPO-KONNR is not equal to NULL.

category = c2 if EKPO-PSTYP is equal to 1 and EKPO-KONNR is qual to NULL.

category = C3 if EKPO-PSTYP is not equal to 1 and EKPO-KONNR is equal to NULL

Category = C4 if EKPO-PSTYP is not equal to 1 and EKPO-KONNR is not qual to NULL and

category = C5 if EBAN-ESTKZ = R.

All these C1 to C5 will be populated in a single field based on the above conditions. I need to write a code for this category field.

I dont know how to handle the if and endif and else if in a single statement.

I can try, please correct it gurus.

if EKPO-PSTYP is equal to 1 and EKPO-KONNR is not equal to NULL then category = C1

else if

if EKPO-PSTYP is equal to 1 and EKPO-KONNR is qual to NULL then category = C2

else if

if EKPO-PSTYP is not equal to 1 and EKPO-KONNR is equal to NULL then category = C3

else if

if EKPO-PSTYP is not equal to 1 and EKPO-KONNR is not qual to NULL then category = C4

else if

EBAN-ESTKZ = R then category = C5.

endif.

endif.

endif.

endif.

I am not sure about these if and endif concept. Please correct my code and suggest the original code in ABAP please. I appreciate it.

thank You,

DR