Skip to Content

Create Custom Tab at Header in Purchase Requistion

As we all know we can create a custom tab at item level in Purchase Requistion and wonder is it possible to create custom tab in header lvel of Purchase Requistion ??

                       I have tried a lot by searching all the Function exists, Sreen exists and BADI but unable to find any enahcement . I even searched SAP forums but could not find any positive approach.At last I have found myself small information which lead to me to discover custom tab in Header level in Purchase Requistion.

              6-3-2014 3-58-41 PM.jpg

We can clealry see that CUSTOM TAB which we create ‘0111’ in Program SAPLXM02  is register here. So there may possibilty for custom tab in header level also.With this intennt I tried hard to explore, than I FMMEGUI_BUILD_REQ_HEADER_PLUGIN which enables custom tab at header level if we can create an implicit enahncment in it as shown below.

6-6-2014 12-38-47 AM.jpg

**–Declare a custom header view with ref to local class  LCL_CUST_HEADER_VIEW_MM of function pool MEGUI.

DATA: CUST_HEADER_VIEW   TYPE REF TO LCL_CUST_HEADER_VIEW_MM.

  CREATE OBJECT CUST_HEADER_VIEW
                EXPORTING im_dynpro         = ‘1227’               “Custom tab provided by SAP
                          im_prog                         = megui               “Function Group
                         im_foreign_prog            = ‘SAPLXM02’    “Main Program to create Custom Screen
                         im_foreign_dynpro        = ‘0999’.              “Custom screen ->Can have any no

  CALL METHOD CUST_HEADER_VIEW->set_label( ‘Custom Tab – Header ‘).    “Set Label as shown on screen
  CALL METHOD CUST_HEADER_VIEW->set_name( ‘Cust Header Tab’ ).          “Set a name to refer
  CALL METHOD CUST_HEADER_VIEW->set_struct_name( ).                             “Get default structure

  CALL METHOD header_view->add
    EXPORTING
      im_screen_view = CUST_HEADER_VIEW
      im_position    = 4.

  SET HANDLER CUST_HEADER_VIEW->if_observer_mm~handle_subject_changed
              FOR header_view.

  SET HANDLER header_view->if_observer_mm~handle_subject_changed FOR
              CUST_HEADER_VIEW.

                 Now, we need to create a screen in the program SAPLXM02, I shall leave this to you guys. We need to create implicit enhancement to method ‘TRANSPORT_FROM_MODEL’  of class LCL_CUST_HEADER_VIEW_MM  to view the custom tab at header level.

6-6-2014 12-55-09 AM.jpg              

  6-6-2014 12-58-33 AM.jpg

DATA: L1_HEADER        TYPE REF TO IF_PURCHASE_REQUISITION.
        
    FOREIGN_APPLICATION_OK = MMPUR_NO.
    MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
    CHECK NOT L1_HEADER IS INITIAL.
    FOREIGN_APPLICATION_OK = MMPUR_YES.
 
**—Export values to PBO of Custom Screen 999 of SAPLXM02- to use in PBO

      EXPORT L1_HEADER from L1_HEADER to MEMORY id ‘REq@Header_value’.
        
    EXIT.“Over write Standard Implementation –THIS IS MANDATORY

            Now, we are all set to call transaction ME51N to view Custom tab in Header level in Purchase Requisition

         6-6-2014 1-05-32 AM.jpg

             [ Now the data part is left to you, how to handle data at PAI , PBO and fetch from Table and Save into Table …….Hope this helps at least a bit]

DISCLAIMER: APOLOGIZE IF MY INFORMATION TOO OLD TO SHARE..!!

