Hello Srikant -- Instead of using the code below, check out function: SD_CREDIT_EXPOSURE to figure out open sales order , delivery, and billing for a customer. FUNCTION SD_CREDIT_EXPOSURE. *"--- *"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(FLAG_OPEN_DELIVERY) DEFAULT 'X' *" VALUE(FLAG_OPEN_INVOICE) DEFAULT 'X' *" VALUE(FLAG_OPEN_ORDER) DEFAULT 'X' *" VALUE(HORIZON_DATE) LIKE S066-SPTAG *" DEFAULT '99991231' *" VALUE(KKBER) LIKE T014-KKBER *" VALUE(KNKLI) LIKE KNKK-KNKLI *" VALUE(T014) LIKE T014 STRUCTURE T014 DEFAULT SPACE *" EXPORTING *" VALUE(OPEN_DELIVERY) LIKE S067-OLIKW *" VALUE(OPEN_INVOICE) LIKE S067-OFAKW *" VALUE(OPEN_ORDER) LIKE S066-OEIKW *" VALUE(OPEN_DELIVERY_SECURE) LIKE S067-AOLIW *" VALUE(OPEN_INVOICE_SECURE) LIKE S067-AOFAW *" VALUE(OPEN_ORDER_SECURE) LIKE S066-AOEIW *"--- * read credit table T014 CHECK FLAG_OPEN_ORDER EQ TRUE OR FLAG_OPEN_DELIVERY EQ TRUE OR FLAG_OPEN_INVOICE EQ TRUE. check not kkber is initial. IF T014-KKBER IS INITIAL. PERFORM T014_READ USING KKBER. ENDIF. PERFORM CREDIT_EXPOSURE_GET USING KKBER KNKLI HORIZON_DATE T014 FLAG_OPEN_ORDER FLAG_OPEN_DELIVERY FLAG_OPEN_INVOICE CHANGING OPEN_ORDER OPEN_DELIVERY OPEN_INVOICE OPEN_ORDER_SECURE OPEN_DELIVERY_SECURE OPEN_INVOICE_SECURE DELTA_SPTAG DELTA_SPWOC DELTA_SPMON DELTA_SPBUP. ENDFUNCTION. -Tung
| | | ---------------Original Message--------------- From: srikant Sent: Thursday, August 04, 2011 5:44 AM Subject: Credit Customer Blocked Hi Tung Ho As per your request below is the code for the credit check * DATA : lc_cramt LIKE knkk-klimk. * DATA : lc_amt LIKE knkk-klimk. * LOOP AT int_accept WHERE shopcode(1) = 'S' ** AND ( orderno(1) = 'S' OR orderno(1) = 'G' ) "*00-048-A * AND ( delorderno(2) = 'SS' OR delorderno(1) = 'G' ) * AND matnr(1) <> 'A'. * MOVE-CORRESPONDING int_accept TO int_accept1. * COLLECT int_accept1. * ENDLOOP. * CLEAR int_errtab. * LOOP AT int_accept1. * CLEAR knkk. * SELECT SINGLE * FROM knkk WHERE kunnr = int_accept1-shopcode * AND kkber = p_kkber. * IF sy-subrc = 0. * * CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY' * EXPORTING * date = sy-datum * foreign_amount = int_accept1-price * foreign_currency = 'SGD' * local_currency = 'USD' * rate = 0 * type_of_rate = 'M' * IMPORTING * local_amount = lc_amt * EXCEPTIONS * no_rate_found = 1 * overflow = 2 * no_factors_found = 3 * no_spread_found = 4 * derived_2_times = 5 * OTHERS = 6. * ** lc_cramt = knkk-skfor + int_accept1-price. * lc_cramt = knkk-skfor + lc_amt. * IF lc_cramt > knkk-klimk. * MOVE : int_accept1-delorderno TO int_errtab-delorderno, ** int_accept1-maktx to int_errtab-maktx, ** int_accept1-matnr to int_errtab-matnr, * int_accept1-shopcode TO int_errtab-shopcode, * int_accept1-custcomp TO int_errtab-custcomp, ** int_accept1-qty to int_errtab-qty, * int_accept1-price TO int_errtab-price, * 'Credit Limit Exceeds'(031) TO int_errtab-text. ** '2' to int_errtab-rec_type. * APPEND int_errtab. * ENDIF. We use the customised transaction to create sales order Thanks srikant | | __.____._ Copyright © 2011 Toolbox.com and message author. Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251 | | Popular White Papers In the Spotlight _.____.__ |