Application Development and Automation 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: 
Read only

using the values entered in select options..

Former Member
0 Likes
2,383

hi,

when i enter some value in my select option at runtime, it is not stored in the field, for e.g. S_KUNNR !! , i debugged and checked in my select statement, S_KUNNR is blank !! i checked the S_KUNNR structure and it's low and high both were blank !

why so ?

SELECT * INTO CORRESPONDING FIELDS OF TABLE I_TAB FROM ZXXX WHERE VSTEL IN S_VSTEL AND KUNNR IN S_KUNNR.

thks

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,349

Select-options are tables, so look at the body of the table, not the header line.

Regards,

Rich Heilman

hi,

when i enter some value in my select option at runtime, it is not stored in the field, for e.g. S_KUNNR !! , i debugged and checked in my select statement, S_KUNNR is blank !! i checked the S_KUNNR structure and it's low and high both were blank !

why so ?

SELECT * INTO CORRESPONDING FIELDS OF TABLE I_TAB FROM ZXXX WHERE VSTEL IN S_VSTEL AND KUNNR IN S_KUNNR.

thks

21 REPLIES 21
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,350

Select-options are tables, so look at the body of the table, not the header line.

Regards,

Rich Heilman

Read only

0 Likes
2,349

I am very sorry, if my questions sound silly !! But I am new to this and trying my best to learn.

Rich, u said "Select-options are tables, so look at the body of the table, not the header line."

In debugger, I checked the table contents for S_KUNNR, the screen which had

LINE SIGN OPTION LOW HIGH columns. All were blank !!

Also I tried modifying my select statement as Vijay told me earlier, S_KUNNR[] instead of S_KUNNR. Did not work !! Still the table content is blank !!

Any other way ??

Read only

0 Likes
2,349

Post your coding, lets take a look.

Regards,

Rich Heilman

Read only

0 Likes
2,349

hi,

select options is a table. So when you are passing values dynamically to the table you have to append the select option.like append s_aufnr after passing the values.

Regards,

radhakrishna

Read only

0 Likes
2,349

yes it is behaving exactly what you said...

the solution is using the Function DYNP_VALUES_READ.

REPORT  ztest_mod.

DATA: kunnr TYPE kunnr.

* Custom Selection Screen 0200
SELECTION-SCREEN BEGIN OF SCREEN 0200 AS SUBSCREEN.
SELECT-OPTIONS: s_kunnr FOR  kunnr.
SELECTION-SCREEN END OF SCREEN 0200.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kunnr-low.
  BREAK-POINT.

START-OF-SELECTION.
  "in this screen i have a button with function code 'SEARCH'
  " and a subscreen area with name sub
  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS'.
ENDMODULE.                    "status_0100 OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  DATA:
      i_dyn_fields LIKE TABLE
                     OF dynpread
                   WITH HEADER LINE.
  MOVE:
    'S_KUNNR-LOW' TO i_dyn_fields-fieldname.
  APPEND i_dyn_fields.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = '0200'
    TABLES
      dynpfields           = i_dyn_fields
    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 eq 0. 
   read table i_dyn_fields index 1.
    s_kunnr-low = i_dynp_fields-VALUE
    s_kunnr-sign = 'I'.
    s_kunnr-option = 'EQ'.
    append s_kunnr.
  ENDIF.

  DATA: it_kunnr TYPE TABLE OF kna1.
  CASE sy-ucomm.
    WHEN 'SEARCH'.
      SELECT * FROM kna1
      INTO TABLE it_kunnr
      WHERE kunnr IN s_kunnr.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                    "user_command_0100 INPUT

Flow Logic

PROCESS BEFORE OUTPUT.
*
  MODULE status_0100.
*
  CALL SUBSCREEN sub INCLUDING sy-repid '0200'.
*
PROCESS AFTER INPUT.
*
  MODULE user_command_0100.

Read only

0 Likes
2,349

No way man, you do NOT have to use the 'DYNP_VALUES_READ' function to get the values from a select-option. There is another reason why he is not seeing the values in S_KUNNR.

Regards,

Rich Heilman

Read only

0 Likes
2,349

Oh, when using the select-option in a subscreen, then maybe you would have to use the FM, Otheriwse, you would not.

Regards,

RIch Heilman

Read only

0 Likes
2,349

I spend my full time with my slow system and Found that finally. I tried differently , atlast i used that FM it is working,

Read only

0 Likes
2,349

Thanks Vijay..Yes i am using as subscreen where the selection screen is displayed. So I am trying the Function module solution. One question on that ..

read table i_dyn_fields index 1.

s_KUNNR-low = i_dyn_fields-FIELDVALUE.

s_KUNNR-sign = 'I'.

s_KUNNR-option = 'EQ'.

append s_KUNNR.

this wont work in ECC 6.0 as i need to define a work area for S_KUNNR . what data type is it ? it has sign, low, high etc, right !!

