cancel
Showing results for 
Search instead for 
Did you mean: 

SAMPLE REPORT PROGRAM

Former Member
0 Kudos

can anybody send me one sample program that is using all FI tables..

Regards,

pandu

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

go to se38 and check the programs with RSS*

these some of the standard programs on FI.

or

If you are for standard, follow the path in the SAP easy access menu.

Accounting

-


> Financial Accouting

-


>General Ledger

-


>Information System

-


> General Ledger Reports

Regards

Former Member
0 Kudos

Hi

Check the sample reports here it has used max number of FI tables

<u><b>Main Report</b></u>

REPORT Zj_1iewt_cert  MESSAGE-ID 8i NO STANDARD PAGE HEADING.
*--------------------------------------------------------------
*
*                 SELECTION SCREEN
*
*--------------------------------------------------------------
* Data Include
INCLUDE zj_1iewt_cert_top.
*
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
PARAMETERS :      zbukrs LIKE bseg-bukrs ,
                  zyear  LIKE bseg-gjahr .
SELECT-OPTIONS :  zsecco FOR  seccode-seccode . " Note 604606
PARAMETERS :      zsect  LIKE j_1iewtnumgr-qscod .
SELECTION-SCREEN END OF BLOCK 1.
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE text-002 .
SELECT-OPTIONS: zpdate FOR bkpf-budat ,
                ZDOCTYPE FOR BKPF-BLART,
                zchall FOR j_1iewtchln-j_1iextchln ,
                zchdt FOR  j_1iewtchln-j_1iextchdt ,
                zvendor FOR lfb1-lifnr.
SELECTION-SCREEN END  OF BLOCK 2 .
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK 3 WITH FRAME TITLE text-003.
PARAMETERS : zcertdt     LIKE with_item-j_1icertdt ,
             zfname(30)  TYPE c ,    " signatory
             zfdsg(35)   TYPE c ,    " Designation
             zplace(20)  TYPE c .    " Place of Printing
SELECTION-SCREEN END OF BLOCK 3.

*** Added on 05June2007

SELECTION-SCREEN BEGIN OF BLOCK 4 WITH FRAME TITLE text-004.
PARAMETERS : zq1(15) type c,
             zq2(15) type c,
             zq3(15) type c,
             zq4(15) type c.
SELECTION-SCREEN END OF BLOCK 4.

*** End of addition
* Dummy Variables declarations
DATA: zcertno LIKE j_1iewt_certif-ctnumber,
      zcerdt LIKE sy-datum.
*--------------------------------------------------------------
*                 SELECTION SCREEN   VALIDATIONS
*--------------------------------------------------------------
AT SELECTION-SCREEN.
  PERFORM country_check.
  PERFORM select_form USING zsecco-low CHANGING  layout. " Note 604606
  LOOP AT zsecco .                                       " Note 604606
    AUTHORITY-CHECK OBJECT 'J_1IEWTCER'
       ID 'BUKRS' FIELD zbukrs
       ID 'BUPLA' FIELD zsecco-low                       " Note 604606
       ID 'ACTVT' FIELD '01'.
    IF sy-subrc NE 0.
      MESSAGE e000(8i) WITH
      'No authorization for current action'.
    ENDIF.
  ENDLOOP.

AT SELECTION-SCREEN ON zbukrs.
  PERFORM ewt_active.

AT SELECTION-SCREEN ON zsecco.                           " Note 604606
  PERFORM check_bupla.
  PERFORM check_secco.                                   " Note 604606

AT SELECTION-SCREEN ON zsect.
  PERFORM check_section.

AT SELECTION-SCREEN ON  zchdt.
  PERFORM check_challan.

AT SELECTION-SCREEN ON zvendor.
  PERFORM check_vendor.

AT SELECTION-SCREEN ON zcertdt.
  PERFORM check_dates.

*--------------------------------------------------------------
*                 START OF SELECTION
*--------------------------------------------------------------
START-OF-SELECTION.
* Select documents
*** Reverting note for testing
  PERFORM select_bkpf.
*** Reverting note for testing
* Section
  PERFORM select_section.
* Fill withholding tax data
  PERFORM fill_withtab.
* Fill invtab and paytab and Modify signs and values in invtab
* for credit memos and invoices.
  PERFORM modify_invtab.
* Process credit memos
  PERFORM process_credit_memos.
* Process downpayments
  PERFORM process_dp.
* Fill all records to one table
  PERFORM fill_printtab.
* Select all vendors
  PERFORM select_vendors.
*  PERFORM SELECT_JV.
* Print the certificate
  PERFORM print_routines.

END-OF-SELECTION.
*--------------------------------------------------------------
*                FORM ROUTINES
*--------------------------------------------------------------
  INCLUDE zj_1iewt_cert_f01.

<b><u>INclude Report</u></b>

*&---------------------------------------------------------------------*
*&  Include           ZJ_1IEWT_CERT_F01                                *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  COUNTRY_CHECK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM country_check.

  CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'
    EXPORTING
      bukrs                = zbukrs
      component            = 'IN'
    EXCEPTIONS
      component_not_active = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
    MESSAGE e712.
  ENDIF.

ENDFORM.                               " COUNTRY_CHECK

*&---------------------------------------------------------------------*
*&      Form  EWT_ACTIVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ewt_active.

  SELECT SINGLE * FROM t001
       WHERE bukrs = zbukrs.
  IF sy-subrc NE 0.
    MESSAGE e128 .
  ELSE.
    CALL FUNCTION 'FI_CHECK_EXTENDED_WT'
      EXPORTING
        i_bukrs              = zbukrs
      EXCEPTIONS
        component_not_active = 1
        not_found            = 2
        OTHERS               = 3.

    IF sy-subrc <> 0.
      MESSAGE e714 WITH zbukrs.
    ENDIF.
  ENDIF.

ENDFORM.                               " EWT_ACTIVE

*&---------------------------------------------------------------------*
*&      Form  CHECK_SECTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_section.

  SELECT SINGLE * FROM t059o
             WHERE land1    = 'IN'
               AND wt_qscod = zsect.
  IF sy-subrc <> 0.
    MESSAGE e703 WITH zsect.
  ENDIF .

ENDFORM.                               " CHECK_SECTION

*&---------------------------------------------------------------------*
*&      Form  CHECK_BUPLA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_bupla.

  CLEAR j_1bbranch.
  SELECT COUNT( * ) FROM j_1bbranch
             WHERE bukrs  = zbukrs
               AND branch IN zsecco.                       " Note 604606
  IF sy-subrc <> 0.
    MESSAGE e707.
  ENDIF .

ENDFORM.                               " CHECK_BUPLA
*&---------------------------------------------------------------------*
*&      Form  CHECK_VENDOR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_vendor.

  SELECT COUNT( * ) FROM lfb1
      WHERE lifnr IN zvendor
        AND bukrs  = zbukrs.
  IF sy-subrc <> 0.
    MESSAGE e396 WITH zvendor+3(10).
  ENDIF.

ENDFORM.                               " CHECK_VENDOR
*&---------------------------------------------------------------------*
*&      Form  CHECK_CHALLAN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_challan.
  CLEAR challantab[].
  IF NOT zchall IS INITIAL.
    SELECT * FROM j_1iewtchln INTO TABLE challantab
                    WHERE bukrs      = zbukrs
                    AND j_1iextchln IN zchall
                    AND j_1iextchdt IN zchdt.
  ELSE.
    SELECT * FROM j_1iewtchln INTO TABLE challantab
                    WHERE bukrs      = zbukrs
                    AND j_1iextchdt IN zchdt.
  ENDIF.

  DELETE challantab WHERE j_1iextchln IS INITIAL.
* Check for entry in itab
  CLEAR lin.
  DESCRIBE TABLE challantab LINES lin.
  IF lin = 0.
    MESSAGE e729.
  ENDIF.

ENDFORM.                               " CHECK_CHALLAN

*&---------------------------------------------------------------------*
*&      Form  CHECK_DATES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_dates.

  IF zchdt-low GT zcertdt.
    MESSAGE e754.
  ELSEIF zchdt-high GT zcertdt.
    MESSAGE e754.
  ENDIF.

ENDFORM.                               " CHECK_DATES

*---------------------------------------------------------------------*
*       FORM select_bkpf                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_bkpf.

  SELECT * FROM  bkpf INTO TABLE bkpftab
         WHERE  bukrs  = zbukrs
         AND    gjahr  = zyear
         AND    bstat  IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')
         AND    budat IN zpdate " Note 804529
         AND    blart IN zdoctype.


******** Delete Reversed Documents ***********
*  LOOP AT bkpftab WHERE NOT stblg IS INITIAL.
*    bkpftab-rev_ind = 'X'.
*    MODIFY bkpftab TRANSPORTING rev_ind WHERE
*              belnr = bkpftab-stblg OR
*              belnr = bkpftab-belnr.
*  ENDLOOP.
*  DELETE bkpftab WHERE rev_ind = 'X'.

  DELETE bkpftab WHERE NOT stblg IS INITIAL.

ENDFORM.                    "select_bkpf

*---------------------------------------------------------------------*
*       FORM select_section                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_section.

* Select all sections into itab.
  SELECT * FROM  t059z INTO CORRESPONDING FIELDS OF taxtab
           WHERE  land1  = 'IN'
           AND    qscod  = zsect.
    SELECT SINGLE * FROM t059p
               WHERE land1  = taxtab-land1
                 AND  witht = taxtab-witht.
    IF t059p-wt_postm = 1.
      taxtab-method = 'I'.
    ELSE.
      taxtab-method = 'P'.
    ENDIF.
    APPEND taxtab.
  ENDSELECT.

ENDFORM.                    "select_section

*---------------------------------------------------------------------*
*       FORM fill_withtab                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_withtab.
  DATA : v_gjahr(4) TYPE n.
* fill table for JV documents.

  SELECT * FROM with_item INTO TABLE jvtab
        WHERE  bukrs  = zbukrs
         AND   gjahr  = zyear
         AND   j_1iewtrec = 'B'.
*** Reverting note for testing

* -------- Start of note 887656
**OSS 891565-START
*  callback_wa-ldbnode     = 'BSIK'.
*  callback_wa-get         = 'X'.
**  callback_wa-get_late    = 'X'.
*  callback_wa-cb_prog     = sy-repid.
*  callback_wa-cb_form     = 'CALLBACK_BSIK'.
*  APPEND callback_wa TO callback.
**OSS 891565-end
*
*  callback_wa-ldbnode     = 'BKPF'.
*  callback_wa-get         = 'X'.
**  callback_wa-get_late    = 'X'.
*  callback_wa-cb_prog     = sy-repid.
*  callback_wa-cb_form     = 'CALLBACK_BKPF'.
*  APPEND callback_wa TO callback.
*
*  callback_wa-ldbnode     = 'BSEG'.
*  callback_wa-get         = 'X'.
**  callback_wa-get_late    = 'X'.
*  callback_wa-cb_prog     = sy-repid.
*  callback_wa-cb_form     = 'CALLBACK_BSEG'.
*  APPEND callback_wa TO callback.
*
*  callback_wa-ldbnode     = 'WITH_ITEM'.
*  callback_wa-get         = 'X'.
**  callback_wa-get_late    = 'X'.
*  callback_wa-cb_prog     = sy-repid.
*  callback_wa-cb_form     = 'CALLBACK_WITH'.
*  APPEND callback_wa TO callback.
*
**OSS 891565-START
*  seltab_wa-selname = 'KD_AUGDT'.
*  seltab_wa-kind = 'S'.
*  seltab_wa-sign = 'I'.
*  seltab_wa-option = 'EQ'.
*  CLEAR seltab_wa-low.
*  APPEND seltab_wa TO seltab.
*
*  seltab_wa-selname = 'KD_AUGDT'.
*  seltab_wa-kind = 'S'.
*  seltab_wa-sign = 'I'.
*  seltab_wa-option = 'NE'.
*  CLEAR: seltab_wa-low, seltab_wa-high.
*  APPEND seltab_wa TO seltab.
*
**OSS 891565-end
*  seltab_wa-kind = 'S'.
*  seltab_wa-selname = 'KD_BUKRS'.
*  seltab_wa-option = 'EQ'.
*  seltab_wa-sign = 'I'.
*  seltab_wa-low = zbukrs.
*  APPEND seltab_wa TO seltab.
*
*  CLEAR seltab_wa.
*  seltab_wa-kind = 'S'.
*  seltab_wa-selname = 'KD_GJAHR'.
*  seltab_wa-option = 'EQ'.
*  seltab_wa-sign = 'I'.
*  seltab_wa-low = zyear.
*  APPEND seltab_wa TO seltab.
*
*  CLEAR seltab_wa.
*  seltab_wa-kind = 'S'.
*  seltab_wa-selname = 'KD_BUDAT'.
*  LOOP AT zpdate.
*    MOVE-CORRESPONDING zpdate TO seltab_wa.
*    APPEND seltab_wa TO seltab.
*  ENDLOOP.
*
*  CLEAR seltab_wa.
*  seltab_wa-kind = 'S'.
*  seltab_wa-selname = 'KD_LIFNR'.
*  LOOP AT zvendor.
*    MOVE-CORRESPONDING zvendor TO seltab_wa.
*    APPEND seltab_wa TO seltab.
*  ENDLOOP.
*
*  CLEAR seltab_wa.
*  seltab_wa-kind = 'S'.
*  seltab_wa-selname = 'XBR_BLAR'.
*  LOOP AT zdoctype.
*    MOVE-CORRESPONDING zdoctype TO seltab_wa.
*    APPEND seltab_wa TO seltab.
*  ENDLOOP.
*
*  CALL FUNCTION 'LDB_PROCESS'
*       EXPORTING
*            ldbname                     = 'KDF'
*            variant                     = ' '
**          EXPRESSIONS                 = TEXPR
**          FIELD_SELECTION             = FSEL
*       TABLES
*            callback                    = callback
*            selections                  = seltab
*       EXCEPTIONS
*            ldb_not_reentrant           = 1
*            ldb_incorrect               = 2
*            ldb_already_running         = 3
*            ldb_error                   = 4
*            ldb_selections_error        = 5
*            ldb_selections_not_accepted = 6
*            variant_not_existent        = 7
*            variant_obsolete            = 8
*            variant_error               = 9
*            free_selections_error       = 10
*            callback_no_event           = 11
*            callback_node_duplicate     = 12
*            OTHERS                      = 13.
*
*  IF sy-subrc <> 0.
*    WRITE: 'Exception with SY-SUBRC', sy-subrc.
*  ENDIF.

* -------- End of note 887656

 LOOP AT bkpftab.
    SELECT        * FROM  with_item
           WHERE  bukrs        = bkpftab-bukrs
           AND    belnr        = bkpftab-belnr
           AND    gjahr        = bkpftab-gjahr
           AND    wt_stat      = ' '
           AND    koart        = 'K'
           AND    wt_acco      IN zvendor
           AND    ctnumber     =  ' '
           AND    wt_opowtpd   NE 'X'
           AND    wt_gruwtpd   NE 'X'
           AND j_1iewtrec      NE 'B'.


* Validate for BUPLA here itself.
      READ TABLE taxtab WITH KEY witht = with_item-witht
                             wt_withcd = with_item-wt_withcd.
      CHECK sy-subrc = 0 .

      CLEAR bsas.
      SELECT SINGLE augbl augdt FROM bsas INTO (bsas-augbl,bsas-augdt)
                               WHERE bukrs = with_item-bukrs
                               AND   hkont = with_item-hkont
                               AND   gjahr = with_item-gjahr
                               AND   belnr = with_item-belnr
                               AND   buzei = with_item-j_1ibuzei.
      CHECK sy-subrc = 0 .
      SELECT SINGLE gjahr FROM bkpf INTO v_gjahr
                                    WHERE bukrs = with_item-bukrs
                                    AND   belnr = bsas-augbl
                                    AND   budat = bsas-augdt.
*      CALL FUNCTION 'J_1I6_DETERMINE_EXC_YEAR'
*        EXPORTING
*          I_BUKRS      = with_item-bukrs
*          I_BUDAT      = bsas-augdt
*        IMPORTING
*          EXCISE_YEAR  = v_gjahr
*        EXCEPTIONS
*          MISS_COMPANY = 1
*          OTHERS       = 2.

      READ TABLE challantab WITH KEY   bukrs  = with_item-bukrs
                                       belnr  = bsas-augbl
                                       gjahr  = v_gjahr.


      CHECK sy-subrc = 0 .

* Filter records not belonging to this BUPLA/SECCO         " Note 604606
      SELECT SINGLE secco  FROM bseg INTO bseg-secco
                         WHERE  bukrs        = bkpftab-bukrs
                         AND    belnr        = bkpftab-belnr
                         AND    gjahr        = bkpftab-gjahr
                         AND    buzei        = with_item-j_1ibuzei
                         AND    ktosl        = 'WIT'.
      IF sy-subrc NE 0 OR NOT bseg-secco IN zsecco.
        SELECT SINGLE bupla  FROM bseg INTO bseg-bupla
                           WHERE  bukrs        = bkpftab-bukrs
                           AND    belnr        = bkpftab-belnr
                           AND    gjahr        = bkpftab-gjahr
                           AND    buzei        = with_item-j_1ibuzei
                           AND    ktosl        = 'WIT'.
        CHECK sy-subrc = 0 AND bseg-bupla IN zsecco.
      ENDIF.
* Move data to withtab.
      MOVE-CORRESPONDING with_item TO withtab.
      MOVE: bkpftab-budat          TO withtab-budat,
            bseg-bupla             TO withtab-bupla,
            bseg-secco             TO withtab-secco,
            challantab-j_1iextchln TO withtab-j_1iextchln,
            challantab-j_1iextchdt TO withtab-j_1iextchdt,
            challantab-bankl       TO withtab-bankl,
            taxtab-method          TO withtab-method.

*      to adjust for JV documents where loss is recognized
      READ TABLE jvtab WITH KEY wt_withcd = withtab-wt_withcd
                                augbl = withtab-belnr.
      IF sy-subrc = 0.
        withtab-wt_qbshh = withtab-wt_qbshh - jvtab-wt_qbshh.
        withtab-wt_qbshb = withtab-wt_qbshb - jvtab-wt_qbshb.
        withtab-wt_qszrt = ' '.
        withtab-qsatz = ( withtab-wt_qbshh / withtab-wt_qsshh ) * 100.
      ENDIF.

      APPEND withtab.
    ENDSELECT.
  ENDLOOP.
