You are on page 1of 14

*&---------------------------------------------------------------------* *& Report ZST_FI_RPT_RECIEPT *& *& This is a driver program for Reciept.

*& This calls the smartform ZST_FI_SF_RECEIPT. *&---------------------------------------------------------------------* REPORT zst_fi_rpt_reciept. ************************************************************************ **** TABLES DEFINITION **** ************************************************************************ TABLES : bseg, "Accounting Document Segm ent bkpf, "Accounting Document Head er kna1, "General Data in Customer Master spell, "Transfer structure for a mounts rendered in words lfa1, "Vendor Master (General S ection) t001, "Company Codes adrc, "Addresses (Business Addr ess Services) t005u, "Taxes: Region Key: Texts vbkpf, "Document Header for Docu ment Parking vbsegd, "Document Segment for Cus tomer Document Parking vbsegk, "Document Segment for Vend or Document Parking zfi_reciept. ************************************************************************ **** SELECTION-SCREEN **** ************************************************************************ SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. PARAMETERS: p_bukrs LIKE bkpf-bukrs OBLIGATORY, p_gjahr LIKE bkpf-gjahr OBLIGATORY, p_blart LIKE bkpf-blart OBLIGATORY. SELECT-OPTIONS: s_belnr FOR bkpf-belnr OBLIGATORY.

PARAMETERS: p_sqft RADIOBUTTON GROUP r1 USER-COMMAND rusr MODIF ID MD0, rr RADIOBUTTON GROUP r1 DEFAULT 'X', main RADIOBUTTON GROUP r1 , coup RADIOBUTTON GROUP r1 ,

flat RADIOBUTTON shop RADIOBUTTON elec RADIOBUTTON secu RADIOBUTTON PARAMETERS: p_xsqft(40) TYPE

GROUP r1 , GROUP r1 , GROUP r1 , GROUP r1 . c MODIF ID MD1 .

SELECTION-SCREEN: END OF BLOCK blk1. selection-screen : begin of block b2 with frame title text-002. parameters : prin radiobutton group abc. parameters : priv radiobutton group abc. selection-screen : end of block b2.

DATA : text(40) TYPE c. ************************************************************************ **** INTERNAL TABLES **** ************************************************************************ DATA: BEGIN OF wa_bkpf, bukrs LIKE bkpf-bukrs, "Company Code * bukrs LIKE VBKPF-bukrs, " For Parked Doc belnr LIKE bkpfbelnr, "Accounting Document Number gjahr LIKE bkpf-gjahr, "Fiscal Year budat LIKE bkpfbudat, "Posting Date in the Document blart LIKE bkpf-blart, "Document Type xblnr like bkpf-xblnr, bktxt like bkpf-bktxt, END OF wa_bkpf. DATA: BEGIN OF wa_bseg, bukrs LIKE bseg-bukrs, "Company Code * bukrs like vbsegdbukrs, "Source Comp Code(For Parked Docs). belnr LIKE bseg-belnr, "Accounting Document Number gjahr LIKE bseg-gjahr, "Fiscal Year dmbtr LIKE bseg-dmbtr, "Amount in Local Currency koart LIKE bseg-koart, "Account Type zuonr LIKE bseg-zuonr, "Assignment sgtxt LIKE bseg-sgtxt, "Item Text kunnr LIKE bseg-kunnr, "Customer Number 1 lifnr LIKE bseglifnr, "Account Number of Vendor or Creditor buzei LIKE bseg-buzei, " ADDED ON 12.02.2008 END OF wa_bseg. DATA: BEGIN OF wa_reg, region LIKE adrc-

region, "Region (State, Province, County) bland LIKE t005ubland, "Region (State, Province, County) bezei LIKE t005u-bezei, "Description END OF wa_reg. DATA: BEGIN OF wa_kna1, kunnr LIKE kna1-kunnr, anred LIKE kna1-anred, name1 LIKE kna1-name1, END OF wa_kna1. DATA: BEGIN OF wa_lfa1, lifnr LIKE lfa1lifnr, anred LIKE lfa1-anred, name1 LIKE lfa1-name1, END OF wa_lfa1.

"Customer Number 1 "Title "Name 1

"Account Number of Vendor or Creditor "Title "Name 1

DATA: it_bkpf LIKE STANDARD TABLE OF wa_bkpf WITH HEADER LINE. DATA: it_bseg LIKE STANDARD TABLE OF wa_bseg WITH HEADER LINE. DATA: it_bsegd LIKE STANDARD TABLE OF wa_bseg WITH HEADER LINE. DATA: it_bsegk LIKE STANDARD TABLE OF wa_bseg WITH HEADER LINE. DATA: itab3 TYPE zfi_note OCCURS 0 WITH HEADER LINE. DATA: it_fin1 TYPE zfi_note OCCURS 0 WITH HEADER LINE. DATA: it_reg LIKE STANDARD TABLE OF wa_reg WITH HEADER LINE. DATA: it_kna1 LIKE STANDARD TABLE OF kna1 WITH HEADER LINE. DATA: it_lfa1 LIKE STANDARD TABLE OF wa_lfa1 WITH HEADER LINE. DATA : p_control_parameters TYPE ssfctrlop OCCURS 0 WITH HEADER LINE. data : i_output_options type ssfcompop. data: it_reciept type standard table of zfi_reciept with header line. ************************************************************************ **** DATA DECLARATION **** ************************************************************************ DATA : word TYPE spell-word. data: num1 type bsec-name1. DATA : tdid TYPE thead-tdid, tdname TYPE thead-tdname, tdobject TYPE thead-tdobject, adrnr LIKE t001-adrnr. DATA : t_line TYPE tline OCCURS 0 WITH HEADER LINE. DATA : s_type(68) TYPE c,result1(80) TYPE c. DATA: v_amt LIKE pc207-betrg. DATA: v_words(100), vlen TYPE i. ************************************************************************

**** ADDED ON 11.02.2008 **** ************************************************************************ INITIALIZATION. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF screen-group1 EQ 'MD1'. IF p_sqft NE 'X'. screen-active = 0. MODIFY SCREEN. * CLEAR: p_xsqft. ENDIF. ENDIF. ENDLOOP. ************************************************************************ **** START-OF-SELECTION **** ************************************************************************ START-OF-SELECTION.

SELECT bukrs "For Posted Documents belnr gjahr budat blart xblnr FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf WHERE bukrs = p_bukrs AND belnr IN s_belnr AND gjahr = p_gjahr AND blart = p_blart. if prin = 'X'. p_control_parameters-preview i_output_options-tdnoprint i_output_options-tdnoprev i_output_options-tdnewid i_output_options-tdimmed

= = = = =

' '. ' '. 'X'. 'X'. 'X'.

loop at it_bkpf . select single * from zfi_reciept into it_reciept where belnr = it_bkpfbelnr and gjahr = p_gjahr and bukrs = p_bukrs. if sy-subrc = 0. include zduplicate_print. DATA : lf_formname TYPE tdsfname. lf_formname = 'ZST_FI_SF_RECEIPT_DUPLICATE'.

PERFORM f_call_smart_form USING lf_formname. stop. delete it_bkpf. endif. endloop. elseif priv = 'X'. p_control_parameters-preview = 'X'. i_output_options-tdnoprint = 'X'. p_control_parameters-no_dialog = ''. endif. if it_bkpf[] is not initial. loop at it_bkpf. itab3-budat = it_bkpf-budat. itab3-xblnr = it_bkpf-xblnr. itab3-text1 = it_bkpf-bktxt. append itab3. endloop. else. message 'Given Reciept(s) has already been printed' type 'I'. stop. endif.

LOOP AT itab3. MOVE-CORRESPONDING itab3 TO it_fin1. APPEND it_fin1. ENDLOOP. data: xblnr type bkpf-xblnr. xblnr = itab3-xblnr. CLEAR: itab3[], itab3. IF NOT it_bkpf[] IS INITIAL. SELECT bukrs belnr gjahr zuonr sgtxt dmbtr koart sgtxt kunnr lifnr buzei INTO CORRESPONDING FIELDS OF TABLE it_bseg

FROM bseg FOR ALL ENTRIES IN it_bkpf WHERE bukrs = it_bkpf-bukrs AND belnr = it_bkpf-belnr AND gjahr = it_bkpf-gjahr AND koart IN ('D','K'). IF sy-subrc = 0. READ TABLE it_bseg INDEX sy-index INTO it_bseg. LOOP AT it_bseg. itab3-bukrs = it_bseg-bukrs. itab3-belnr = it_bseg-belnr. itab3-budat = it_fin1-budat. itab3-gjahr = it_bseg-gjahr. itab3-dmbtr = it_bseg-dmbtr. itab3-zuonr = it_bseg-zuonr. itab3-sgtxt = it_bseg-sgtxt. IF itab3-sgtxt = ''. CONCATENATE '1000' it_bseg-belnr it_bseg-gjahr it_bsegbuzei INTO tdname. CALL FUNCTION 'READ_TEXT' EXPORTING * CLIENT = SY-MANDT id = '0001' language = 'E' name = tdname object = 'DOC_ITEM' * ARCHIVE_HANDLE = 0 * LOCAL_CAT = ' ' * IMPORTING * HEADER = TABLES lines = t_line EXCEPTIONS id = 1 language = 2 name = 3 not_found = 4 object = 5 reference_check = 6 wrong_access_to_archive = 7 OTHERS = 8 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. READ TABLE t_line INDEX 1.

IF sy-subrc = 0. itab3-ltext4 = t_line-tdline. ENDIF. CLEAR tdname. ENDIF. *--------------------------------------------------------------------------* itab3-kunnr = it_bseg-kunnr. itab3-lifnr = it_bseg-lifnr. APPEND itab3. ENDLOOP. ENDIF. * if sy-subrc ne 0. "Parked Docs from Vendor Table VBSEGD. SELECT bukrs belnr gjahr sgtxt dmbtr zuonr sgtxt kunnr INTO CORRESPONDING FIELDS OF TABLE it_bsegd FROM vbsegd FOR ALL ENTRIES IN it_bkpf WHERE bukrs = it_bkpf-bukrs AND belnr = it_bkpf-belnr AND gjahr = it_bkpf-gjahr. IF sy-subrc = 0. READ TABLE it_bsegd INDEX sy-index INTO it_bsegd. LOOP AT it_bsegd. itab3-bukrs = it_bsegd-bukrs. itab3-belnr = it_bsegd-belnr. itab3-budat = it_fin1-budat. itab3-gjahr = it_bsegd-gjahr. itab3-dmbtr = it_bsegd-dmbtr. itab3-zuonr = it_bsegd-zuonr. itab3-sgtxt = it_bsegd-sgtxt. itab3-kunnr = it_bsegd-kunnr. itab3-lifnr = it_bsegd-lifnr. APPEND itab3. ENDLOOP. ENDIF. SELECT bukrs K. belnr gjahr zuonr "Parked Docs from Customer Table VBSEG

