Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SELECT-OPTIONS with single value

Hello Experts,

Im having trouble in making my requirement, im just new in abap so please help me.

I have 3 SELECT-OPTIONS where in i need to put the values into my Internal table,,

my code works if i fill up both FROM and TO textboxs for example in POSITION. but if i will just fill the POSITION-LOW and leave blank to POSITION-HIGH,

it doesnt get the data that i need.

IF POSITION IS NOT INITIAL AND EMPSUB IS INITIAL AND EMPGROUP IS INITIAL.   "POSITION

       SELECT PERNR PERSK BEGDA

         INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

         FROM PA0001

         WHERE PLANS BETWEEN POSITION-LOW AND POSITION-HIGH.

     ELSEIF POSITION IS INITIAL AND EMPSUB IS NOT INITIAL AND EMPGROUP IS INITIAL. "EMPLOYEE SUB GROUP

       SELECT PERNR PERSK BEGDA

         INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

         FROM PA0001

         WHERE PERSK BETWEEN EMPSUB-LOW AND EMPSUB-HIGH.

     ELSEIF POSITION IS INITIAL AND EMPSUB IS INITIAL AND EMPGROUP IS NOT INITIAL.   "EMPLOYEE GROUP

       SELECT PERNR PERSK BEGDA

         INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

         FROM PA0001

         WHERE PERSG BETWEEN EMPGROUP-LOW AND EMPGROUP-HIGH.

     ELSEIF POSITION IS NOT INITIAL AND EMPSUB IS NOT INITIAL AND EMPGROUP IS NOT INITIAL.

       SELECT PERNR PERSK BEGDA

               INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

               FROM PA0001

               WHERE PERSG BETWEEN EMPGROUP-LOW AND EMPGROUP-HIGH

               AND PERSK BETWEEN EMPSUB-LOW AND EMPSUB-HIGH

               AND PLANS BETWEEN POSITION-LOW AND POSITION-HIGH.

     ENDIF.

Former Member
Former Member replied

Hi Jepoy,

"IN" is best option in your case , but if you want to use "BETWEEN" then write your code as below

IF POSITION-HIGH IS INITIAL .

  

    POSITION-HIGH = POSITION-LOW .

  

        SELECT PERNR PERSK BEGDA

          INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

          FROM PA0001

          WHERE PLANS BETWEEN POSITION-LOW AND POSITION-HIGH.

         

   ELSE.

        SELECT PERNR PERSK BEGDA

          INTO  CORRESPONDING FIELDS OF TABLE IT_PA0001

          FROM PA0001

          WHERE PLANS BETWEEN POSITION-LOW AND POSITION-HIGH.

            

ENDIF.

Note :

Still i suggested you go with "IN" Operator , Unnecessary "IF/ELSE" Increase in your code .

Regard's

Smruti

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question