I have no idea about ABAP, but my colleague (also no idea about it) showed me some code he came up with and it consisted of way too many if
-statements. In JavaScript, I could've improved it, but in ABAP I'm a bit lost because I'm missing my arrays. I found out that internal tables are used instead, but I still can't figure it out.
The code is placed in a column of a query manager made by EPI-USE. It's just a way to adjust some results of the query and I noticed I get an error if I try to create a report ("already in a program") and if I create a class or a method ("close try-catch-block before declaring new Class").
The problem is extremely simple:
There's a person that has many properties, the values are numbers. These are the properties:
PA0013-RVNUM
PA0013_01-PERNR
PA0013_02-PERNR
PA0013_03-PERNR
PA0013_04-PERNR
PA0013_05-PERNR
PA0013_06-PERNR
PA0000_01-STAT2
PA0000_02-STAT2
PA0000_03-STAT2
PA0000_04-STAT2
PA0000_05-STAT2
PA0000_06-STAT2
I want to Loop through the PA0013
-block and follow These rules:
Conditions:
If PA0013-RVNUM
is empty all other properties have to be set to empty.
If a PA0013
-value is empty all following PA0013
-values have to be set to empty (not the previous ones).
If a PA0013
-value is empty the corresponding PA0000
-value has to be set to empty.
After the first Loop:
If any of the PA0000
-values has the value 3 execute the command REJECT
in order to kick the line out of the results.
My JS Code for this would look like that:
var pa0013Array = [
PA0013_01-NUM
PA0013_02-NUM
PA0013_03-NUM
PA0013_04-NUM
PA0013_05-NUM
PA0013_06-NUM];
var pa0000Array = [
PA0000_01-NUM
PA0000_02-NUM
PA0000_03-NUM
PA0000_04-NUM
PA0000_05-NUM
PA0000_06-NUM];
var emptyRest = (PA0005-NUM) ? false : true;
for (var i = 0; i < pa0013Array.length; i++) {
if (pa0013Array[i] == "") {
emptyRest = true;
}
if (emptyRest) {
pa0013Array[i] = "";
pa0000Array[i] = "";
}
}
if (pa0000Array.indexOf(3) != -1) {
reject();
}
Can someone help me by "translating" my js code into ABAP?
My colleague just did something like this for all of the conditions:
IF PA0013-RVNUM is INITIAL.
PA0013_01-PERNR = ''.
PA0013_02-PERNR = ''.
PA0013_03-PERNR = ''.
PA0013_04-PERNR = ''.
PA0013_05-PERNR = ''.
PA0013_06-PERNR = ''.
ENDIF.
IF PA0013_01-PERNR = ''.
PA0013_02-PERNR = ''.
PA0013_03-PERNR = ''.
PA0013_04-PERNR = ''.
PA0013_05-PERNR = ''.
PA0013_06-PERNR = ''.
ENDIF.
...
IF PA0013_01-PERNR = ''.
PA0000_01-STAT2 = ''.
ENDIF.
...
IF PA0000_01-STAT2 = 03.
REJECT.
ENDIF.
He told me he set the PERNR
s empty in order for the query not to fill them with wrong PERNR
s.
Here is how this program could look like. No guarantee at all that it works and does what your JavaScript does.