sgtxt dmbtr zuonr sgtxt lifnr INTO CORRESPONDING FIELDS OF TABLE it_bsegk FROM vbsegk FOR ALL ENTRIES IN it_bkpf WHERE bukrs = it_bkpf-bukrs AND belnr = it_bkpf-belnr AND gjahr = it_bkpf-gjahr. IF sy-subrc = 0. READ TABLE it_bsegk INDEX sy-index INTO it_bsegk. LOOP AT it_bsegk. itab3-bukrs = it_bsegk-bukrs. itab3-belnr = it_bsegk-belnr. itab3-budat = it_fin1-budat. itab3-gjahr = it_bsegk-gjahr. itab3-dmbtr = it_bsegk-dmbtr. itab3-zounr = it_bsegk-zounr. itab3-sgtxt = it_bsegk-sgtxt. itab3-kunnr = it_bsegk-kunnr. itab3-lifnr = it_bsegk-lifnr. APPEND itab3. ENDLOOP. ENDIF. IF it_bseg[] IS INITIAL. IF it_bsegd[] IS INITIAL. IF it_bsegk[] IS INITIAL. MESSAGE 'No Data Found' TYPE 'I'. STOP. ENDIF. ENDIF. ENDIF. ENDIF. CLEAR: it_fin1[], it_fin1. LOOP AT itab3. MOVE-CORRESPONDING itab3 TO it_fin1. APPEND it_fin1. ENDLOOP. CLEAR: itab3[], itab3. LOOP AT it_fin1. itab3-bukrs = it_fin1-bukrs.

itab3-belnr = itab3-gjahr = itab3-dmbtr = itab3-budat = itab3-zuonr = itab3-sgtxt = itab3-kunnr = itab3-lifnr = SELECT SINGLE IF sy-subrc = * *

it_fin1-belnr. it_fin1-gjahr. it_fin1-dmbtr. it_fin1-budat. it_fin1-zuonr. it_fin1-sgtxt. it_fin1-kunnr. it_fin1-lifnr. * FROM t001 WHERE bukrs = it_fin1-bukrs. 0.

itab3-butxt = t001-butxt. itab3-ort01 = t001-ort01. itab3-addrnumber = t001-adrnr. SELECT SINGLE * FROM adrc WHERE addrnumber = t001-adrnr. IF sy-subrc = 0. itab3-street = adrc-street. itab3-butxt = adrc-name1. itab3-house_num1 = adrc-house_num1. itab3-tel_number = adrc-tel_number. itab3-kregion = adrc-region. itab3-post_code1 = adrc-post_code1. itab3-kstreet = adrc-STR_SUPPL3. ENDIF. SELECT SINGLE bland bezei INTO CORRESPONDING FIELDS OF it_reg FROM t005u WHERE t005u~bland = adrc-region AND t005u~land1 = 'IN' AND t005u~spras = 'E'. IF sy-subrc = 0. itab3-bland = it_reg-bland. itab3-bezei = it_reg-bezei. ENDIF. IF NOT it_fin1-kunnr IS INITIAL. SELECT SINGLE * FROM kna1 WHERE kunnr = it_fin1-kunnr. IF sy-subrc = 0. itab3-kunnr = kna1-kunnr. itab3-anred = kna1-anred. itab3-name1 = kna1-name1. ENDIF. ENDIF. IF NOT it_fin1-lifnr IS INITIAL.

SELECT SINGLE lifnr anred name1 FROM lfa1 INTO CORRESPONDING FIELDS OF it_lfa1 WHERE lifnr = it_fin1-lifnr. IF sy-subrc = 0. itab3-lifnr = it_lfa1-lifnr. itab3-anred = it_lfa1-anred. itab3-name1 = it_lfa1-name1. ENDIF. ENDIF. ENDIF. ***********************SS NEW MODIFICATION START********************

if kna1-xcpdk = 'X'. select single name1 from bsec into num1 where belnr in s_belnr. itab3-name1 = num1. endif. ***********************SS NEW MODIFICATION END******************** DELETE ADJACENT DUPLICATES FROM itab3 COMPARING belnr. IF itab3-dmbtr > 0. v_amt = itab3-dmbtr. CALL FUNCTION 'HR_IN_CHG_INR_WRDS' EXPORTING amt_in_num = v_amt IMPORTING amt_in_words = v_words EXCEPTIONS data_type_mismatch = 1 OTHERS = 2. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

IF v_words+0(1) EQ ''. vlen = STRLEN( v_words ). v_words = v_words+1(vlen). ENDIF. CALL FUNCTION 'STRING_UPPER_LOWER_CASE' EXPORTING delimiter = '/' string1 = v_words

IMPORTING string = v_words EXCEPTIONS not_valid = 1 too_long = 2 too_small = 3 OTHERS = 4. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. IF sy-subrc = 0. REPLACE FIRST OCCURRENCE OF 'rupees' IN v_words WITH ' '. itab3-words1 = v_words. ENDIF. ENDIF. APPEND itab3. ENDLOOP. CLEAR itab3. LOOP AT itab3. CONCATENATE itab3-bukrs itab3-belnr itab3-gjahr itab3-buzei tdid = '0001'. tdname = s_type. tdobject = 'DOC_ITEM'. CALL FUNCTION 'READ_TEXT' EXPORTING client id language name object ARCHIVE_HANDLE LOCAL_CAT IMPORTING HEADER TABLES lines EXCEPTIONS ID LANGUAGE NAME not_found OBJECT REFERENCE_CHECK WRONG_ACCESS_TO_ARCHIVE

INTO s_type.

* * * *

= sy-mandt = tdid = sy-langu = tdname = tdobject = 0 = ' ' = = t_line = 1 = 2 = 3 = 4 = 5 = 6 = 7

* * * * * *

* *

= 8 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

OTHERS

ENDLOOP. *--------------------------------------------------------------------* * added on 11.02.2008 *--------------------------------------------------------------------* IF rr = 'X'. text = 'Rent / Revenue'. ELSEIF main = 'X'. text = 'Maintenance'. ELSEIF coup = 'X'. text = 'Sale of Coupons'. ELSEIF flat = 'X'. text = 'Sale of Flat'. ELSEIF shop = 'X'. text = 'Sale of Shop'. ELSEIF elec = 'X'. text = 'Electricity Charges'. ELSEIF secu = 'X'. text = 'Security Charges'. ELSEIF p_sqft = 'X'. "OTHERS text = p_xsqft. ENDIF. *********** nts *********** *********** *********** *********** *********** *********** *********** *********** *********** *********** ************ ************ ************ ************ **** **** SELECT "bukrs "For Posted Docume

"belnr "gjahr "budat "blart xblnr FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf WHERE bukrs = p_bukrs AND belnr IN s_belnr AND gjahr = p_gjahr AND blart = p_blart. loop at it_bkpf. itab3-xblnr = it_bkpf-xblnr. append itab3. endloop.

data: xblnr type bkpf-xblnr. xblnr = itab3-xblnr.

*--------------------------------------------------------------------* * DATA : lf_formname TYPE tdsfname. lf_formname = 'ZST_FI_SF_RECEIPT_OLD'.

PERFORM f_call_smart_form USING lf_formname. *&--------------------------------------------------------------------* *& Form f_call_smart_form *&--------------------------------------------------------------------* FORM f_call_smart_form USING p_lf_formname. DATA: lf_fm_name TYPE rs38l_fnam.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = lf_formname IMPORTING fm_name = lf_fm_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * p_control_parameters-preview = 'X'. * p_control_parameters-no_dialog = ''. * break abapdev.

* * *

* * * *

CALL FUNCTION lf_fm_name EXPORTING xblnr ARCHIVE_INDEX ARCHIVE_INDEX_TAB ARCHIVE_PARAMETERS control_parameters output_options text MAIL_APPL_OBJ MAIL_RECIPIENT MAIL_SENDER OUTPUT_OPTIONS USER_SETTINGS IMPORTING

= xblnr = = = = p_control_parameters = i_output_options = text = = = = = 'X'

* * *

DOCUMENT_OUTPUT_INFO = JOB_OUTPUT_INFO = JOB_OUTPUT_OPTIONS = TABLES itab = itab3 * EXCEPTIONS * FORMATTING_ERROR = 1 * INTERNAL_ERROR = 2 * SEND_ERROR = 3 * USER_CANCELED = 4 * OTHERS = 5 . * IF sy-subrc <> 0. ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO ** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. * ENDIF. if prin = 'X' . move-corresponding itab3 to zfi_reciept. modify zfi_reciept. endif.

ENDFORM.

"F_CALL_SMART_FORM