Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Selection Screen

Former Member
0 Kudos

Hi,

        Following query runs based selection screen. When we do not enter single value S_AUFNR which has to pull based on s_date wise or including S_Aufnr wise. We have an option like radio-button.. is there any option to do?

SELECT ap~dwerk
             ak~aufnr
            ak~plnbez
            ak~gamng
            ak~gltri
            ak~aufld
    INTO CORRESPONDING FIELDS OF TABLE gt_afko
    FROM afko AS ak INNER JOIN
         afpo AS ap
    ON ak~aufnr EQ ap~aufnr
    WHERE ap~dwerk EQ p_dwerk


    AND  ak~gltri IN s_gltri "Date

 
   AND  ak~aufnr EQ s_aufnr "Single value

regards

Shree

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi, No you mean..Multiple selection values..I need single where we can use EQ symbol only...

26 REPLIES 26

former_member491621
Contributor
0 Kudos

Hi Shree,

just change the code as below

AND ak~aufnr IN s_aufnr.

It will work for single value also.

former_member391265
Participant
0 Kudos

Hi

can you please clearly tell your problem, What exactly you want to do?

Former Member
0 Kudos

Hi, try with ak~aufnr EQ s_aufnr-LOW  ?

Former Member
0 Kudos

Hi, No you mean..Multiple selection values..I need single where we can use EQ symbol only...

0 Kudos

the you can use

AND ak~aufnr EQ s_aufnr-low.

why don;t you use parameter instead?

and even if you enter single value in select-options, the system automatically takes oonly single value.

0 Kudos

Try using this if you want select options and restrict to one box

SELECT-OPTIONS : s_aufnr FOR aufk-aufnr NO INTERVALS

Former Member
0 Kudos

yes,  Used Parameter

0 Kudos

Hi Shree,

If you could please close the thread and change it to answered

Former Member
0 Kudos

Hi,

     If you ignore the parameter which has to pull value based on S_DATE or if you use the S_aufnr based single value with date wise...Thanks

Former Member
0 Kudos

Hi Shree,

Use IN insted of EQ in below code:

AND  ak~aufnr EQ s_aufnr "Single value

AND ak~aufnr IN s_aufnr " Single Value

Former Member
0 Kudos

  When i ignore the parameter S_AUFNR...Need result based on S_date wise then you would get multiple AUFNR values on output...When you use S_AUFNR only single value

0 Kudos

Can you please clarify more?

Using the code below suffices all the requirements, whether you give single value,a range or ignore it, the below code works

AND  ak~aufnr EQ s_aufnr

Why don;t you use the below code and debug to see

former_member195270
Active Participant
0 Kudos

Hi Shree,

   if you want that your code should work for single and multiple order then use following code.

TABLES afko.

data gt_afko TYPE STANDARD TABLE OF afko.

PARAMETERS p_dwerk TYPE dwerk.

SELECT-OPTIONS: s_gltri for afko-gltri,

                s_aufnr for afko-aufnr.





IF lines( s_aufnr[] ) EQ 1 AND s_aufnr-high is INITIAL.

  SELECT ap~dwerk

             ak~aufnr

            ak~plnbez

            ak~gamng

            ak~gltri

            ak~aufld

    INTO CORRESPONDING FIELDS OF TABLE gt_afko

    FROM afko AS ak INNER JOIN

         afpo AS ap

    ON ak~aufnr EQ ap~aufnr

    WHERE ap~dwerk EQ p_dwerk

    AND  ak~gltri IN s_gltri "Date

    AND  ak~aufnr EQ s_aufnr-low. "Single value

else.



  SELECT ap~dwerk

             ak~aufnr

            ak~plnbez

            ak~gamng

            ak~gltri

            ak~aufld

    INTO CORRESPONDING FIELDS OF TABLE gt_afko

    FROM afko AS ak INNER JOIN

         afpo AS ap

    ON ak~aufnr EQ ap~aufnr

    WHERE ap~dwerk EQ p_dwerk

    AND  ak~gltri IN s_gltri "Date

    AND  ak~aufnr EQ s_aufnr.

endif.

0 Kudos

Hi Umar,

I don't think using EQ works in case of select-options

0 Kudos

Use as below.Now it will work.

TABLES afko.

data gt_afko TYPE STANDARD TABLE OF afko.

PARAMETERS p_dwerk TYPE dwerk.

