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: 

changing selection screen values

Former Member
0 Kudos

In the selection screen, there are 2 fields, 1 is vendor ID and 1 is vendor name:

Parameters: s_venID like lfa1-lifnr,

s_venNm like lfa1-name1.

The basic requirement is that when user enters the vendor ID, the vendor name could be retrieved and displayed on the screen.

So I wrote in the At selection-screen event:

At selection-screen.

select single name1 into s_venNm from LFA1 where lifnr = s_vendID.

It works fine whenever I change the vendor ID on the screen.

The further requirement is that user could also change the vendor name on the screen.

When I change the vendor name and press enter, the name would load from the vendor ID again.

How could I avoid this?

Thanks!

7 REPLIES 7

Former Member
0 Kudos

Hi,

Make use of flags and control it....i think this is possible...

Rgds.,

subash

0 Kudos

Hi ,

Check if p_name is initial.

then p_name = name_from_kna1.

or else what ever the user enters.

Rgds,

Jey

0 Kudos

Thanks!

But the vendor ID should be able to allow user to re-enter and the name comes out afterwards....

Former Member
0 Kudos

Hi

try like this....


select-options: p_lifnr for lfa1-lifnr,
                      p_name1 for lfa1-name1.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_name1.
  DATA it_dynfield TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = sy-dynnr
      request              = 'A'
      translate_to_upper   = 'X'
    TABLES
      dynpfields           = it_dynfield
    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.

  READ TABLE it_dynfield WITH KEY fieldname = 'P_LIFNR'.
  IF it_dynfield-fieldvalue IS NOT INITIAL.
    p_lifnr-option = 'EQ'.
    p_lifnr-sign = 'I'.
    p_lifnr-low = it_dynfield-fieldvalue.
    IF p_lifnr[] IS INITIAL.
      INSERT p_lifnrs INDEX 1.
    ELSE.
      MODIFY p_lifnr INDEX 1 TRANSPORTING low.
    ENDIF.
  ENDIF.

SELECT lifnr FROM lfa1
         INTO TABLE  it_help1.


  SELECT name1
         FROM lfa1
         INTO CORRESPONDING FIELDS OF TABLE it_help
         FOR ALL ENTRIES IN it_help1
         WHERE lifnr EQ it_help1-lifnr.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'NAME1'
      dynpprog        = '<Your prog name>'
      dynpnr          = '1000'
      dynprofield     = 'P_NAME1'
      value_org       = 'S'
    TABLES
      value_tab       = it_help
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Arunima

Former Member
0 Kudos

Hi,

use the events at selection-screen on statement to achieve this

example.


at selection-screen on vendorid.
"set the original vendor name 

at selection-screen on vendorname.
" compare the original with the contents of the field vendorname
if they differ, keep the fieldcontents as they are.
if they dont, still keep the contents as they are. 

regards,

Advait

murat_kaya
Participant
0 Kudos

Hi Macy,

change your code like this:

At selection-screen.

on change of s_vendID.

select single name1 into s_venNm from LFA1 where lifnr = s_vendID.

endon.

regards,

Murat Kaya

Former Member
0 Kudos

Hi,

Its pretty simple instead of thinking very deeply or using some complex logic

use the statement get cursor...

now with get cursor what happens is if the user changes the name and press enter the cursor is on the name field so the value returned is the field name with the help of get cursor...

see the code below for an example...

DATA : field_name type string.

At selection-screen.
GET CURSOR FIELD field_name.

IF field_name cs 'S_VENID'.
select single name1 into s_venNm from LFA1 where lifnr = s_vendID.
ELSE.
select single lifnr into s_venID from LFA1 where name1 = s_vendNM.
ENDIF.

Regards,

Siddarth