Enhance SAP standard transaction screen which does not have screen exits or screen Badi’s
Topic: Enhancing transaction
Enhancement type: Screen enhancement
I will use the following transaction and screen for making the concept a bit more palatable.
TCODE: MIRO
Screen number: 6000
Standard program: SAPLMR1M
Enhancing transactions are somethings that we do as a regular ABAP-er as apart of our daily job. You might be wondering what would be the justification to create a document for enhancing MIRO.
The fun part is that there are no screen exits or BADis for this particular transaction screen (6000). There is no conventional way to add a button in the standard MIRO screen without making a copy of the standard program. That seems a daunting task.
There are two possible approaches for this:
1. Create a Z-Copy of the program SAPLMR1M
2. Enhance the standard program by using enhancement spots (fortunately SAPLMR1M doesn’t lack in Enhancement spots )
I would discuss approach two here.
This involves a considerable amount of debugging and using standard function modules.
That seems logical on making modifications for the standard as SAP follows the same. Under a layer of module pool programming all that is there for encapsulation are standard Function modules.
It also involves grasping of the concept about PF-status of screens.
Whenever SAP displays a screen there is a PF-status which determines the buttons present in the screen.
It also determines whether the buttons will be active or disabled.
The PF-status can be modified without making any other changes in the program except for writing the command “SET PF-STATUS..”.
The PF-status thus set is retained while displaying the screen.
In other words, when you set PF status the affected screen is the one which is displayed next.
The whole enhancement of including buttons lies on this single concept and it is very important that you grasp it.
The next are all easy.
I will highlight the steps.
Step 1: We find the PBO of the screen we need to enhance. For my specific case it was screen 6000 of program SAPLMR1M.
Step 2: In PBO we find a suitable spot where we can set the PF-status according to our requirement. This should be a spot where the PF-status of the standard is already set. (Yes, we overwrite the PF-status of the standard with our own and it works ). I overwrote the PF-Status using a Z-FM which I developed for this purpose. I will attach it for your reference. Also there are some buttons that are excluded in the standard. You need to take care of it using the exclusion table which SAP standard uses for this purpose. The code example will show you an example. Also an image below.
Step 3: We create a enhancement implementation in PBO where we set the PF-status to our Z-PF-status. I made a copy of the standard PF-status and enhanced it to include a custom button. The PF-status must be in the same package as the Z-FM used to set it. Please check the screenshot of the Z-FM and you will get the idea. See left hand side GUI status.
Step 4: We call the FM from the enhancement spot created and voila, the button is here .
Wait a minute, the button is here but it doesn’t work . What’s the use of a button for show? Which brings us to:
Step 5: Enhance the PAI of the program to include various mumbo-jumbo that will happen when we press the glorified button. Now, for this, one shot of debugging is enough. This will show you the spot where you need to place your own code for handling the OK-code of the custom button.
I will attach screenshots of spots where I enhanced to give you the general idea.
I will not go into specifics of the code as long as you get the general idea. Nevertheless, I will exemplify codes which you may refer.
Thanks for reading.
Please let me know if it helped you by clicking the comment button below.
The below section contains code examples:
1. Custom FM used to set PF-status
FUNCTION zptp_mr1m_gui_dummy_set_global.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_TEXT_ICON) TYPE CHAR20 OPTIONAL
*" REFERENCE(I_TEXT_ICON_V) TYPE CHAR20 OPTIONAL
*" REFERENCE(I_REFRESH) TYPE FLAG OPTIONAL
*" TABLES
*" IT_EXCL OPTIONAL
*"----------------------------------------------------------------------
DATA: BEGIN OF lt_excl OCCURS 25,
funktion(10),
END OF lt_excl.
lt_excl[] = it_excl[].
IF i_refresh IS INITIAL.
MOVE i_text_icon TO gv_text_icon.
MOVE i_text_icon_v TO gv_text_icon_v.
IF sy-langu EQ 'E'.
MOVE 'Duplicate Nota Fiscal' TO gv_nf_label.
ELSEIF sy-langu EQ 'P'.
MOVE 'Duplicar Nota Fiscal' TO gv_nf_label.
ENDIF.
SET PF-STATUS '6001' EXCLUDING lt_excl.
ELSE.
CLEAR: gv_text_icon,
gv_text_icon_v.
ENDIF.
ENDFUNCTION.
2. Enhancement to display button in MIRO (please copy and paste in ABAP editor; couldn’t format it )
data: lt_bukrs type range of bukrs,
lv_nf type j_1bdocnum.
constants: lc_cmpny_code type rvari_vnam value ‘ZPTP_MIRO_CMPNY_DUPL_NF_CRE’,
lc_s type char1 value ‘S’.
field-symbols: <lfs_nfobjn1> type J_1BDOCNUM.
* Get the company codes from TVARVC table.
select sign
opti
low
high
from tvarvc
into table lt_bukrs
where name = lc_cmpny_code
and type = lc_s.
IF sy-subrc eq 0.
IF rbkpv-bukrs in lt_bukrs “Company code 1991
and akt_typ EQ c_trtyp_h. “Change mode
* Access the NF object number variable. This will be available always.
assign (‘(SAPLJ1BI)NFOBJN’) to <lfs_nfobjn1>.
IF <lfs_nfobjn1> is assigned.
IF <lfs_nfobjn1> is not initial or rbkpv-dummy3 is not initial.
rbkpv-dummy3 = ‘X’.
READ TABLE EXCL WITH KEY FUNKTION = fcoj1bn TRANSPORTING NO FIELDS.
IF SY-SUBRC NE 0. “The NF button is not excluded
IF f_nf_activ = x. “NF is active
CALL FUNCTION ‘ZPTP_MR1M_GUI_DUMMY_SET_GLOBAL’ “Set the PF status to include
EXPORTING “the duplicate NF button
I_TEXT_ICON = f_text_icon
I_TEXT_ICON_V = f_text_icon_v
TABLES
it_excl = excl[].
ENDIF.
ENDIF.
ENDIF.
ENDIF.
endif.
ENDIF.
ENDENHANCEMENT.
Dear Arindam Seth,
I need to add a new button to transaction MIRO, so I started to implement this solution.
On step 2 when I create the ENHANCEMENT 1 ZPTP_MIRO_NF_BUTTON in include LMR1MO1S I'm getting an error:
Program LMR1MO1S
Statement is not accessible.
In order to overcome this error, could you please provide the abap code for the enhancements of step 2 and 5?
Best regards,
Marta
Hello Marta,
Regarding enhancement in PBO of MIRO ( include LMR1MO1S ) the point of enhancement is
enhancement-point ehp604_init_6000_output_01 spots es_saplmr1m.
A new enhancement implementation needs to be done for this enhancement point provided by SAP.
The code to be written is provided in example 2 at the end.
Regarding PAI you have to enhance include LMR1MI3W
using enhancement spot
enhancement-point ehp604_fcode_6000_input_01 spots es_saplmr1m.
At this point we check the OK-CODE field to see if the custom button was indeed pressed and implement the actions needed.
Hope this helps.
Best regards,
Arindam
Hello Marta,
Your code should be like this:
"ENHANCEMENT-POINT EHP604_INIT_6000_OUTPUT_01 SPOTS ES_SAPLMR1M.
*$*$-Start: EHP604_INIT_6000_OUTPUT_01----------------------------------------------------------$*$*
ENHANCEMENT 1 MRM_CMPI_SFWS_SC_LMR1MO1S. "active version
* Change Management Posted Invoices "NCF
* Exclude "Cancel and Copy" if necessary
CALL METHOD cl_mrm_invoice_change=>check_invoice_change_allowed
EXPORTING
is_rbkpv = rbkpv
i_mir4_change = import_data_6000-mir4_change
i_archive_display = g_archive_display
CHANGING
c_menu_cancel_copy = g_menu_cancel_copy
cht_excl = excl[]
EXCEPTIONS
no_change_allowed = 1
OTHERS = 2.
IF sy-subrc <> 0.
SET PF-STATUS sy-pfkey EXCLUDING excl.
ENDIF.
ENDENHANCEMENT.
*$*$-End: EHP604_INIT_6000_OUTPUT_01----------------------------------------------------------$*$*
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZPTP_MIRO_NF_BUTTON. "inactive version
*
DATA: lt_bukrs type range of bukrs,
lv_nf type j_1bdocnum.
constants: lc_cmpny_code type rvari_vnam value 'ZPTP_MIRO_CMPNY_DUPL_NF_CRE',
lc_s type char1 value 'S'.
field-symbols: <lfs_nfobjn1> type J_1BDOCNUM.
* Get the company codes from TVARVC table.
select sign
opti
low
high
from tvarvc
into table lt_bukrs
where name = lc_cmpny_code
and type = lc_s.
IF sy-subrc eq 0.
IF rbkpv-bukrs in lt_bukrs "Company code 1991
and akt_typ EQ c_trtyp_h. "Change mode
* Access the NF object number variable. This will be available always.
assign ('(SAPLJ1BI)NFOBJN') to <lfs_nfobjn1>.
IF <lfs_nfobjn1> is assigned.
IF <lfs_nfobjn1> is not initial or rbkpv-dummy3 is not initial.
rbkpv-dummy3 = 'X'.
READ TABLE EXCL WITH KEY FUNKTION = fcoj1bn TRANSPORTING NO FIELDS.
IF SY-SUBRC NE 0. "The NF button is not excluded
IF f_nf_activ = x. "NF is active
CALL FUNCTION 'ZPTP_MR1M_GUI_DUMMY_SET_GLOBAL' "Set the PF status to include
EXPORTING "the duplicate NF button
I_TEXT_ICON = f_text_icon
I_TEXT_ICON_V = f_text_icon_v
TABLES
it_excl = excl[].
ENDIF.
ENDIF.
ENDIF.
ENDIF.
endif.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*"
ENDMODULE. " INIT_6000 OUTPUT
The ENDMODULE statement should be the last statement of the include.
You can send me a private message once you press the follow button in my profile.
Best regards,
Arindam
Nice nice 🙂 amusing and helpful 🙂
Hi Arindam,
Thanks a lot for sharing your findings.
Just had a query,
Well, now we will replace the Standard GUI Status with Z GUI Status,
but, how will we get the Standard Functalities, that SAP will add
to that particular TCode in next Upgrade ?
I believe we will not have to pay this cost.....!!!!!! 🙁 🙁
Or there is some work around ??
Looking for your help over it.
Thanking You All.
Hello Ankit,
Glad to be of help. 🙂
Unfortunately, since we are making a copy of the PF-status, there is no way the new functionality that SAP decides to add will be reflected in the copied one.
In this particular process, there is no work-around (this is comparable to copied standard programs). However, the cost here is very low, as to include the new functionality, we simply need to copy the new PF-status.
However, the probability of adding static buttons to the PF-status of MIRO (or as a matter of fact any standard transaction) is very low. It is more likely to be implemented dynamically by SAP.
This provision has already been accounted for by including/excluding dynamic buttons via the exclusion table.
Hence, the cost of further changes, if at all, are very low.
Hope this helps.
Best regards,
Arindam
Yaa Arindam,
Thanks again for your views, but I will still hasitate to use it, since that particular GUI status will run out of SAP Syncronization, at Upgrades.
Thanking You All.
Hello Arindam,
If I try to create an explicit enhancement inside the enhancement point EHP604_INIT_6000_OUTPUT_01 SPOTS ES_SAPLMR1M, it creates an enhancement ZPTP_MIRO_NF_BUTTON before the ENHANCEMENT 1 MRM_CMPI_SFWS_SC_LMR1MO1S.
I put the cursor on the enhancement point and choosed Edit -> Enhancements Operations -> Create Implementation.
ENHANCEMENT-POINT EHP604_INIT_6000_OUTPUT_01 SPOTS ES_SAPLMR1M. *$*$-Start: EHP604_INIT_6000_OUTPUT_01----------------------------------------------------------$*$* ENHANCEMENT 1 ZPTP_MIRO_NF_BUTTON. "inactive version *
(...)
ENDENHANCEMENT.
ENHANCEMENT 1 MRM_CMPI_SFWS_SC_LMR1MO1S. "active version * Change Management Posted Invoices "NCF * Exclude "Cancel and Copy" if necessary CALL METHOD cl_mrm_invoice_change=>check_invoice_change_allowed EXPORTING is_rbkpv = rbkpv i_mir4_change = import_data_6000-mir4_change i_archive_display = g_archive_display CHANGING c_menu_cancel_copy = g_menu_cancel_copy cht_excl = excl[] EXCEPTIONS no_change_allowed = 1 OTHERS = 2. IF sy-subrc <> 0. SET PF-STATUS sy-pfkey EXCLUDING excl. ENDIF.
ENDENHANCEMENT. *$*$-End: EHP604_INIT_6000_OUTPUT_01----------------------------------------------------------$*$*
ENDMODULE.
There must exist some way to do it after ENHANCEMENT 1 MRM_CMPI_SFWS_SC_LMR1MO1S.
Can you please check?
Thank you.
I've send you a message. Have you received it?
Best regards,
Marta Oliveira
Hello Marta,
I don't think it would make any difference, as long as you do not tamper with the standard flow.
Best regards,
Arindam Seth
Hi Arindam Seth:
Now i have one requirement to add the pushbutton at the Equiment master data Transaction code IE03 at toolbar. It's glad to see one doc published by you and seems can fulfill our requirement.
And i have some questions , and need your help.
1. I have noticed that you have created one FM to set the status. my question is that if i also implement this FM in the IE03, and the FM parameters is the same? or this FM is only to include the status into the standard program, and the parameters are not necessary?
2. i have checked the standard program, there was one module DYNPINIT in PBO (Include MIEQ0O00) , and no explict can be found after the standard code SET PF-STATUS. is it to say that i can implement one implicit enhancement after the SET PF-STATUS, then the standard status can be overwritten?
BTW, the illustration can not be displayed. Could you please restore the illustration or is it possible to sent the illustration to my mail box 10491564@qq.com.
your kindly reply will be appreciated.
Hello Hu Yonghang,
I am glad that it helped you.
Regarding your questions please find the answer below:
1. In case of MIRO, there were a few buttons in the PF-STATUS of the program that were dynamic. To include those in the custom PF-STATUS that I cfreated, the parameter of the FM were necessary. In case of IE03, if you do not have dynamic buttons, no need of any parameter. The FM is just to set the PF-STATUS of the screen to be displayed.
2. Yes, in case of no explicit enhancement points, you can implement implicit enhancement to overwrite the PF-STATUS of the next screen with your custom one. Please make sure that you set the PF-STATUS after the standard one has been set.
Regarding the illustration, my sincere apologies but I have no backups of the images. BTW, the images are only for showing the enhancement spots. I believe for IE03, you will find them useless.
Please let me know if you face any more problems.
Best Regards,
Arindam
Hello Arindam,
I have followed your steps to add a new button on MIR4 main screen and it has worked fine.
Thank you for sharing your knowledge, I have my requirement solved!
Hello Vicente,
Did you register the R3TR FUGR MR1M when creating the new PF-STATUS?
Best regards,
Marta Oliveira
Hello Marta,
I didn't register that object.
I have made a copy of pf-status 6000P of MR1M Function Group to my ZFUNCTION_GROUP.
Be careful if the status you want to create has dynamic elements. In that case, you have to do the function call in the way Arindam did in his example and you have to create variable fields on TOP include of your ZFUNCTION_GROUP and assign its names in those dynamic elements.
I hope this helps.
Hello,
I've created a function group ZPTP_MR1M_GUI where I defined my pf-status 6000. But now how can I call it in the enhancement? I tried with the code below but it goes to the standard user interface SAPLMR1M and not to SAPLZPTP_MR1M_GUI.
ENHANCEMENT 1 ZPTP_MIRO_NF_BUTTON. "active version
SET PF-STATUS '6000'.
ENDENHANCEMENT.
Can you explain the code that you used to call the new pf-status inside the enhancement?
Thank you.
To call your own pf-status you have to call your function module in the enhancement and then, you have to set it there.
ENHANCEMENT 1 Z_MIRO_NEW_BUTTON. "active version
CALL FUNCTION 'Z_MIRO_GUI_DUMMY_SET_GLOBAL'
EXPORTING
I_TEXT_ICON = f_text_icon
I_TEXT_ICON_V = f_text_icon_v
I_PROT_DYN = f_PROT_DYN
I_DPC_DYN = f_DPC_DYN
* I_REFRESH =
TABLES
IT_EXCL = excl[]
.
ENDENHANCEMENT.
Inside the function, I have reduced the code showed by Arindam like as follows:
FUNCTION z_miro_gui_dummy_set_global.
*"----------------------------------------------------------------------
*"*"Interfase local
*" IMPORTING
*" REFERENCE(I_TEXT_ICON) TYPE CHAR20 OPTIONAL
*" REFERENCE(I_TEXT_ICON_V) TYPE CHAR20 OPTIONAL
*" REFERENCE(I_PROT_DYN) TYPE SMP_DYNTXT OPTIONAL
*" REFERENCE(I_DPC_DYN) TYPE SMP_DYNTXT OPTIONAL
*" REFERENCE(I_REFRESH) TYPE FLAG OPTIONAL
*" TABLES
*" IT_EXCL OPTIONAL
*"----------------------------------------------------------------------
DATA: BEGIN OF lt_excl OCCURS 25,
funktion(10),
END OF lt_excl.
lt_excl[] = it_excl[].
IF i_refresh IS INITIAL.
MOVE i_text_icon TO gv_text_icon.
MOVE i_text_icon_v TO gv_text_icon_v.
MOVE i_prot_dyn to gv_prot_dyn.
MOVE i_dpc_dyn to gv_dpc_dyn.
SET PF-STATUS '6000P' EXCLUDING lt_excl.
ELSE.
CLEAR: gv_text_icon, gv_text_icon_v, gv_prot_dyn, gv_dpc_dyn.
ENDIF.
ENDFUNCTION.
Just define in top include the variables such as:
DATA:
f_text_icon(20) TYPE c,
f_text_icon_v(20) TYPE c,
f_prot_dyn TYPE smp_dyntxt,
f_dpc_dyn TYPE smp_dyntxt.
Hope it helps! 🙂
Hi Vincente:
May i know what's the usage fo the parameter I_TEXT_ICON I_TEXT_ICON_V I_REFRESH, and what kind of values should be populated into these parameters?
And what's the purpose for moving I_TEXT_ICON to global variable gv_text_icon?
Your kindly reply will be appreciated!
Hi Arindam,
Thanks for the post. Its really very helpful.
However, I am stuck at a point where I need to add a field to KKRV transaction but I am unable to find any screen-exits or enhancement spots for this transaction.
"In PBO we find a suitable spot where we can set the PF-status according to our requirement."
This is where i fail to proceed. Unfortunately I cannot view the pictures posted by you.
Do you have any suggestions?
Thanks,
Rics
hello i have the same requirment on ME23N, i'm trying to understand how to write my
z_me22n_gui_dummy_set_global, any clue please?
Thank you
don't worry. Solved it.
Regards
Any one can you help me to add the custom button on me29n transaction .