10-28-2008 6:32 AM
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!
10-28-2008 6:37 AM
Hi,
Make use of flags and control it....i think this is possible...
Rgds.,
subash
10-28-2008 8:19 AM
Hi ,
Check if p_name is initial.
then p_name = name_from_kna1.
or else what ever the user enters.
Rgds,
Jey
10-28-2008 9:28 AM
Thanks!
But the vendor ID should be able to allow user to re-enter and the name comes out afterwards....
10-29-2008 10:42 AM
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
10-29-2008 10:55 AM
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
03-08-2009 5:47 PM
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
03-08-2009 6:18 PM
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