*** Reverting Note for testing

ENDFORM.                    "fill_withtab

*---------------------------------------------------------------------*
*       FORM modfy_invtab                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM modify_invtab.

* Certificate with multiple taxcodes
  DATA : counter TYPE i.

  LOOP AT withtab.
    MOVE-CORRESPONDING withtab TO temp_withtab.
    APPEND temp_withtab.
  ENDLOOP.

* putting zero rates into temp_withtab table for transfer into withtab
  SORT withtab BY belnr buzei.
  SORT temp_withtab BY belnr buzei.
  LOOP AT temp_withtab.
    AT NEW belnr.
      READ TABLE withtab WITH KEY
                belnr = temp_withtab-belnr
                buzei = 2.
      IF sy-subrc = 0.
        temp_withtab-qsatz = 0.
        MODIFY temp_withtab TRANSPORTING qsatz WHERE
                              belnr = withtab-belnr.
      ENDIF.
    ENDAT.
  ENDLOOP.

*Transfer the tax base amount per line number and the
* tax rates per line.
  CLEAR counter.
*LOOP AT temp_withtab.
*  at new buzei.
*    sum.
*    counter = 0.
*    loop at withtab where  belnr = temp_withtab-belnr and
*                           buzei = temp_withtab-buzei.
*        counter = counter + 1.
*        If counter = 1.
*****************************************************************
* Note 773106
*  withtab-wt_qbshh = temp_withtab-wt_qbshh.
*  If withtab-wt_basman = 'X'. "Note 692642 Begin
*    withtab-wt_qsshh = temp_withtab-wt_qsshh.
*  Endif. "Note 692642 End
*  withtab-qsatz =  temp_withtab-qsatz.
*  modify withtab INDEX sy-tabix.
*****************************************************************
*        else.
*          MOVE 'X' TO withtab-no_print .
*          MODIFY withtab.
*        endif.
*    endloop.
*  endat.
*ENDLOOP.
*
  CLEAR: temp_withtab, temp_withtab[].

  SORT withtab BY belnr buzei.

* transferring the records not marked as not for printing into
* temp_withtab.
  LOOP AT withtab WHERE no_print EQ space.
    MOVE-CORRESPONDING withtab TO temp_withtab.
    APPEND temp_withtab.
  ENDLOOP.

* 1. summing up the lines in temp_withtab
* 2. Transferring base amounts and tax amount to the first line
* in withtab
* marking any remaining lines in withtab as no print
*sort temp_withtab by belnr.
*sort withtab by belnr no_print.
*clear counter.
*LOOP AT temp_withtab.
*  at new belnr.
*    sum.
*    clear counter.
*    counter = 0.
*    loop at withtab where  belnr = temp_withtab-belnr.
*        counter = counter + 1.
*        If counter = 1.
*          withtab-wt_qsshh = temp_withtab-wt_qsshh.
*          withtab-wt_qbshh = temp_withtab-wt_qbshh.
*          modify withtab INDEX sy-tabix.
*        else.
*          MOVE 'X' TO withtab-no_print .
*          MODIFY withtab.
*        endif.
*    endloop.
*  endat.
*ENDLOOP.

* Certificate with multiple taxcodes

  LOOP AT withtab.
    IF withtab-method = 'I'.
      invtab  = withtab.
      APPEND invtab.
    ELSE .
      paytab = withtab.
      APPEND paytab.
    ENDIF.
  ENDLOOP.


* Only for invoices.
*Note 704757
  LOOP AT invtab.
    IF invtab-wt_qsshh < 0.            " Invoice.
      MOVE 'I' TO invtab-flag.
    ELSE.
      MOVE 'M' TO invtab-flag.         " Credit Memo
    ENDIF.
    IF invtab-j_1iewtrec NE 'J'.
      invtab-wt_qbshh = invtab-wt_qbshh * ( -1 ).
      invtab-wt_qsshh = invtab-wt_qsshh * ( -1 ).
    ENDIF.
    MODIFY invtab.
  ENDLOOP.
  LOOP AT paytab.
    SELECT SINGLE lifnr FROM bseg INTO paytab-lifnr WHERE
                    bukrs        = paytab-bukrs
             AND    belnr        = paytab-belnr
             AND    gjahr        = paytab-gjahr
             AND    koart        = 'K'
             AND    lifnr        IN zvendor
             AND    buzei        = paytab-buzei.
    paytab-no_print = ' '.
    MODIFY paytab.
  ENDLOOP.
*Note 704757

* The subsequent process will be affected by flag in j_1iewtrec.

ENDFORM.                    "modify_invtab

*---------------------------------------------------------------------*
*       FORM refresh_data                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM refresh_data.

  REFRESH : withtab, invtab, paytab,
            bkpftab, it_lfa1, printtab,it_summary.
  CLEAR  :  withtab, invtab, paytab,
            bkpftab, it_lfa1, printtab,it_summary,cnt_print_order.

ENDFORM.                    "refresh_data

*---------------------------------------------------------------------*
*       FORM process_credit_memos                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM process_credit_memos.

  DATA: invcopytab LIKE invtab OCCURS 0 WITH HEADER LINE.

  invcopytab[] = invtab[].

  LOOP AT invcopytab WHERE flag       = 'M'
                       AND j_1ibuzei NE ' '
                       AND no_print NE 'X'.
    SELECT SINGLE * FROM bseg
                       WHERE  bukrs        = invcopytab-bukrs
                       AND    belnr        = invcopytab-belnr
                       AND    gjahr        = invcopytab-gjahr
                       AND    buzei        = invcopytab-buzei.

    IF sy-subrc = 0 AND  bseg-shkzg = 'S'
                    AND  bseg-koart = 'K'
                    AND  bseg-rebzg NE space  . " there is doc.ref

      READ TABLE invtab WITH KEY
                           bukrs = bseg-bukrs
                           gjahr = bseg-rebzj
                           belnr = bseg-rebzg
                           buzei = bseg-rebzz
                           witht = invcopytab-witht
                           no_print = ''.
      IF sy-subrc = 0.
* The reference invoice is also there for certificate Processing.
        IF invtab-j_1iintchln = invcopytab-j_1iintchln
          AND invtab-j_1iintchdt = invcopytab-j_1iintchdt .
* Both documents are cleared using same Challan.
          invtab-wt_qsshh = invtab-wt_qsshh +  invcopytab-wt_qsshh.
          invtab-wt_qbshh = invtab-wt_qbshh +  invcopytab-wt_qbshh.
          invtab-print_order = cnt_print_order = cnt_print_order + 1.
* Invoice is net of credit memo values
          MODIFY  invtab INDEX sy-tabix.

          READ TABLE invtab WITH KEY bukrs = invcopytab-bukrs
                                  gjahr = invcopytab-gjahr
                                  belnr = invcopytab-belnr
                                  buzei = invcopytab-buzei
                                  witht = invcopytab-witht.
* This step removes that credit memo item since it is already reduced
          MOVE 'X' TO invtab-no_print .
          MODIFY  invtab INDEX sy-tabix.
* Do not print this credit memo line since it is already adjusted
* with invoice
        ELSE.
* If challan number of invoice is different that of credit memo
          invtab-wt_qsshh = invtab-wt_qsshh +  invcopytab-wt_qsshh.
          invtab-wt_qbshh = invtab-wt_qbshh +  invcopytab-wt_qbshh.
          invtab-print_order = cnt_print_order = cnt_print_order + 1.
* Now invoice is net of credit memo
          MODIFY TABLE invtab.
* Read credit memo line in invtab.
          READ TABLE invtab WITH KEY bukrs = invcopytab-bukrs
                              gjahr = invcopytab-gjahr
                              belnr = invcopytab-belnr
                              buzei = invcopytab-buzei
                              witht = invcopytab-witht.
          invtab-wt_qsshh = 0.
          invtab-wt_qbshh = 0.
          invtab-budat    = ' '.
          invtab-qsatz    = ' '.
          invtab-print_order = cnt_print_order = cnt_print_order + 1.
          MODIFY  invtab INDEX sy-tabix.
*  In case of Credit Memos paid with challan number other than that
*  of invoice,It is necessary to show invoice net of credit memo,but
*  to print the Challan number of credit memo as well
*  There will be two Lines Printed. One for invoice- all fields filled,
*  another for Credit Memo. Amount, base,date and tax rates will not be
*  printed , only challan no and date will be printed under the invoice.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.

  REFRESH invcopytab.

ENDFORM.                    "process_credit_memos

*---------------------------------------------------------------------*
*       FORM process_dp                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM process_dp.

  DATA : cleartab LIKE invtab OCCURS 0 WITH HEADER LINE.
  DATA : cleartab_buzei LIKE cleartab-buzei. "Note 826877
  DATA : v_amt TYPE i. "Note 831817

  LOOP AT paytab INTO cleartab
                WHERE  wt_downc = 'X'
                AND j_1ibuzei NE '000'
                AND j_1iewtrec = 'C'.
    APPEND cleartab.
  ENDLOOP.

  LOOP AT cleartab WHERE no_print NE 'X'.
    SELECT SINGLE * FROM bseg INTO bseg
                       WHERE  bukrs        = cleartab-bukrs
                       AND    belnr        = cleartab-belnr
                       AND    gjahr        = cleartab-gjahr
                       AND    buzei        = cleartab-buzei.
    IF sy-subrc  = 0 AND bseg-shkzg = 'S'
        AND bseg-koart = 'K'
        AND bseg-rebzg NE ' '.         " invoice reference

      READ TABLE invtab WITH KEY bukrs = bseg-bukrs
                                 gjahr = bseg-rebzj
                                 belnr = bseg-rebzg
                                 buzei = bseg-rebzz
                                 no_print = ''.
      IF sy-subrc = 0.
* The parent invoice is also there for certificate Processing
        IF invtab-j_1iintchln = cleartab-j_1iintchln
          AND invtab-j_1iintchdt = cleartab-j_1iintchdt .

* Both documents are cleared using same Challan.
********************************************************************
* Note 773106
          IF NOT cleartab_buzei IS INITIAL. "Note 826877
            IF cleartab_buzei NE cleartab-buzei.
              invtab-base_mod = ''.
            ENDIF.
          ENDIF.

          IF invtab-base_mod NE 'X'.
            invtab-wt_qsshh = invtab-wt_qsshh -  cleartab-wt_qsshh.
            invtab-base_mod = 'X'.
          ENDIF.
********************************************************************
          invtab-wt_qbshh = invtab-wt_qbshh -  cleartab-wt_qbshh.
          v_amt  = TRUNC( invtab-wt_qsshh ). "Note 831817

          IF v_amt = 0. "Note 826877  " Note 831817
            DELETE  invtab INDEX sy-tabix.
          ELSE.
            MODIFY invtab INDEX sy-tabix.
          ENDIF.

* Now invoice is net of credit memo values
          READ TABLE paytab WITH KEY bukrs = cleartab-bukrs
                                     gjahr = cleartab-gjahr
                                     belnr = cleartab-belnr
                                     buzei = cleartab-buzei
                                     no_print = ''.   " Note 773106


* This step removes that DP clear item since it is already reduced
          MOVE 'X' TO paytab-no_print .
          MOVE 'X' TO cleartab-no_print.      " Note 773106
          MODIFY cleartab.                    " Note 773106
          MODIFY paytab INDEX sy-tabix.

        ELSE.
* If challan number of invoice is different that of DP clear.
* Note 773106
*          invtab-wt_qsshh = invtab-wt_qsshh -  cleartab-wt_qsshh.
          invtab-wt_qbshh = invtab-wt_qbshh -  cleartab-wt_qbshh.
          invtab-print_order = cnt_print_order = cnt_print_order + 1.
          MODIFY invtab INDEX sy-tabix.
* Now invoice is net of DP clear values
          READ TABLE paytab WITH KEY bukrs = cleartab-bukrs
                                     gjahr = cleartab-gjahr
                                     belnr = cleartab-belnr
                                     buzei = cleartab-buzei
                                     no_print = ''.   " Note 773106
* Read DP clearing line in invtab.
          paytab-wt_qsshh = 0.
          paytab-wt_qbshh = 0.
          paytab-budat    = ' '.
          paytab-qsatz    = ' '.
          invtab-print_order = cnt_print_order = cnt_print_order + 1.
          MODIFY paytab INDEX sy-tabix.
          MOVE 'X' TO cleartab-no_print.   " Note 773106
          MODIFY cleartab.                 " Note 773106

* This step is executed so that in case of DP clear refunds  with
* challan number other than that of invoice, it is necessary to show
* invoice net of refund but to print the Challan number of refund  as
* well. There will be two or more lines printed. One for invoice - all
* fields filled,  another for Clearing refund  Amount, base, date & tax
* rates  will not be printed, only challan no and date  will be printed
* under the invoice.
        ENDIF.
      ELSE.
        READ TABLE paytab WITH KEY bukrs = cleartab-bukrs
                                     gjahr = cleartab-gjahr
                                     belnr = cleartab-belnr
                                     buzei = cleartab-buzei.
        MOVE 'X' TO paytab-no_print .
        MODIFY paytab INDEX sy-tabix.
      ENDIF.
    ENDIF.
    cleartab_buzei = cleartab-buzei. "Note 826877

  ENDLOOP.

ENDFORM.                    "process_dp

*---------------------------------------------------------------------*
*       FORM open_form                                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM open_form.
  DATA : tmp_answer.
  itcpo-tdimmed = 'X' .

  CALL FUNCTION 'OPEN_FORM'
    EXPORTING
      form                        = layout
      language                    = sy-langu
      OPTIONS                     = itcpo
    EXCEPTIONS
      canceled                    = 1
      device                      = 2
      form                        = 3
      OPTIONS                     = 4
      unclosed                    = 5
      mail_options                = 6
      archive_error               = 7
      invalid_fax_number          = 8
      more_params_needed_in_batch = 9
      OTHERS                      = 10.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    "open_form
*---------------------------------------------------------------------*
*       FORM write_form                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM write_form USING element function p_type window.

  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      element                  = element
      function                 = function
      type                     = p_type
      window                   = window
    EXCEPTIONS
      element                  = 1
      function                 = 2
      type                     = 3
      unopened                 = 4
      unstarted                = 5
      window                   = 6
      bad_pageformat_for_print = 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.

ENDFORM.                    "write_form
*---------------------------------------------------------------------*
*       FORM close_form                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM close_form.

  CALL FUNCTION 'CLOSE_FORM'
    EXCEPTIONS
      unopened                 = 1
      bad_pageformat_for_print = 2
      send_error               = 3
      OTHERS                   = 4.

  IF sy-subrc EQ 0.
    STOP.
  ENDIF.

ENDFORM.                    "close_form

*---------------------------------------------------------------------*
*       FORM select_data_for_layout                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_data_for_layout.
*  commented by naim on 17-0707
  PERFORM fill_adrc_for_bupla.
  PERFORM select_adrc USING t001-adrnr CHANGING t_adrc.
  PERFORM fill_nature_of_payment.

ENDFORM.                    "select_data_for_layout

*---------------------------------------------------------------------*
*       FORM fill_adrc_for_bupla                                      *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_adrc_for_bupla.
  CLEAR adrc.
*  commented by naim on 17-0707

  SELECT  SINGLE adrnr name FROM  j_1bbranch
          INTO (j_1bbranch-adrnr,j_1bbranch-name)
          WHERE  bukrs  = zbukrs
            AND  branch = printtab-bupla.

  CHECK NOT   j_1bbranch-adrnr IS INITIAL.
  PERFORM select_adrc USING j_1bbranch-adrnr CHANGING adrc.
**   added by naim on 17-07-07
*   perform select_adrc using t001-adrnr changing adrc.


ENDFORM.                    "fill_adrc_for_bupla


*---------------------------------------------------------------------*
*       FORM select_adrc                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_adrnr                                                       *
*  -->  p_adrc                                                        *
*---------------------------------------------------------------------*
FORM select_adrc USING    p_adrnr
                 CHANGING p_adrc STRUCTURE adrc.

  SELECT        * FROM  adrc INTO p_adrc
         WHERE  addrnumber  = p_adrnr.
    EXIT.
  ENDSELECT.

ENDFORM.                    "select_adrc

*---------------------------------------------------------------------*
*       FORM select_vendors                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_vendors.

  DATA: tmp_adrc LIKE adrc.
  SORT  printtab BY wt_acco.

  LOOP AT printtab.
    ON CHANGE OF printtab-wt_acco.
* Get vendor PAN NO
      CLEAR j_1imovend.
      SELECT SINGLE * FROM j_1imovend
           WHERE lifnr = printtab-wt_acco.
      SELECT SINGLE * FROM lfa1
           INTO CORRESPONDING FIELDS OF it_lfa1
           WHERE lifnr = printtab-wt_acco.
      it_lfa1-one_time = it_lfa1-xcpdk.
      it_lfa1-bupla    = printtab-bupla.
      it_lfa1-secco    = printtab-secco.                 " Note 604606
      PERFORM select_adrc USING it_lfa1-adrnr
                       CHANGING tmp_adrc.
      MOVE :
            tmp_adrc-str_suppl1  TO it_lfa1-str_suppl1,
            tmp_adrc-str_suppl2  TO it_lfa1-str_suppl2,
            tmp_adrc-street      TO it_lfa1-street,
            tmp_adrc-city1       TO it_lfa1-city1,
            tmp_adrc-city2       TO it_lfa1-city2,
            tmp_adrc-post_code1  TO it_lfa1-post_code1,
            j_1imovend-j_1ipanno TO it_lfa1-pan.

      APPEND it_lfa1.
    ENDON.
  ENDLOOP.

ENDFORM.                    "select_vendors

*---------------------------------------------------------------------*
*       FORM get_qsatz                                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_withcd                                                      *
*  -->  p_qsatz                                                       *
*---------------------------------------------------------------------*
FORM get_qsatz USING p_witht
                     p_withcd
            CHANGING p_qsatz.

  CHECK p_qsatz IS INITIAL.

  SELECT SINGLE qsatz FROM  t059z INTO p_qsatz
         WHERE  land1      = t001-land1
         AND    witht      = p_witht
         AND    wt_withcd  = p_withcd.

  IF t059z-xqfor = 'X' .
    SELECT  qsatz FROM  t059fb INTO p_qsatz
           WHERE  land1      = t001-land1
           AND    waers      = t001-waers
           AND    witht      = p_witht
           AND    wt_withcd  = p_withcd
           AND    qland      = t001-land1
           AND    wt_valid   <= sy-datum.
      EXIT.
    ENDSELECT.
  ENDIF .

