‎2014 Jan 20 12:50 PM
Hi all,
I am doing a project on step loops. Now I do know that it is hardly used nowadays after the inception of table control, however I do need some assistance in my issue as I have to work with it.
I have explained my program using the necessary steps and screenshots below.
1) I have declared the following variables in my program.
DATA idx TYPE sy-loopc.
DATA: line TYPE i .
DATA: l_vbeln_l TYPE vbeln_va,
l_vbeln_h TYPE vbeln_va.
TYPES:BEGIN OF ty_vbak,
vbeln TYPE vbeln_va,
kunnr TYPE kunnr,
END OF ty_vbak.
DATA it_vbak TYPE STANDARD TABLE OF ty_vbak.
DATA wa_vbak TYPE ty_vbak.
DATA WA_X LIKE LINE OF IT_vbak.
2) I have created a screen 9000 as shown for my select options:
3) I have written the following code in the PAI.
CASE sy-ucomm.
WHEN'CONFIRM'.
SELECT vbeln kunnr FROM vbak INTO TABLE it_vbak
WHERE vbeln ge l_vbeln_l and vbeln le l_vbeln_h.
IF sy-subrc NE 0.
MESSAGE 'NOT A VALID INPUT' TYPE 'I'.
ELSE.
idx = 1.
line = 0.
LOOP AT it_vbak INTO wa_x .
line = line + 1.
ENDLOOP.
CALL SCREEN 9001.
ENDIF.
WHEN'CLEAR'.
CLEAR: L_VBELN_L, L_VBELN_H.
ENDCASE.
4) I have created screen 9001 and I have drawn the layout for the 2 fields as shown:
5) I created the flow logic for screen 9001 as shown below:
6) In module filldata, I wrote the following code:
if idx > 0.
READ TABLE it_VBAK INTO wa_VBAK INDEX idx.
idx = idx + 1.
endif.
7) In PAI, I wrote the following:
CASE sy-ucomm.
WHEN 'PAGEDOWN'.
IF idx > line.
idx = idx - 10. [idx = idx - n]
ENDIF.
WHEN'PAGEUP'.
IF idx <= 11.
idx = 1.
ELSEIF idx > 20.
idx = idx - 20.
ENDIF.
ENDCASE.
😎 After executing the program, and giving the values for the select-options, I get the result:
9) On hitting PAGE DOWN buttoon, 10 records are scrolled in the screen i.e. from 4969 to 4978 etc.
However, the main issue here is that, when I am pressing ENTER, the PAGE DOWN functionality is working as well whereas it is not supposed to. This is happening after the first PAGE DOWN function, i.e. when the records are from 4979 to 4989 and so on. The ENTER key does not cause problems when the first 10 records OR the last 10 records are showing on screen.
Can someone please advise how to eradicate this problem so that the ENTER key doesnt cause the records to scroll up/down?
Thanks.
‎2014 Jan 20 4:31 PM
Hi,
After every input on screen 9001 (Pagedown button, enter, etc) PAI gets executed and after that also PBO gets executed. Your "loop. MODULE filldata.Endloop." in PBO gets executed no matter what your actions are.
Because IDX is global and in form filldata it gets incremented after every input you get a new (down) page.
Also use a variable to store SY-UCOMM and use it in CASE ... ENDCASE in PAI 9001 and aflter that clear it.
Hope this helps.
Adi.
‎2014 Jan 20 2:40 PM
"Step loops", omg, not used for ages (and never liked) 😉
The strange behavior happens maybe because the push button still has the focus after the first page down. Please try to set the focus to the first input field ("SET CURSOR").
‎2014 Jan 20 4:31 PM
Hi,
After every input on screen 9001 (Pagedown button, enter, etc) PAI gets executed and after that also PBO gets executed. Your "loop. MODULE filldata.Endloop." in PBO gets executed no matter what your actions are.
Because IDX is global and in form filldata it gets incremented after every input you get a new (down) page.
Also use a variable to store SY-UCOMM and use it in CASE ... ENDCASE in PAI 9001 and aflter that clear it.
Hope this helps.
Adi.
‎2014 Jan 21 4:44 AM
Hi Adi,
Thanks for ur reply. But can u plz give me a code snippet as to how to go about it as I am unable to follow what I need to do. I will declare a variable for SY-UCOMM and clear it but what else do I need to do?
Regards.
Manish.
‎2014 Jan 21 4:52 AM
I also feels it an issue of clearing ok_code.
Declare an ok code variable.
data : Ok_code like sy-ucomm.
In the PAI make the following changes.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'PAGEDOWN'.
IF idx > line.
idx = idx - 10. [idx = idx - n]
ENDIF.
WHEN'PAGEUP'.
IF idx <= 11.
idx = 1.
ELSEIF idx > 20.
idx = idx - 20.
ENDIF.
ENDCASE.
clear ok_code.
‎2014 Jan 21 5:16 AM
Hi Susmitha,
I have tried your approach, but I am still facing the same issue.
Manish.
‎2014 Jan 21 5:21 AM
When you are debugging, what is the ok_code that is coming when you press the Enter key?
‎2014 Jan 21 5:29 AM
Hi Manish,
Do it this way.
Go to the menu painter of this screen in SE41.
In the function keys, give a function code for the Enter button. (The green tick button), say ENTER. This function code will be triggered when you press the Enter key also.
Now in the PAI, include a case for ENTER and code nothing it it.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'ENTER'.
* do nothing.
WHEN 'PAGEDOWN'.
‎2014 Jan 21 7:33 AM
Hi Susmitha,
The value of ok_code after pressing the ENTER key is a hexadecimal value as shown my below screenshot. Also I did try your approach wherein I did not write any code after pressing ENTER, but its still not workin. 😞
‎2014 Jan 21 7:38 AM
‎2014 Jan 21 7:41 AM
‎2014 Jan 21 7:47 AM
And after that on debugging, when you press Enter key, the function code is still the hexadecimal value or the function code that you gave for Enter?
(Just for confirmation, you have a set pf-status in the PBO of your screen right? )
‎2014 Jan 21 7:57 AM
Yes Susmitha, after pressing the ENTER key , the function code is still the hexadecimal value. I have set a pf-status in my pbo for screen 9001.
‎2014 Jan 21 8:06 AM
If the function code is this hexadecimal value, is it still entering the case in ok_code for page down????
It should not be logically doing anything when you press enter as there is no associated case implemented. Please debug and see how the page down is executing when you are pressing enter.
And , one more suggestion.
Dont use sy-ucomm.
What is the ok_code variable declared in the screen 9001? Assuming its ok_code.
In your program also, you have this ok_code declared.
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
In the PAI module of 9001. .
save_ok = ok_code.
clear ok_code.
case save_ok.
endcase.
‎2014 Jan 21 8:12 AM
Hi,
for your code do it like this:
declare globally DATA: OK_CODE type sy-ucomm. "
for PAI screen 9001:
data: l_tmp_CODE TYPE sy-ucomm, l_tmp_line LIKE line.
l_tmp_CODE = OK_CODE. " OK_CODE is variable set for OK screen element
clear OK_CODE. " reset
CASE l_tmp_CODE.
WHEN 'BTNPD'.
l_tmp_line = line - 10.
IF idx > l_tmp_line.
" nothing
else.
idx = idx + 10.
ENDIF.
WHEN'BTNPU'.
IF idx <= 11.
idx = 1.
ELSE.
idx = idx - 10.
ENDIF.
ENDCASE.
flow logic for screen 9001:
PROCESS BEFORE OUTPUT.
MODULE STATUS_9001.
LOOP.
MODULE filldata.
ENDLOOP.
MODULE reset_idx.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9001.
LOOP.
ENDLOOP.reset_idx logic:
MODULE reset_idx OUTPUT.
idx = idx - 10.
ENDMODULE. " RESET_IDX OUTPUTIt doesn't matter what fcode you have for ENTER.
Regards,
Adi.
‎2014 Jan 21 9:51 AM
I have declared the ok_code as you have shown in your code snippet. But the issue is that I am not able to figure out why the ENTER key is triggering the page down functionality in my program. Now I am referring to the demo program DEMO_DYNPRO_STEP_LOOP. In this program the ENTER key is not creating any problem whatsoever. I might have to use this program's approach.
‎2014 Jan 21 10:00 AM
‎2014 Jan 21 6:24 AM
Hi,
You can try like this
in the PAI
IF ok_code = 'PREV_LINE'.------>button in the layout
PERFORM move_to_prev_line.
CLEAR ok_code.
ENDIF.
IF ok_code = 'NEXT_LINE'.------>button in the layout
PERFORM move_to_next_line.
CLEAR ok_code.
ENDIF.
FORM move_to_prev_line .
v_tc-top_line = v_tc-top_line - 1.
ENDFORM.
FORM move_to_next_line.
DATA : lv_fill TYPE i.
DESCRIBE TABLE t_banking LINES lv_fill.
v_tc-top_line = v_tc-top_line + 1.
IF v_tc-top_line GE lv_fill.
v_tc-top_line = lv_fill.
ENDIF.
ENDFORM.