-5

I have the following code and as can be seen that in both the cases I'm using Section = A. But, is there a way to check both 1&2 in "When" so that to avoid more lines of code?

Evaluate INTERFACE
When "1"
   SECTION = "A";
   Break;
When "2"
   SECTION = "A";
   Break;

Any help is highly appreciated and please remember I'm still, learning. Thanks! :)

Muhammad Saqib
  • 2,185
  • 3
  • 35
  • 48
  • 1
    So when you looked at the **manual**, which documents the **syntax** of the `Evaluate` statement, what did you find? Assuming that you did look at the manual, and found that you can't, why ask here? Assuming that you *didn't* look, that's why you got lots of down-votes, because *"this question does not show any research effort"*. – Andreas Feb 06 '17 at 16:24

2 Answers2

2

first of all: Your code does not really look like Java, C or Cpp, and it has nothing to do with OOP, so correct the tags.

To the question: After a quick search for Evaluate-When it seems like COBOL (see IBM) with the same attributes as the well-known switch-case.

In switch-case you can not really have ORstatements, but you can assign multiple values to the same block by not using the break:

char c = 'a';
switch(c){
    case 'a':
    case 'A':
        fooA(); //'a' AND 'A' will land here
        break;
    case 'b':
        fooSmallB(); //only 'b' lands here
    case 'B':
        fooB(); //'b' AND 'B' lands here
        break;
    default:
        fooDef(); //Everything that does not hit any case lands here
}

This simulates an OR-statement. And is not possible.

EDIT: I see now, the language is peoplecode. Never heard of that before, but documentation shows: Evaluate-When is not much different than Switch-Case

Nevertheless: There is nearly always a better possibilities than switch-case, see 1st comment from Michael here.

Community
  • 1
  • 1
Dániel Somogyi
  • 730
  • 7
  • 19
  • Apparently it's [peoplecode](https://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tpcl/langref_PeopleCodeBuilt-inFunctionsandLanguageConstructs-073e6a.html). – George Feb 06 '17 at 16:33
  • Thanks everyone :) and sorry for the basic question. Hopefully i will learn soon and won't be bothering with wrong tags. Thanks once again! – LearningDeveloper Feb 06 '17 at 16:44
  • never heard of peoplecode before. But reading the [docu](https://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tpcd/concept_Statements-074b4d.html) it's nearly the same as any other switch/case... – Dániel Somogyi Feb 06 '17 at 16:51
0

Your syntax and the Evaluate statement belongs to PeopleCode programming language which used in Oracle ERP PeopleSoft

Evaluate is similar to switch/case statement and here is the example how you can use it correctly in PeopleCode according to your given scenario.

Evaluate &yourVariable
When = "1"
When = "2"
   Warning "Value is either 1 or 2";
   Break;
When = "3"
   Warning "Value is 3";
   Break;
When = "4"
   Warning "Value is 4";
   Break;
When-Other
   Warning "Unexpected value."
End-Evaluate;

Here is the detailed official documentation about PeopleCode evaluate statement.

Muhammad Saqib
  • 2,185
  • 3
  • 35
  • 48