Skip to Content
0
Former Member
Sep 20, 2007 at 07:50 AM

how to add logic in FM in User exit

69 Views

Hi All,

here i m giving my Function Module Logic here.

FUNCTION zqm_upd_insp_lot.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_QALS) LIKE QALS STRUCTURE QALS

*" VALUE(I_QAVE) LIKE QAVE STRUCTURE QAVE OPTIONAL

*" EXPORTING

*" REFERENCE(E_QALS) LIKE QALS STRUCTURE QALS

*" REFERENCE(E_ACTIVE) LIKE QM00-QKZ

*" VALUE(E_SUBRC) LIKE SY-SUBRC

*" TABLES

*" E_PROTOCOL STRUCTURE RQEVP OPTIONAL

*"----


DATA : lv_pono TYPE ekko-ebeln,

lv_mnfr TYPE wyt3-lifn2,

lv_lifnr TYPE ekko-lifnr,

lv_ekorg TYPE ekko-ekorg,

lv_ktext TYPE qals-ktextlos,

lv_prod_off TYPE qals-zzprodoff,

lv_po_valid TYPE c,

lv_pdoff_valid TYPE c.

CONSTANTS: lc_active TYPE qm00-qkz VALUE 'X',

lc_comma(1) TYPE c VALUE ','.

  • I_QALS-KTEXTLOS will contain value of purchase order number

CLEAR : lv_pono,

lv_ktext,

lv_prod_off.

MOVE i_qals-ktextlos TO lv_ktext.

CONDENSE lv_ktext NO-GAPS.

SPLIT lv_ktext AT lc_comma INTO lv_pono lv_prod_off.

TRANSLATE lv_prod_off TO UPPER CASE.

CLEAR : lv_pdoff_valid,

lv_po_valid.

  • Validate purchase order number

PERFORM f_validate_po USING lv_pono

CHANGING lv_po_valid.

  • Validate production office

PERFORM f_validate_prod_off USING lv_prod_off

CHANGING lv_pdoff_valid.

IF lv_pdoff_valid NE gc_valid

OR lv_po_valid NE gc_valid.

  • Send a message to user and allow the user to enter new PO number

  • and production office.

PERFORM f_process_invalid_po_pdoff USING lv_po_valid

lv_pdoff_valid

lv_pono

lv_prod_off.

ENDIF.

CLEAR lv_ktext.

IF NOT lv_pono IS INITIAL

AND NOT lv_prod_off IS INITIAL.

CONCATENATE lv_pono lc_comma lv_prod_off INTO lv_ktext.

ELSEIF NOT lv_prod_off IS INITIAL

AND lv_pono IS INITIAL.

CONCATENATE lv_pono lc_comma lv_prod_off INTO lv_ktext.

ELSEIF NOT lv_pono IS INITIAL

AND lv_prod_off IS INITIAL .

lv_ktext = lv_pono.

ENDIF.

  • If po is in initial,Invalid OR No purchase order exists. So

  • only update Manufacturer field.

IF ( lv_pono IS INITIAL

AND lv_prod_off IS INITIAL )

OR ( lv_pono IS INITIAL )."Invaild PO and production office

  • Get 'Reference to other vendor' value

PERFORM f_get_manufacturer USING i_qals-lifnr

CHANGING lv_mnfr.

IF NOT lv_mnfr IS INITIAL

OR NOT lv_prod_off IS INITIAL .

  • Update Manufacturer

MOVE i_qals TO e_qals.

e_qals-hersteller = lv_mnfr.

e_qals-zzprodoff = lv_prod_off.

e_qals-ktextlos = lv_ktext.

e_active = lc_active.

ENDIF.

ELSE."Valid PO

  • it has valid PO, so get requried field value based on PO

PERFORM f_get_po_values USING lv_pono

CHANGING lv_mnfr

lv_lifnr

lv_ekorg.

  • Update the PO number,Short Text,Vendor,Manufacturer and purchasing

  • organization

MOVE i_qals TO e_qals.

e_qals-ebeln = lv_pono.

e_qals-ktextlos = lv_ktext.

e_qals-hersteller = lv_mnfr.

e_qals-lifnr = lv_lifnr.

e_qals-ekorg = lv_ekorg.

e_qals-zzprodoff = lv_prod_off.

e_active = lc_active.

ENDIF.

ENDFUNCTION.

plz help me, this is very urgent.

regards,

JD