2009 Feb 13 4:14 PM
Hi all @SAPForums,
I need to manage an IF statement whose conditional expression depends on certain parameters. I wonder if there's an easy way to do as follows:
IF parameter 1 is not set (EQ SPACE), then the condition must be: IF it_po_items-delete_ind <> 'L'.
IF parameter 2 is not set (EQ SPACE), then the condition must be: IF it_po_items-delete_ind <> 'S'.
IF both parameters are not set, the condition must be the concatenation of the two above:
IF it_po_items-delete_ind <> 'L' AND it_po_items-delete_ind <> 'S'.
IF both params are set (EQ 'X', they are flags), then there's no condition at all. (IF true?).
Sounds like a thing I could manage using dynamic conditional statements, I did once time ago on a WHERE clause in a SELECT statement, but I'm not able to redo it in this case... maybe because isn't possible in an IF statement?
Thanks for any help you would give me
2009 Feb 13 4:26 PM
hi
you can use case statement
if p1 is initial.
IF it_po_items-delete_ind = 'L'.
endif.
elseif p2 is initial.
IF it_po_items-delete_ind = 'S'.
endif.
elseif p1 is initial and p2 is initial.
IF it_po_items-delete_ind eq 'L' AND it_po_items-delete_ind eq 'S'.
endif.
endif.regards
sarves
hi
you can use case statement
if p1 is initial.
IF it_po_items-delete_ind = 'L'.
endif.
elseif p2 is initial.
IF it_po_items-delete_ind = 'S'.
endif.
elseif p1 is initial and p2 is initial.
IF it_po_items-delete_ind eq 'L' AND it_po_items-delete_ind eq 'S'.
endif.
endif.regards
sarves
2009 Feb 13 4:19 PM
Maybe you can work around by using a range based on delete_ind.
> DATA: r_delind TYPE RANGE OF ...
You can fill it according to your parameters and then apply it as IF condition.
Thomas
2009 Feb 13 4:22 PM
hi thomas and thanks for your help.
Sound like a good solution.... Can you provide an example is code / pseudocode in order to evaluate how to apply this solution in my report? Thanks again.
2009 Feb 13 4:22 PM
Hi,
You can use ranges...for this..
Ex..
DATA: r_range TYPE RANGE OF loekz,
s_range LIKE LINE OF r_range.
s_range-sign = 'I'.
s_range-option = 'EQ'.
*IF parameter 1 is not set (EQ SPACE), then the condition must be: IF it_po_items-delete_ind 'L'.
IF parameter1 = SPACE.
s_range-low = 'L'.
APPEND s_range TO r_range.
ENDIF.
*IF parameter 2 is not set (EQ SPACE), then the condition must be: IF it_po_items-delete_ind 'S'.
IF parameter2 = SPACE.
s_range-low = 'S'.
APPEND s_range TO r_range.
ENDIF.
IF it_po_items-delete_ind IN r_range. " Only one IF condition should be enough..
**Condition satisfied.
ENDIF.Hope this is clear.
Thanks
Naren
2009 Feb 13 4:26 PM
hi
you can use case statement
if p1 is initial.
IF it_po_items-delete_ind = 'L'.
endif.
elseif p2 is initial.
IF it_po_items-delete_ind = 'S'.
endif.
elseif p1 is initial and p2 is initial.
IF it_po_items-delete_ind eq 'L' AND it_po_items-delete_ind eq 'S'.
endif.
endif.regards
sarves
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |