Wednesday, July 25, 2012

Grey out fields on ME21N/ME22N/ME23N

How to grey out fields on ME21N/ME22N/ME23N

For certain Purchase orders, based on some condition, we need to grey out the fields NETPR & KBETR.

In order to do this, we need to find the right BADI or the right user exit to code our functionality. For this debug tool is a must to know where and how these fields are populated on the purchase order screen.

This functionality can be achieved by following the below steps.

For the PO creation/change screen below is the solution to gray out the required fields (NETPR & KBETR)

1. for NETPR:

The field catalog that fills NETPR is TC_1211 Actually in standard program SAPLMEGUI, there is a call to the FM MEGUI_BUILD_PO_ITEMOV_PLUGIN.. Inside that, in line 44, TC_1211 gets populated. This contains all field catalog values. So in BADI, code to disable field NETPR by reading values using field symbols.

In SE19:

Create Implementation — > Classic BADI –> ME_ACTV_CANCEL_PO –> Implementation name ZCL_IM_TEST

In method CHECK_ACTIVITY code the following:

Method IF_EX_ME_ACTV_CANCEL_PO~CHECK_ACTIVITY.
FIELD-SYMBOLS :<fs>        TYPE ANY TABLE,
<ls>        TYPE ANY,
<lr_screen> TYPE screen.

ASSIGN (‘(SAPLMEGUI)TC_1211-COLS’) TO <fs>.
IF sy-subrc IS INITIAL.
LOOP AT <fs> ASSIGNING <ls>.
ASSIGN COMPONENT ’SCREEN’ OF STRUCTURE <ls> TO <lr_screen>.
IF <lr_screen>-name = ’MEPO1211-NETPR’.
<lr_screen>-input = 0.
ENDIF.
ENDLOOP.
ENDIF.

endmethod.

Activate the implementation. NETPR will be disabled in the header when u try to create or change purchase order.

2. for KBETR

In Screen 6201 of program SAPLV69A -> LV69AO03à Module FELDAUSWAHL, there is a User Exit: PERFORM userexit_field_modification.

Inside this EXIT, change the contents of TCTRL_KONDITIONEN-COLS [6]-SCREEN-INPUT to 0. KBETR will get grayed out.

6 comments:

  1. Hi, I was try it but "1. for NETPR: " dose not work, could you told me how you completed it ? very thank.

    ReplyDelete
  2. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor led live training in SAP ABAP, kindly Contact GRONYSA
    Click for SAP ABAP Course details SAP ABAP
    GRONYSA Offer World Class Virtual Instructor led training on SAP ABAP. We have industry expert trainer. We provide Training Material and Software Support. GRONYSA has successfully conducted 10,000 + trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Nitesh Kumar
    GRONYSA
    E-mail: nitesh.kumar@gronysa.com
    Ph: +91-9632072659/ +1-2142700660
    www.GRONYSA.com



    ReplyDelete
  3. Tried the solution for Net price. Its not working.

    ReplyDelete
  4. MODIFY SCREEN is missing once the value is set to 0.
    Also, to disable, -activ = abap_false.

    This is working.

    ReplyDelete
    Replies
    1. Where you have written.. it is not screen.. how Modify screen worked for you?

      Delete
  5. Can any one help me for Doc.date must enable in ME21N screen. As of now in ME21N it's non-editable mode

    ReplyDelete