DATA WA_KUNNRSTRUCT TYPE ????

thanks

Read only

0 Likes
2,349

It will work in ECC 6.0, its just not recommended, and it will not work if written in the OO context. But you can define a work area like this.

data: wa_kunnr like line of s_kunnr.

Regards,

Rich Heilman

Read only

0 Likes
2,349
data: r_kunnr type range of kna1-kunnr.
        w_kunnr like line of r_kunnr.
data: wa_dynfield like line of i_dyn_fields.

read table i_dyn_fields into wa_dynfield index 1.

w_kunnr-low = wa_dynfield-fieldvalue.
w_KUNNR-sign = 'I'.
w_KUNNR-option = 'EQ'.
append w_KUNNR to s_kunnr.
Read only

0 Likes
2,349

yes got it..now the value is read !! one last related question..the code looks like we r handling only the low value !! so i need to read the high values also like this ??

MOVE: 'S_VSTEL-LOW' TO i_dyn_fields-fieldname.

APPEND i_dyn_fields.

MOVE: 'S_VSTEL-HIGH' TO i_dyn_fields-fieldname.

APPEND i_dyn_fields.

...

...

CALL FUNCTION 'DYNP_VALUES_READ'

...

..

read table i_dyn_fields into wa_dynfield index 1.

w_kunnr-low = wa_dynfield-fieldvalue.

w_KUNNR-sign = 'I'.

w_KUNNR-option = 'EQ'.

append w_KUNNR to s_kunnr.

read table i_dyn_fields into wa_dynfield index 2.

w_kunnr-high = wa_dynfield-fieldvalue.

w_KUNNR-sign = 'I'.

w_KUNNR-option = 'EQ'.

append w_KUNNR to s_kunnr.

will this hold good ??

then my select statement will check for all values in this range and fetch the data based on that, right ??

thks

Read only

0 Likes
2,349

yes you need to pass HIGH also

but little modification to your code

read table i_dyn_fields into wa_dynfield index 1. <==SKUNNR-LOW
w_kunnr-low = wa_dynfield-fieldvalue.
w_KUNNR-sign = 'I'.
w_KUNNR-option = 'BT'.

read table i_dyn_fields into wa_dynfield index 2. <== you suppose to read it with S_KUNNR-HIGH
w_kunnr-high = wa_dynfield-fieldvalue.

append w_KUNNR to s_kunnr.

if you enter

1 to 10

you want between 1 to 10

Read only

0 Likes
2,349
read table i_dyn_fields into wa_dynfield with key fieldname = 'S_KUNNR-LOW'. 
w_kunnr-low = wa_dynfield-fieldvalue.
w_KUNNR-sign = 'I'.
w_KUNNR-option = 'BT'.


read table i_dyn_fields into wa_dynfield with key fieldname = 'S_KUNNR-HIGH'.
w_kunnr-HIGH = wa_dynfield-fieldvalue.
append w_KUNNR to s_kunnr.
Read only

0 Likes
2,349

Actually Vijay, user may enter just one value which i think will be automatically assigned to kunnr-low ??

if he enters for both low and high, this code what u sent will work with w_KUNNR-option = 'BT'.

but, in my case user may enter a single value or a range !!!

so what to do ??

for a note, i have 4 such select options in my subscreen and like this I have 3 subscreens !!

thanks

Read only

0 Likes
2,349

read table i_dyn_fields into wa_dynfield with key fieldname = 'S_KUNNR-LOW'.

w_kunnr-low = wa_dynfield-fieldvalue.

w_KUNNR-sign = 'I'.

w_kunnr-option = 'EQ'.

read table i_dyn_fields into wa_dynfield with key fieldname = 'S_KUNNR-HIGH'.

w_kunnr-HIGH = wa_dynfield-fieldvalue.

if w_kunnr-high is not initial.

w_KUNNR-option = 'BT'. <===if the value there EQ will be overwritten by BT

endif.

append w_KUNNR to s_kunnr.

Read only

0 Likes
2,349

Works great !! Thanks to all ...

Read only

Former Member
0 Likes
2,349

may be you are checking the header, Check the Body of the S_KUNNR .

Read only

Former Member
0 Likes
2,349

What's different from this post, other than now you don't have a value for s_kunnr?

Read only

Former Member
0 Likes
2,349

Duplicate post - marked as solved in other one.

Rob

Read only

Former Member
0 Likes
2,349

Hi,

I think problem could be...the SQL is in an event for a selection screen field which is declared above the field S_KUNNR.

Let's take this example...In this p_date is declared above so_date...and in the event ON p_date...The value so_date will not be available..

PARAMETERS: p_date TYPE sy-datum.

SELECT-OPTIONS: so_date FOR sy-datum.

AT SELECTION-SCREEN ON p_date.

BREAK-POINT.

so in this case you have might have to use the function module DYNP_VALUES_READ .

Thanks

Naren