Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Adding custom fields to the Purchase Order transaction ME51N ITEM LEVEL.

$
0
0

Enhancement for ME51N Is : MEREQ001

 

Go to SMOD and search for Enhancement.

 

If enhancement is know then got to CMOD.

 

Go to CMOD and create Project For Example : ZMM_PR.

 

 

Click CREATE button and following Screen appears.

 

 

Give Short Text and Go to Enhancement assignment and give Enhancement for ME51N as MEREQ001 and Save.

 

 

Now go to Components and following Screen appears.

 

 

We can find Function Exit , Screen Exit, Include tables.

 

Now go to Include tables : Double click on CI_EBANDB Add ZZKOSTL Field and activate the STRUCTURE.


 

Now go to Screen Exit.

 

Double click on SAPLMEGUI Program and Create the Program.

After Program Create Screen with Field name EBAN-ZZKOSTL

 

 

 

And Activate it.

Now go to Function Exit


     EXIT_SAPLMEREQ_001
     EXIT_SAPLMEREQ_003

 

These are the two Function exits for ME51N.

 

EXIT_SAPLMEREQ_001 is the PBO .

 


EXIT_SAPLMEREQ_003 is the PAI.

 

Implementation in EXIT_SAPLMEREQ_001 --- PBO.

 

Double click on EXIT_SAPLMEREQ_001

You will find INCLUDE ZXM02U01 in Source code tab.

Now Doble click on Include FIle.

 

Now According to you Requirement add Your Custom Code.

 

I am adding Custom Field i.e COST CENTER - KOSTL .

 


TABLES : CI_EBANDB,
                  EBAN.

DATA :   L_MEREQ_ITEM  TYPE  MEREQ_ITEM,
                  L_HEADER            TYPE  REF TO IF_PURCHASE_REQUISITION,
                  L_EDIT                   TYPE  CHAR1,
                  T_ENQ                    TYPE  TABLE OF SEQG3,
                  L_GARG                 TYPE  EQEGRAARG,
                  L_HEAD                 TYPE  MEREQ_HEADER,
                  L_AKTVT              TYPE  AKTVT.


IF SY-TCODE EQ 'ME51N' OR SY-TCODE EQ 'ME52N' OR SY-TCODE EQ 'ME53N'.
        IF IM_REQ_ITEM IS INITIAL.
               CLEAR: CI_EBANDB.
        ELSE.
               L_MEREQ_ITEM = IM_REQ_ITEM->GET_DATA( ).
     MOVE-CORRESPONDING L_MEREQ_ITEM TO CI_EBANDB.

     EBAN-ZZKOSTL = L_MEREQ_ITEM-ZZKOSTL.

* Check Mode (Display/Edit)
     CALL METHOD IM_REQ_ITEM->GET_ACTIVITY
       RECEIVING
         RE_AKTVT = L_AKTVT.
*     * EXPORT MODE TO MEMORY
     EXPORT L_AKTVT TO MEMORY ID 'EDIT_MODE'.


   ENDIF.


        L_MEREQ_ITEM-ZZKOSTL = EBAN-ZZKOSTL.


ENDIF.

 

*------------------------------------------------------------------------------------

 

Implementation in EXIT_SAPLMEREQ_003--PAI

 


DATA : L_MEREQ_ITEM TYPE MEREQ_ITEM,
           L_AKTVT TYPE AKTVT.

IF SY-TCODE EQ 'ME51N' OR SY-TCODE EQ 'ME52N' OR SY-TCODE EQ 'ME53N'.


        IF NOT IM_REQ_ITEM IS INITIAL.


               L_MEREQ_ITEM = IM_REQ_ITEM->GET_DATA( ).

               L_AKTVT = IM_REQ_ITEM->GET_ACTIVITY( ).


* Display mode
     IF L_AKTVT EQ 'A'.


* Create Mode or Change mode
     ELSEIF L_AKTVT EQ 'V' OR L_AKTVT EQ 'H'.
*       * COPY DATA FROM SCREEN TO STRUCTURE
       IF EBAN-ZZKOSTL NE CI_EBANDB-ZZKOSTL.
       

           L_MEREQ_ITEM-ZZKOSTL = EBAN-ZZKOSTL.
           EX_CHANGED = 'X'.


       ENDIF.
* Move data to table EBAN


       IF EX_CHANGED EQ 'X'.
        

          CALL METHOD IM_REQ_ITEM->SET_DATA( L_MEREQ_ITEM ).
     

       ENDIF.
     ENDIF.
   ENDIF.
ENDIF.

 

*-----------------------------------------------------------------

 

The out put will be as follows.

 


 

...


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>