ENDFORM.                    "get_qsatz
*---------------------------------------------------------------------*
*       FORM select_bank                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_bank1                                                       *
*  -->  p_banka                                                       *
*  -->  p_branch                                                      *
*---------------------------------------------------------------------*
FORM select_bank USING p_bank1 CHANGING p_banka p_ort01 p_branch
p_j_1itdbank.

  SELECT SINGLE * FROM t012
      WHERE bukrs = zbukrs
        AND hbkid = p_bank1.

*  SELECT SINGLE banka ort01 brnch FROM  bnka
*         INTO (p_banka, p_ort01, p_branch)
*         WHERE  banks  = t001-land1
*           AND   bankl = t012-bankl.


*note 885104

  SELECT SINGLE banka brnch bankl FROM bnka
         INTO (p_banka, p_branch, p_j_1itdbank)  "Note 912767
         WHERE banks EQ t001-land1
         AND bankl EQ t012-bankl.

*** Changes by Vivek 01-Jun-06

  p_branch = p_j_1itdbank.                                  "921787

p_branch = t012-stcd1. " Tax Number 1 is having the BSR Code

***End of Changes by Vivek 01-Jun-06


  CLEAR p_ort01.

*end note 885104
ENDFORM.                    "select_bank
*---------------------------------------------------------------------*
*       FORM convert_to_words                                         *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_amount                                                      *
*  -->  p_word                                                        *
*---------------------------------------------------------------------*
FORM convert_to_words USING p_amount LIKE bseg-dmbtr CHANGING p_word
p_paise.
  DATA:  spell LIKE spell.

  CALL FUNCTION 'SPELL_AMOUNT'
    EXPORTING
      amount    = p_amount
      currency  = t001-waers
      filler    = space
      language  = sy-langu
    IMPORTING
      in_words  = spell
    EXCEPTIONS
      not_found = 01
      too_large = 02.


  MOVE spell-word TO p_word.
  MOVE spell-decword TO p_paise.
ENDFORM.                    "convert_to_words

*---------------------------------------------------------------------*
*       FORM print_certificate                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*FORM print_certificate_old USING p_one_time.
*
*  DATA : tmp_count LIKE sy-tabix ,
*         flg_new_page,
*         tmp_mod LIKE sy-tabix,
*         tmp_lines LIKE sy-tabix.
*
*
*  CLEAR tmp_amount.
*  DESCRIBE TABLE printtab LINES tmp_lines.
*
*  PERFORM select_pan.
*  PERFORM print_header.
*  SORT printtab BY print_order .
**Line item data
*  LOOP AT printtab WHERE wt_acco = it_lfa1-lifnr .
*
**----address for one time vendors
*    IF p_one_time = 'X' .
*    PERFORM   get_address_from_bsec USING printtab-belnr printtab-buzei
*                              CHANGING it_lfa1.
*    ENDIF.
*
*
**---Calculation for new page
*    tmp_mod  = sy-tabix MOD 11.
*    IF tmp_mod = tmp_count.
*      flg_new_page = 'X'.
*      tmp_count = tmp_count + 2.
*    ENDIF.
*
*
** Printing headers and brought forward amount in new page
*    IF flg_new_page = 'X' .
*      PERFORM write_form USING 'MAIN_LINE' 'SET' 'BODY' 'MAIN'.
*      PERFORM write_form USING 'CRFORWARD' 'SET' 'BODY' 'MAIN'.
*      PERFORM new_page.
*      PERFORM write_form USING 'MAIN_HEADING' 'SET' 'BODY' 'MAIN'.
*      PERFORM write_form USING 'BRFORWARD' 'SET' 'BODY' 'MAIN'.
*      flg_new_page = space.
*    ENDIF.
*
**    if it_lfa1-one_time = 'X' .
**    PERFORM   get_address_from_bsec USING printtab-belnr
*printtab-buzei
**                      CHANGING it_lfa1.
**    endif.
*
**    PERFORM select_bank USING printtab-bankl CHANGING printtab-banka
**                              printtab-ort01 printtab-brnch.
*
*    PERFORM get_qsatz USING printtab-witht printtab-wt_withcd
*                                      CHANGING printtab-qsatz.
*    PERFORM write_form USING 'MAIN_DATA' 'SET' 'BODY' 'MAIN'.
*
**    PERFORM write_form USING 'BANK' 'SET' 'BODY' 'CHALLAN'.
*    tmp_amount  = tmp_amount + printtab-wt_qbshh.
*
*  ENDLOOP.
**Sum and footer data
*
*  PERFORM append_summary.
*
*
*
*  PERFORM print_footer.
**    PERFORM write_form USING 'FOOTER' 'SET' 'BODY' 'FOOTER'.
*
*
*
*ENDFORM.



*---------------------------------------------------------------------*
*       FORM fill_printtab                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_printtab.
  REFRESH printtab.

  LOOP AT invtab  WHERE no_print <>  'X' .
    MOVE-CORRESPONDING invtab TO printtab.
    APPEND printtab.
  ENDLOOP.
  LOOP AT paytab WHERE no_print <>  'X' .
    MOVE-CORRESPONDING paytab TO printtab.
    APPEND printtab.
  ENDLOOP.
  LOOP AT printtab.
    PERFORM select_bank USING printtab-bankl
                     CHANGING printtab-banka
                              printtab-ort01
                              printtab-brnch
                              printtab-j_1itdbank. " Note 912767



    MODIFY printtab.
  ENDLOOP.
  PERFORM select_jv.
  PERFORM filter_data.


  CALL FUNCTION 'J_1I7_USEREXIT_CHEQUENO_CERT'   " Note 912767
   TABLES
     i_printtab       = printtab.

ENDFORM.                    "fill_printtab

*---------------------------------------------------------------------*
*       FORM generate_number                                          *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_number                                                      *
*---------------------------------------------------------------------*
FORM generate_number CHANGING p_number.

  DATA  : xyear LIKE bseg-gjahr.
  CLEAR : xyear.

  CALL FUNCTION 'J_1I6_DETERMINE_EXC_YEAR'
    EXPORTING
      i_bukrs      = zbukrs
      i_budat      = zpdate-low
    IMPORTING
      excise_year  = xyear
    EXCEPTIONS
      miss_company = 1
      OTHERS       = 2.

  zyear = xyear.

  IF con_reprint = 'X' .
    p_number  = zcertno.
  ELSE.

    CHECK sy-ucomm = 'PRNT'.
    CLEAR: j_1iewt_cert,j_1iewt_certno.


    IF sy-subrc NE 0.
      MESSAGE e017.
    ENDIF.

    SELECT SINGLE * FROM j_1iewt_cert_n
            WHERE bukrs = zbukrs
            AND   ( secco = save_printtab-secco            " Note 604606
            OR secco = save_printtab-bupla )
            AND   qscod = zsect.
    IF sy-subrc NE 0 OR j_1iewt_cert_n-j_1inogroup IS INITIAL.
      " Note 604606
      MESSAGE e766.
    ELSE.
      SELECT SINGLE * FROM j_1iewt_certno
             WHERE j_1inogroup = j_1iewt_cert_n-j_1inogroup.
      " Note 604606
      IF sy-subrc NE 0 OR j_1iewt_certno-numki IS INITIAL.
        MESSAGE e766.
      ENDIF.
    ENDIF.

    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        nr_range_nr             = j_1iewt_certno-numki
        object                  = 'J_1ICERT'
        subobject               = zbukrs
        toyear                  = xyear
      IMPORTING
        number                  = p_number
      EXCEPTIONS
        interval_not_found      = 1
        number_range_not_intern = 2
        object_not_found        = 3
        quantity_is_0           = 4
        quantity_is_not_1       = 5
        interval_overflow       = 6
        OTHERS                  = 7.
    IF sy-subrc <> 0.
      MESSAGE a166 .
    ENDIF.
  ENDIF.
ENDFORM.                    "generate_number

*---------------------------------------------------------------------*
*       FORM get_address_from_bsec                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_belnr                                                       *
*  -->  p_buzei                                                       *
*  -->  p_lfa1                                                        *
*---------------------------------------------------------------------*
FORM get_address_from_bsec USING p_belnr p_buzei CHANGING p_lfa1 LIKE
it_lfa1.

  TABLES bsec.
*user exit for PAN number for one time vendors.
  DATA : pan LIKE j_2icomm-c20.
  CLEAR: pan.
*end of changes for PAN number for one time vendors
  SELECT  SINGLE      * FROM  bsec INTO bsec
  WHERE  bukrs  = zbukrs
  AND    belnr  = p_belnr
  AND    gjahr  = zyear
  AND    buzei  = p_buzei.
*user exit for PAN number for one time vendors
  IF sy-subrc = 0.
    CALL FUNCTION 'J_1I7_USEREXIT_ONETIME_PAN'
      EXPORTING
        y_bsec = bsec
      IMPORTING
        panno  = pan.

    .
    IF pan NE ' ' .
      p_lfa1-pan = pan.
    ENDIF.

*end of changes for PAN number for one time vendors

    MOVE :
    bsec-name1 TO p_lfa1-name1 ,
    bsec-name2 TO p_lfa1-str_suppl1,
*bsec-stras to p_lfa1-STR_SUPPL2
    bsec-stras TO p_lfa1-street      ,
    bsec-ort01 TO p_lfa1-city1         ,
*p_lfa1-city2
    bsec-pstlz TO p_lfa1-post_code1         .
*user exit for PAN number for one time vendors.
  ENDIF.



ENDFORM.                    "get_address_from_bsec


*---------------------------------------------------------------------*
*       FORM print_header                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_header.

  IF NOT save_printtab-secco IS INITIAL.                    "Note 604606
    SELECT SINGLE * FROM j_1iewt_cert_n
          WHERE bukrs = zbukrs
          AND secco   = save_printtab-secco
          AND   qscod = zsect.
    PERFORM select_data_for_layout_secco.
  ELSE.
    SELECT SINGLE * FROM j_1iewt_cert
              WHERE bukrs = zbukrs
              AND bupla   = save_printtab-bupla
              AND   qscod = zsect.
    PERFORM select_data_for_layout.
  ENDIF.
  move-corresponding t_adrc to adrc.
  IF con_reprint IS INITIAL.
    PERFORM write_form USING 'NUMBER' 'SET' 'BODY' 'NUMBER'.
  ELSE.
    PERFORM write_form USING 'REPRINT' 'SET' 'BODY' 'DUPNUM'.
  ENDIF.
  PERFORM write_form USING 'INFO1' 'SET' 'BODY' 'INFO1'.
  PERFORM write_form USING 'INFO2' 'SET' 'BODY' 'INFO2'.
  PERFORM write_form USING 'INFO3' 'SET' 'BODY' 'INFO3'.
  PERFORM write_form USING 'MAIN_HEADING' 'SET' 'BODY' 'MAIN'.

ENDFORM.                    "print_header

*---------------------------------------------------------------------*
*       FORM print_footer                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_footer.

  PERFORM write_form USING 'MAIN_LINE' 'SET' 'BODY' 'MAIN'.
  PERFORM convert_to_words USING tmp_amount CHANGING
                      printtab-word printtab-paise.
  printtab-total_tax = tmp_amount . "Sapna 040507
  PERFORM write_form USING 'TOTAL' 'SET' 'BODY' 'MAIN'.
  PERFORM write_form USING 'SIGNATURE' 'SET' 'BODY' 'MAIN'.

ENDFORM.                    "print_footer

*---------------------------------------------------------------------*
*       FORM select_pan                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_pan.

* for gir number
  SELECT SINGLE * FROM t001z
       WHERE bukrs = t001-bukrs
       AND   party = 'J_1I03' .
  girno = t001z-paval.
* For PAN no
  SELECT SINGLE  paval FROM  t001z INTO t001z-paval
         WHERE  bukrs  = t001-bukrs
         AND    party  = 'J_1I02'.

ENDFORM.                    "select_pan


*---------------------------------------------------------------------*
*       FORM popup_to_decide                                          *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  answer                                                        *
*---------------------------------------------------------------------*
FORM popup_to_decide CHANGING answer.
  CALL FUNCTION 'POPUP_TO_DECIDE'
       EXPORTING
*         DEFAULTOPTION     = '1'
            textline1         = 'Please choose an option'

*         TEXTLINE2         = ' '
*         TEXTLINE3         = ' '
            text_option1      = 'Print Certificate'
            text_option2      = 'View Print preview only'
           icon_text_option1 = 'ICON_PRINT'
*         ICON_TEXT_OPTION2 = ' '
            titel             = 'Print Option'
*         START_COLUMN      = 25
*         START_ROW         = 6
*         CANCEL_DISPLAY    = 'X'
      IMPORTING
           answer            = answer
            .

ENDFORM.                    "popup_to_decide


*---------------------------------------------------------------------*
*       FORM new_page                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM new_page.

  CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
      command   = 'NEW-PAGE'
    EXCEPTIONS
      unopened  = 1
      unstarted = 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.

ENDFORM.                    "new_page

*---------------------------------------------------------------------*
*       FORM print_summaries                                          *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_summaries.
  CHECK NOT printtab[] IS INITIAL AND con_reprint IS INITIAL.
*  perform new_page.
*  PERFORM end_form.
  PERFORM start_form USING layout 'FNEXT'.
  PERFORM print_challanwise_summary.
  PERFORM end_form.

  PERFORM start_form USING layout 'THIRD'.
  PERFORM print_certificate_summary.
  PERFORM end_form.


ENDFORM.                    "print_summaries

*---------------------------------------------------------------------*
*       FORM start_form                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_layout                                                      *
*  -->  ppage                                                         *
*---------------------------------------------------------------------*
FORM start_form USING p_layout ppage.

  CALL FUNCTION 'START_FORM'
    EXPORTING
      form      = p_layout
      startpage = ppage
    EXCEPTIONS
      form      = 01
      format    = 02
      unended   = 03
      unopened  = 04
      unused    = 05.
ENDFORM.                    "start_form

*---------------------------------------------------------------------*
*       FORM select_form                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_bupla                                                       *
*  -->  p_form                                                        *
*---------------------------------------------------------------------*
FORM select_form USING p_secco CHANGING p_form.

  SELECT SINGLE tdform  FROM  j_1iewt_cert_n INTO p_form
        WHERE  bukrs    = zbukrs
         AND    secco   = p_secco
         AND    qscod   = zsect.

  IF layout = space.
    MESSAGE e743.
  ENDIF.

ENDFORM.                    "select_form

*---------------------------------------------------------------------*
*       FORM print_challanwise_summary                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_challanwise_summary.
  DATA : tmp_bankl LIKE bnka-bankl.
  CLEAR: total_amt,total_challan_amt.
  DATA : ls_belnr LIKE bseg-belnr,
         ls_wrbtr LIKE bseg-wrbtr.
* Data
  DATA : BEGIN OF printtab_loc OCCURS 5,
           j_1iextchln LIKE printtab-j_1iextchln,
           j_1iextchdt LIKE printtab-j_1iextchdt,
           banka       LIKE bnka-banka ,
           wt_qbshh    LIKE with_item-wt_qbshh,
         END OF printtab_loc .

  PERFORM select_company_name.
  PERFORM write_form USING 'CHALLAN_SUMMARY' 'SET' 'BODY' 'SUMMARY2'.
  SORT printtab BY j_1iextchdt j_1iextchln .

  LOOP AT printtab.


    MOVE-CORRESPONDING printtab TO printtab_loc .
    COLLECT printtab_loc .
  ENDLOOP .
  CLEAR printtab .

  LOOP AT printtab_loc WHERE
*                no_print <> 'X' AND
                NOT wt_qbshh IS INITIAL.
*    on change of printtab-j_1iextchln.
    MOVE-CORRESPONDING printtab_loc TO printtab .

    SELECT SINGLE belnr INTO ls_belnr FROM j_1iewtchln
           WHERE bukrs EQ zbukrs
             AND gjahr EQ zyear
             AND j_1iextchln EQ printtab_loc-j_1iextchln
             AND j_1iextchdt EQ printtab_loc-j_1iextchdt.
    IF sy-subrc = 0.
      SELECT SINGLE wrbtr INTO ls_wrbtr FROM bseg
                 WHERE belnr EQ ls_belnr
                   AND gjahr EQ zyear
                   AND bukrs EQ zbukrs.

      IF sy-subrc EQ 0.
        ls_wrbtr = ABS( ls_wrbtr ).
        printtab_loc-wt_qbshh = ls_wrbtr.
        MODIFY printtab_loc.
      ENDIF.

    ENDIF.


    PERFORM write_form USING 'CHALLAN_DATA' 'SET' 'BODY' 'MAIN'.
*   endon.
    total_challan_amt  = total_challan_amt + printtab-wt_qbshh.
    CLEAR printtab .
  ENDLOOP.
  total_amt = total_challan_amt.

  PERFORM write_form USING 'CERT_SUM' 'SET' 'BODY' 'MAIN'.
ENDFORM.                    "print_challanwise_summary

*---------------------------------------------------------------------*
*       FORM select_company_name                                      *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_company_name.
  SELECT SINGLE name1  FROM sadr INTO sadr-name1
                WHERE  adrnr = t001-adrnr" geting addresses
                AND    natio = ' ' .
ENDFORM.                    "select_company_name

*---------------------------------------------------------------------*
*       FORM end_form                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM end_form.

  CALL FUNCTION 'END_FORM'
    EXCEPTIONS
      unopened                 = 1
      bad_pageformat_for_print = 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.

ENDFORM.                    "end_form

*---------------------------------------------------------------------*
*       FORM print_certificate_summary                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_certificate_summary.

  CLEAR total_amt.

  DATA : ls_belnr LIKE bseg-belnr,
         ls_wrbtr LIKE bseg-wrbtr,
         wa_bseg LIKE bseg,
         j_1iintchln LIKE j_1iewtchln-j_1iintchln,
         j_1iintchdt LIKE j_1iewtchln-j_1iintchdt,
         wa_withtab LIKE LINE OF withtab.


  PERFORM write_form USING 'CERT_SUMMARY' 'SET' 'BODY' 'SUMMARY'.

  CLEAR it_summary.

  LOOP AT it_summary.
