Skip to Content
author's profile photo
Former Member

Dynamic Selection criteria

Hi All,

We are facing a problem in selection criteria when we have to do it dynamicaaly.

The actual prob is

we hav a user screen where in user can give one of the 3 selection criteria.

We hav to select depending upon the values he has entered.

Is ther any way where in we can specify the selection criteria dynamicaaly.

Any suggestions are atmost regarded as this is an urgent issue.

Thanks and Regards,

Rajashree

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    author's profile photo
    Former Member
    Oct 03, 2005 at 07:12 AM

    when you say selection criteria dynamically, do you mean dynamic where clause in select query?

    If so, you can have dynamic select query.

    Please check help on

    "Dynamic Selections in the database program"

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 03, 2005 at 07:19 AM

    hai,

    hopeing that your problrm is inth following way , that if a user enters a value for one field then automatically the values for the two fields have to be dispalyed.

    one thing if you enter a value to filed ad without pressing any of the keys it would not place the code directly into other fields.

    do it in the following way

    tables: stxh,vbak.

    DATA: BEGIN OF it_dynp_value_tab OCCURS 0.

    INCLUDE STRUCTURE dynpread.

    DATA: END OF it_dynp_value_tab.

    data pprog like sy-repid value 'Z_TEMP'.

    data pdynnr like sy-dynnr value '1000'.

    ranges: RTDOBJ FOR STXH-TDOBJECT .

    select-options : p1 for vbak-vbeln,

    d2 for vbak-kunnr..

    at selection-screen on value-request for d2-low.

    MOVE: 'P1-LOW' TO it_dynp_value_tab-fieldname.

    APPEND it_dynp_value_tab.

    *MOVE: 'KUNNR' TO it_dynp_value_tab-fieldname.

    *APPEND it_dynp_value_tab.

    *do .

    CALL FUNCTION 'DYNP_VALUES_READ'

    EXPORTING

    dyname = pprog

    dynumb = pdynnr

    TABLES

    dynpfields = it_dynp_value_tab

    EXCEPTIONS

    invalid_abapworkarea = 1

    invalid_dynprofield = 2

    invalid_dynproname = 3

    invalid_dynpronummer = 4

    invalid_request = 5

    no_fielddescription = 6

    invalid_parameter = 7

    undefind_error = 8

    double_conversion = 9

    stepl_not_found = 10

    OTHERS = 11.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    this code does half the part of what you want. if the problem of yours is whati have thought , pls come back for the other part of the answer

    cheers

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 03, 2005 at 07:15 AM

    hi, you can write you select statement like following:

    SELECT *

    into XXXX

    from XXXX

    where field1 in R_field1

    and field2 in R_field2

    and field3 in R_field3.

    R_fieldX is associated with a select-option on the screen,

    SELECT-OPTIONS: R_fieldX type XXXX.

    if user doesn't input any value into the select-option, your select statement will still userful. in null input case, the condition will equal to this:

    SELECT *

    into XXXX

    from XXXX.

    Hope it will be helpful

    thanks

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 03, 2005 at 07:17 AM

    Hi

    Yes, but it depends on what dynamic selection means for you. How many tables do you have to read?

    You can use the where options for statament SELECT:

    SELECT * FROM <TABLE> WHERE (TAB_COND).

    TAB_COND is char table where you insert your selection criteria:

    PARAMETERS: P_BUK1 LIKE T001-BUKRS,

    P_BUK2 LIKE T001-BUKRS.

    DATA: TAB_COND(100) OCCURS 0 WITH HEADER LINE.

    IF NOT P_BUK1 IS INITIAL.

    CONCATENATE 'BUKRS = ''' P_BUK1 '''' INTO

    TAB_COND.

    ELSE.

    CONCATENATE 'BUKRS = ''' P_BUK2 '''' INTO

    TAB_COND.

    ENDIF.

    APPEND TAB_COND.

    SELECT * FROM T001 INTO TABLE T_BUKRS

    WHERE (TAB_COND).

    Max

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 03, 2005 at 07:24 AM

    Hi Rajashree Pattem,

    As per my understanding .......

    Ur selection screen will be like :

    Comapny code : -


    Project : -


    to -


    Order Reason : -


    And u have to get the data from the database depending upon the selection - screen values which the user has given in the screen !!! ( am i correct in understanding ur question ?? )

    IN the ABAP - Program code will be ........

    >...... bla bla ..........

    Selection-screen begin of block AB1 with frame title 'Kripa'

    parameter : P_BUKRS_VF like VBAK-BUKRS_VF.

    select-options : S_VBELN for VBAK-VBELN.

    parameter : P_AUGRU like VBAK-AUGRU.

    and in the select statements u have to use like the follwoing :

    select * from VBAK where .... and BUKRS = P_BUKRS and VBELN in S_VBELN and AUGRU = P_AUGRU

    Hope the above helps...........

    Reward with points if the above really helped u 😊

    Cheers,

    R.Kripa.

    Add comment
    10|10000 characters needed characters exceeded