SELECT-OPTIONS: s_gltri for afko-gltri,

                s_aufnr for afko-aufnr.





IF lines( s_aufnr[] ) EQ 1 AND s_aufnr-high is INITIAL.

  SELECT ap~dwerk

             ak~aufnr

            ak~plnbez

            ak~gamng

            ak~gltri

            ak~aufld

    INTO CORRESPONDING FIELDS OF TABLE gt_afko

    FROM afko AS ak INNER JOIN

         afpo AS ap

    ON ak~aufnr EQ ap~aufnr

    WHERE ap~dwerk EQ p_dwerk

    AND  ak~gltri IN s_gltri "Date

    AND  ak~aufnr EQ s_aufnr-low. "Single value

else.



  SELECT ap~dwerk

             ak~aufnr

            ak~plnbez

            ak~gamng

            ak~gltri

            ak~aufld

    INTO CORRESPONDING FIELDS OF TABLE gt_afko

    FROM afko AS ak INNER JOIN

         afpo AS ap

    ON ak~aufnr EQ ap~aufnr

    WHERE ap~dwerk EQ p_dwerk

    AND  ak~gltri IN s_gltri "Date

    AND  ak~aufnr IN s_aufnr.

endif.

0 Kudos

When we use select-options in a query and a single value is entered on the selection screen, the system automatically changes the value of S_XXXX-LOW to IEQ<value>. We don't have to do anything except using it as normal select-options

Former Member
0 Kudos

Every one of their aspect is right...But ketan bhajni is right...We can use no intervals, it would satisfy both condition... thank you all..

0 Kudos

You could have declared it as parameter rather than select-options if you wanted single value

0 Kudos

Hi aniket,

             I declared parameter only but when i leave the input values then it has to satisfy s_date wise...Now i use selection-option no intervals.... you are also right.....

Former Member
0 Kudos

Hi Omar,

      Why don't use select-option and no interval then query retrieves multiple values. In case, giving S_aufnr value which gives single value...Right... 

Former Member
0 Kudos

Hi,

     When we do not use the parameter or input the value S_Aufnr...which will retrieve based on S_date where we would get all aufnr data because the join condition you would see...

When we S_Aufnr we get single value based aufnr value...

0 Kudos

Hi Shree,

Your requirement is:

If S_AUFNR is entered with a single value, then the select query should get records corresponding to that.

And if S_AUFNR is left blank, then the records must be fetched based on S_DATE?

Is it right????

If yes, then in either case the below code works

AND ak~aufnr IN S_AUFNR.

0 Kudos

Yes, absolutely right...

0 Kudos

The go ahead and use the code

AND ak~aufnr IN S_AUFNR.

This will definitely work

0 Kudos

Thank you..

raymond_giuseppi
Active Contributor
0 Kudos

Not sure to understand your requirement, if you only want user to input a list of order numbers, you could rely on FM SELECT_OPTIONS_RESTRICT. Then use a syntax like aufnr IN so_aufnr or even a FOR ALL ENRIES IN so_aufnr WHERE aufnr = so_aufnr-low, second syntax get lesser performance, but will not raise an error for many order numbers.

  data: restrict type sscr_restrict,

        opt_list type sscr_opt_list,

        ass type sscr_ass.

* Default option for other criteria

  clear opt_list.

  move 'ALL' to opt_list-name.

  move 'X' to: opt_list-options-bt,

               opt_list-options-cp,

               opt_list-options-eq,

               opt_list-options-ge,

               opt_list-options-gt,

               opt_list-options-le,

               opt_list-options-lt,

               opt_list-options-nb,

               opt_list-options-ne,

               opt_list-options-np.

  clear ass.

  move: 'A'          to ass-kind,

        '*'          to ass-sg_main,

        'ALL'        to ass-op_main.

* Option for only list of values

  clear opt_list.

  move 'EQU' to opt_list-name.

  move 'X' to opt_list-options-eq.

  append opt_list to restrict-opt_list_tab.

  clear ass.

  move: 'S'          to ass-kind,

        'SO_AUFNR'   to ass-name,

        'I'          to ass-sg_main, " no exclude

        'EQU'        to ass-op_main. " only list of values

* Execute FM call

  call function 'SELECT_OPTIONS_RESTRICT'

    exporting

      restriction = restrict

    exceptions

      others      = 0.

Otherwise, try to make your request more clearly or read abap online documentation like col [NOT] IN seltab.

Regards,

Raymond