‎2013 Jan 29 5:50 AM
Hi,
My screen containing 7 input fields ( first 2 fields are mandatory).
case 1: After providing values to first 2 fields if I hit enter,
I am fetching entry from table and displaying other 5 field values in the screen respectively.-- working
case 2: If I am changing some value again in the screen for any one of the 5 fields and if I hit enter
(before saving) , its removing new value which I gave in screen and taking table (old value).
Since I have written code in PAI (for case 1) if ok_code = space to fetch enty from table and to display.
When hitting enter for case 2, It should be as it is in the screen.
Since both cases to hit enter, Please let me know any grouping or box should be added for first 2 fields
or any other way to handle this.
Regards,
Jack
‎2013 Jan 29 6:07 AM
Hi Jack,
you can achieve by getting the cursor position when they hit enter.if the cursor is in first 2 fields when they press enter then do the case 1 and if the cursor is in any one of the 5 fields then do the case 2 .
The below link explains how to get the cursor field.
http://help.sap.com/saphelp_erp2004/helpdata/en/9f/dbabf135c111d1829f0000e829fbfe/content.htm
Regards,
Vikram
‎2013 Jan 29 6:08 AM
Hi,
For your requirement for both the cases you have to write the code in Ok_code = space with condition.for first case check whether your remaining 5 fileds are empty if yse then you fetch the data from table and display .
If you metion this condition your requirement will fullfill.If any problem reply me.
Thanks
Mani
‎2013 Jan 29 6:10 AM
That's probably happening because the code to fetch data from the table is getting executed each time you change a field and press Enter. Try separating your fields in blocks and then use AT SELECTION-SCREEN ON BLOCK event.
‎2013 Jan 29 6:19 AM
Hi,
Case 2: Can't you specify a condition that only when the field value is initial then fetch the values from table else leave the values as it is on pressing enter? Thanks!
Regards,
Kumud
‎2013 Jan 29 6:21 AM
Hi jack,
Copy your ok_code value to anothe zfield so that you value doesnot affect.
sy-Ucom = ok_code.
If you want to keep your new value , write your logic like
Case ok_code.
when 'Enter'.
update your values to the screen field.
Thanks
Vijay
‎2013 Jan 29 5:46 PM
Hi ,
User may keep cursor in field 1 or 2 after changing values for other field...In this case cursor position changes will fail.
field value wont be initial in all cases ( user wont clear all values everytime )
Since all field is input enabled, first execution values will be there in screen.
user will again run with different data for first case to display other fields.so
we can't specify a condition that only when the field value is initial then fetch the values from table
In my module pool program, both ok_code and sy-ucomm is space when hitting enter.
Regards,
Jack
‎2013 Jan 29 6:17 PM
Hi Jack,
You can add something like below to your logic
1. You can keep the logic of ok_code as the first condition in the PAI.
2. Then read the screen values using the FM DYNP_VALUES_READ and store them in internal table.
3. After that select the values from the table(as you are doing) and store them in a local work area.
4. Compare the values of 5 fields you get in step 2 and step 3. If there is a difference in value of any of those 5 fields then update the values to the screen fields which you get in step 2.
Here in step 2 and step 4, you need to take care that the values of 5 fields are initial or not(check if the user is executing for the first time or not).
Hope this helps
‎2013 Jan 29 6:46 PM
Hi,
Try using a condition that compare the first two values with the same old values (which you have to store in some temporary variable) if they are equal then don't populate it again. Otherwise populate.
IF first_field = old_val_of_first_field AND second_field = old_val_of_second_field.
........dont populate values to other fields.
ELSE.
........Populate new values to other fields.
ENDIF.
thanks.