‎2008 Feb 22 8:32 AM
Hi,
This is probably easy, but I've never had the need to do it before.
I need to execute a report with selection criteria from a Pushbutton instead of the SAP Execute button.
What code do I put behind the Pushbutton to do this?
Thanks,
‎2008 Feb 22 8:35 AM
Hi,
Maybe you can use this:
selection-screen pushbutton 35(20) text-012 user-command start.
case sscrfields-ucomm.
when 'START'.
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = text-004
text_question = text-008
text_button_1 = 'Yes'
text_button_2 = 'No'
importing
answer = v_answer
exceptions
text_not_found = 1
others = 2.
if sy-subrc <> 0.
message e....
endif.
if v_answer = c_yes.
submit z_your_program and return.
if sy-subrc <> 0.
Errors derived from memory
errors ..............
when others.
Set initial dynpro
call screen 100.
endcase.
Cheers...............
‎2008 Feb 22 8:36 AM
hi,
go through this example.
TABLES sscrfields.
PARAMETERS: p_carrid TYPE s_carr_id,
p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
INITIALIZATION.
sscrfields-functxt_01 = 'LH'.
sscrfields-functxt_02 = 'UA'.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN'FC01'.
p_carrid = 'LH'.
p_cityfr = 'Frankfurt'.
WHEN 'FC02'.
p_carrid = 'UA'.
p_cityfr = 'Chicago'.
ENDCASE.
START-OF-SELECTION.
WRITE / 'START-OF-SELECTION'.
hope it is useful.
regards,
sreelakshmi.
‎2008 Feb 22 8:43 AM
create push buton
PROCESS AFTER INPUT.
...
MODULE user_command_100.
. . .
DATA:ok_code LIKE sy-ucomm.
...
MODULE user_command_100 INPUT.
CASE ok_code.
WHEN 'SRTU'.
SORT it_book by ... .
. . .
ENDCASE.
ENDMODULE.
When you create a pushbutton, you must:
Create a pushbutton: Choose the Pushbutton object from the Screen Painter element list, place it
on the screen, and assign a name to it. You can enter a static text in the Text attribute. Enter a
function code for the pushbutton in the Function code attribute. This is placed in the OK_CODE
field automatically when the user chooses the pushbutton on the screen.
Activate the command field (OK_CODE field): You must give the field a name in the element list
of the Screen Painter, then declare an identically-named field in the ABAP program with reference
to the system field sy-ucomm.
When the user chooses a function on the screen, the system places the corresponding function code
into the OK_CODE field. You can then query the field and use the result to trigger the appropriate coded
processing block.
If the user chooses a pushbutton that has the function type ' ' (space), the PAI event is processed.
If the user chooses a pushbutton that has the function type "E", the system processes a module with the
addition AT EXIT-COMMAND. This happens before the automatic field transport and the field input
checks. The system places the function code that has been triggered into the OK_CODE field, which you
can then query in the module.
After the AT EXIT-COMMAND module, the system continues processing the screen normally (field input
checks, followed by PAI processing
example
Create the program
Create a new program in the repository browser (Transaction SE80) . Name standard for dialog programs is SAPMZ
In the attributes window:
- Module pool = M
- Application = Z
Create the screen
Create a new screen.
Add a pushbutton to the screen
In the attributes screen for the pushbutton, enter a function code
in the FctCode field ( In this example: 0020 ).
When you create a screen, SAP automathic creates a field with the type OK. The function code of the psuhbutton will be placed here when you push the button. However you have to supply the name of the OK field ( In this example: OK_CODE ).
You must also create a global variable in the program, to store the value of the OK field ( See below ).
Create global variables
DATA:
* Global variable to store OK code
ok_code(4),
* Temporary store the value of the OK code
save_ok_code(4).
Create code for the screen
PROCESS BEFORE OUTPUT.
MODULE status_0001.
PROCESS AFTER INPUT.
MODULE user_command_0001.
MODULE status_0001 OUTPUT.
SET PF-STATUS '0001'.
SET TITLEBAR '001'.
Example of how deactivate a field on the screen
ZCOSTAFSTM-ZAFSTEMNR is the name of the screen field we want to
deactivate.
LOOP AT SCREEN.
CHECK screen-name = 'ZCOSTAFSTM-ZAFSTEMNR'.
screen-input = '0'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDMODULE.
MODULE user_command_0001 INPUT.
Here you can catch when user pushes a pushbutton
Save the OK code in save_ok_code and clear it
save_ok_code = ok_code.
CLEAR ok_code.
CASE save_ok_code.
WHEN '0010'.
Afstemninger
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
PERFORM my_list.
WHEN '0020'.
CALL TRANSACTION 'ZCO1'.
WHEN 'RETU'.
LEAVE TO SCREEN '0000'.
ENDCASE.
ENDMODULE.
AT USER-COMMAND.
Here you can catch when the user psuh a button on the menu bar or presses a function key
CASE sy-ucomm.
WHEN 'OPRT'.
PERFORM something.
ENDCASE.
hope u find it useful <REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 4:02 PM
‎2008 Feb 22 9:14 AM
hi
good
you can do the same functionality using the SE41 transaction code.
thanks
mrutyun^