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 hide Tabstrip created in Screen Exit of MEREQ001 for particular Conditions

biswajit_das6
Participant
0 Kudos

Hi Exparts

we have used enhancement  MEREQ001 for Screen exit

                Screen exit                    SAPLMEGUI                      0014 SUB0     SAPLXM02                       0111. Here we have created a tabstrip.

Now our requirement is for particular condition we have to hide the tabstrip . Is there any way we can do that?

Thanks & regards,

Biswajit

1 ACCEPTED SOLUTION

nomssi
Active Contributor
0 Kudos

Hello Biswajit,

the tabstrip will be hidden if ALL fields on the subscreen are invisible, so you must conditionally change the visibility of fields on the subscreen.

This can be done for custom fields using BAdI ME_PROCESS_REQ_CUST methods, e.g. FIELDSELECTION_ITEM( ), or by implementing a LOOP AT SCREEN / MODIFY SCREEN in the subscreen PBO. Someone proposed to  replace the whole subscreen with another empty one.

regards,

JNN

P.S: I have reviewed Arindam's comment and I agree. My proposed solution will not work with the standard customer screen. So I decided to propose something I have tried that actually works, you will decide if it is worth the effort to implement.

Create your own additional customer tab instead of using screen 0111 in function group XM02. There is a document method for PO customer  tab. The same method can be reused for purchase requisition if you use source code plugins(implicit enhancements) to add the missing standard code.

You must:

- implement BAdI ME_GUI_PO_CUST and ME_PROCESS_PO_CUST and follow the logic to implement a new customer tab in the PO item.

This involves the steps of

- creating a custom function group with your custom screen (say 0111) and 2 function module (POP / PUSH) to get/set the screen data, copy the standard PBO&PAI logic in screen from the standard (include LMEVIEWSF01, logic similar to the PO custom tab)

- implement the methods of BAdI ME_GUI_PO_CUST

1) Subscribe( ) - with im_application = 'REQ' / im_element = 'ITEM' -> publish custom tabstrib for ME5xN transactions

2) Map_dynpro_fields( )

3) Transport_from_model( )

4) Transport_to_dynp( )

5) Transport_from_dynp( )

6) Transport_to_model( )

- implement the methods of BAdI ME_PROCESS_REQ_CUST

1) Initialize( )

2) Open( )

3) Process_Header( )

4) Process_item( )

5) Fieldselection_Item( ) <-- Field suppression / input / display logic for ME5xNn transaction

All those steps are the similar to the one needed to create a custom tab in the purchase order item. Search the forum for help if needed.

Now, since SAP did not release the ME_GUI_PO_CUST for requisition, I have identified 3 changes needed in the standard in function group MEGUI. They are documented anywhere else, so I am writing down my source code for here (applies to item tab only, not to header tabs):

1) Function module MEGUI_BUILD_REQ_ITEM_PLUGIN

Add an implicit enh. implementation at the END to register the custom tab, e.g.

DATA lt_subscribers TYPE mepo_t_subscribers.

DATA ls_subscriber LIKE LINE OF lt_subscribers.

DATA lo_badi_view TYPE REF TO lcl_cust_badi_view.

DATA li_observer TYPE REF TO if_observer_mm.

  li_observer ?= l_model_holder.

  IF li_observer IS BOUND.

    lt_subscribers  = lcl_cust_badi_view=>subscribe( im_application = 'REQ'

                                                                          im_element = 'ITEM' ).

     LOOP  AT lt_subscribers INTO ls_subscriber

        WHERE name IS NOT INITIAL

             AND dynpro IS NOT INITIAL

             AND program IS NOT INITIAL

            AND struct_name IS NOT INITIAL

            AND label IS NOT INITIAL.

          CREATE OBJECT lo_badi_view

               EXPORTING

                   im_dynpro = ls_subscriber-dynpro

                   im_prog = ls_subscriber-program

                   im_height = ls_subscriber-height

                   im_application = 'REQ'

                  im_element = 'ITEM'.

*          Setup / Register the new custom view

           lo_badi_view->set_struct_name( im_struct_name = ls_subscriber-struct_name

                                                                        im_application = po_views ).                 " <-- global in function group

           lo_badi_view->set_label( ls_subscriber-label ).

           lo_badi_view->set_name( ls_subscriber-name ).

           item_view->add( im_screen_view = lo_badi_view

                                          im_position = ls_subscriber-position ).

           SET HANDLER:

               lo_badi_view->if_observer_mm~handle_subject_changed FOR item_view,

               item_view->if_observer_mm~handle_subject_changed FOR lo_badi_view.

      ENDLOOP.

  ENDIF.

2) in Local class LCL_CUST_BADI_VUEW, 2 methods must be enhanced - Include LMEGUICIO

2a) Method TRANSPORT_TO_MODEL( )

Implicit enhancement at the begining to start transport for customer field in case of 'REQ'

DATA li_reqitem TYPE REF TO if_purchase_requisition_item.

    CHECK my_badi_active NE space.

    mmpur_dynamic_cast li_reqitem my_model.

     IF li_reqitem IS BOUND.

          my_badi_instance->transport_to_model( im_name = me->name

                                                                                      im_model = my_model ).

          RETURN.

     ENDIF.

2b) Method CAN_ACCEPT( )

Implicit enhancement at the begining to add application 'REQ'

DATA li_reqitem TYPE REF TO if_purchase_requisition_item.

  CASE my_application.

       WHEN 'REQ'.

           CASE my_element.

               WHEN 'ITEM'.

                    mmpur_dynamic_cast li_reqitem im_model.

                    IF li_reqitem IS BOUND.

*                    can accept!!

                       RETURN.

                    ENDIF.

          ENDCASE. 

  ENDCASE.

With this logic, you can add you custom purchase requisition item tab ME5xN transaction. The tab will be disabled if no fields are visible.

There, I have published it and I hope it helps someone.

best regards,

JNN

9 REPLIES 9

arindam_m
Active Contributor
0 Kudos

Hi,

Not clear on what you want you can deactivate the enhancement if you want to.

Cheers,

Arindam

0 Kudos

Our requirement is based on valuation ( for Purchase requisition item label) that tabstip should be visible.

say for lline item 10 if the valuation is $25000 or more than that tabstrip will be appear if the line item 20 contains less value than it will not be appeared.

Thanks,

Biswajit

arindam_m
Active Contributor
0 Kudos

Hi,

In that case the tab strip is a part of a screen which is called by CALL SCREEN 'nnnn'  where nnnn is the number. In you case you might have to design and call alternate screen that is designed without this Tab.

But as it is standard T-Code and some restriction is applicable so might not be possible to hide it conditionally. The documentation says

If you use the enhancement, you must create and generate screen 111 i

function group XM02 (even if the screen is not to be used).

You must flag the screen as a subscreen, The screen does not have to

contain fields but it must exist to prevent the program terminating.

Cheers,

Arindam

nomssi
Active Contributor
0 Kudos

Hello Biswajit,

the tabstrip will be hidden if ALL fields on the subscreen are invisible, so you must conditionally change the visibility of fields on the subscreen.

This can be done for custom fields using BAdI ME_PROCESS_REQ_CUST methods, e.g. FIELDSELECTION_ITEM( ), or by implementing a LOOP AT SCREEN / MODIFY SCREEN in the subscreen PBO. Someone proposed to  replace the whole subscreen with another empty one.

regards,

JNN

P.S: I have reviewed Arindam's comment and I agree. My proposed solution will not work with the standard customer screen. So I decided to propose something I have tried that actually works, you will decide if it is worth the effort to implement.

Create your own additional customer tab instead of using screen 0111 in function group XM02. There is a document method for PO customer  tab. The same method can be reused for purchase requisition if you use source code plugins(implicit enhancements) to add the missing standard code.

You must:

- implement BAdI ME_GUI_PO_CUST and ME_PROCESS_PO_CUST and follow the logic to implement a new customer tab in the PO item.

This involves the steps of

- creating a custom function group with your custom screen (say 0111) and 2 function module (POP / PUSH) to get/set the screen data, copy the standard PBO&PAI logic in screen from the standard (include LMEVIEWSF01, logic similar to the PO custom tab)

- implement the methods of BAdI ME_GUI_PO_CUST

1) Subscribe( ) - with im_application = 'REQ' / im_element = 'ITEM' -> publish custom tabstrib for ME5xN transactions

2) Map_dynpro_fields( )

3) Transport_from_model( )

4) Transport_to_dynp( )

5) Transport_from_dynp( )

6) Transport_to_model( )

- implement the methods of BAdI ME_PROCESS_REQ_CUST

1) Initialize( )

2) Open( )

3) Process_Header( )

4) Process_item( )

5) Fieldselection_Item( ) <-- Field suppression / input / display logic for ME5xNn transaction

All those steps are the similar to the one needed to create a custom tab in the purchase order item. Search the forum for help if needed.

Now, since SAP did not release the ME_GUI_PO_CUST for requisition, I have identified 3 changes needed in the standard in function group MEGUI. They are documented anywhere else, so I am writing down my source code for here (applies to item tab only, not to header tabs):

1) Function module MEGUI_BUILD_REQ_ITEM_PLUGIN

Add an implicit enh. implementation at the END to register the custom tab, e.g.

DATA lt_subscribers TYPE mepo_t_subscribers.

DATA ls_subscriber LIKE LINE OF lt_subscribers.

DATA lo_badi_view TYPE REF TO lcl_cust_badi_view.

DATA li_observer TYPE REF TO if_observer_mm.

  li_observer ?= l_model_holder.

  IF li_observer IS BOUND.

    lt_subscribers  = lcl_cust_badi_view=>subscribe( im_application = 'REQ'

                                                                          im_element = 'ITEM' ).

     LOOP  AT lt_subscribers INTO ls_subscriber

        WHERE name IS NOT INITIAL

             AND dynpro IS NOT INITIAL

             AND program IS NOT INITIAL

            AND struct_name IS NOT INITIAL

            AND label IS NOT INITIAL.

          CREATE OBJECT lo_badi_view

               EXPORTING

                   im_dynpro = ls_subscriber-dynpro

                   im_prog = ls_subscriber-program

                   im_height = ls_subscriber-height

                   im_application = 'REQ'

                  im_element = 'ITEM'.

