Application Development 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: 

How to add a button in a standard transaction

ceieneka
Explorer
0 Kudos
602

HI,

I want to add a simple button inside screen 8309 of SAPMV45A program. After click, button should change value of custom text field on the screen and run save processing (as if the save button was pressed).

I added a button (dummy_btn) with FctCode set to 'FCT_COM' and a textbox (dummy_fld) with screen painter, i also created a PAI obj and a module that should run on btn press.

Screen flow logic:

PROCESS AFTER INPUT.
* Verarbeitung nach der Eingabe
*{ INSERT
MODULE cmnt_order .
*} INSERT

cmnt_order module:

*----------------------------------------------------------------------*
***INCLUDE ZMV45A_CMNT_ORDER .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module CMNT_ORDER INPUT
*&---------------------------------------------------------------------*
* Changes the comment field
* from value "" to value ""
*----------------------------------------------------------------------*
MODULE CMNT_ORDER INPUT.
DATA: DUMMY_BTN TYPE c.

IF sy-ucomm = 'FCT_COM'.
DUMMY_BTN = 'Sent'.
ENDIF.
ENDMODULE. " CMNT_ORDER INPUT

Unfortunately, when I press the button, I get the message 'function cmnt_order is not available here'. What did I forget - how to resolve this problem? From debuger i see that module is performed correctly and the error is displayed outside the module.


And second: how to trigger from that module(CMT_ORDER) automatic code execution just like the save button was clicked?

4 REPLIES 4

raymond_giuseppi
Active Contributor
519

You added the button in a subscreen, so the ok_code/sy-ucomm is checked in the main dynpro logic, the dynpro that carries a pf-status.

  • Check the PAI logic of main dynpro, you should be required to add reference to your function code in some custimizing tabl

To execute some code juste after SAVE look at user-exits SAVE_DOCUMENT_PREPARE (if you want to change some standard data) and SAVE_DOCUMENT (otherwise) of include MV45AFFZZ.

0 Kudos
519

"Check the PAI logic of main dynpro, you should be required to add reference to your function code in some custimizing tabl" can you be more specific: how to add that reference, what table, or share a link with a more detailed description.

"To execute some code juste after SAVE ( ... )" OK it looks complicated, I thought there is some way to simulate such a click by simply changing in my module the function code or something.

chaouki_akir
Contributor
0 Kudos
519

Hello,

I would debug to see why the error message is send. For example, may be SAP standard is checking some T8* customizing tables.

Sandra_Rossi
Active Contributor
0 Kudos
519

If you don't know how to debug the standard programs, you can try a workaround, if the double-click is allowed by the standard program, you may try to define a hotspot text (appears as an hyperlink) instead of a button, and see if the standard program let your PAI module manage the action. If yes, you can then get the field name of the text with GET CURSOR FIELD.