*    CLEAR PRINTTAB.
*    LOOP AT PRINTTAB WHERE BELNR EQ IT_SUMMARY-BELNR AND
*                    J_1IINTCHLN NE SPACE AND
*                    J_1IINTCHDT NE SPACE AND
*                    WT_ACCO EQ IT_SUMMARY-LIFNR AND
*                    GJAHR EQ IT_SUMMARY-GJAHR.
*
*      J_1IINTCHLN = PRINTTAB-J_1IINTCHLN.
*      J_1IINTCHDT = PRINTTAB-J_1IINTCHDT.
*      EXIT.
*    ENDLOOP.
*
*    SELECT SINGLE BELNR FROM J_1IEWTCHLN INTO LS_BELNR
*           WHERE BUKRS EQ ZBUKRS
*             AND GJAHR EQ ZYEAR
*             AND J_1IINTCHLN EQ J_1IINTCHLN
*             AND J_1IINTCHDT EQ J_1IINTCHDT.
*
*    IF SY-SUBRC EQ 0.
*      SELECT SINGLE WRBTR INTO LS_WRBTR FROM BSEG
*                    WHERE BELNR EQ LS_BELNR
*                      AND GJAHR EQ ZYEAR
*                      AND BUKRS EQ ZBUKRS.
*
*    LS_WRBTR = ABS( LS_WRBTR ).
*    IT_SUMMARY-AMOUNT = LS_WRBTR.
*    MODIFY IT_SUMMARY.
*
*    ENDIF.



    IF NOT it_summary-secco IS INITIAL.
      PERFORM write_form USING 'CERT_DATA' 'SET' 'BODY' 'MAIN'.
      total_amt  = total_amt + it_summary-amount.
    ELSE.
      IF NOT it_summary-bupla IS INITIAL.
        it_summary-secco = it_summary-bupla.
        PERFORM write_form USING 'CERT_DATA' 'SET' 'BODY' 'MAIN'.
        total_amt  = total_amt + it_summary-amount.
      ENDIF.
    ENDIF.

  ENDLOOP.

  PERFORM write_form USING 'CERT_SUM' 'SET' 'BODY' 'MAIN'.

ENDFORM.                    "print_certificate_summary

*---------------------------------------------------------------------*
*       FORM append_summary                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM append_summary USING p_lifnr p_bupla p_amount p_belnr p_gjahr.
  "Note 804529
  it_summary-lifnr = p_lifnr.
  it_summary-bupla = p_bupla.
  it_summary-certno = cert_number.
  it_summary-amount = p_amount.
  it_summary-belnr = p_belnr.   "Note 804529
  it_summary-gjahr = p_gjahr.   "Note 804529
  APPEND it_summary.
ENDFORM.                    "append_summary

*---------------------------------------------------------------------*
*       FORM update_tables                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_certno                                                      *
*---------------------------------------------------------------------*
FORM update_tables.
  CHECK con_reprint IS INITIAL.        "Update tables only for reprint
*USING p_certno.
*Update with_item table
*  CHECK NOT p_certno IS INITIAL.

*Loop at the summary table. For each certificate printed, select ffrom
*invtab and paytab for vendor and bupla. Update certificate number there
*modify withitem table from this internal table.
  REFRESH update_tab.

  LOOP AT it_summary.
    CHECK NOT it_summary-certno IS INITIAL.
    READ TABLE it_lfa1 WITH KEY lifnr = it_summary-lifnr. "Note 837288
    IF it_lfa1-one_time IS INITIAL.   " Note 815118
      LOOP AT invtab WHERE wt_acco = it_summary-lifnr
                     AND ( secco   = it_summary-secco      " Note 604606
                     OR    bupla   = it_summary-bupla )
* Belnr field has been removed " Note 815118
                     AND gjahr     = it_summary-gjahr.     " Note 804529
        MOVE-CORRESPONDING invtab TO update_tab.
        update_tab-ctnumber = it_summary-certno.
        update_tab-j_1icertdt = zcertdt.
        APPEND update_tab.
      ENDLOOP.
    ELSE.  " Note 815118
      LOOP AT invtab WHERE wt_acco = it_summary-lifnr
                     AND ( secco   = it_summary-secco      " Note 604606
                     OR    bupla   = it_summary-bupla )
                     AND belnr     = it_summary-belnr      " Note 804529
                     AND gjahr     = it_summary-gjahr.     " Note 804529
        MOVE-CORRESPONDING invtab TO update_tab.
        update_tab-ctnumber = it_summary-certno.
        update_tab-j_1icertdt = zcertdt.
        APPEND update_tab.
      ENDLOOP.
    ENDIF. " Note 815118

    IF it_lfa1-one_time IS INITIAL. " Note 815118
      LOOP AT paytab WHERE wt_acco = it_summary-lifnr
                     AND ( secco   = it_summary-secco      " Note 604606
                     OR    bupla   = it_summary-bupla )
* Belnr field has been removed " Note 815118
                     AND gjahr     = it_summary-gjahr.     " Note 804529
        MOVE-CORRESPONDING paytab TO update_tab.
        update_tab-ctnumber = it_summary-certno.
        update_tab-j_1icertdt = zcertdt.
        APPEND update_tab.
      ENDLOOP.
    ELSE. " Note 815118
      LOOP AT paytab WHERE wt_acco = it_summary-lifnr
                     AND ( secco   = it_summary-secco      " Note 604606
                     OR    bupla   = it_summary-bupla )
                     AND belnr     = it_summary-belnr      " Note 804529
                     AND gjahr     = it_summary-gjahr.     " Note 804529
        MOVE-CORRESPONDING paytab TO update_tab.
        update_tab-ctnumber = it_summary-certno.
        update_tab-j_1icertdt = zcertdt.
        APPEND update_tab.
      ENDLOOP.
    ENDIF. " Note 815118
  ENDLOOP.

  CHECK NOT update_tab[] IS INITIAL.
*update_tab now contains all the records which have to be updated into
*with_item and certificate table
  LOOP AT update_tab.
    UPDATE with_item SET ctnumber   = update_tab-ctnumber
                         j_1icertdt = update_tab-j_1icertdt
           WHERE  bukrs  = update_tab-bukrs
           AND    belnr  = update_tab-belnr
           AND    gjahr  = update_tab-gjahr
           AND    buzei  = update_tab-buzei
           AND    witht  = update_tab-witht.
  ENDLOOP.

  LOOP AT it_summary.
    IF NOT it_summary-secco IS INITIAL.                 " Note 604606
      CLEAR j_1iewt_certif_n.
      j_1iewt_certif_n-bukrs  = zbukrs.
      j_1iewt_certif_n-gjahr  = zyear.
      j_1iewt_certif_n-secco  = it_summary-secco.
      j_1iewt_certif_n-qscod  = zsect.
      j_1iewt_certif_n-ctnumber = it_summary-certno.
      j_1iewt_certif_n-j_1icertdt = zcertdt.
      j_1iewt_certif_n-wt_qbshh    = it_summary-amount.
      j_1iewt_certif_n-usnam = sy-uname.
      j_1iewt_certif_n-cputm = sy-uzeit.
      j_1iewt_certif_n-cpudt = sy-datum.

      CALL FUNCTION 'J_1I7_USEREXIT_CERTPRINT'
        EXPORTING
          print_flag          = 'X'
        CHANGING
          from_date           = zpdate-low
          to_date             = zpdate-high
          wa_j_1iewt_certif_n = j_1iewt_certif_n.

      MODIFY j_1iewt_certif_n.
    ELSE.                                                " Note 604606
      CLEAR j_1iewt_certif.
      j_1iewt_certif-bukrs  = zbukrs.
      j_1iewt_certif-gjahr  = zyear.
      j_1iewt_certif-bupla  = it_summary-bupla.
      j_1iewt_certif-qscod  = zsect.
      j_1iewt_certif-ctnumber = it_summary-certno.
      j_1iewt_certif-j_1icertdt = zcertdt.
      j_1iewt_certif-wt_qbshh    = it_summary-amount.
*insert to update user information  12.10.2000
      j_1iewt_certif-usnam = sy-uname.
      j_1iewt_certif-cputm = sy-uzeit.
      j_1iewt_certif-cpudt = sy-datum.
* end of insert to update user information  12.10.2000
      MODIFY j_1iewt_certif .
    ENDIF.                                                " Note 604606
  ENDLOOP.

  MESSAGE s749 .

ENDFORM.                    "update_tables

*---------------------------------------------------------------------*
*       FORM print_routines                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_routines.

  DATA :  tmp_secco LIKE invtab-secco,                      "Note 604606
          tmp_bupla LIKE invtab-bupla,
          tmp_lifnr LIKE lfa1-lifnr,
          loc_lifnr LIKE lfa1-lifnr,
          rc LIKE sy-subrc,
          loc_bupla LIKE zsecco,
          loc_secco LIKE zsecco,                            "Note 604606
          it LIKE printtab OCCURS 0 WITH HEADER LINE.

  DATA : pyear LIKE bkpf-gjahr.
  pyear = zyear.

  DATA : wa_printtab LIKE printtab. "Note 837288

  REFRESH: tmp_printtab, save_printtab.

  IF printtab[] IS INITIAL.
    MESSAGE e000 WITH 'No data selected' 'for printing'.
    STOP.
  ENDIF.

  PERFORM open_form.
  SORT it_lfa1  BY lifnr   secco bupla.                     "Note 604606
  SORT printtab BY wt_acco secco bupla.                     "Note 604606
* Since printtab is modified and taken for printing, another temporary
* internal table is created to store the values in printtab. At the time
* of printting, printtab is populated and passed to write_form_routines

  SORT printtab BY wt_acco secco bupla belnr.  " Start of 837288

  DATA : var_wt_qsshh  LIKE printtab-wt_qsshh,
         zvar_wt_qsshh LIKE printtab-wt_qsshh,
         var_wt_qbshh  LIKE printtab-wt_qbshh,
         sno LIKE printtab-sno.


  LOOP AT printtab.
    ON CHANGE OF printtab-wt_acco.
      CLEAR sno.
    ENDON.
    sno = sno + 1.
    wa_printtab = printtab.
    wa_printtab-sno = sno.
    SELECT SINGLE * FROM t059p
     WHERE land1 = 'IN'
       AND witht = printtab-witht
       AND wt_wtdp = '00'
       AND wt_inheritbase = ''.

    IF sy-subrc = 0.
      zvar_wt_qsshh = zvar_wt_qsshh + printtab-wt_qsshh.
    ELSE.
      IF  zvar_wt_qsshh < printtab-wt_qsshh.
        zvar_wt_qsshh = printtab-wt_qsshh.
      ENDIF.
    ENDIF.

    var_wt_qbshh = var_wt_qbshh + wa_printtab-wt_qbshh.

    AT END OF belnr.
      IF it_lfa1-one_time = ''.
        IF zvar_wt_qsshh = 0.
          wa_printtab-qsatz = 0.
        ELSE.
          wa_printtab-qsatz = ( var_wt_qbshh / zvar_wt_qsshh ) * 100.
        ENDIF.
      ENDIF.

      MOVE-CORRESPONDING wa_printtab TO save_printtab.
      save_printtab-wt_qsshh = zvar_wt_qsshh.
      save_printtab-wt_qbshh = var_wt_qbshh.
      APPEND save_printtab.
      CLEAR save_printtab.
      CLEAR : zvar_wt_qsshh, var_wt_qbshh.
    ENDAT.
  ENDLOOP.

  printtab[] = save_printtab[].  "End of 837288

  LOOP AT save_printtab.
    IF NOT save_printtab-secco IS INITIAL.
      PERFORM read_next_line_secco USING sy-tabix
      "Note 604606
                          CHANGING loc_lifnr
                                   loc_secco
                                   rc.
      READ TABLE it_lfa1 WITH KEY lifnr = save_printtab-wt_acco
                                   secco   = save_printtab-secco.
      IF it_lfa1-one_time IS INITIAL.    "Normal vendor
        IF loc_lifnr <> save_printtab-wt_acco
           OR rc <> 0
           OR loc_secco <> save_printtab-secco.
          PERFORM fill_tmp_table_for_vendor.
          PERFORM generate_number CHANGING cert_number.
          PERFORM print_certificate USING it_lfa1-one_time.
          REFRESH tmp_printtab.
        ELSE.
          PERFORM fill_tmp_table_for_vendor.
          CONTINUE.
        ENDIF.
      ELSE.                              "One time Vendor
        PERFORM generate_number CHANGING cert_number.
        PERFORM print_certificate USING it_lfa1-one_time.
      ENDIF.
    ELSE.
      PERFORM read_next_line USING sy-tabix
                          CHANGING loc_lifnr
                                   loc_bupla
                                   rc.
      READ TABLE it_lfa1 WITH KEY lifnr = save_printtab-wt_acco
                     bupla   = save_printtab-bupla.

      IF it_lfa1-one_time IS INITIAL.    "Normal vendor
        IF loc_lifnr <> save_printtab-wt_acco
           OR rc <> 0
           OR loc_bupla <> save_printtab-bupla.
          PERFORM fill_tmp_table_for_vendor.
          PERFORM generate_number CHANGING cert_number.
          PERFORM print_certificate USING it_lfa1-one_time.
          REFRESH tmp_printtab.
        ELSE.
          PERFORM fill_tmp_table_for_vendor.
          CONTINUE.
        ENDIF.
      ELSE.                              "One time Vendor
        PERFORM generate_number CHANGING cert_number.
        PERFORM print_certificate USING it_lfa1-one_time.
      ENDIF.
    ENDIF.
  ENDLOOP.

  zyear = pyear.

  PERFORM print_summaries.
  PERFORM update_tables .
  PERFORM close_form.

ENDFORM.                    "print_routines

*---------------------------------------------------------------------*
*       FORM print_certificate                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_one_time                                                    *
*---------------------------------------------------------------------*
FORM print_certificate  USING p_one_time.


  DATA:loc_printtab LIKE printtab OCCURS 0 WITH HEADER LINE.

  IF p_one_time <> 'X' .
* Printtab is the internal table used in the layout for all the details.
* This is the case of a normal vendor. So, the table tmp_printtab will
* contain the details which has to be printed. Hence printtab is locally
* moved to another internal table and then it is filled with entries in
* tmp_printtab . After printing, printtab is restored with old entries.
*To print correct tax rate in certificate for exemptions
    LOOP  AT tmp_printtab .
      IF  tmp_printtab-qsatz =  ' '  AND  tmp_printtab-wt_qszrt = ' '.
* When rate & exemption % not updates  like in cases  of  formulaee
        IF tmp_printtab-wt_qsshh NE 0.
          tmp_printtab-qsatz =
          ( tmp_printtab-wt_qbshh / tmp_printtab-wt_qsshh ) * 100.
        ELSE.
          tmp_printtab-qsatz = 0.
        ENDIF.
*    ELSEIF tmp_printtab-qsatz NE  ' ' AND  tmp_printtab-wt_qszrt NE '
*'.
** When rate & exemption %  as  been defined , actual  rate calculated
*        IF tmp_printtab-wt_qszrt NE 100.
*          tmp_printtab-qsatz =
*          tmp_printtab-qsatz * ( 100 - tmp_printtab-wt_qszrt ) / 100.
*        ELSE.
*          tmp_printtab-qsatz = 0.
*        ENDIF.
      ENDIF.
      MODIFY tmp_printtab TRANSPORTING qsatz.
    ENDLOOP.

* Perform start_form using layout 'FIRST'.
    loc_printtab[]  = printtab[].
    REFRESH printtab. CLEAR tmp_amount.
    printtab[]      = tmp_printtab[].
    PERFORM print_details_normal.
    printtab[]      = loc_printtab[].

  ELSE.
    MOVE save_printtab TO printtab.
* Address for one time vendors
    PERFORM get_address_from_bsec USING printtab-belnr
                                        printtab-buzei
                               CHANGING it_lfa1.
    PERFORM print_details_one_time.
  ENDIF.

ENDFORM.                    "print_certificate

*---------------------------------------------------------------------*
*       FORM fill_tmp_table_for_vendor                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_tmp_table_for_vendor.
  tmp_printtab = save_printtab.
  APPEND tmp_printtab.
ENDFORM.                    "fill_tmp_table_for_vendor

*---------------------------------------------------------------------*
*       FORM print_details_normal                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_details_normal.

  DATA : tds_calc TYPE i,
       sur_calc TYPE i,
       ecs_calc TYPE i.


  DATA :  tmp_count LIKE sy-tabix ,
          flg_new_page,
          tmp_mod   LIKE sy-tabix,
          tmp_lines LIKE sy-tabix.

  PERFORM start_form USING layout 'FIRST'.
  DESCRIBE TABLE printtab LINES tmp_lines.
  READ TABLE printtab INDEX 1.
  PERFORM select_pan.
  PERFORM print_header.
*  SORT printtab BY print_order .
  SORT printtab  BY sno gjahr budat.      "Note 891923
*  SORT printtab  BY gjahr budat.
  LOOP AT printtab WHERE wt_qbshh NE ''.
* Calculation for new page
    tmp_mod  = sy-tabix MOD 11.
    IF tmp_mod = tmp_count.
      flg_new_page = 'X'.
      tmp_count    = tmp_count + 1.
    ENDIF.
*** start sapna
* Logic for page numbering chngd
* Page no increment on customer change.
    ON CHANGE OF it_lfa1-lifnr.
      page_no = page_no + 1.
    ENDON.
*** end  sapna

* Printing headers and brought forward amount in new page
    IF flg_new_page = 'X' .
      PERFORM write_form USING 'MAIN_LINE' 'SET' 'BODY' 'MAIN'.
      PERFORM write_form USING 'CRFORWARD' 'SET' 'BODY' 'MAIN'.
      PERFORM new_page.
      PERFORM write_form USING 'MAIN_HEADING' 'SET' 'BODY' 'MAIN'.
      PERFORM write_form USING 'BRFORWARD' 'SET' 'BODY' 'MAIN'.
      flg_new_page = space.
      CLEAR tmp_count.
    ENDIF.
    PERFORM get_qsatz USING printtab-witht
                            printtab-wt_withcd
                   CHANGING printtab-qsatz.

*** Start of Changes made by Vivek for TDS, SURCHARGE, ECESS - 23Mar2007
***  Copied from J_1IEWT_CERT_F01
*** The rates are based on ZSECT and TaxType - WITHT & WT_WITHCD

*** 194A
    IF zsect = '194A'.
*** A1 - AA
      IF printtab-witht = 'A1' OR printtab-wt_withcd = 'AA'.
        tds_calc = 10 / 100 * printtab-wt_qsshh.
        printtab-tds_amount   = tds_calc.

        sur_calc = 0 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.
