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.

 

PBO_Enh_point.PNG

 

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.

 

zptp_mr1m_gui_dummy_set_global.PNG

 

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.

 

PAI_Enh_point.PNG

 

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.