Automatically filling the field "payment terms" and disable the same while creating PO using the transaction ME22N

...Previous

Write the following code for getting F4 help as shown below.

   

  TABLES ekko.
  DATA: fs_return TYPE ddshretval,
          it_return LIKE TABLE OF fs_return.
  DATA: BEGIN OF fs_value,
          vendorno  TYPE lifnr,
          contractno TYPE bbp_er_ctr_no,
          cstart     TYPE vbdat_veda,
          cend       TYPE vndat_veda,
          pterm      TYPE dzterm,
        END OF fs_value,
        it_value LIKE TABLE OF fs_value.
  DATA: w_lifnr  TYPE lifnr.
  FIELD-SYMBOLS : <fs_ekko> TYPE ekko.
  ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>.
  IF sy-subrc EQ 0.
    MOVE <fs_ekko>-lifnr TO w_lifnr.
  ENDIF.
  SELECT vendorno
         contractno
         con_start_dt
         con_end_dt
         payment_terms
    FROM zcontract
    INTO TABLE it_value
   WHERE vendorno EQ w_lifnr.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield               = 'CONTRACTNO'
*   DYNPPROG               = ' '
*   DYNPNR                 = ' '
*   DYNPROFIELD            = ' '
     value_org              = 'S'
* IMPORTING
*   USER_RESET             =
    TABLES
      value_tab              = it_value
      return_tab             = it_return
    EXCEPTIONS
      parameter_error        = 1
      no_values_found        = 2
      OTHERS                 = 3
            .
  IF sy-subrc EQ 0.
    READ TABLE it_return INTO fs_return INDEX 1.
    IF sy-subrc EQ 0.
      ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>.
      MOVE :fs_return-fieldval TO ekko-contractno,
            ekko-contractno TO <fs_ekko>-contractno.
      READ TABLE it_value INTO fs_value WITH KEY contractno = ekko-contractno.
      IF sy-subrc EQ 0.
        IF sy-subrc EQ 0.
          MOVE fs_value-pterm TO <fs_ekko>-zterm.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.  

Step5: Save and activate include.

When you execute the ME22N,  

When we select the contract number ‘9001’, the automatically the payment term field is filled with ‘0001’ as shown.  

Now it is in enable mode. We have to make it to display mode.

We can achieve this by enhance the method FS_GET in the method PBO of the class CL_BASIC_MODEL_VIEW_MM (Write the enhancement spot in the method FS_GET).  

Step6: Now create the enhancement spot in the method ‘FS_GET’ and write the following code as shown.  

FIELD-SYMBOLS: <fs_ekko> TYPE ekko,
               <fs_fieldselection> TYPE MMPUR_FS.
ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>.
IF sy-subrc EQ 0.
  IF <fs_ekko>-bsart EQ 'NB' AND
     <fs_ekko>-contractno NE space.
    READ TABLE my_fieldselection assigning <fs_fieldselection>
                                 WITH KEY metafield = '11'.
    IF sy-subrc EQ 0.
      <fs_fieldselection>-fieldstatus = '*'.
    ENDIF.
  ENDIF.
ENDIF.  

Step7: Now execute the transaction ME22N,

After selecting the contract number, the payment term field would be disabled.  

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image