*printtab-ecess_amount = 2 / 1000 * ( printtab-tds_amount +
*printtab-surc_amount ).

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** A2 - AB
      IF printtab-witht = 'A2' OR printtab-wt_withcd = 'AB'.

        tds_calc   = 10 / 100   * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100   * printtab-tds_amount.
        printtab-surc_amount = sur_calc.


        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** A3 - AC
      IF printtab-witht = 'A3' OR printtab-wt_withcd = 'AC'.

        tds_calc   = 20 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.



        CLEAR : tds_calc, sur_calc, ecs_calc.


      ENDIF.

*** 194C
    ELSEIF zsect = '194C'.

*** Z1 - CA
      IF printtab-witht = 'Z1' OR printtab-wt_withcd = 'CA' OR
      printtab-wt_withcd = 'C1'.

        tds_calc   = 2 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  =       0 * printtab-tds_amount.
        printtab-surc_amount = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.



      ENDIF.
*** Z2 - CB
      IF printtab-witht = 'Z2' OR printtab-wt_withcd = 'CB' OR
      printtab-wt_withcd = 'C2'.

        tds_calc   =  2 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.



        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.
      ENDIF.
*** Z3 - ZC
      IF printtab-witht = 'Z3' OR printtab-wt_withcd = 'CC' OR
      printtab-wt_withcd = 'C3'.

        tds_calc = 2 / 100 * printtab-wt_qsshh.
        printtab-tds_amount   =  tds_calc.

        sur_calc = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).