*          Setup / Register the new custom view

           lo_badi_view->set_struct_name( im_struct_name = ls_subscriber-struct_name

                                                                        im_application = po_views ).                 " <-- global in function group

           lo_badi_view->set_label( ls_subscriber-label ).

           lo_badi_view->set_name( ls_subscriber-name ).

           item_view->add( im_screen_view = lo_badi_view

                                          im_position = ls_subscriber-position ).

           SET HANDLER:

               lo_badi_view->if_observer_mm~handle_subject_changed FOR item_view,

               item_view->if_observer_mm~handle_subject_changed FOR lo_badi_view.

      ENDLOOP.

  ENDIF.

2) in Local class LCL_CUST_BADI_VUEW, 2 methods must be enhanced - Include LMEGUICIO

2a) Method TRANSPORT_TO_MODEL( )

Implicit enhancement at the begining to start transport for customer field in case of 'REQ'

DATA li_reqitem TYPE REF TO if_purchase_requisition_item.

    CHECK my_badi_active NE space.

    mmpur_dynamic_cast li_reqitem my_model.

     IF li_reqitem IS BOUND.

          my_badi_instance->transport_to_model( im_name = me->name

                                                                                      im_model = my_model ).

          RETURN.

     ENDIF.

2b) Method CAN_ACCEPT( )

Implicit enhancement at the begining to add application 'REQ'

DATA li_reqitem TYPE REF TO if_purchase_requisition_item.

  CASE my_application.

       WHEN 'REQ'.

           CASE my_element.

               WHEN 'ITEM'.

                    mmpur_dynamic_cast li_reqitem im_model.

                    IF li_reqitem IS BOUND.

*                    can accept!!

                       RETURN.

                    ENDIF.

          ENDCASE. 

  ENDCASE.

With this logic, you can add you custom purchase requisition item tab ME5xN transaction. The tab will be disabled if no fields are visible.

There, I have published it and I hope it helps someone.

best regards,

JNN

Former Member
0 Kudos

You can use the LOOP AT SCREEN statement.

Example:

LOOP AT SCREEN.

   "Here you check your conditions

   "If true:

   IF screen-name = 'YOUR_TAB_NAME'.

     screen-invisible = '1'.

     screen-active = '0'.

   ENDIF.

  MODIFY SCREEN.

ENDLOOP.

Do it on PBO of your subscreen.

Use EXIT_SAPLMEREQ_001 user-exit to retrieve data from Purchase Requisition and be able to check your condition.

krish469
Contributor
0 Kudos

@Biswajit Das - Let me know if I read your question correctly - You want to Enable/Disable a Custom Tab in Item View detail Tabstrip of Purchase Requistion. Is it right ??

--> I was searching for the same thing for past couple of days and at last I have found it.Here it is.

-->Create an Implicit enhancement in Class      -   CL_TABSTRIP_VIEW_MM

                                                             Method  -   PBO

-->Here is the sample Code

if CONDITION  = 'SATISFIED'.

CLEAR:l_cnt_tabs.

                 LOOP AT SCREEN.

                       IF SCREEN-GROUP1 EQ 'TAB'.

                             ADD 1 TO l_cnt_tabs.


                    IF l_cnt_tabs <= MAX_SUBVIEWS AND l_cnt_tabs <= l_cnt_views.


                    READ TABLE SUBVIEWS INTO ls_subview INDEX l_cnt_tabs.


                    IF SY-SUBRC EQ 0.

                         if ls_subview-view->is_active( im_ask_parent = mmpur_no )

                                           eq mmpur_yes.



                     CALL METHOD ls_subview-VIEW->GET_LABEL

                             IMPORTING EX_LABEL = L_LABEL.


**--Disable the CUSTOM TAB based on CONDITION

                     IF l_label eq 'Customer Tab'.

                               SCREEN-INVISIBLE = 1.

                               SCREEN-ACTIVE    = 0.

                     ENDIF.


                     PERFORM SET_VALUE IN PROGRAM (PROG) USING

                                          SCREEN-NAME L_LABEL.

                 ENDIF.

                ENDIF.

                ENDIF.

                    MODIFY SCREEN.

                ENDIF.

                ENDLOOP. "LOOP AT SCREEN.

ENDIF.

0 Kudos

Hi Biswajit,

I applied the logic given by you, but now i am facing some other issue, I am able to hide the custom tab , but what happens is the standatd tab Material Data gets replaced by fields of Custom tab some times.

PFB details :

If my last open tab was custom tab and then i exist from the transaction ME51N and

then try to enter again for creating a new  PR for some condition which should not have custom atb displayed, in that case the custom tab is not visible , but instead its fields are displayed in Material Data standard Tab.

How do i get rid of it. i copied the same code given by you as it is.

Thanks

0 Kudos

Hello Biswajit Das

Could you tell me how you made about the tabstrip in MEREQ001 for ME51N/ME54N?

Thank you.

Rafael Escobar