08-18-2020 4:44 AM
Hi Experts,
I have two questions regarding ABAP:
1. I have read that EXPORT IMPORT is not totally obsolete, export/import without MEMORY ID is obsolete but if we use:
EXPORT itab FROM itab FROM MEMORY ID 'XXXXX'
IMPORT itab TO itab FROM MEMORY ID 'XXXXX'
I have read threads regarding this from 2013 and just wanted to confirm if this is still true?
2. Is there a way to make an IF statement dynamic? Requirement is I have operations maintained in a custom table field: GT/LE/EQ/LT/GE and want to use this field. Instead of explicitly writing IF lv_var1 EQ lv_var2, I want to use the table field: IF lv_var1 <table_field> lv_var2. Is this possible?
Thanks in advance for any inputs!
Regards,
Katherine Darunday
08-18-2020 5:13 AM
Hello,
1. Yes, IMPORT/EXPORT memory can be used but just be aware of clearing the memory id and using within one LUW.
2. Dynamic IF condition is not possible straightforward way. But there is a bit complex, alternative available, please go through this blog:
https://blogs.sap.com/2016/02/29/dynamic-if-condition/
You can also consider using CASE statement as dynamic options will be limited.
Gaurav
08-18-2020 5:13 AM
Hello,
1. Yes, IMPORT/EXPORT memory can be used but just be aware of clearing the memory id and using within one LUW.
2. Dynamic IF condition is not possible straightforward way. But there is a bit complex, alternative available, please go through this blog:
https://blogs.sap.com/2016/02/29/dynamic-if-condition/
You can also consider using CASE statement as dynamic options will be limited.
Gaurav
08-18-2020 9:21 AM
Please ask the questions separately, otherwise it will be very difficult for visitors to locate answers.
08-18-2020 10:02 AM
It is easy to check what is obsolete or not in the F1 help on a keyword or the whole chapter - Obsolete Language Elements.
08-18-2020 10:07 AM
1. The way you say it, people could think that EXPORT IMPORT is mostly obsolete. That's incorrect. You're talking about a very specific syntax without ID which was not documented and has been obsolete for a long time (I didn't even know that some people used it). It's officially obsolete since at least 2011 (ABAP 7.31), but developers didn't use it before because anything error-prone should not be used.
08-18-2020 10:11 AM
IF dynamic_condition-operator = 'GT'.
IF operand1 GT operand2.
...
ENDIF.
ELSEIF dynamic_condition-operator = 'LE'.
IF operand1 LE operand2.
...
ENDIF.
ELSEIF dynamic_condition-operator = 'EQ'.
IF operand1 EQ operand2.
...
ENDIF.
ELSEIF ...
...
08-18-2020 10:25 AM
For 2)
The other alternate that can be used is via Dynamic WHERE clauses on internal tables you are going to use the tables. Otherwise, you can also choose to convert your variables into type table use the dynamic where clause. Hope this helps.