*printtab-ecess_amount =  2 / 100 * ( printtab-tds_amount +
*printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.


      ENDIF.
*** Z4 - CD
      IF printtab-witht = 'Z4' OR printtab-wt_withcd = 'CD' OR
      printtab-wt_withcd = 'C4'.

        tds_calc   = 1 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  =       0 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.
        .

      ENDIF.
*** Z5 - CE
      IF printtab-witht = 'Z5' OR printtab-wt_withcd = 'CE' OR
      printtab-wt_withcd = 'C5'.

        tds_calc   =  1 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** Z6 - ZF
      IF printtab-witht = 'Z6' OR printtab-wt_withcd = 'CF' OR
      printtab-wt_withcd = 'C6'.

        tds_calc   =  1 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.

    ELSEIF  zsect = '194H'.
*** Z7 - H1
      IF printtab-witht = 'Z7' OR printtab-wt_withcd = 'H1' OR
      printtab-wt_withcd = 'HA'.

        tds_calc   = 5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  =       0 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** Z8 - H2
      IF printtab-witht = 'Z8' OR printtab-wt_withcd = 'H2' OR
      printtab-wt_withcd = 'HB'.

        tds_calc   =  5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** Z9 - H3
      IF printtab-witht = 'Z9' OR printtab-wt_withcd = 'H3' OR
      printtab-wt_withcd = 'HC'.

        tds_calc   =  5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.

    ELSEIF  zsect = '194J'.

*** Y1-JA
      IF printtab-witht = 'Y1' OR printtab-wt_withcd = 'JA' OR
      printtab-wt_withcd = 'J1'.

        tds_calc   = 5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  =       0 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** Y2 - JB
      IF printtab-witht = 'Y2' OR printtab-wt_withcd = 'JB' OR
      printtab-wt_withcd = 'J2'.

        tds_calc   =  5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** Y3 - JC
      IF printtab-witht = 'Y3' OR printtab-wt_withcd = 'JC' OR
      printtab-wt_withcd = 'J3'.

        tds_calc   =  5 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.

    ELSEIF  zsect = '194I'.

*** R1 - RA
      IF printtab-witht = 'R1' OR printtab-wt_withcd = 'RA'.

        tds_calc   = 15 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  =        0 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** R2 - RB
      IF printtab-witht = 'R2' OR printtab-wt_withcd = 'RB'.

        tds_calc   = 15 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR: tds_calc, sur_calc, ecs_calc.

      ENDIF.
*** R3 - RC
      IF printtab-witht = 'R3' OR printtab-wt_withcd = 'RC'.

        tds_calc   = 20 / 100 * printtab-wt_qsshh.
        printtab-tds_amount = tds_calc.

        sur_calc  = 10 / 100 * printtab-tds_amount.
        printtab-surc_amount  = sur_calc.

        ecs_calc = ( printtab-wt_qbshh ) - ( printtab-tds_amount +
        printtab-surc_amount ).
        printtab-ecess_amount =  ecs_calc.

        CLEAR : tds_calc, sur_calc, ecs_calc.


      ENDIF.

    ENDIF.

*** Added by Vivek K on 28-May-2007 for Cheque #

    DATA: clrdoc LIKE bseg-augbl.

    SELECT SINGLE augbl FROM bseg INTO clrdoc WHERE
                     bukrs        = printtab-bukrs
              AND    belnr        = printtab-belnr
              AND    gjahr        = printtab-gjahr
              AND    koart        = 'S'                  " GL Accounts
              AND    shkzg        = 'H'                  " Only Credit
              AND    qsskz        = printtab-WITHT.
              " Withholding Tax Code Not equal to Blank

    CLEAR printtab-cheque_no.

    IF sy-subrc = 0 AND clrdoc <> ' '.

      SELECT SINGLE chect FROM payr INTO printtab-cheque_no WHERE
                        zbukr        = printtab-bukrs
                 AND    vblnr        = clrdoc.

    ENDIF.
*** End of addition by Vivek K


    MODIFY printtab .


    CLEAR clrdoc.

*** End of Changes made by Vivek for TDS, SURCHARGE, ECESS - 23Mar2007


    PERFORM write_form USING 'MAIN_DATA' 'SET' 'BODY' 'MAIN'.

    tmp_amount  = tmp_amount + printtab-wt_qbshh.
  ENDLOOP.

* Sum and footer data
  IF NOT printtab-secco IS INITIAL.                     "Note 604606
    PERFORM append_summary_secco  USING printtab-wt_acco
                                printtab-secco
                                tmp_amount
                                printtab-belnr          " Note 804529
                                printtab-gjahr.         " Note 804529
  ELSE.
    PERFORM append_summary USING printtab-wt_acco
                                printtab-bupla
                                tmp_amount
                                printtab-belnr         " Note 804529
                                printtab-gjahr.        " Note 804529
  ENDIF.
  PERFORM print_footer.
  PERFORM end_form.

ENDFORM.                    "print_details_normal

*---------------------------------------------------------------------*
*       FORM print_details_one_time                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM print_details_one_time.

  CLEAR tmp_amount.
  PERFORM start_form USING layout 'FIRST'.
  PERFORM select_pan.
  PERFORM print_header.
  PERFORM get_qsatz USING printtab-witht
                          printtab-wt_withcd
                 CHANGING printtab-qsatz.
  PERFORM write_form USING 'MAIN_DATA' 'SET' 'BODY' 'MAIN'.
  tmp_amount  = tmp_amount + printtab-wt_qbshh.
* Sum and footer data
  IF NOT printtab-secco IS INITIAL.               "Note 604606
    PERFORM append_summary_secco  USING printtab-wt_acco
                                printtab-secco
                                tmp_amount
                                printtab-belnr    "Note 804529
                                printtab-gjahr.   "Note 804529
  ELSE.
    PERFORM append_summary USING printtab-wt_acco
                                printtab-bupla
                                printtab-wt_qbshh
                                printtab-belnr    "Note 804529
                                printtab-gjahr.   "Note 804529
  ENDIF.
  PERFORM print_footer.
  PERFORM end_form.

ENDFORM.                    "print_details_one_time

*---------------------------------------------------------------------*
*       FORM read_next_line                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  p_index                                                       *
*  -->  p_lifnr                                                       *
*---------------------------------------------------------------------*
FORM read_next_line USING value(p_index)
                 CHANGING p_lifnr
                          p_bupla
                          p_rc.

  DATA: loc_print LIKE printtab.
  loc_print = printtab.
  p_index   = p_index + 1.

  READ TABLE printtab INDEX p_index.
  p_rc     = sy-subrc.
  p_lifnr  = printtab-wt_acco.
  p_bupla  = printtab-bupla.
  printtab = loc_print.

ENDFORM.                    "read_next_line

*---------------------------------------------------------------------*
*       FORM filter_data                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM filter_data.
* Printtab contains the original data.
* If the following conditions apply, the records have to be filtered
* with the sum of tax amounts and only one record needs to be displayed.
* There is only one tax code for tax and surcharge .
* Document numbers, challan numbers and dates are same for the lines

  DATA : hold_tab  LIKE printtab OCCURS 0 WITH HEADER LINE,
         tmp_sum   LIKE bseg-dmbtr,
         tmp_sum_wt_basam LIKE with_item-wt_qsshh,  "Note 692642
          tmp_tabix LIKE sy-tabix.
  TYPES: BEGIN OF tp_index ,
           start(4) TYPE n ,  "change from 2 to 4 Note 803806
           end(4)   TYPE n,   "change from 2 to 4 Note 803806

  END OF tp_index.
  DATA : it_index  TYPE STANDARD TABLE OF tp_index  WITH HEADER LINE.
  DATA: lv_wt_qsshh LIKE with_item-wt_qsshh. "Note 850802

  TYPES: BEGIN OF rate_type ,        "Note 891923
          witht LIKE with_item-witht,
          wt_withcd LIKE with_item-wt_withcd,
          rate LIKE j_1iewt_surc1-j_1isurrat,
  END OF rate_type.

*---------------Declaration for legal change------------------------*
  "Note 891923
  DATA: surchtype_tab1 TYPE STANDARD TABLE OF rate_type WITH HEADER LINE
  ,
        surchtype_tab2 TYPE STANDARD TABLE OF rate_type WITH HEADER LINE
        ,
        ecesstype_tab1 TYPE STANDARD TABLE OF rate_type WITH HEADER LINE
        ,
        ecesstype_tab2 TYPE STANDARD TABLE OF rate_type WITH HEADER LINE
        .

  DATA:surc_wt_qbshh LIKE with_item-wt_qbshh,
       ecess_wt_qbshh LIKE with_item-wt_qbshh,
       tds_wt_qbshh LIKE with_item-wt_qbshh.

  "Change for Surcharge Error
  DATA:surc_wt_qbshh_tmp LIKE with_item-wt_qbshh,
       ecess_wt_qbshh_tmp LIKE with_item-wt_qbshh,
       tds_wt_qbshh_tmp LIKE with_item-wt_qbshh.

*----------------End of declaration---------------------------------*

*  SELECT SINGLE j_1isurc FROM  j_1iewt_comp
*            INTO  j_1iewt_comp-j_1isurc
*            WHERE bukrs     = zbukrs.
*  CHECK sy-subrc = 0
*    AND j_1iewt_comp-j_1isurc = 'X'.

* Check  for Surcharge as seperate  taxcode
  LOOP AT printtab.
*    READ TABLE printtab WITH KEY BELNR = printtab-belnr. " Note 843833
*      IF sy-tfill > 2.
    printtab-qsatz    = ( printtab-wt_qbshh / printtab-wt_qsshh )
                        * 100 .
    MODIFY printtab TRANSPORTING qsatz.
*      ELSE.
*        CONTINUE.
*      ENDIF.       Note 856124
  ENDLOOP.
  SELECT SINGLE * FROM  t001
      WHERE  bukrs   = zbukrs.
*  CHECK sy-subrc = 0  AND t001-surccm = 'X'.
  CHECK sy-subrc = 0.
  printtab_copy[] = printtab[]. "Note 826877

  SORT printtab BY belnr j_1iextchln j_1iextchdt.
  hold_tab[] = printtab[].

  LOOP AT printtab.
    CLEAR: it_index.
    LOOP AT hold_tab WHERE belnr       = printtab-belnr
                       AND wt_acco     = printtab-wt_acco
                       AND buzei       = printtab-buzei "Note 826877
                       AND j_1iextchln = printtab-j_1iextchln
                       AND j_1iextchdt = printtab-j_1iextchdt.
      IF it_index-start IS INITIAL.
        it_index-start = sy-tabix.
      ENDIF.
      tmp_tabix = sy-tabix.
    ENDLOOP.

    CHECK sy-subrc = 0 .
    it_index-end = tmp_tabix.
    CHECK NOT it_index-start IS INITIAL
      AND NOT it_index-end   IS INITIAL.
    APPEND it_index.
  ENDLOOP.
  printtab[] = printtab_copy[]. "Note 826877
  SORT it_index BY start end.
  DELETE ADJACENT DUPLICATES FROM it_index.

*---------start of change for implementation of legal change--------*
  "Note 891923
  SELECT witht wt_withcd FROM j_1iewtsurc INTO TABLE surchtype_tab1.
  SELECT witht wt_withcd FROM j_1iewtecess INTO TABLE ecesstype_tab1.

  SELECT witht wt_withcd j_1isurrat FROM j_1iewt_surc1 INTO TABLE
surchtype_tab2.
  SELECT witht wt_withcd j_1iecessrt FROM j_1iewt_ecess1 INTO TABLE
ecesstype_tab2.
*---------end of change for implementation of legal change--------*

  LOOP AT it_index.
    REFRESH hold_tab.
    APPEND LINES OF printtab
         FROM it_index-start TO it_index-end
           TO  hold_tab.
    CLEAR:tmp_sum, surc_wt_qbshh, tds_wt_qbshh, ecess_wt_qbshh.
    CLEAR: tmp_sum_wt_basam.   "Note 792298
    LOOP AT hold_tab.
      tmp_sum = tmp_sum + hold_tab-wt_qbshh.
*     Note 692642
      lv_wt_qsshh = ABS( hold_tab-wt_qsshh ). "Note 850802
      IF lv_wt_qsshh GT tmp_sum_wt_basam.
        tmp_sum_wt_basam = lv_wt_qsshh.
      ENDIF.  "Note 792298
*     Note 692642

*---------start of change for implementation of legal change--------*
      "Note 891923
      SELECT SINGLE * FROM t001 WHERE bukrs = hold_tab-bukrs AND surccm
      = 'X'.
      IF sy-subrc = 0.
        READ TABLE surchtype_tab1 WITH KEY
        witht = hold_tab-witht
        wt_withcd = hold_tab-wt_withcd.
        IF sy-subrc = 0 .
          surc_wt_qbshh = surc_wt_qbshh + hold_tab-wt_qbshh.
        ELSE.                                           "Note 910865
          SELECT SINGLE * FROM j_1iewt_ecflag WHERE bukrs =
          hold_tab-bukrs AND
       ecess_separate = 'X'.
          IF sy-subrc = 0.
            READ TABLE ecesstype_tab1 WITH KEY
            witht = hold_tab-witht
            wt_withcd = hold_tab-wt_withcd.
            IF sy-subrc = 0 .
              ecess_wt_qbshh = ecess_wt_qbshh + hold_tab-wt_qbshh.
            ELSE.
              tds_wt_qbshh = tds_wt_qbshh +  hold_tab-wt_qbshh.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
        SELECT SINGLE * FROM j_1iewt_ecflag WHERE bukrs = hold_tab-bukrs
 AND ecess_separate = 'X'.
        IF sy-subrc = 0.
          READ TABLE ecesstype_tab1 WITH KEY
          witht = hold_tab-witht
          wt_withcd = hold_tab-wt_withcd.
          IF sy-subrc = 0 .
            ecess_wt_qbshh = ecess_wt_qbshh + hold_tab-wt_qbshh.
          ELSE.
            READ TABLE surchtype_tab2 WITH KEY
            witht = hold_tab-witht
            wt_withcd = hold_tab-wt_withcd.
            IF sy-subrc = 0.
              tds_wt_qbshh_tmp = ( hold_tab-wt_qbshh ) *
                                 100 / ( 100 + surchtype_tab2-rate ).
              surc_wt_qbshh_tmp = ( tds_wt_qbshh_tmp *
              surchtype_tab2-rate
                                   ) / 100.
              tds_wt_qbshh = tds_wt_qbshh + tds_wt_qbshh_tmp.
              surc_wt_qbshh = surc_wt_qbshh + surc_wt_qbshh_tmp.
            ENDIF.
          ENDIF.
        ELSE.
          READ TABLE surchtype_tab2 WITH KEY
            witht = hold_tab-witht
            wt_withcd = hold_tab-wt_withcd.
          IF sy-subrc = 0.
            READ TABLE ecesstype_tab2 WITH KEY
              witht = hold_tab-witht
              wt_withcd = hold_tab-wt_withcd.
            IF sy-subrc = 0 .
              tds_wt_qbshh_tmp = ( hold_tab-wt_qbshh * 100 * 100 ) / (
                                  10000 + ( 100 *
              surchtype_tab2-rate ) + ( 100 + surchtype_tab2-rate ) *
              ecesstype_tab2-rate ).
              tds_wt_qbshh = tds_wt_qbshh + tds_wt_qbshh_tmp.
              surc_wt_qbshh_tmp = ( tds_wt_qbshh_tmp *
                                   surchtype_tab2-rate ) / 100.
              surc_wt_qbshh = surc_wt_qbshh + surc_wt_qbshh_tmp.
              ecess_wt_qbshh_tmp = ( ( tds_wt_qbshh_tmp +
                                    surc_wt_qbshh_tmp ) *
              ecesstype_tab2-rate ) / 100.
              ecess_wt_qbshh = ecess_wt_qbshh + ecess_wt_qbshh_tmp.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.

    ENDLOOP.
    READ TABLE printtab INDEX it_index-start.

    printtab-wt_qbshh = tmp_sum.
    printtab-tds_amount = tds_wt_qbshh.

    printtab-surc_amount = surc_wt_qbshh.
    printtab-ecess_amount = ecess_wt_qbshh.
    printtab-wt_qsshh = tmp_sum_wt_basam. "Note 850802
    printtab-qsatz    = ( printtab-wt_qbshh / printtab-wt_qsshh )
                        * 100 .
    MODIFY printtab INDEX it_index-start
         TRANSPORTING wt_qbshh qsatz wt_qsshh tds_amount surc_amount
ecess_amount."Note 792298/826877/856124
  ENDLOOP.
*---------end of change for implementation of legal change--------*

  REFRESH hold_tab.

  LOOP AT it_index.
    it_index-start = it_index-start + 1.
    APPEND LINES OF printtab
         FROM it_index-start TO it_index-end
           TO  hold_tab.
  ENDLOOP.

  LOOP AT hold_tab.
    DELETE printtab
          WHERE belnr = hold_tab-belnr
            AND gjahr = hold_tab-gjahr
            AND buzei = hold_tab-buzei
            AND witht = hold_tab-witht
            AND wt_withcd = hold_tab-wt_withcd.

  ENDLOOP.

ENDFORM.                    "filter_data

*---------------------------------------------------------------------*
*       FORM check_certificate                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM check_certificate.
  CLEAR: bupla_cert, secco_cert.

  SELECT * FROM  j_1iewt_certif INTO j_1iewt_certif
          WHERE  bukrs       = zbukrs
          AND    qscod       = zsect
          AND    ctnumber    = zcertno
          AND    j_1icertdt  = zcerdt.
    IF sy-subrc = 0.
      bupla_cert = 'X'.
      EXIT.
    ENDIF.
  ENDSELECT.

  IF NOT bupla_cert = 'X'.
    SELECT * FROM  j_1iewt_certif_n INTO j_1iewt_certif_n
           WHERE  bukrs       = zbukrs
           AND    qscod       = zsect
           AND    ctnumber    = zcertno
           AND    j_1icertdt  = zcerdt.
      IF sy-subrc = 0.
        secco_cert = 'X'.
        EXIT.
      ENDIF.
    ENDSELECT.
  ENDIF.

  CHECK sy-subrc <> 0.
  MESSAGE e000 WITH 'No Certificates found'.

ENDFORM.                    "check_certificate



*---------------------------------------------------------------------*
*       FORM fill_withtab                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_withtab_reprint.

  SELECT        * FROM  with_item
         WHERE  bukrs        = j_1iewt_certif-bukrs
         AND    gjahr        = j_1iewt_certif-gjahr
         AND    wt_stat      = ' '
         AND    koart        = 'K'
         AND    ctnumber     =  j_1iewt_certif-ctnumber
         AND    wt_opowtpd   NE 'X'
         AND    wt_gruwtpd   NE 'X' .
* Validate for BUPLA here itself.
    CHECK sy-subrc = 0 .
    READ TABLE taxtab WITH KEY witht = with_item-witht
                           wt_withcd = with_item-wt_withcd.
    CHECK sy-subrc = 0 .

    SELECT  SINGLE budat FROM  bkpf INTO bkpftab-budat
           WHERE  bukrs  = j_1iewt_certif-bukrs
           AND    belnr  = with_item-belnr
           AND    gjahr  = j_1iewt_certif-gjahr.

    SELECT SINGLE bupla  FROM bseg INTO bseg-bupla
                WHERE  bukrs        = j_1iewt_certif-bukrs
                AND    belnr        = with_item-belnr
                AND    gjahr        = j_1iewt_certif-gjahr
                AND    buzei        = with_item-j_1ibuzei
                AND    ktosl        = 'WIT'.
    CHECK sy-subrc = 0 .
    PERFORM select_challan_reprint.
* Move data to withtab.
    MOVE-CORRESPONDING with_item TO withtab.
    MOVE: bkpftab-budat TO withtab-budat,
          bseg-bupla TO withtab-bupla,
          bseg-secco TO withtab-secco,
          challantab-j_1iextchln TO withtab-j_1iextchln,
          challantab-j_1iextchdt TO withtab-j_1iextchdt,
          challantab-bankl       TO withtab-bankl,
          taxtab-method TO withtab-method.
    APPEND withtab.
  ENDSELECT.

ENDFORM.                    "fill_withtab_reprint

*---------------------------------------------------------------------*
*       FORM check_dates                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  start_date                                                    *
*  -->  end_date                                                      *
*---------------------------------------------------------------------*
FORM check_dates_reprint USING start_date end_date .

  CHECK start_date > end_date.
  MESSAGE e000 WITH
  'Certificate Reprint date should be'  ' on or later than '
    'Certificate date'.


ENDFORM.                    "check_dates_reprint

*---------------------------------------------------------------------*
*       FORM select_challan_reprint                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM select_challan_reprint.
  SELECT *
         FROM  j_1iewtchln INTO challantab
         WHERE  bukrs        = with_item-bukrs
*        AND    belnr        = with_item-belnr
*        AND    gjahr        = with_item-gjahr
         AND    j_1iintchln  = with_item-j_1iintchln
         AND    j_1iintchdt  = with_item-j_1iintchdt.
    EXIT.
  ENDSELECT.
ENDFORM.                    "select_challan_reprint

*---------------------------------------------------------------------*
*       FORM fill_nature_of_payment                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_nature_of_payment.

  SELECT SINGLE text40 FROM  t059ot INTO t059o-text40
         WHERE  land1     = t001-land1
         AND spras = sy-langu
         AND    wt_qscod  = zsect.

ENDFORM.                    "fill_nature_of_payment


*&---------------------------------------------------------------------*
*&      Form  check_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM check_secco.
  CLEAR seccode.
  SELECT COUNT( * ) FROM seccode
             WHERE bukrs  = zbukrs
               AND seccode IN zsecco.
  IF sy-subrc <> 0.
    MESSAGE e707.
  ENDIF .
ENDFORM.                    " check_secco

*&---------------------------------------------------------------------*
*&      Form  read_next_line_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_SY_TABIX  text
*      <--P_LOC_LIFNR  text
*      <--P_LOC_SECCO  text
*      <--P_RC  text
*----------------------------------------------------------------------*
FORM read_next_line_secco USING value(p_index)
                 CHANGING p_lifnr
                          p_secco
                          p_rc.
  DATA: loc_print LIKE printtab.
  loc_print = printtab.
  p_index   = p_index + 1.

  READ TABLE printtab INDEX p_index.
  p_rc     = sy-subrc.
  p_lifnr  = printtab-wt_acco.
  p_secco  = printtab-secco.
  printtab = loc_print.

ENDFORM.                    " read_next_line_secco


*&---------------------------------------------------------------------*
*&      Form  select_data_for_layout_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM select_data_for_layout_secco.

  PERFORM fill_adrc_for_secco.
  PERFORM select_adrc USING t001-adrnr CHANGING t_adrc.
  PERFORM fill_nature_of_payment.

ENDFORM.                    " select_data_for_layout_secco


*&---------------------------------------------------------------------*
*&      Form  fill_adrc_for_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fill_adrc_for_secco.
  CLEAR adrc.
  SELECT  SINGLE adrnr FROM  seccode
          INTO seccode-adrnr
          WHERE  bukrs  = zbukrs
            AND  seccode = printtab-secco.

  CHECK NOT   seccode-adrnr IS INITIAL.
  PERFORM select_adrc_secco USING seccode-adrnr CHANGING adrc.

ENDFORM.                    " fill_adrc_for_secco
*&---------------------------------------------------------------------*
*&      Form  select_adrc_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_SECCODE_ADRNR  text
*      <--P_ADRC  text
*----------------------------------------------------------------------*
FORM select_adrc_secco USING    p_adrnr
                 CHANGING p_adrc STRUCTURE adrc.

  SELECT * FROM  adrc INTO p_adrc
         WHERE  addrnumber  = p_adrnr.
    EXIT.
  ENDSELECT.

ENDFORM.                    " select_adrc_secco
*&---------------------------------------------------------------------*
*&      Form  append_summary_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PRINTTAB_WT_ACCO  text
*      -->P_PRINTTAB_SECCO  text
*      -->P_TMP_AMOUNT  text
*----------------------------------------------------------------------*
FORM append_summary_secco USING   p_lifnr p_secco  p_amount p_belnr
p_gjahr.   " Note 804529
  it_summary-lifnr = p_lifnr.
  it_summary-secco = p_secco.
  it_summary-certno = cert_number.
  it_summary-amount = p_amount.
  it_summary-belnr = p_belnr.   " Note 804529
  it_summary-gjahr = p_gjahr.   " Note 804529
  APPEND it_summary.

ENDFORM.                    " append_summary_secco
*&---------------------------------------------------------------------*
*&      Form  select_form_bupla
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ZBUPLA_LOW  text
*      <--P_LAYOUT  text
*----------------------------------------------------------------------*
FORM select_form_bupla USING p_bupla CHANGING p_form.

  SELECT SINGLE tdform  FROM  j_1iewt_cert INTO p_form
        WHERE  bukrs    = zbukrs
         AND    bupla   = p_bupla
         AND    qscod   = zsect.

  IF layout = space.
    MESSAGE e743.
  ENDIF.

ENDFORM.                    " select_form_bupla
*&---------------------------------------------------------------------*
*&      Form  fill_withtab_reprint_secco
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fill_withtab_reprint_secco.

  SELECT * FROM  with_item
          WHERE  bukrs        = j_1iewt_certif_n-bukrs
          AND    gjahr        = j_1iewt_certif_n-gjahr
          AND    wt_stat      = ' '
          AND    koart        = 'K'
          AND    ctnumber     =  j_1iewt_certif_n-ctnumber
          AND    wt_opowtpd   NE 'X'
          AND    wt_gruwtpd   NE 'X' .
* Validate for BUPLA here itself.
    CHECK sy-subrc = 0 .
    READ TABLE taxtab WITH KEY witht = with_item-witht
                           wt_withcd = with_item-wt_withcd.
    CHECK sy-subrc = 0 .

    SELECT  SINGLE budat FROM  bkpf INTO bkpftab-budat
           WHERE  bukrs  = j_1iewt_certif_n-bukrs
           AND    belnr  = with_item-belnr
           AND    gjahr  = j_1iewt_certif_n-gjahr.

    SELECT SINGLE secco  FROM bseg INTO bseg-secco
                          WHERE  bukrs        = j_1iewt_certif_n-bukrs
                          AND    belnr        = with_item-belnr
                          AND    gjahr        = j_1iewt_certif_n-gjahr
                          AND    buzei        = with_item-j_1ibuzei
                          AND    ktosl        = 'WIT'.
    CHECK sy-subrc = 0 .
    PERFORM select_challan_reprint.
* Move data to withtab.
    MOVE-CORRESPONDING with_item TO withtab.
    MOVE: bkpftab-budat TO withtab-budat,
          bseg-bupla TO withtab-bupla,
          bseg-secco TO withtab-secco,
          challantab-j_1iextchln TO withtab-j_1iextchln,
          challantab-j_1iextchdt TO withtab-j_1iextchdt,
          challantab-bankl       TO withtab-bankl,
          taxtab-method TO withtab-method.
    APPEND withtab.
  ENDSELECT.

ENDFORM.                    " fill_withtab_reprint_secco

*&---------------------------------------------------------------------*
*&      Form  callback_bsik
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*------------------------------------------------------------------
FORM callback_bsik USING name  TYPE ldbn-ldbnode
                        wa    TYPE bsik
                        evt   TYPE c
                        check TYPE c.
  CLEAR wa_bsik.
  MOVE-CORRESPONDING wa TO wa_bsik.

*  insert wa_bkpf into table bkpftab.
  APPEND wa_bsik TO bsiktab.


ENDFORM.                    "callback_bsik


* ---------- Note 887656 ----------------------------------------------
*&---------------------------------------------------------------------*
*&      Form  callback_bkpf
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->NAME       text
*      -->WA         text
*      -->EVT        text
*      -->CHECK      text
*----------------------------------------------------------------------*
FORM callback_bkpf USING name  TYPE ldbn-ldbnode
                          wa    TYPE bkpf
                          evt   TYPE c
                          check TYPE c.
  CLEAR wa_bkpf.
  MOVE-CORRESPONDING wa TO wa_bkpf.

*  insert wa_bkpf into table bkpftab.
  IF wa_bkpf-stblg IS INITIAL.
    APPEND wa_bkpf TO bkpftab.
  ENDIF.

ENDFORM.                    "callback_bkpf

*&---------------------------------------------------------------------*
*&      Form  callback_bseg
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->NAME       text
*      -->WA         text
*      -->EVT        text
*      -->CHECK      text
*----------------------------------------------------------------------*
FORM callback_bseg USING name  TYPE ldbn-ldbnode
                          wa    TYPE bseg
                          evt   TYPE c
                          check TYPE c.
  CLEAR wa_bseg.
  MOVE-CORRESPONDING wa TO wa_bseg.

*  insert wa_bseg into  table bsegtab.
  APPEND wa_bseg TO bsegtab.
ENDFORM.                    "callback_bseg

*&---------------------------------------------------------------------*
*&      Form  callback_with
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->NAME       text
*      -->WA         text
*      -->EVT        text
*      -->CHECK      text
*----------------------------------------------------------------------*
FORM callback_with USING name  TYPE ldbn-ldbnode
                          wa    TYPE with_item
                          evt   TYPE c
                          check TYPE c.
  DATA : v_gjahr(4) TYPE n.

  READ TABLE taxtab WITH KEY witht = wa-witht
                             wt_withcd = wa-wt_withcd.
  CHECK sy-subrc = 0.
  IF wa-wt_stat = ' ' AND    wa-koart = 'K'  AND    wa-wt_acco IN
zvendor
    AND wa-ctnumber = ' ' AND  wa-wt_opowtpd NE 'X' AND wa-wt_gruwtpd NE
 'X' AND wa-j_1iewtrec NE 'B'.

    SELECT SINGLE augbl augdt FROM bsas INTO (bsas-augbl,bsas-augdt)
                             WHERE bukrs = wa-bukrs
                             AND   hkont = wa-hkont
                             AND   gjahr = wa-gjahr
                             AND   belnr = wa-belnr
                             AND   buzei = wa-j_1ibuzei.
    CHECK sy-subrc = 0 .
    SELECT SINGLE gjahr FROM bkpf INTO v_gjahr
                                  WHERE bukrs = wa-bukrs
                                  AND   belnr = bsas-augbl
                                  AND   budat = bsas-augdt.

*      CALL FUNCTION 'J_1I6_DETERMINE_EXC_YEAR'
*        EXPORTING
*          I_BUKRS      = with_item-bukrs
*          I_BUDAT      = bsas-augdt
*        IMPORTING
*          EXCISE_YEAR  = v_gjahr
*        EXCEPTIONS
*          MISS_COMPANY = 1
*          OTHERS       = 2.

    READ TABLE challantab WITH KEY   bukrs  = wa-bukrs
                                     belnr  = bsas-augbl
                                     gjahr  = v_gjahr.


    CHECK sy-subrc = 0 .

    IF NOT wa_bseg-secco IN zsecco.
      CHECK wa_bseg-bupla IN zsecco.
    ENDIF.
    MOVE-CORRESPONDING wa TO withitem_wa.
    withitem_wa-budat = wa_bkpf-budat.
    withitem_wa-bupla = wa_bseg-bupla.
    withitem_wa-secco = wa_bseg-secco.
    withitem_wa-j_1iextchln = challantab-j_1iextchln.
    withitem_wa-j_1iextchdt = challantab-j_1iextchdt.
    withitem_wa-bankl = challantab-bankl.
    withitem_wa-method = taxtab-method.

    READ TABLE jvtab WITH KEY wt_withcd = withitem_wa-wt_withcd
                                 augbl = withitem_wa-belnr.
    IF sy-subrc = 0.
      withitem_wa-wt_qbshh = withitem_wa-wt_qbshh - jvtab-wt_qbshh.
      withitem_wa-wt_qbshb = withitem_wa-wt_qbshb - jvtab-wt_qbshb.
      withitem_wa-wt_qszrt = ' '.
      withitem_wa-qsatz = ( withitem_wa-wt_qbshh / withitem_wa-wt_qsshh
      )
                                                            * 100.
    ENDIF.

*  insert withitem_wa into table withtab.
    APPEND withitem_wa TO withtab.
    CLEAR withitem_wa.
  ENDIF.
ENDFORM.                    "fill_withtab
*&---------------------------------------------------------------------*
*&      Form  SELECT_JV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM select_jv .


  DATA: BEGIN OF it_bkpf OCCURS 0.
          INCLUDE STRUCTURE bkpf.
  DATA : buzei LIKE bseg-buzei.
  DATA : wrbtr LIKE bseg-wrbtr.
  DATA : END OF it_bkpf.

  DATA : it_bseg LIKE bseg OCCURS 0 WITH HEADER LINE,
         xblnr LIKE bkpf-xblnr,
         buzei LIKE bseg-buzei,
         wa LIKE LINE OF it_bkpf.


  DELETE printtab WHERE j_1iewtrec EQ 'J'.

  IF sy-subrc EQ 0.

    SELECT * FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
             WHERE bukrs = zbukrs
               AND gjahr = zyear
               AND tcode = 'J1INJV'
               AND xblnr NE space
               AND budat IN zpdate
               AND blart IN zdoctype
               AND stgrd NE space.

    LOOP AT it_bkpf INTO wa.

      SPLIT wa-xblnr AT '-' INTO xblnr buzei.

      IF sy-subrc = 0.

        REPLACE ALL OCCURRENCES OF '*' IN xblnr WITH space.
        CONDENSE xblnr NO-GAPS.
        CONDENSE buzei NO-GAPS.
        wa-xblnr = xblnr.
        wa-buzei = buzei.
        MODIFY it_bkpf FROM wa TRANSPORTING xblnr buzei.

      ENDIF.

    ENDLOOP.


    SELECT * FROM bseg INTO TABLE it_bseg
             FOR ALL ENTRIES IN it_bkpf
             WHERE bukrs = it_bkpf-bukrs
               AND belnr = it_bkpf-belnr
               AND gjahr = it_bkpf-gjahr.


    LOOP AT it_bkpf.

      CLEAR printtab.
      READ TABLE printtab WITH KEY bukrs = it_bkpf-bukrs
                                   belnr = it_bkpf-xblnr
                                   gjahr = it_bkpf-gjahr
                                   j_1ibuzei = it_bkpf-buzei.

      IF sy-subrc = 0.

        CLEAR it_bseg.

        READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs
                                    belnr = it_bkpf-belnr
                                    gjahr = it_bkpf-gjahr
                                    koart = 'S'
                                    hkont = printtab-hkont.


        IF sy-subrc = 0.
          IF it_bseg-shkzg = 'S'.
            printtab-wt_qbshh = printtab-wt_qbshh - it_bseg-dmbtr.
            printtab-wt_qbshb = printtab-wt_qbshb - it_bseg-wrbtr.
          ELSE.
            printtab-wt_qbshh = printtab-wt_qbshh + it_bseg-dmbtr.
            printtab-wt_qbshb = printtab-wt_qbshb + it_bseg-wrbtr.
          ENDIF.

          MODIFY TABLE printtab.

        ENDIF.
      ENDIF.
    ENDLOOP.

  ENDIF.



ENDFORM.                    " SELECT_JV

<u><b>Inculde Report for Table declaration</b></u>

*----------------------------------------------------------------------*
*   INCLUDE ZJ_1IEWT_CERT_TOP                                   *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*                 TABLES                                       *
*----------------------------------------------------------------------*

TABLES: bkpf,
        bseg,
        bsas,
        with_item,
        j_1iewtchln,
        j_1iewt_cert,
        j_1iewt_certno,
        j_1iewt_certif,
        j_1imovend,
        j_1imocust,
        t059z,
        t059p,
        t001,
        j_1bbranch,
        t059ot,
        t059o,
        t001z,
        t059fb,
        t059c,
        skb1,
        adrc,
        sadr,
        itcpo,
        lfb1,
        knb1,
        t012,
        seccode,            " Note 604606
        j_1iewt_cert_n,     " Note 604606
        j_1iewt_certif_n,   " Note 604606
        j_1iewt_ecflag.     " Note 910865

*----------------------------------------------------------------------*
*                 DATA                                                 *
*----------------------------------------------------------------------*
DATA : lin             TYPE i,
       cert_number     LIKE inrdp-fromnumber,
       flg_first_time  TYPE c VALUE 'X' ,
       tmp_amount      LIKE bseg-dmbtr,
       layout          LIKE  itcta-tdform,
       bankname        LIKE bnka-banka,
       bankbrnch       LIKE bnka-brnch,
       bankcity        LIKE bnka-ort01,
       total_challan_amt LIKE bseg-dmbtr,
       total_amt       LIKE  bseg-dmbtr,
       cnt_print_order LIKE sy-tabix,
       rc              LIKE sy-subrc,
       con_reprint     TYPE c VALUE space, "Set as X for reprint program
       girno           like t001z-paval.
*----------------------------------------------------------------------*
*                 INTERNAL TABLES                              *
*----------------------------------------------------------------------*
DATA : BEGIN OF withtab OCCURS  0.
        INCLUDE STRUCTURE with_item.
DATA:    budat       LIKE bkpf-budat,
         bupla       LIKE bseg-bupla,
         secco       LIKE bseg-secco,                      " Note 604606
         j_1iextchln LIKE j_1iewtchln-j_1iextchln,
         j_1iextchdt LIKE j_1iewtchln-j_1iextchdt,
         bankl       LIKE j_1iewtchln-bankl,
         flag        TYPE c,
         no_print    TYPE c,
         method      type c,              "I- Invoice, P- Downpayment
         print_order LIKE sy-tabix,
         lifnr       LIKE bseg-lifnr,     "Note 704757
        END OF withtab.

DATA: begin of bkpftab OCCURS 0.
      include structure  bkpf .
data : rev_ind(1).
data : end of bkpftab.
data : challantab LIKE j_1iewtchln OCCURS 0 WITH HEADER LINE.

data: BEGIN OF taxtab OCCURS 0 .
        INCLUDE STRUCTURE  t059z .
DATA:   method ,                     "I-Invoice and P-Payment
      END OF taxtab.

*Note 773106

*DATA: invtab LIKE withtab OCCURS 0 WITH HEADER LINE,
 DATA: paytab LIKE withtab OCCURS 0 WITH HEADER LINE.

data: begin of invtab occurs 0.
      include structure withtab.
data : base_mod type c.
data : end of invtab.


data:  bEGIN OF it_lfa1 OCCURS 0.
        INCLUDE STRUCTURE lfa1.
DATA :  one_time ,
        bupla LIKE bseg-bupla,
        secco like bseg-secco,                             " Note 604606
        str_suppl1 LIKE adrc-str_suppl1,                " Street 2
        str_suppl2 LIKE adrc-str_suppl2,                " Street 3
        street     LIKE adrc-street    ,
        city1      LIKE adrc-city1,
        city2      LIKE adrc-city2     ,       "District
        post_code1 LIKE adrc-post_code1,      " Post code
        pan        LIKE j_1imovend-j_1ipanno,
       END OF it_lfa1.

*data for reprint program

DATA: it_cert LIKE j_1iewt_certif OCCURS 0 WITH HEADER LINE,
      t_adrc  LIKE adrc.

DATA: BEGIN OF temp_withtab OCCURS 0.
  DATA: belnr LIKE withtab-belnr,
        buzei like withtab-buzei,
        wt_qsshh LIKE withtab-wt_qsshh,
        wt_qbshh LIKE withtab-wt_qbshh,
        qsatz LIKE withtab-qsatz.
  DATA: END OF temp_withtab.

data : BEGIN OF printtab OCCURS 0 .
        INCLUDE STRUCTURE invtab.



DATA :  sno LIKE sy-tabix,                  "Note 891923
        tds_amount LIKE bseg-wrbtr,
        surc_amount LIKE bseg-wrbtr,
        ecess_amount LIKE bseg-wrbtr,
        cheque_no like inrdp-fromnumber,
        banka LIKE bnka-banka,
        ort01 LIKE bnka-ort01,
*** Changes by Vivek 01-Jun-06
        brnch LIKE bnka-brnch,
*        brnch LIKE t012-stcd1,
***END OF Changes by Vivek 01-Jun-06
        j_1itdbank like J_1ICERTIF-j_1itdbank,  " Note 912767
        word LIKE spell-word,
        paise LIKE spell-decword,
        total_tax LIKE bseg-dmbtr, "sapna 040507
       END OF printtab.
DATA : BEGIN OF it_summary OCCURS 0,
        lifnr LIKE lfa1-lifnr,
        bupla LIKE bseg-bupla,
        secco LIKE bseg-secco,                           " Note 604606
        certno LIKE inrdp-fromnumber,
        amount LIKE bseg-wrbtr,
        belnr LIKE bseg-belnr,     " Note 804529
        gjahr LIKE bseg-gjahr,     " Note 804529
       END OF it_summary.

DATA: tmp_printtab LIKE printtab OCCURS 0 WITH HEADER LINE,
      save_printtab LIKE printtab OCCURS 0 WITH HEADER LINE,
      printtab_copy LIKE printtab OCCURS 0 WITH HEADER LINE."Note 826877

DATA : BEGIN OF update_tab OCCURS 0.
        INCLUDE STRUCTURE with_item.
DATA : END OF update_tab.

data: JVTAB like with_item occurs 10 with header line.

DATA: BUPLA_CERT TYPE C,
      SECCO_CERT TYPE C.

DATA : BEGIN OF with_tab OCCURS 0.        "Note 887656
        INCLUDE STRUCTURE with_item.
DATA : END OF with_tab.

DATA: BEGIN OF bsegtab OCCURS 0.
        INCLUDE STRUCTURE  bseg .
DATA : END OF bsegtab.

DATA: wa_bkpf like line of bkpftab,
      wa_bseg like line of bsegtab.

DATA: callback TYPE TABLE OF ldbcb,
      callback_wa LIKE LINE OF callback.

DATA: seltab TYPE TABLE OF rsparams,
      seltab_wa LIKE LINE OF seltab.

DATA: withitem_wa LIKE LINE OF withtab.
*Note 891565
 DATA : BEGIN OF BSIKTAB OCCURS 0.
         INCLUDE STRUCTURE BSIK.
 DATA: END OF BSIKTAB.
 DATA: WA_BSIK LIKE LINE OF  BSIKTAB.

 data : PAGE_NO TYPE N.

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

FG99 Flexible G/L: Report Selection

FGI0 Execute Report

FGI1 Create Report

FGI2 Change Report

FGI3 Display Report

FGI4 Create Form

FGI5 Change Form

FGI6 Display Form

FGIB Background Processing

FGIC Maintain Currency Translation Type

FGIK Maintain Key Figures

FGIM Report Monitor

FGIO Transport Reports

FGIP Transport Forms

FGIQ Import Reports from Client 000

FGIR Import Forms from Client 000

FGIT Translation Tool - Drilldown Report.

FGIV Maintain Global Variable

FGIX Reorganize Drilldown Reports

FGIY Reorganize Report Data

FGIZ Reorganize Forms

FGM0 Special Purpose Ledger Menu

FGRP Report Painter

FGRW Report Writer Menu

FI01 Create Bank

FI02 Change Bank

FI03 Display Bank

FI04 Display Bank Changes

FI06 Mark Bank for Deletion

FI07 Change Current Number Range Number

FI12 Change House Banks/Bank Accounts

FI12CORE Change House Banks/Bank Accounts

FI13 Display House Banks/Bank Accounts

FIBB Bank chain determination

FIBC Scenarios for Bank Chain Determin.

FIBD Allocation client

FIBF Maintenance transaction BTE

FIBHS Display bank chains for house banks

FIBHU Maintain bank chains for house banks

FIBL1 Control Origin Indicator

FIBL2 Assign Origin

FIBL3 Group of House Bank Accounts

FIBPS Display bank chians for partners

FIBPU Maintain bank chains for partner

FIBTS Dis. bank chains for acct carry over

FIBTU Main. bank chains for acctCarry over

FIHC Create Inhouse Cash Center

FILAUF_WF_CUST Store Order: Workflow Customizing

FILE Cross-Client File Names/Paths

FILINV_WF_CUST Store Inventory:Workflow Customizing

FINA Branch to Financial Accounting

FINF Info System Events

FINP Info System Processes

FITP_RESPO Contact Partner Responsibilities

FITP_SETTINGS Settings for Travel Planning

FITP_SETTINGS_TREE Tree Maintenance Current Settings

FITVFELD Tree

FJA1 Inflation Adjustment of G/L Accounts

FJA2 Reset Transaction Data G/L Acc.Infl.

FJA3 Balance Sheet/P&L with Inflation

FJA4 Infl. Adjustment of Open Items (FC)

FJA5 Infl. Adj. of Open Receivables (LC)

FJA6 Infl. Adj. of Open Payables (LC)

FJEE Exercise Subscription Right

FK01 Create Vendor (Accounting)

FK02 Change Vendor (Accounting)

FK02CORE Maintain vendor

FK03 Display Vendor (Accounting)

FK04 Vendor Changes (Accounting)

FK05 Block Vendor (Accounting)

FK06 Mark Vendor for Deletion (Acctng)

FK08 Confirm Vendor Individually (Acctng)

FK09 Confirm Vendor List (Accounting)

FK10 Vendor Account Balance

FK10N Vendor Balance Display

FK10NA Vendor Balance Display

FK15 Transfer vendor changes: receive

FK16 Transfer vendor changes: receive

FKI0 Execute Report

FKI1 Create Report

FKI2 Change Report

FKI3 Display Report

FKI4 Create Form

FKI5 Change Form

FKI6 Display Form

FKIB Background Processing

FKIC Maintain Currency Translation Type

FKIK Maintain Key Figures

FKIM Report Monitor

FKIO Transport Reports

FKIP Transport Forms

FKIQ Import Reports from Client 000

FKIR Import Forms from Client 000

FKIT Translation Tool - Drilldown Report.

FKIV Maintain Global Variable

FKIX Reorganize Drilldown Reports

FKIY Reorganize Report Data

FKIZ Reorganize Forms

FKMN

FKMT FI Acct Assignment Model Management

FLB1 Postprocessing Lockbox Data

FLB2 Import Lockbox File

FLBP Post Lockbox Data

FLCV Create/Edit Document Template WF

FM+0 Display FM Main Role Definition

FM+1 Maintain FM Main Role Definition

FM+2 Display FM Amount Groups

FM+3 Maintain FM Amount Groups

FM+4 Display FM Budget Line Groups

FM+5 Maintain FM Budget Line Groups

FM+6 Display FM Document Classes

FM+7 Maintain FM Document Classes

FM+8 Display FM Activity Categories

FM+9 Maintain FM Activity Categories

FM+A Display Doc.Class->Doc.Cat. Assgmt

FM+B Maintain Doc.Clase->Doc.Cat.Assgmt

FM03 Display FM Document

FM21 Change Original Budget

FM22 Display Original Budget

FM25 Change Supplement

FM26 Display Supplement

FM27 Change Return

FM28 Transfer Budget

FM29 Display Return

FM2D Display Funds Center Hierarchy

FM2E Change Budget Document

FM2F Display Budget Document

FM2G Funds Center Hierarchy

FM2H Maintain Funds Center Hierarchy

FM2I Create Funds Center

FM2S Display Funds Center

FM2T Change Releases

FM2U Change Funds Center

FM2V Display Releases

FM3D Display Commitment Item Hierarchy

FM3G Commitment Item Hierarchy

FM3H Maintain Commitment Item Hierarchy

FM3I Create Commitment Item

FM3N Commitment Items for G/L Accounts

FM3S Display Commitment Item

FM3U Change Commitment Item

FM48 Change Financial Budget: Initial Scn

FM48_1 PS-CM: Create Planning Layout

FM48_2 PS-CM: Change Planning Layout

FM48_3 PS-CM: Display Planning Layout

FM49 Display Financial Budget: Init.Scrn

FM4G Budget Structure Element Hierarchy

FM5I Create Fund

FM5S Display Fund

FM5U Change Fund

FM5_DEL Delete fund preselection

FM5_DISP Display fund preselection

FM5_SEL Preselection Fund

FM6I Create Application of Funds

FM6S Display Application of Funds

FM6U Change Application of Funds

FM71 Maintain Cover Pools

FM72 Assign FM Acct Asst to Cover Pool

FM78 Charact.Groups for Cover Pools

FM79 Grouping Chars for Cover Pool

FM7A Display Cover Eligibility Rules

FM7I Create Attributes for FM Acct Asst

FM7P Maintain Cover Eligibility Rules

FM7S Display Cover Eligibility Rules

FM7U Maintain Cover Eligibility Rules

FM9B Copy Budget Version

FM9C Plan Data Transfer from CO

FM9D Lock Budget Version

FM9E Unlock Budget Version

FM9F Delete Budget Version

FM9G Roll Up Supplement

FM9H Roll up Original Budget

FM9I Roll Up Return

FM9J Roll Up Releases

FM9K Change Budget Structure

FM9L Display Budget Structure

FM9M Delete Budget Structure

FM9N Generate Budget Object

FM9P Reconstruct Budget Distrbtd Values

FM9Q Total Up Budget

FM9W Adjust Funds Management Budget

FMA1 Matching: Totals and Balances (CBM)

FMA2 Matching: CBM Line Items and Totals

FMA3 Matching: FI Line Items (CBM)

FMA4 Matching: FI Bank Line Items (CBM)

FMAA Matching: Line Items and Totals (FM)

FMAB Matching: FI FM Line Items

FMAC Leveling: FM Commitment Line Items

FMAD Leveling: FI-FM Totals Records

FMAE Display Change Documents

FMAF Level Line Items and Totals Items

FMB0 CO Document Transfer

FMB1 Display Security Prices-Collect.

FMBI Use Revenues to Increase Expend.Bdgt

FMBUD005 FIFM Budget Data Export

FMBUD006 FIFM Budget Data Import

FMBV Activate Availability Control

FMC2 Customizing in Day-to-Day Business

FMCB Reassignment: Document Selection

FMCC Reassignment: FM-CO Assignment

FMCD Reassignment: Delete Work List

FMCG Reassignment: Overall Assignment

FMCN Reassignment: Supplement.Acct Assgt

FMCR Reassignment: Display Work List

FMCT Reassignment: Transfer

FMD1 Change Carryforward Rules

FMD2 Display Carryforward Rules

FMDM Monitor Closing Operations

FMDS Copy Carryforward Rules

FMDT Display Carryforward Rules

FME1 Import Forms from Client 000

FME2 Import Reports from Client 000

FME3 Transport Forms

FME4 Transport Reports

FME5 Reorganize Forms

FME6 Reorganize Drilldown Reports

FME7 Reorganize Report Data

FME8 Maintain Batch Variants

FME9 Translation Tool - Drilldown

FMEB Structure Report Backgrnd Processing

FMEH SAP-EIS: Hierarchy Maintenance

FMEK FMCA: Create Drilldown Report

FMEL FMCA: Change Drilldown Report

FMEM FMCA: Display Drilldown Report

FMEN FMCA: Create Form

FMEO FMCA: Change Form

FMEP FMCA: Display Form

FMEQ FMCA: Run Drilldown Report

FMER FMCA: Drilldown Tool Test Monitor

FMEURO1 Create Euro FM Area

FMEURO2 Refresh Euro Master Data

FMEURO3 Display Euro FM Areas

FMEURO4 Deactivate Euro FM Areas

FMEV Maintain Global Variable

FMF0 Payment Selection

FMF1 Revenue Transfer

FMG1 FM: Create Commitment Item Group

FMG2 FM: Change Commitment Item Group

FMG3 FM: Display Commitment Item Group

FMG4 FM: Delete Commitment Item Group

FMG5 Generate BS Objects fr.Cmmt Item Grp

FMHC Check Bdgt Structure Elements in HR

FMHG Generate Bdgt Struc Elements in HR

FMHGG Generate BS Elements f. Several Fnds

FMHH Master Data Check

FMHIST Apportion Document in FM

FMHV Budget Memo Texts

FMIA Display Rules for Revs.Incr.Budget

FMIB Increase Budget by Revenues

FMIC Generate Additional Budget Incr.Data

FMIL Delete Rules for Revs Incr. Budget

FMIP Maintain Rules for Revs.Incr.Budget

FMIS Display Rules for Revs.Incr.Budget

FMIU Maintain Rules for Revs.Incr.Budget

FMJ1 Fiscal Year Close: Select Commitment

FMJ1_TR Settlement: Select Commitment

FMJ2 Fiscal Year Close: Carr.Fwd Commts

FMJ2_TR Settlement: Transfer Commitment

FMJ3 Reverse Commitments Carryforward

FMJA Budget Fiscal Year Close: Prepare

FMJA_TR Budget Settlement: Prepare

FMJB Determine Budget Year-End Closing

FMJB_TR Budget Settlement: Determine

FMJC Budget Fiscal-Year Close: Carry Fwd

FMJC_TR Budget Settlement: Transfer

FMJD Reverse Fiscal Year Close: Budget

FMLD Ledger Deletion

FMLF Classify Movement Types

FMN0 Subsequent Posting of FI Documents

FMN1 Subsequent Posting of MM Documents

FMN2 Subsequent Posting of Billing Docs

FMN3 Transfer Purchase Req. Documents

FMN4 Transfer Purchase Order Documents

FMN5 Transfer Funds Reservation Documents

FMN8 Simulation Lists Debit Position

FMN8_OLD Simulation Lists Debit Position

FMN9 Posted Debit Position List

FMN9_OLD Posted Debit Position List

FMNA Display CBA Rules

FMNP Maintain CBA Rules

FMNR Assign SN-BUSTL to CBA

FMNS Display CBA Rules

FMNU Maintain CBA Rules

FMP0 Maintain Financial Budget

FMP1 Display Financial Budget

FMP2 Delete Financial Budget Version

FMR0 Reconstruct Parked Documents

FMR1 Actual/Commitment Report

FMR2 Actual/Commitment per Company Code

FMR3 Plan/Actual/Commitment Report

FMR4 Plan/Commitment Report w.Hierarchy

FMR5A 12 Period Forecast: Actual and Plan

FMR6A Three Period Display: Plan/Actual

FMRA Access Report Tree

FMRB Access Report Tree

FMRE_ARCH Archive Earmarked Funds

FMRE_EWU01 Earmarked Funds: Euro Preprocessing

FMRE_EWU02 Earmarked Funds: Euro Postprocessing

FMRE_SERLK Close Earmarked Funds

FMRP18 Clear Subsequent Postings

FMSS Display Status Assignment

FMSU Change Assigned Status

FMU0 Display Funds Reservation Doc.Types

FMU1 Maintain Funds Reservation Doc.Types

FMU2 Display Funds Reservtn Fld Variants

FMU3 Maintain Funds Resvtn Field Variants

FMU4 Display Funds Reservation Fld Groups

FMU5 Maintain Funds Reservatn Fld Groups

FMU6 Display Funds Reservtn Field Selctn

FMU7 Maintain Funds Resvtn Field Selctn

FMU8 Display Template Type for Fds Resvtn

FMU9 Maintain Template Type for Fds Resvn

FMUA Dispay Fds Res.Template Type Fields

FMUB Maintain Fds Res.Template Type Flds

FMUC Display Funds Res. Reference Type

FMUD Maintain Funds Res.Reference Type

FMUE Display Funds Res.Ref.Type Fields

FMUF Maintaine Fds Rsvtn Ref.Type Fields

FMUG Display Reasons for Decision

FMUH Maintain Reasons for Decisions

FMUI Display Groups for Workflow Fields

FMUJ Maintain Groups for Workflow Fields

FMUK Display Fields in Groups for WF

FMUL Maintain Fields in Groups for WF

FMUM Display Field Selctn ->Variant/Group

FMUN Display Field Seln->Variant/Group

FMUV Funds Resvtn Field Status Var.Asst

FMV1 Create Forecast of Revenue

FMV2 Change Forecast of Revenue

FMV3 Display Forecast of Revenue

FMV4 Approve Forecast of Revenue

FMV5 Change FM Acct Asst in Fcst of Rev.

FMV6 Reduce Forecast of Revenue Manually

FMVI Create Summarization Item

FMVO Fund Balance Carryforward

FMVS Display Summarization Item

FMVT Carry Forward Fund Balance

FMVU Change Summarization Item

FMW1 Create Funds Blocking

FMW2 Change Funds Blocking

FMW3 Display Funds Blocking

FMW4 Approve Funds Blocking

FMW5 Change FM Acct Asst in Funds Blkg

FMWA Create Funds Transfer

FMWAZ Payment Transfer

FMWB Change Funds Transfer

FMWC Display Funds Transfer

FMWD Approve Funds Transfer

FMWE Change FM Acct Asst in Funds Trsfr

FMX1 Create Funds Reservation

FMX2 Change Funds Reservation

FMX3 Display Funds Reservation

FMX4 Approve Funds Reservation

FMX5 Change FM Acct Asst in Funds Resvn

FMX6 Funds Reservation: Manual Reduction

FMY1 Create Funds Commitment

FMY2 Change Funds Commitment

FMY3 Display Funds Precommitment

FMY4 Approve Funds Precommitment

FMY5 Change FM Acct Asst in Funds Prcmmt

FMY6 Reduce Funds Precommitment Manually

FMZ1 Create Funds Commitment

FMZ2 Change Funds Commitment

FMZ3 Display Funds Commitment

FMZ4 Approve Funds Commitment

FMZ5 Change FM Acct Asst in Funds Commt

FMZ6 Reduce Funds Commitment Manually

FMZBVT Carry Forward Balance

FMZZ Revalue Funds Commitments

FM_DL07 Delete Worklist

FM_DLFI Deletes FI Documnts Transferred from

FM_DLFM Deletes all FM Data (fast)

FM_DLOI Deletes Cmmts Transferred from FM

FM_EURO_M Parameter maintenance for euro conv.

FM_RC06 Reconcile FI Paymts-> FM Totals Itms

FM_RC07 Reconcile FI Paymts-> FM Line Items

FM_RC08 Reconcile FM Paymts -> FM Line Items

FM_RC11 Select Old Payments

FM_S123 GR/IR: Post OIs to FM Again

FM_S201 Post Payments on Account to FIFM

FM_SD07 Display Worklist

FN-1 No.range: FVVD_RANL (Loan number)

FN-4 Number range maintenance: FVVD_PNNR

FN-5 Number range maintenance: FVVD_SNBNR

FN-6 Number range maintenance: FVVD_RPNR

FN09 Create Borrower's Note Order

FN11 Change borrower's note order

FN12 Display borrower's note order

FN13 Delete borrower's note order

FN15 Create borrower's note contract

FN16 Change borrower's note contract

FN17 Display borrower's note contract

FN18 Payoff borrower's note contract

FN19 Reverse borrower's note contract

FN1A Create other loan contract

FN1V Create other loan contract

FN20 Create borrower's note offer

FN21 Change borrower's note offer

FN22 Display borrower's note offer

FN23 Delete borrower's note offer

FN24 Activate borrower's note offer

FN2A Change other loan application

FN2V Change other loan contract

FN30 Create policy interested party

FN31 Change policy interested party

FN32 Display policy interested party

FN33 Delete policy interested party

FN34 Policy interested party in applic.

FN35 Policy interested party in contract

FN37 Loan Reversal Chain

FN3A Display other loan application

FN3V Display other loan contract

FN40 Create other loan interested party

FN41 Change other loan interested party

FN42 Display other loan interested party

FN43 Delete other loan interested party

FN44 Other loan interest.party in applic.

FN45 Other loan interested prty in cntrct

FN4A Delete other loan application

FN4V Delete other loan contract

FN5A Other loan application in contract

FN5V Payoff other loan contract

FN61 Create collateral value

FN62 Change collateral value

FN63 Display collateral value

FN70 List 25

FN72 List 54

FN80 Enter manual debit position

FN81 Change manual debit position

FN82 Display manual debit position

FN83 Create waiver

FN84 Change waiver

FN85 Display waiver

FN86 Enter debit position depreciation

FN87 Change debit position depreciation

FN88 Display debit position depreciation

FN8A Manual Entry: Unsched. Repayment

FN8B Manual Entry: Other Bus. Operations

FN8C Manual Entry: Charges

FN8D Post Planned Records

FNA0 Policy application in contract

FNA1 Create mortgage application

FNA2 Change mortgage application

FNA3 Display mortgage application

FNA4 Complete mortgage application

FNA5 Mortgage application in contract

FNA6 Create policy application

FNA7 Change policy application

FNA8 Display policy application

FNA9 Delete policy application

FNAA Reactivate deleted mortgage applic.

FNAB Reactivate deleted mortg. int.party

FNAC Reactivate deleted mortgage contract

FNAD Reactivate deleted policy applicat.

FNAE Reactivate deleted policy contract

FNAG Reactivate deleted other loan applic

FNAH Reactivate del. other loan int.party

FNAI Reactivate deleted other loan cntrct

FNAK Select file character

FNAL Reactivate deleted BNL contract

FNAM Reactivate deleted policy contract

FNASL Loans: Account Analysis

FNB1 Transfer to a Loan

FNB2 Transfer from a Loan

FNB3 Document Reversal - Loans

FNB8 BAV Information

FNB9 BAV transfer

FNBD Loans-Automatic bal.sheet transfer

FNBG Guarantee charges list

FNBU DARWIN- Loans accounting menu

FNCD Transfer Customizing for Dunning

FNCW1 Maintain Standard Role

FNCW2 Transaction Release: Adjust Workflow

FNDD Convert Dunning Data in Dunn.History

FNEN Create Loan

FNENALG Create General Loan

FNENHYP Create Mortgage Loan

FNENPOL Create Policy Loan

FNENSSD Create Borrower's Note Loan

FNF1 Rollover: Create file

FNF2 Rollover: Change file

FNF3 Rollover: Display file

FNF4 Rollover: Fill file

FNF9 Rollover: Evaluations

FNFO ISIS: Create file

FNFP ISIS: Change file

FNFQ ISIS: Display file

FNFR ISIS: Fill file

FNFT Rollover: File evaluation

FNFU Rollover: Update file

FNG2 Total Loan Commitment

FNG3 Total Commitment

FNI0

FNI1 Create mortgage application

FNI2 Change mortgage application

FNI3 Display mortgage application

FNI4 Delete mortgage application

FNI5 Mortgage application to offer

FNI6 Mortgage application in contract

FNIA Create interested party

FNIB Change interested party

FNIC Display interested party

FNID Delete interested party

FNIE Reactivate interested party

FNIH Decision-making

FNIJ Create credit standing

FNIK Change credit standing

FNIL Display credit standing

FNIN Create collateral value

FNIO Change collateral value

FNIP Display collateral value

FNK0 Multimillion Loan Display (GBA14)

FNK1 Loans to Managers (GBA15)

FNKO Cond.types - Cond.groups allocation

FNL1 Rollover: Create Main File

FNL2 Rollover: Change Main File

FNL3 Rollover: Displ. Main File Structure

FNL4 New business

FNL5 New business

FNL6 New business

FNM1 Automatic Posting

FNM1S Automatic Posting - Single

FNM2 Balance sheet transfer

FNM3 Loans reversal module

FNM4 Undisclosed assignment

FNM5 Automatic debit position simulation

FNM6 Post dunning charges/int.on arrears

FNM7 Loan reversal chain

FNMA Partner data: Settings menu

FNMD Submenu General Loans

FNME Loans management menu

FNMEC Loans Management Menu

FNMH Loans management menu

FNMI Loans information system

FNMO Loans Menu Policy Loans

FNMP Rollover

FNMS Loans Menu Borrower's Notes

FNN4 Display general file

FNN5 Edit general file

FNN6 Display general main file

FNN7 Edit general main file

FNN8 Display general main file

FNN9 Edit general overall file

FNO1 Create Object

FNO2 Change Object

FNO3 Display Object

FNO5 Create collateral

FNO6 Change collateral

FNO7 Display collateral

FNO8 Create Objects from File

FNO9 Create Collateral from File

FNP0 Edit rollover manually

FNP4 Rollover: Display file

FNP5 Rollover: Edit File

FNP6 Rollover: Display main file

FNP7 Rollover: Edit main file

FNP8 Rollover: Display overall file

FNP9 Rollover: Edit overall file

FNQ2 New Business Statistics

FNQ3 Postprocessing IP rejection

FNQ4 Customer Inc. Payment Postprocessing

FNQ5 Transact.type - Acct determinat.adj.

FNQ6 Compare Flow Type/Account Determin.

FNQ7 Generate flow type

FNQ8 Automatic Clearing for Overpayments

FNQ9 Int. adjustment run

FNQF Swiss interest adjustment run

FNQG Swiss special interest run

FNR0 Loans: Posting Journal

FNR6 Insur.prtfolio trends - NEW

FNR7 Totals and Balance List

FNR8 Account statement

FNR9 Planning list

FNRA Other accruals/deferrals

FNRB Memo record update

FNRC Accruals/deferrals reset

FNRD Display incoming payments

FNRE Reverse incoming payments

FNRI Portfolio Analysis Discount/Premium

FNRS Reversal Accrual/Deferral

FNS1 Collateral number range

FNS4 Cust. list parameters for loan order

FNS6 Installation parameter lists

FNS7 Loan Portfolio Trend Customizing

FNSA Foreign currency valuation

FNSB Master data summary

FNSL Balance reconciliation list

FNT0 Loan correspondence (Switzerland)

FNT1 Autom. deadline monitoring

FNT2 Copy text modules to client

FNUB Treasury transfer

FNV0 Payoff policy contract

FNV1 Create mortgage contract

FNV2 Change mortgage contract

FNV3 Display mortgage contract

FNV4 Delete mortgage contract

FNV5 Payoff mortgage contract

FNV6 Create policy contract

FNV7 Change policy contract

FNV8 Display policy contract

FNV9 Delete policy contract

FNVA Create paid off contracts

FNVCOMPRESSION Loans: Document Data Summarization

FNVD Disburse Contract

FNVI Loans: General Overview

FNVM Change Contract

FNVR Reactivate Contract

FNVS Display Contract

FNVW Waive Contract

FNWF WF Loans Release: List of Work Items

FNWF_REP Release Workflow: Synchronization

FNWO Loans: Fast Processing

FNWS Housing statistics

FNX1 Rollover: Create Table

FNX2 Rollover: Change Table

FNX3 Rollover: Display Table

FNX6 Rollover: Delete Table

FNX7 Rollover: Deactivate Table

FNX8 Rollover: Print Table

FNXD TR-EDT: Documentation

FNXG List of Bus. Partners Transferred

FNXU List of Imported Loans

FNY1 New Business: Create Table

FNY2 New Business: Change Table

FNY3 New Business: Display Table

FNY6 New Business: Delete Table

FNY7 New Business: Deactivate Table

FNY8 New Business: Print Table

FNZ0 Rejections report

FNZ1 Postprocessing payment transactions

FNZA Account Determination Customizing

FN_1 Table maint. transferred loans

FN_2 Table maintenance transf. partner

FN_UPD_FELDAUSW Update Program for Field Selection

http://www.sap-img.com/sap-fi.htm

http://www.sap-img.com/sap-fi.htm

Former Member
0 Kudos

i need a sample program which is developed by using fi tables..

Regards

pandu

Former Member
0 Kudos

Hi

These are the standard FI Reports plz check it out this too

FIAA_HELP_EDIT_CONTENT

FIAA_HELP_SCAN_PROG_FOR_STRING

FIACEITMDEL

FIACEITMWRI

FIACEOBJDEL

FIACEOBJWRI

FIADKTOP

FIARCHIV

FIBANCDC

FIBANCDF

FIBANCDT

FIBANCDT_1

FIBANCDV

FIBANCDV_1

FIBIFORM

FIBINVALUESCDC

FIBINVALUESCDF

FIBINVALUESCDT

FIBINVALUESCDV

FIBLCHK_DATA1

FIBLCHK_PAI1

FIBLCHK_PBO1

FIBLCHK_SUB1

FIBL_CONVERT_TRBP01

FIBL_CONVERT_TRBPTOP

FIBL_RPCODE_PARTN_MODIFY_ONCE

FIBSTP

FIBSTPC

FIC530PR

FIC540PR

FIC550PR

FICACG00

FICACG0S

FICACG10

FICACG1S

FICACGI1

FICACGI2

FICACGO1

FICACGO2

FICADI00

FICALV00

FICARCF01

FICARCLI

FICARCLIF01

FICARCLISEL

FICARCSR

FICARCSRF01

FICARCSRSEL

FICARCTOP

FICASS00

FICASS0S

FICAST00

FICAST0S

FICASTFL

FICASTGD

FICAXL99

FICBAD00

FICBAD0S

FICBARD2

FICBCF00

FICBCF0S

FICBCFF1

FICBIW00

FICBIW0S

FICBIW10

FICBIW20

FICBIW2S

FICC2E01

FICC2E02

FICC2E03

FICC2E04

FICC2E10

FICC2E12

FICC2E13

FICC2E20

FICC2E21

FICC2E22

FICC2E25

FICC2E50

FICC2E51

FICC2E52

FICC2E60

FICC2E61

FICC2E62

FICC2E90

FICC2E91

FICC2F00

FICC2F01

FICC2F02

FICC2F03

FICC2F04

FICC2F05

FICC2F06

FICC2F07

FICC2F10

FICC2F11

FICC2F12

FICC2F13

FICC2F14

FICC2F15

FICC2F16

FICC2F20

FICC2F21

FICC2F22

FICC2F23

FICC2F24

FICC2F30

FICC2F31

FICC2F32

FICC2F38

FICC2F39

FICC2F40

FICC2F41

FICC2F42

FICC2F43

FICC2F50

FICC2F51

FICC2F52

FICC2F53

FICC2F54

FICC2F55

FICC2F56

FICC2F71

FICC2F80

FICC2F81

FICC2F90

FICC2F99

FICC2I00

FICC2L00

FICC2L01

FICC2L02

FICC2L03

FICC2L04

FICC2L05

FICC2L06

FICC2L09

FICC2L10

FICC2L11

FICC2L12

FICC2L13

FICC2L14

FICC2L15

FICC2L20

FICC2L21

FICCIFEU

FICCIFLO

FICCIFUS

FICCIT46

FICCITAB

FICCITLM

FICCITLO

FICCITMA

FICCITOP

FICCITYP

FICCMP00

FICCMP0C

FICCMP0F

FICCMP0M

FICCMP0S

FICCMP0T

FICCNV00

FICCNV0E

FICCNV0S

FICCOA00

FICCOA0S

FICCOAFL

FICCOAGD

FICCOD01

FICCOF01

FICCOI00

FICCOI0S

FICCOI10

FICCOI20

FICCOI30

FICCOI3S

FICCOI40

FICCOI4S

FICCOI70

FICCOI80

FICCOI90

FICCOI91

FICCOI9S

FICCOIA0

FICCOIA0_F01

FICCOIA0_TOP

FICCOIAS

FICCOIB0

FICCOIBS

FICCOMD0

FICCON00

FICCON05

FICCON06

FICCON10

FICCON20

FICCPT00_F01

FICCPT00_TOP

FICCPT0S

FICCPT10

FICCPT10_F01

FICCPT10_TOP

FICCPT1S

FICCPTOP

FICCPY00

FICCPY0S

FICCPY10

FICCPY1S

FICCPYD0

FICCPYFA

FICCRTCC

FICCSH00

FICCTDPR

FICCTERT

FICCUC00

FICCUC0S

FICCUCFL

FICCUTOP

FICCVS00

Or goto SE38 type FI* and make a search u can get a list of standard reports prepared by sap

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos