Wednesday, February 2, 2011

Automatically filling the field "Payment Terms" and disable the same while creating PO using the transaction ME22N

The requirement is to capture contract number wise payment terms while creating PO. This contract number is maintained in Z-Table along with vendor and payment terms etc. When we select the contract number the corresponding payment terms should automatically reflect in payment terms irrespective of the original value and make that field display mode immediately.

To add the contract number in the standard PO , we have to enhance the screen using the exit ‘MM06E005’.

Step1: Go to transaction CMOD to create the project.

Click on Create button and provide the meaningful description in the following screen.

Step2: Now click on’ Enhancement assignments’ button to add the PO enhancement.

Step3: Now click on ‘Component’ button and activate the project.

Double click on screen ‘0101’. Then it opens screen painter to add the contract number.

Now open the Layout editor by click on Layout button.

Select the contract number field from the table EKKO (Add the field contract number to the structure ‘CI_EKKODB’).

Save and activate.

Step4: Go back to ‘Flow logic’ and write the following code in POV (Process on Value-Request) to get the F4 help.


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 :  TYPE ekko.
  ASSIGN ('(SAPLMEPO)EKKO') TO .
IF sy-subrc EQ 0.
MOVE -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 .
MOVE :fs_return-fieldval TO ekko-contractno,
ekko-contractno TO -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 -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:  TYPE ekko,
TYPE MMPUR_FS.
ASSIGN ('(SAPLMEPO)EKKO') TO .
IF sy-subrc EQ 0.
IF -bsart EQ 'NB' AND
-contractno NE space.
READ TABLE my_fieldselection assigning
WITH KEY metafield = '11'.
IF sy-subrc EQ 0.
-fieldstatus = '*'.
ENDIF.
ENDIF.
ENDIF.

Step7: Now execute the transaction ME22N,

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

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites