Skip to Content
author's profile photo Former Member
Former Member

how to manage select options

hai gurus i am writing a function module to read employee details , so i want to add selection criteria as cost center , employee group and personal area and some other , so based on these inputs i have to filter the employee details, but the problem is that the user may enter any selection critirea plus or and conditions

for example he may give condtions like

1) cost center or employee group and personal area

2)cost center and employee group or personal area

if there are no such or and conditions i would have just writen select queries for all these paramters

but the or and and conditions can come in any combination so can i manage that

in my code if yes then how if any standard report available please give me some reference

regards

afzal

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 12, 2007 at 04:41 AM

    Hi Mohammed ..

    As i understand your FM has import parameters COSTCENTER ,EMPGROUP, PER_AREA. all these parameters are optional.

    Then you have to write the FM source code like this.

    IF COSTCENTER IS SUPPLIED

    AND EMPGROUP IS SUPPLIED

    AND PER_AREA IS SUPPLIED .

    SELECT <FIELDS> FROM <TABLE> INTO TABLE <ITAB>

    WHERE CS = COSTCENTER

    AND EG = EMPGROUP

    AND PA = PER_AREA .

    ELSEIF COSTCENTER IS NOT SUPPLIED.

    ELSEIF .

    ENDIF.

    reward if Helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2007 at 05:30 AM

    If you turn each of the selections criteria provided into a range table then you can achieve this with a single "select". For example, in a report this might be coded as below (but note that this may not be the most efficient for the database).

    Jonathan

    report zlocal_jc_parm_to_range.
    *" criteria provided:
    parameters:
      p_kostl               like csks-kostl,    
      p_pernr               like pa0001-pernr.
    
    start-of-selection.
      perform get_data.
    
    form get_data.
    
      ranges:
        lr_kostl            for p_kostl,
        lr_pernr            for p_pernr.
    
    *" Convert single criteria to range
      if not p_kostl is initial.
        lr_kostl-sign   = 'I'.  "include
        lr_kostl-option = 'EQ'. "equals
        lr_kostl-low    = p_kostl.
        append lr_kostl.
      endif.  
    
      if not p_pernr is initial.
        lr_pernr-sign   = 'I'.  "include
        lr_pernr-option = 'EQ'. "equals
        lr_pernr-low    = p_pernr.
        append lr_pernr.
      endif. 
      
      select *
        from zz_my_data
        where kostl in lr_kostl  "if empty, gets ignored
        and   pernr in lr_pernr. "if empty, gets ignored
        
    endform.  

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.