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

Enter in Module Pool.

Former Member
0 Likes
3,665


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

8 REPLIES 8
Read only

Former Member
0 Likes
1,926

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

Read only

Former Member
0 Likes
1,926

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

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
1,926

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.

Read only

kumud
Active Contributor
0 Likes
1,926

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

Read only

Former Member
0 Likes
1,926

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

Read only

Former Member
0 Likes
1,926

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

Read only

0 Likes
1,926

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

Read only

0 Likes
1,926

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.