20 Comments
You must be Logged on to comment or reply to a post.
  • Hi Siva,

    Hope you are doing great.  I have a similar requirement where in I have to add a custom tab at PR header and add some custom field and update those fields to the table when we save the PR or do some changes to the PR. I followed your docuement and able to add the tab and fields to the custom tab. Now the problem i am facing here is when ever i am i am creating the PR and entering the custom fields it’s not updating into the table. and same is happeing for the PR change. Can you please help me where exactly i am missing the logic or please to send the code you have implemented the code for this requirement.

    Hoping for the reply from your side.

    Thanks and Regards,

    Mohammed Farooq

    • Hi Farooq,

                   Please share me your approach to save the entries, meanwhile I shall search my code and will update you.

                Code for saving entries would be very similar to the BADI screen enhancement ON PO/PR to store custom fields in Ztable/Standard table.

      Have a Nice day ..!!

      Regards,

      Siva

    • Hi Siva,

      I did steps  provided in your blog for adding  customtab,   Here custom tab  is added.

      Then  created   new screen  0999 of program SAPLXM02   and added   two custom fields.

       

      Next triggered ME53n Tran code, only  Custom tab screen  with out fields display.

      Please let me know how to display  fields, if fields display   how to store data into  EBAN .

       

      This  Eban   added tow  custom fields through CI_EBANDB

      Thanks,

      Sai

    • Hi Siva,

      Getting this message  when i use this code  in  enh LMEGUICIX

       


      SPAN {
      font-family: “Courier New”;
      font-size: 10pt;
      color: #000000;
      background: #FFFFFF;
      }
      .L0S33 {
      color: #4DA619;
      }
      .L0S52 {
      color: #0000FF;
      }
      .L0S55 {
      color: #800080;
      }
      DATAL1_HEADER TYPE REF TO IF_PURCHASE_REQUISITION.
      FOREIGN_APPLICATION_OK MMPUR_NO.
      MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
      CHECK NOT L1_HEADER IS INITIAL.
      FOREIGN_APPLICATION_OK MMPUR_YES.
      EXPORT L1_HEADER FROM L1_HEADER TO MEMORY ID ‘SAMPLE’.
      EXIT.

       

       

      Error message

      Filed   L1_HEADER Cannot be reference and cannot contain references

      Thanks,Sai

       

       

       

    • Hi Siva,

      Custom tab  displaying  but not custom fields, Please let me know  how issue resolved

      and  export  statement  giving  error

      DATA : cust_header_view type ref to LCL_CUST_HEADER_VIEW_MM.
      CREATE OBJECT cust_header_view
      EXPORTING im_dynpro         = ‘1227’
      im_prog           = megui
      im_foreign_prog   = ‘SAPLXM02’
      im_foreign_dynpro = ‘0999’.

      CALL METHOD cust_header_view->set_label( ‘Custom Tab- 3’ ).
      CALL METHOD cust_header_view->set_name( ‘Custom Header Tab’ ).
      CALL METHOD cust_header_view->set_struct_name( ).

      CALL METHOD header_view->add
      EXPORTING
      im_screen_view = cust_header_view
      im_position    = 1.

      SET HANDLER cust_header_view->if_observer_mm~handle_subject_changed
      FOR header_view.
      SET HANDLER header_view->if_observer_mm~handle_subject_changed FOR
      cust_header_view.

      another  enh
      DATA: L1_HEADER TYPE REF TO IF_PURCHASE_REQUISITION.
      FOREIGN_APPLICATION_OK = MMPUR_NO.
      MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
      CHECK NOT L1_HEADER IS INITIAL.
      FOREIGN_APPLICATION_OK = MMPUR_YES.
      *           EXPORT L1_HEADER from L1_HEADER to MEMORY id ‘sample’.
      *        EXPORT L1_HEADER TO MEMORY id ‘SAMPLE’.
      *      EXIT.

       

      thanks,

      Sai

  • Hi Shiva,

     

    I am unable to create a screen in above approach..Kindly explain me bit clear and kindly  share the datailed documantaion.

     

    Regards,

    Sunil kumar

  • Hi siva,

    I followed everything how u mentioned and tab is appearing in me51n but in ur last line code of exporting showing error “In EXPORT/IMPORT and ASSERT…FIELDS, “L2_HEADER” cannot be or contain references”

    it is not passing the values even if u write some other statement to get data from the enhancement which you provided

    and it is not updating the information in eban table for custom field 

    • Hi Sreekanth,

      Custom tab  displaying  but not custom fields, Please let me know  how issue resolved

      and  export  statement  giving  error

      DATA : cust_header_view type ref to LCL_CUST_HEADER_VIEW_MM.
      CREATE OBJECT cust_header_view
      EXPORTING im_dynpro         = ‘1227’
      im_prog           = megui
      im_foreign_prog   = ‘SAPLXM02’
      im_foreign_dynpro = ‘0999’.

      CALL METHOD cust_header_view->set_label( ‘Custom Tab- 3’ ).
      CALL METHOD cust_header_view->set_name( ‘Custom Header Tab’ ).
      CALL METHOD cust_header_view->set_struct_name( ).

      CALL METHOD header_view->add
      EXPORTING
      im_screen_view = cust_header_view
      im_position    = 1.

      SET HANDLER cust_header_view->if_observer_mm~handle_subject_changed
      FOR header_view.
      SET HANDLER header_view->if_observer_mm~handle_subject_changed FOR
      cust_header_view.

      another  enh
      DATA: L1_HEADER TYPE REF TO IF_PURCHASE_REQUISITION.
      FOREIGN_APPLICATION_OK = MMPUR_NO.
      MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
      CHECK NOT L1_HEADER IS INITIAL.
      FOREIGN_APPLICATION_OK = MMPUR_YES.
      *           EXPORT L1_HEADER from L1_HEADER to MEMORY id ‘sample’.
      *        EXPORT L1_HEADER TO MEMORY id ‘SAMPLE’.
      *      EXIT.

       

      Thanks,

      Sai

  • HI Siva,

    Hope you are doing great.  I have a similar requirement where in I have to add a custom tab at PR header and add Push button in that tab. when the user click on that push button print preview will display. please help me .how can I do this…

     

    Thanks in advance

    kamal

     

     

     

    • Hi  ,

      I did steps  provided in the blog for adding  customtab,   Here custom tab  is added.

      Then  created   new screen  0999 of program SAPLXM02   and added   two custom fields.

       

      Next triggered ME53n Tran code, only  Custom tab screen  with out fields display.

      Please let me know how to display  fields, if fields display   how to store data into  EBAN .

       

      This  Eban   added tow  custom fields through CI_EBANDB

      Thanks,

      Sai

  • Hi Siva,

    The given inputs are helpful.

    Can you please elaborate on how the header values can be saved in the include CI_EBANDB of  table EBAN.

    Regards,

    Shabbir

     

  • hi,

    i did the same step as given in the blog but i have one issue custom tab is coming and i made the screen in SAPLXM02 with screen no and when i define the screen no in  (im_foreign_dynpro        = ‘0999’).

    then i am not getting the custom field in the tab.

    Please help me out on this its a very urgent issue

      • Hi  ,

        I did steps  provided in the blog for adding  customtab,   Here custom tab  is added.

        Then  created   new screen  0999 of program SAPLXM02   and added   two custom fields.

         

        Next triggered ME53n Tran code, only  Custom tab screen  with out fields display.

        Please let me know how to display  fields, if fields display   how to store data into  EBAN .

         

        This  Eban   added tow  custom fields through CI_EBANDB

        Thanks,

        Sai

      • Please let me  know  clearly  how you resolve issue.

        in program


        SPAN {
        font-family: “Courier New”;
        font-size: 10pt;
        color: #000000;
        background: #FFFFFF;
        }
        .L0S31 {
        font-style: italic;
        color: #808080;
        }
        .L0S52 {
        color: #0000FF;
        }
        .L0S55 {
        color: #800080;
        }
        DATAL1_HEADER TYPE REF TO IF_PURCHASE_REQUISITION.
        FOREIGN_APPLICATION_OK MMPUR_NO.
        MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
        CHECK NOT L1_HEADER IS INITIAL.
        FOREIGN_APPLICATION_OK MMPUR_YES.
              EXPORT L1_HEADER FROM L1_HEADER TO MEMORY ID ‘SAMPLE’.
        *       EXPORT L1_HEADER  TO MEMORY id ‘SAMPLE’.
        EXIT.

         

         

        getting  error message as :

        Filed:    L1_header   cannot be ref and contain ref vari.

        2)  getting  empty   custom tab  evethough   field   created   in  0999  screen

        Thank,

        Sai

    • Hi  Shagun,

      I am getting  same issue  ,

      code


      SPAN {
      font-family: “Courier New”;
      font-size: 10pt;
      color: #000000;
      background: #FFFFFF;
      }
      .L0S32 {
      color: #3399FF;
      }
      .L0S33 {
      color: #4DA619;
      }
      .L0S52 {
      color: #0000FF;
      }
      .L0S55 {
      color: #800080;
      }
      .L0S70 {
      color: #808080;
      }
       DATA cust_header_view type ref to LCL_CUST_HEADER_VIEW_MM.
      CREATE OBJECT cust_header_view
      EXPORTING im_dynpro         ‘1227’
      im_prog           megui
      im_foreign_prog   ‘SAPLXM02’
      im_foreign_dynpro ‘0999’.

      CALL METHOD cust_header_view->set_label‘Custom Tab- 3’ ).
      CALL METHOD cust_header_view->set_name‘Custom Header Tab’ ).
      CALL METHOD cust_header_view->set_struct_name).

      CALL METHOD header_view->add
      EXPORTING
      im_screen_view cust_header_view
      im_position    1.

      SET HANDLER cust_header_view->if_observer_mm~handle_subject_changed
      FOR header_view.
      SET HANDLER header_view->if_observer_mm~handle_subject_changed FOR
      cust_header_view.

       

       

      No  custom  fields  displaying,  while creating screen  are you  used  subecreen  or  normal  screen.

       

      Thanks,

      Ravi

  • Hi,

    Created  fields  in program SAPLXM02  for screen  no:0999 but when i trigger Me53n  Tran code:  custom tab  screen is there but not  fields are not there.

     

    Please give me input,  i did n’t get exit  command where to place.

    Thanks,

    Sai

  • Hi,

    I got a similar kind of requirement to add custom tab at header level in ME51N/ME52N/ME53N.

     

    I have followed the steps given by Siva, but i’m not able to save the values in EBAN table. Could you please help me, how to update EBAN table.

     

    Regard

    Balu