V V URGENT Report  for Vendor Aging

Hi ABAP Gurus,
I have to develop a report for VENDOR AGING. My requirement is i have to post an invoice. From Payment terms i have to get Dependent on posting date. Let us assume if payment term is 100 by adding posting date + payment term (100) i have to get due date. I'am giving I/P terms as Company code & Period. If i enter company code i have to get O/P as vendor name(lfa1-name1),vendor no(bsik-lifnr),bill no(bsik-xblnr),bill date(bsik-bldat) i.e., baseline date,amount(bsik-dmbtr) and duedate (this i have to pick from payment terms). For period i have to get O/P as 1st week bucket,2nd week bucket,3rd week bucket,4th week bucket and beyond. For this you have to take the difference b/n due date and that buckets based on this result you have to put that amount of rupees whether it is going to pay in 1st week r 2nd r 3rd r 4th or beyond this. If that due date is less than or equal to 1st week it has to come and fall in 1st week. THIS IS MY REQUIREMENT.
For this i'am using tables BSIK,LFA1.
Can any body send me the code on this. For this my delivery date is on monday.
Please help me on this it's very Urgent...
I will REWARD you the points definitely for those who help me on this.
my mail id : [email protected]
waiting for your VALUABLE REPLIES. Please intimate me if you send it to my mail.
Thanks and Regards,
Sundeep.

Hi
See the report code and modify as per your requirements
REPORT  zfi_vendor_ageing
        NO STANDARD PAGE HEADING
        LINE-COUNT 58
       line-size 168
        MESSAGE-ID zh_msg.
       D A T A B A S E  T A B L E S   D E C L A R A T I O N
TABLES: lfa1,           " Vendor Master (General)
        t001,           " Company Codes
        rfpdo.
     I N T E R N A L  T A B L E S  D E C L A R A T I O N S           *
Internal Table for Vendor Open Items Data
DATA: BEGIN OF int_bsik OCCURS 0,
        lifnr   LIKE bsik-lifnr,         " Vendor Number
        name1   LIKE lfa1-name1,         " Vendor Name
        shkzg   LIKE bsik-shkzg,         " Dr/Cr Indicator
        belnr   LIKE bsik-belnr,         " Document Number
        xblnr   LIKE bsik-xblnr,         " Ref Doc No
        blart   LIKE bsik-blart,         " Document Type
        zfbdt   LIKE bsik-zfbdt,         " Base Line Date
        zbd1t   LIKE bsik-zbd1t,         " Due date1
        zbd2t   LIKE bsik-zbd2t,         " Due Date2
        zbd3t   LIKE bsik-zbd3t,         " Due Date3
        waers   LIKE bsik-waers,         " Currency
        dmbtr   LIKE bsik-dmbtr,         " Amount in Local Curr
      END OF int_bsik.
Internal Table for Amounts Sum Up Data
DATA: BEGIN OF int_final OCCURS 0,
        lifnr   LIKE bsik-lifnr,         " Vendor Number
        name1   LIKE lfa1-name1,         " Vendor Name
        total1  LIKE bsik-dmbtr,         " Amount in Local Curr
        total2  LIKE bsik-dmbtr,         " Amount in Local Curr
        total3  LIKE bsik-dmbtr,         " Amount in Local Curr
        total4  LIKE bsik-dmbtr,         " Amount in Local Curr
        total5  LIKE bsik-dmbtr,         " Amount in Local Curr
        total6  LIKE bsik-dmbtr,         " Amount in Local Curr
        total   LIKE bsik-dmbtr,         " Amount in Local Curr
      END OF int_final.
           D A T A  D E C L A R A T I O N S
DATA : v_flag,                          " Flag
       v_gtotal1     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal2     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal3     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal4     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal5     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal6     LIKE bsik-dmbtr,   " Amount Totals
       v_gtotal      LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal1   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal2   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal3   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal4   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal5   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal6   LIKE bsik-dmbtr,   " Amount Totals
       v_subtotal    LIKE bsik-dmbtr,   " Amount Totals
       v_date        LIKE bsik-zfbdt,   " Due Date
       v_tage1(4),                      " Age 30 days
       v_tage2(4),                      " Age 60 days
       v_tage3(4),                      " Age 90 days
       v_fir(15),                       " Column Text1
       v_sec(15),                       " Column Text2
       v_thir(15),                      " Column Text3
       v_four(17),                      " Column Text4
       v_fidd(4),                       " Days field1
       v_sedd(4),                       " Days field2
       v_thdd(4),                       " Days field3
       v_fodd(4),                       " Days field4
       v_str  TYPE  SY-LISEL,           " String
       v_str1(11),                      " String
       v_tage(3),                       " String
       v_date1(10).                     " Date field
     R A N G E   D E C L A R A T I O N S
RANGES: r_date1 FOR bsik-zfbdt,      " Date Range 1
        r_date2 FOR bsik-zfbdt,      " Date Range 2
        r_date3 FOR bsik-zfbdt,      " Date Range 3
        r_date4 FOR bsik-zfbdt.      " Date Range 4
         S E L E C T I O N  S C R E E N                      *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr. "Vendor account
PARAMETERS:     p_bukrs LIKE t001-bukrs. "Co. Code
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS:   p_allgst LIKE rfpdo-allgstid OBLIGATORY DEFAULT sy-datum.
"Open items at key date
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_tage1 LIKE rfpdo1-allgfael DEFAULT '30',
            p_tage2 LIKE rfpdo1-allgfael DEFAULT '60',
            p_tage3 LIKE rfpdo1-allgfael DEFAULT '90',
            p_tage4 LIKE rfpdo1-allgfael DEFAULT '120'.
SELECTION-SCREEN END OF BLOCK b3.
              A T  S E L E C T I O N  S C R E E N                   *
AT SELECTION-SCREEN.
Validate the screen fields
  PERFORM validate_flds.
               S T A R T  O F  S E L E C T I O N                    *
START-OF-SELECTION.
Fetch main data
  PERFORM fetch_data.
                       T O P  O F  P A G E
Header
TOP-OF-PAGE.
  PERFORM header.
                       E N D  O F  P A G E
Footer
END-OF-PAGE.
  ULINE.
   T O P  O F  P A G E  D U R I N G  L I N E  S E L E C T I O N     *
Top of Page in Secondary List
TOP-OF-PAGE DURING LINE-SELECTION.
  PERFORM header1.
              A T  L I N E  S E L E C T I O N                    *
AT LINE-SELECTION.
Perform Line Selections
  PERFORM line_selection.
                 E N D  O F  S E L E C T I O N
END-OF-SELECTION.
List generation
  PERFORM basic_list.
*&      Form  validate_flds
Validation of Selection Screen fields
FORM validate_flds .
Validate Vendor Code
  CLEAR lfa1-lifnr.
  SELECT lifnr UP TO 1 ROWS
      INTO lfa1-lifnr
      FROM lfa1
      WHERE lifnr IN s_lifnr AND
            spras = sy-langu.
  ENDSELECT.
  IF sy-subrc <> 0.
    MESSAGE e000 WITH 'Invalid Vendor Code range'(023).
  ENDIF.
Validate Company Code
  CLEAR t001-bukrs.
  SELECT bukrs  UP TO 1 ROWS
      INTO t001-bukrs
      FROM t001
      WHERE bukrs =  p_bukrs AND
            spras = sy-langu.
  ENDSELECT.
  IF sy-subrc <> 0.
    MESSAGE e021.      " Invalid Company Code range
  ENDIF.
  IF ( p_tage1 > p_tage2 ) OR ( p_tage1 > p_tage3 ) OR
      ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 1 greater'(004)
                'than Column# 2 or 3 or 4'(005).
  ENDIF.
*column 2
  IF ( p_tage2 > p_tage3 ) OR ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 2 greater'(006)
                'than Column# 3 or 4'(007).
  ENDIF.
*column3
  IF ( p_tage3 > p_tage4 ).
    MESSAGE e999 WITH 'Column 3 greater'(008)
                'than Column#4'(009).
  ENDIF.
ENDFORM.                    " validate_flds
*&      Form  fetch_data
Fetching Data from Database Tables
FORM fetch_data .
Date Range Population
  r_date1-sign   = 'I'.
  r_date1-option = 'BT'.
  r_date1-low    = p_allgst.
  r_date1-high    = r_date1-low + p_tage1.
  APPEND r_date1.
  r_date2-sign   = 'I'.
  r_date2-option = 'BT'.
  r_date2-low    =  r_date1-high + 1.
  r_date2-high    = r_date1-low + p_tage2.
  APPEND r_date2.
  r_date3-sign   = 'I'.
  r_date3-option = 'BT'.
  r_date3-low    = r_date2-high + 1.
  r_date3-high    = r_date1-low + p_tage3.
  APPEND r_date3.
  r_date4-sign   = 'I'.
  r_date4-option = 'BT'.
  r_date4-low    = r_date3-high + 1.
  r_date4-high    = r_date1-low + p_tage4.
  APPEND r_date4.
Select the Vendor Open Items data from BSIK
  SELECT l~lifnr
         l1~name1
         b~waers
         b~dmbtr
         b~zfbdt
         b~zbd1t
         b~zbd2t
         b~zbd3t
         b~belnr
         b~xblnr
         b~shkzg
         b~blart
   INTO CORRESPONDING FIELDS OF TABLE int_bsik
   FROM lfb1 AS l INNER JOIN lfa1 AS l1
                ON llifnr  = l1lifnr
       INNER JOIN   bsik AS b
         ON llifnr  = blifnr AND
            lbukrs  = bbukrs
         WHERE l~lifnr  IN s_lifnr AND
               l~bukrs = p_bukrs and
               b~zfbdt le p_allgst.
  IF SY-SUBRC <> 0.
    MESSAGE i000 WITH 'No Data found'(027).
  ENDIF.
Removing the date limit to get the due items in the past
  DELETE int_bsik WHERE
              ( blart  NE 'RE' AND blart  NE 'KR' ) OR
                shkzg  NE 'H'.
  SORT int_bsik BY lifnr.
ENDFORM.                    " fetch_data
*&      Form  header
Display the Report Columns
FORM header .
  v_tage1 = p_tage1 + 1.
  v_tage2 = p_tage2 + 1.
  v_tage3 = p_tage3 + 1.
  v_fidd = p_tage1.
  v_sedd = p_tage2.
  v_thdd = p_tage3.
  v_fodd = p_tage4.
  MOVE v_fodd0(4) TO v_fodd1(3).
  v_fodd+0(1) = space.
  CONCATENATE '1 to'(010) v_fidd INTO v_fir.
  CONCATENATE v_tage1 ' to '(011) v_sedd INTO v_sec.
  CONCATENATE v_tage2 ' to '(011) v_thdd INTO v_thir.
  CONCATENATE v_tage3 ' to '(011) space v_fodd INTO v_four.
Standard header
  clear: v_date1, v_str, v_str1, v_tage.
  write p_allgst to v_date1.
  Move  p_tage4 to v_tage.
  concatenate '>' v_tage text-025 into v_str1.
  concatenate
  'Summary of Ageing Analysis for Vendor Open Invoices as on'(013)
   v_date1 into v_str separated by space.
  CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
     title1 = 'Saudi International Petrochemical Company'(012)
     title2 = v_str.
  FORMAT COLOR OFF.
  WRITE  : /1(168) sy-uline.
  FORMAT COLOR 1 INTENSIFIED.
  WRITE :/1 sy-vline, 13 sy-vline, 49 sy-vline,
        50(101) 'Invoices Due For(In Days)'(014) CENTERED,
       151 sy-vline, 168 sy-vline .
  WRITE :/1 sy-vline,  2(11)  'Vendor#'(015) CENTERED,
         13 sy-vline ,14(35) 'Vendor Name'(016) CENTERED,
         49 sy-vline,
         50(101) sy-uline,151 sy-vline,
        152(16) 'Total'(017) CENTERED,
        168 sy-vline.
  WRITE : /1 sy-vline,13 sy-vline,      49 sy-vline,
          50(16) v_fir CENTERED,        66 sy-vline,
          67(16) v_sec CENTERED,        83 sy-vline,
          84(16) v_thir CENTERED,      100 sy-vline,
         101(16) v_four CENTERED,      117 sy-vline,
         118(16) v_str1 centered,      134 sy-vline,
         135(16) 'Already Overdue'(018) CENTERED,151 sy-vline,
         168 sy-vline.
  FORMAT COLOR OFF.
  WRITE  : /1(168) sy-uline.
ENDFORM.                    " header
*&      Form  basic_list
Display the Basic List
FORM basic_list .
  NEW-PAGE LINE-SIZE 168.
  LOOP AT int_bsik.
    CLEAR v_date.
    IF int_bsik-zbd3t <> ' '.
      v_date = int_bsik-zfbdt + int_bsik-zbd3t.
    ELSE.
      IF int_bsik-zbd2t <> ' '.
        v_date = int_bsik-zfbdt + int_bsik-zbd2t.
      ELSE.
        v_date = int_bsik-zfbdt + int_bsik-zbd1t.
      ENDIF.
    ENDIF.
    IF int_bsik-zbd1t = ' '.
      v_date = int_bsik-zfbdt.
    ENDIF.
    IF v_date IN r_date1.
      int_final-total1 =   int_final-total1 +  int_bsik-dmbtr.
    ELSEIF v_date IN r_date2.
      int_final-total2 =   int_final-total2 +  int_bsik-dmbtr.
    ELSEIF v_date IN r_date3.
      int_final-total3 =   int_final-total3 +  int_bsik-dmbtr.
    ELSEIF v_date IN r_date4.
      int_final-total4 =   int_final-total4 +  int_bsik-dmbtr.
    ELSEif v_date > r_date4-high.
      int_final-total5 =   int_final-total5 +  int_bsik-dmbtr.
    ELSEif v_date < p_allgst.
      int_final-total6 =   int_final-total6 +  int_bsik-dmbtr.
    ENDIF.
    AT END OF lifnr.
      v_flag = 1.
    ENDAT.
    IF v_flag = 1.
      int_final-lifnr = int_bsik-lifnr.
      int_final-name1 = int_bsik-name1.
      int_final-total =   int_final-total1 + int_final-total2 +
       int_final-total3 + int_final-total4 + int_final-total5 +
       int_final-total6.
      APPEND int_final.
      v_gtotal1 = v_gtotal1 + int_final-total1.
      v_gtotal2 = v_gtotal2 + int_final-total2.
      v_gtotal3 = v_gtotal3 + int_final-total3.
      v_gtotal4 = v_gtotal4 + int_final-total4.
      v_gtotal5 = v_gtotal5 + int_final-total5.
      v_gtotal6 = v_gtotal6 + int_final-total6.
      v_gtotal = v_gtotal + int_final-total.
      WRITE: /1 sy-vline,
              2 int_final-lifnr COLOR 4 INTENSIFIED ON,
             13 sy-vline,
             14 int_final-name1 COLOR 4 INTENSIFIED ON,
             49 sy-vline.
      DATA : v_rem.
      v_rem = sy-tabix MOD 2.
      IF v_rem NE 0.
        FORMAT COLOR 2 INTENSIFIED.
        WRITE :    50 int_final-total1 CURRENCY int_bsik-waers,
                   66 sy-vline,
                   67 int_final-total2 CURRENCY int_bsik-waers,
                   83 sy-vline,
                   84 int_final-total3 CURRENCY int_bsik-waers,
                  100 sy-vline,
                  101 int_final-total4 CURRENCY int_bsik-waers,
                  117 sy-vline,
                  118 int_final-total5 CURRENCY int_bsik-waers,
                  134 sy-vline,
                  135 int_final-total6 CURRENCY int_bsik-waers,
                  151 sy-vline,
                  152 int_final-total CURRENCY int_bsik-waers,
                  168 sy-vline.
      ELSE.
        WRITE :    50 int_final-total1 CURRENCY int_bsik-waers,
                   66 sy-vline,
                   67 int_final-total2 CURRENCY int_bsik-waers,
                   83 sy-vline,
                   84 int_final-total3 CURRENCY int_bsik-waers,
                  100 sy-vline,
                  101 int_final-total4 CURRENCY int_bsik-waers,
                  117 sy-vline,
                  118 int_final-total5 CURRENCY int_bsik-waers,
                  134 sy-vline,
                  135 int_final-total6 CURRENCY int_bsik-waers,
                  151 sy-vline,
                  152 int_final-total CURRENCY int_bsik-waers,
                  168 sy-vline.
      ENDIF.
      FORMAT COLOR OFF.
      HIDE int_final.
      CLEAR int_final.
      v_flag = 0.
    ENDIF.
    AT LAST.
      WRITE  : /1(168) sy-uline.
      FORMAT COLOR 3 INTENSIFIED.
      WRITE : /1 sy-vline,  2(47) 'GRAND TOTAL'(022) CENTERED,
              49 sy-vline, 50 v_gtotal1 CURRENCY int_bsik-waers,
              66 sy-vline, 67 v_gtotal2 CURRENCY int_bsik-waers,
              83 sy-vline, 84 v_gtotal3 CURRENCY int_bsik-waers,
             100 sy-vline,101 v_gtotal4 CURRENCY int_bsik-waers,
             117 sy-vline,118 v_gtotal5 CURRENCY int_bsik-waers,
             134 sy-vline,135 v_gtotal6 CURRENCY int_bsik-waers,
             151 sy-vline,152 v_gtotal CURRENCY int_bsik-waers,
             168 sy-vline.
      HIDE :  v_gtotal1,
              v_gtotal2,
              v_gtotal3,
              v_gtotal4,
              v_gtotal5,
              v_gtotal6,
              v_gtotal.
    ENDAT.
    FORMAT COLOR OFF.
  ENDLOOP.
  WRITE  : /1(168) sy-uline.
ENDFORM.                    " basic_list
*&      Form  line_selection
When double clicked on the line display the seconday list
FORM line_selection .
  NEW-PAGE LINE-SIZE 206.
Sy-lsind = 1.
  DATA : v_rem,v_cnt LIKE sy-tabix.
  v_cnt = 0.
  SORT int_bsik BY belnr zfbdt.
  LOOP AT int_bsik WHERE lifnr EQ int_final-lifnr.
    v_rem = v_cnt MOD 2.
    CLEAR v_date.
    IF int_bsik-zbd3t <> ' '.
      v_date = int_bsik-zfbdt + int_bsik-zbd3t.
    ELSE.
      IF int_bsik-zbd2t <> ' '.
        v_date = int_bsik-zfbdt + int_bsik-zbd2t.
      ELSE.
        v_date = int_bsik-zfbdt + int_bsik-zbd1t.
      ENDIF.
    ENDIF.
    IF int_bsik-zbd1t = ' '.
      v_date = int_bsik-zfbdt.
    ENDIF.
    IF v_rem NE 0.
      format color 2 intensified.
      WRITE :/1 sy-vline, 2 int_bsik-belnr,
             12 sy-vline,13 int_bsik-lifnr,
             23 sy-vline,24 int_bsik-name1,
             59 sy-vline,60 int_bsik-xblnr,
             76 sy-vline,77 int_bsik-zfbdt,
             87 sy-vline.
      WRITE : 104 sy-vline,121 sy-vline,
              138 sy-vline,155 sy-vline,
              172 sy-vline, 189 sy-vline,
              190 int_bsik-dmbtr CURRENCY int_bsik-waers,
              206 sy-vline.
      IF v_date IN r_date1.
        v_subtotal1 =   v_subtotal1 +  int_bsik-dmbtr.
        WRITE : 88 int_bsik-dmbtr  CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date2.
        v_subtotal2 =   v_subtotal2 +  int_bsik-dmbtr.
        WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date3.
        v_subtotal3 =   v_subtotal3 +  int_bsik-dmbtr.
        WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date4.
        v_subtotal4 =   v_subtotal4 +  int_bsik-dmbtr.
        WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEif v_date > r_date4-high.
        v_subtotal5 =   v_subtotal5 +  int_bsik-dmbtr.
        WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEif v_date < p_allgst.
        v_subtotal6 =   v_subtotal6 +  int_bsik-dmbtr.
        WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ENDIF.
      format color off.
    ELSE.
      WRITE :/1 sy-vline, 2 int_bsik-belnr,
             12 sy-vline,13 int_bsik-lifnr,
             23 sy-vline,24 int_bsik-name1,
             59 sy-vline,60 int_bsik-xblnr,
             76 sy-vline,77 int_bsik-zfbdt,
             87 sy-vline.
      WRITE : 104 sy-vline,121 sy-vline,
              138 sy-vline,155 sy-vline,
              172 sy-vline,189 sy-vline,
              190 int_bsik-dmbtr CURRENCY int_bsik-waers,
              206 sy-vline.
      IF v_date IN r_date1.
        v_subtotal1 =   v_subtotal1 +  int_bsik-dmbtr.
        WRITE : 88 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date2.
        v_subtotal2 =   v_subtotal2 +  int_bsik-dmbtr.
        WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date3.
        v_subtotal3 =   v_subtotal3 +  int_bsik-dmbtr.
        WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEIF v_date IN r_date4.
        v_subtotal4 =   v_subtotal4 +  int_bsik-dmbtr.
        WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEif v_date > r_date4-high.
        v_subtotal5 =   v_subtotal5 +  int_bsik-dmbtr.
        WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ELSEif v_date < p_allgst.
        v_subtotal6 =   v_subtotal6 +  int_bsik-dmbtr.
        WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
      ENDIF.
    ENDIF.
    FORMAT COLOR OFF.
    v_cnt = v_cnt + 1.
  ENDLOOP.
  WRITE : /1(206) sy-uline.
  v_subtotal = v_subtotal1 + v_subtotal2 + v_subtotal3
              + v_subtotal4 + v_subtotal5 + v_subtotal6.
  FORMAT COLOR 3 INTENSIFIED.
  WRITE : /1 sy-vline,
             2(85) 'Total'(017) CENTERED CURRENCY int_bsik-waers ,
             87 sy-vline,
             88 v_subtotal1 CURRENCY int_bsik-waers,
            104 sy-vline,
            105 v_subtotal2 CURRENCY int_bsik-waers,
            121 sy-vline,
            122 v_subtotal3 CURRENCY int_bsik-waers,
            138 sy-vline,
            139 v_subtotal4 CURRENCY int_bsik-waers,
            155 sy-vline,
            156 v_subtotal5 CURRENCY int_bsik-waers,
            172 sy-vline,
            173 v_subtotal6 CURRENCY int_bsik-waers,
            189 sy-vline,
            190 v_subtotal CURRENCY int_bsik-waers,
            206 sy-vline.
  FORMAT COLOR OFF.
  WRITE : /1(206) sy-uline.
  CLEAR : v_subtotal,v_subtotal1,v_subtotal2,v_subtotal3,
          v_subtotal4,v_subtotal5,v_gtotal1,v_gtotal2,v_gtotal3,
          v_gtotal4, v_gtotal5,v_gtotal,v_subtotal6,v_gtotal6.
ENDFORM.                    " line_selection
*&      Form  header1
Secondary List Header
FORM header1 .
Standard header
  clear: v_date1, v_str, v_str1, v_tage.
  write p_allgst to v_date1.
  Move  p_tage4 to v_tage.
  concatenate '>' v_tage text-025 into v_str1.
  concatenate
   'Details of Ageing Analysis for Vendor Open Invoices as on'(024)
    v_date1 into v_str separated by space.
  CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
     title1 = 'Company'(012)
     title2 =  v_str.
  FORMAT COLOR 1 intensified.
  WRITE  :/1(206) sy-uline.
  WRITE  :/1 sy-vline,12 sy-vline ,
          23 sy-vline,59 sy-vline,76 sy-vline,87 sy-vline,
          88(101) 'Invoices Due For(In Days)'(014) CENTERED,
         189 sy-vline,206 sy-vline.
  WRITE  : /1 sy-vline,  2(10) 'Doc Number'(021) CENTERED,
           12 sy-vline, 13(10) 'Vendor#'(015) CENTERED,
           23 sy-vline, 24(35) 'Vendor Name'(016) CENTERED,
           59 sy-vline, 60(16) 'Ref invoice#'(019) CENTERED,
           76 sy-vline, 77(10) 'Inv dt'(020) CENTERED,
           87 sy-vline, 88(101) sy-uline,
          189 sy-vline,190(16) 'Total'(017) CENTERED,
          206 sy-vline.
  WRITE : /1 sy-vline, 12 sy-vline,
           23 sy-vline,59 sy-vline,
           76 sy-vline,87 sy-vline,
           88(16) v_fir CENTERED, 104 sy-vline,
          105(16) v_sec CENTERED, 121 sy-vline,
          122(16) v_thir CENTERED, 138 sy-vline,
          139(16) v_four CENTERED, 155 sy-vline,
          156(16) v_str1 CENTERED,
          172    sy-vline,
          173(16) 'Already Overdue'(018) CENTERED,
          189 sy-vline,
          206 sy-vline.
          format color off.
  WRITE  : /1(206) sy-uline.
ENDFORM.                                                    " header1
Reward points if useful
Regards
Anji

Similar Messages

  • Functional Spec for VENDOR AGE ANALYSIS report

    Hi experts
    I need to develope a VENDOR AGE ANALYSIS REPORT. But due to some reason i cant be able to get the Functional Specification for that object. So could you please help me by sending the above mention functional Specification.
    thanks and regadrs
    Pratik

    got the following from sdn thread:
    This is the sample report for vendor aging:
    Std reports Tcodes are:
    customer : s_alr_87012178
    vendor : s_alr_87012084
    Custom designed:
    REPORT zfi_customer_ageing
    NO STANDARD PAGE HEADING
    LINE-COUNT 58
    line-size 168
    MESSAGE-ID zh_msg.
    D A T A B A S E T A B L E S D E C L A R A T I O N
    TABLES: kna1, " Customer Master (General)
    t001, " Company Codes
    rfpdo.
    I N T E R N A L T A B L E S D E C L A R A T I O N S *
    Internal Table for Customer Open Items Data
    DATA: BEGIN OF int_bsid OCCURS 0,
    kunnr LIKE bsid-kunnr, " Customer Number
    name1 LIKE kna1-name1, " Customer Name
    shkzg LIKE bsid-shkzg, " Dr/Cr Indicator
    belnr LIKE bsid-belnr, " Document Number
    xblnr LIKE bsid-xblnr, " Ref Doc No
    blart LIKE bsid-blart, " Document Type
    zfbdt LIKE bsid-zfbdt, " Base Line Date
    zbd1t LIKE bsid-zbd1t, " Due date1
    zbd2t LIKE bsid-zbd2t, " Due Date2
    zbd3t LIKE bsid-zbd3t, " Due Date3
    waers LIKE bsid-waers, " Currency
    dmbtr LIKE bsid-dmbtr, " Amount in Local Curr
    END OF int_bsid.
    Internal Table for Amounts Sum Up Data
    DATA: BEGIN OF int_final OCCURS 0,
    kunnr LIKE bsid-kunnr, " Customer Number
    name1 LIKE kna1-name1, " Customer Name
    total1 LIKE bsid-dmbtr, " Amount in Local Curr
    total2 LIKE bsid-dmbtr, " Amount in Local Curr
    total3 LIKE bsid-dmbtr, " Amount in Local Curr
    total4 LIKE bsid-dmbtr, " Amount in Local Curr
    total5 LIKE bsid-dmbtr, " Amount in Local Curr
    total6 LIKE bsid-dmbtr, " Amount in Local Curr
    total LIKE bsid-dmbtr, " Amount in Local Curr
    END OF int_final.
    D A T A D E C L A R A T I O N S
    DATA : v_flag, " Flag
    v_gtotal1 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal2 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal3 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal4 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal5 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal6 LIKE bsid-dmbtr, " Amount Totals
    v_gtotal LIKE bsid-dmbtr, " Amount Totals
    v_subtotal1 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal2 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal3 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal4 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal5 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal6 LIKE bsid-dmbtr, " Amount Totals
    v_subtotal LIKE bsid-dmbtr, " Amount Totals
    v_date LIKE bsid-zfbdt, " Due Date
    v_tage1(4), " Age 30 days
    v_tage2(4), " Age 60 days
    v_tage3(4), " Age 90 days
    v_fir(15), " Column Text1
    v_sec(15), " Column Text2
    v_thir(15), " Column Text3
    v_four(17), " Column Text4
    v_fidd(4), " Days field1
    v_sedd(4), " Days field2
    v_thdd(4), " Days field3
    v_fodd(4), " Days field4
    v_str TYPE SY-LISEL, " String
    v_str1(11), " String
    v_tage(3), " String
    v_date1(10). " Date field
    R A N G E D E C L A R A T I O N S
    RANGES: r_date1 FOR bsid-zfbdt, " Date Range 1
    r_date2 FOR bsid-zfbdt, " Date Range 2
    r_date3 FOR bsid-zfbdt, " Date Range 3
    r_date4 FOR bsid-zfbdt. " Date Range 4
    S E L E C T I O N S C R E E N *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_kunnr FOR kna1-kunnr. "Customer account
    PARAMETERS: p_bukrs LIKE t001-bukrs. "Co. Code
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS: p_allgst LIKE rfpdo-allgstid OBLIGATORY DEFAULT sy-datum.
    "Open items at key date
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    PARAMETERS: p_tage1 LIKE rfpdo1-allgfael DEFAULT '30',
    p_tage2 LIKE rfpdo1-allgfael DEFAULT '60',
    p_tage3 LIKE rfpdo1-allgfael DEFAULT '90',
    p_tage4 LIKE rfpdo1-allgfael DEFAULT '120'.
    SELECTION-SCREEN END OF BLOCK b3.
    A T S E L E C T I O N S C R E E N *
    AT SELECTION-SCREEN.
    Validate the screen fields
    PERFORM validate_flds.
    S T A R T O F S E L E C T I O N *
    START-OF-SELECTION.
    Fetch main data
    PERFORM fetch_data.
    T O P O F P A G E
    Header
    TOP-OF-PAGE.
    PERFORM header.
    E N D O F P A G E
    Footer
    END-OF-PAGE.
    ULINE.
    T O P O F P A G E D U R I N G L I N E S E L E C T I O N *
    Top of Page in Secondary List
    TOP-OF-PAGE DURING LINE-SELECTION.
    PERFORM header1.
    A T L I N E S E L E C T I O N *
    AT LINE-SELECTION.
    Perform Line Selections
    PERFORM line_selection.
    E N D O F S E L E C T I O N
    END-OF-SELECTION.
    List generation
    PERFORM basic_list.
    *& Form validate_flds
    Validation of Selection Screen fields
    FORM validate_flds .
    Validate Customer Code
    CLEAR kna1-kunnr.
    SELECT kunnr UP TO 1 ROWS
    INTO kna1-kunnr
    FROM kna1
    WHERE kunnr IN s_kunnr AND
    spras = sy-langu.
    ENDSELECT.
    IF sy-subrc 0.
    MESSAGE e000 WITH 'Invalid Customer Code range'(023).
    ENDIF.
    Validate Company Code
    CLEAR t001-bukrs.
    SELECT bukrs UP TO 1 ROWS
    INTO t001-bukrs
    FROM t001
    WHERE bukrs = p_bukrs AND
    spras = sy-langu.
    ENDSELECT.
    IF sy-subrc 0.
    MESSAGE e021. " Invalid Company Code range
    ENDIF.
    IF ( p_tage1 > p_tage2 ) OR ( p_tage1 > p_tage3 ) OR
    ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 1 greater'(004)
    'than Column# 2 or 3 or 4'(005).
    ENDIF.
    *column 2
    IF ( p_tage2 > p_tage3 ) OR ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 2 greater'(006)
    'than Column# 3 or 4'(007).
    ENDIF.
    *column3
    IF ( p_tage3 > p_tage4 ).
    MESSAGE e999 WITH 'Column 3 greater'(008)
    'than Column#4'(009).
    ENDIF.
    ENDFORM. " validate_flds
    *& Form fetch_data
    Fetching Data from Database Tables
    FORM fetch_data .
    Date Range Population
    r_date1-sign = 'I'.
    r_date1-option = 'BT'.
    r_date1-low = p_allgst.
    r_date1-high = r_date1-low + p_tage1.
    APPEND r_date1.
    r_date2-sign = 'I'.
    r_date2-option = 'BT'.
    r_date2-low = r_date1-high + 1.
    r_date2-high = r_date1-low + p_tage2.
    APPEND r_date2.
    r_date3-sign = 'I'.
    r_date3-option = 'BT'.
    r_date3-low = r_date2-high + 1.
    r_date3-high = r_date1-low + p_tage3.
    APPEND r_date3.
    r_date4-sign = 'I'.
    r_date4-option = 'BT'.
    r_date4-low = r_date3-high + 1.
    r_date4-high = r_date1-low + p_tage4.
    APPEND r_date4.
    Select the Customer Open Items data from bsid
    SELECT l~kunnr
    l1~name1
    b~waers
    b~dmbtr
    b~zfbdt
    b~zbd1t
    b~zbd2t
    b~zbd3t
    b~belnr
    b~xblnr
    b~shkzg
    b~blart
    INTO CORRESPONDING FIELDS OF TABLE int_bsid
    FROM knb1 AS l INNER JOIN kna1 AS l1
    ON lkunnr = l1kunnr
    INNER JOIN bsid AS b
    ON lkunnr = bkunnr AND
    lbukrs = bbukrs
    WHERE l~kunnr IN s_kunnr AND
    l~bukrs = p_bukrs and
    b~zfbdt le p_allgst.
    IF SY-SUBRC 0.
    MESSAGE i000 WITH 'No Data found'(027).
    ENDIF.
    Removing the date limit to get the due items in the past
    DELETE int_bsid WHERE
    ( blart NE 'RE' AND blart NE 'KR' ) OR
    shkzg NE 'H'.
    SORT int_bsid BY kunnr.
    ENDFORM. " fetch_data
    *& Form header
    Display the Report Columns
    FORM header .
    v_tage1 = p_tage1 + 1.
    v_tage2 = p_tage2 + 1.
    v_tage3 = p_tage3 + 1.
    v_fidd = p_tage1.
    v_sedd = p_tage2.
    v_thdd = p_tage3.
    v_fodd = p_tage4.
    MOVE v_fodd0(4) TO v_fodd1(3).
    v_fodd+0(1) = space.
    CONCATENATE '1 to'(010) v_fidd INTO v_fir.
    CONCATENATE v_tage1 ' to '(011) v_sedd INTO v_sec.
    CONCATENATE v_tage2 ' to '(011) v_thdd INTO v_thir.
    CONCATENATE v_tage3 ' to '(011) space v_fodd INTO v_four.
    Standard header
    clear: v_date1, v_str, v_str1, v_tage.
    write p_allgst to v_date1.
    Move p_tage4 to v_tage.
    concatenate '>' v_tage text-025 into v_str1.
    concatenate
    'Summary of Ageing Analysis for Customer Open Invoices as on'(013)
    v_date1 into v_str separated by space.
    CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
    title1 = 'Saudi International Petrochemical Company'(012)
    title2 = v_str.
    FORMAT COLOR OFF.
    WRITE : /1(168) sy-uline.
    FORMAT COLOR 1 INTENSIFIED.
    WRITE :/1 sy-vline, 13 sy-vline, 49 sy-vline,
    50(101) 'Invoices Due For(In Days)'(014) CENTERED,
    151 sy-vline, 168 sy-vline .
    WRITE :/1 sy-vline, 2(11) 'Customer#'(015) CENTERED,
    13 sy-vline ,14(35) 'Customer Name'(016) CENTERED,
    49 sy-vline,
    50(101) sy-uline,151 sy-vline,
    152(16) 'Total'(017) CENTERED,
    168 sy-vline.
    WRITE : /1 sy-vline,13 sy-vline, 49 sy-vline,
    50(16) v_fir CENTERED, 66 sy-vline,
    67(16) v_sec CENTERED, 83 sy-vline,
    84(16) v_thir CENTERED, 100 sy-vline,
    101(16) v_four CENTERED, 117 sy-vline,
    118(16) v_str1 centered, 134 sy-vline,
    135(16) 'Already Overdue'(018) CENTERED,151 sy-vline,
    168 sy-vline.
    FORMAT COLOR OFF.
    WRITE : /1(168) sy-uline.
    ENDFORM. " header
    *& Form basic_list
    Display the Basic List
    FORM basic_list .
    NEW-PAGE LINE-SIZE 168.
    LOOP AT int_bsid.
    CLEAR v_date.
    IF int_bsid-zbd3t ' '.
    v_date = int_bsid-zfbdt + int_bsid-zbd3t.
    ELSE.
    IF int_bsid-zbd2t ' '.
    v_date = int_bsid-zfbdt + int_bsid-zbd2t.
    ELSE.
    v_date = int_bsid-zfbdt + int_bsid-zbd1t.
    ENDIF.
    ENDIF.
    IF int_bsid-zbd1t = ' '.
    v_date = int_bsid-zfbdt.
    ENDIF.
    IF v_date IN r_date1.
    int_final-total1 = int_final-total1 + int_bsid-dmbtr.
    ELSEIF v_date IN r_date2.
    int_final-total2 = int_final-total2 + int_bsid-dmbtr.
    ELSEIF v_date IN r_date3.
    int_final-total3 = int_final-total3 + int_bsid-dmbtr.
    ELSEIF v_date IN r_date4.
    int_final-total4 = int_final-total4 + int_bsid-dmbtr.
    ELSEif v_date > r_date4-high.
    int_final-total5 = int_final-total5 + int_bsid-dmbtr.
    ELSEif v_date < p_allgst.
    int_final-total6 = int_final-total6 + int_bsid-dmbtr.
    ENDIF.
    AT END OF kunnr.
    v_flag = 1.
    ENDAT.
    IF v_flag = 1.
    int_final-kunnr = int_bsid-kunnr.
    int_final-name1 = int_bsid-name1.
    int_final-total = int_final-total1 + int_final-total2 +
    int_final-total3 + int_final-total4 + int_final-total5 +
    int_final-total6.
    APPEND int_final.
    v_gtotal1 = v_gtotal1 + int_final-total1.
    v_gtotal2 = v_gtotal2 + int_final-total2.
    v_gtotal3 = v_gtotal3 + int_final-total3.
    v_gtotal4 = v_gtotal4 + int_final-total4.
    v_gtotal5 = v_gtotal5 + int_final-total5.
    v_gtotal6 = v_gtotal6 + int_final-total6.
    v_gtotal = v_gtotal + int_final-total.
    WRITE: /1 sy-vline,
    2 int_final-kunnr COLOR 4 INTENSIFIED ON,
    13 sy-vline,
    14 int_final-name1 COLOR 4 INTENSIFIED ON,
    49 sy-vline.
    DATA : v_rem.
    v_rem = sy-tabix MOD 2.
    IF v_rem NE 0.
    FORMAT COLOR 2 INTENSIFIED.
    WRITE : 50 int_final-total1 CURRENCY int_bsid-waers,
    66 sy-vline,
    67 int_final-total2 CURRENCY int_bsid-waers,
    83 sy-vline,
    84 int_final-total3 CURRENCY int_bsid-waers,
    100 sy-vline,
    101 int_final-total4 CURRENCY int_bsid-waers,
    117 sy-vline,
    118 int_final-total5 CURRENCY int_bsid-waers,
    134 sy-vline,
    135 int_final-total6 CURRENCY int_bsid-waers,
    151 sy-vline,
    152 int_final-total CURRENCY int_bsid-waers,
    168 sy-vline.
    ELSE.
    WRITE : 50 int_final-total1 CURRENCY int_bsid-waers,
    66 sy-vline,
    67 int_final-total2 CURRENCY int_bsid-waers,
    83 sy-vline,
    84 int_final-total3 CURRENCY int_bsid-waers,
    100 sy-vline,
    101 int_final-total4 CURRENCY int_bsid-waers,
    117 sy-vline,
    118 int_final-total5 CURRENCY int_bsid-waers,
    134 sy-vline,
    135 int_final-total6 CURRENCY int_bsid-waers,
    151 sy-vline,
    152 int_final-total CURRENCY int_bsid-waers,
    168 sy-vline.
    ENDIF.
    FORMAT COLOR OFF.
    HIDE int_final.
    CLEAR int_final.
    v_flag = 0.
    ENDIF.
    AT LAST.
    WRITE : /1(168) sy-uline.
    FORMAT COLOR 3 INTENSIFIED.
    WRITE : /1 sy-vline, 2(47) 'GRAND TOTAL'(022) CENTERED,
    49 sy-vline, 50 v_gtotal1 CURRENCY int_bsid-waers,
    66 sy-vline, 67 v_gtotal2 CURRENCY int_bsid-waers,
    83 sy-vline, 84 v_gtotal3 CURRENCY int_bsid-waers,
    100 sy-vline,101 v_gtotal4 CURRENCY int_bsid-waers,
    117 sy-vline,118 v_gtotal5 CURRENCY int_bsid-waers,
    134 sy-vline,135 v_gtotal6 CURRENCY int_bsid-waers,
    151 sy-vline,152 v_gtotal CURRENCY int_bsid-waers,
    168 sy-vline.
    HIDE : v_gtotal1,
    v_gtotal2,
    v_gtotal3,
    v_gtotal4,
    v_gtotal5,
    v_gtotal6,
    v_gtotal.
    ENDAT.
    FORMAT COLOR OFF.
    ENDLOOP.
    WRITE : /1(168) sy-uline.
    ENDFORM. " basic_list
    *& Form line_selection
    When double clicked on the line display the seconday list
    FORM line_selection .
    NEW-PAGE LINE-SIZE 206.
    Sy-lsind = 1.
    DATA : v_rem,v_cnt LIKE sy-tabix.
    v_cnt = 0.
    SORT int_bsid BY belnr zfbdt.
    LOOP AT int_bsid WHERE kunnr EQ int_final-kunnr.
    v_rem = v_cnt MOD 2.
    CLEAR v_date.
    IF int_bsid-zbd3t ' '.
    v_date = int_bsid-zfbdt + int_bsid-zbd3t.
    ELSE.
    IF int_bsid-zbd2t ' '.
    v_date = int_bsid-zfbdt + int_bsid-zbd2t.
    ELSE.
    v_date = int_bsid-zfbdt + int_bsid-zbd1t.
    ENDIF.
    ENDIF.
    IF int_bsid-zbd1t = ' '.
    v_date = int_bsid-zfbdt.
    ENDIF.
    IF v_rem NE 0.
    format color 2 intensified.
    WRITE :/1 sy-vline, 2 int_bsid-belnr,
    12 sy-vline,13 int_bsid-kunnr,
    23 sy-vline,24 int_bsid-name1,
    59 sy-vline,60 int_bsid-xblnr,
    76 sy-vline,77 int_bsid-zfbdt,
    87 sy-vline.
    WRITE : 104 sy-vline,121 sy-vline,
    138 sy-vline,155 sy-vline,
    172 sy-vline, 189 sy-vline,
    190 int_bsid-dmbtr CURRENCY int_bsid-waers,
    206 sy-vline.
    IF v_date IN r_date1.
    v_subtotal1 = v_subtotal1 + int_bsid-dmbtr.
    WRITE : 88 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date2.
    v_subtotal2 = v_subtotal2 + int_bsid-dmbtr.
    WRITE : 105 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date3.
    v_subtotal3 = v_subtotal3 + int_bsid-dmbtr.
    WRITE : 122 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date4.
    v_subtotal4 = v_subtotal4 + int_bsid-dmbtr.
    WRITE : 139 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEif v_date > r_date4-high.
    v_subtotal5 = v_subtotal5 + int_bsid-dmbtr.
    WRITE : 156 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEif v_date < p_allgst.
    v_subtotal6 = v_subtotal6 + int_bsid-dmbtr.
    WRITE : 173 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ENDIF.
    format color off.
    ELSE.
    WRITE :/1 sy-vline, 2 int_bsid-belnr,
    12 sy-vline,13 int_bsid-kunnr,
    23 sy-vline,24 int_bsid-name1,
    59 sy-vline,60 int_bsid-xblnr,
    76 sy-vline,77 int_bsid-zfbdt,
    87 sy-vline.
    WRITE : 104 sy-vline,121 sy-vline,
    138 sy-vline,155 sy-vline,
    172 sy-vline,189 sy-vline,
    190 int_bsid-dmbtr CURRENCY int_bsid-waers,
    206 sy-vline.
    IF v_date IN r_date1.
    v_subtotal1 = v_subtotal1 + int_bsid-dmbtr.
    WRITE : 88 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date2.
    v_subtotal2 = v_subtotal2 + int_bsid-dmbtr.
    WRITE : 105 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date3.
    v_subtotal3 = v_subtotal3 + int_bsid-dmbtr.
    WRITE : 122 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEIF v_date IN r_date4.
    v_subtotal4 = v_subtotal4 + int_bsid-dmbtr.
    WRITE : 139 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEif v_date > r_date4-high.
    v_subtotal5 = v_subtotal5 + int_bsid-dmbtr.
    WRITE : 156 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ELSEif v_date < p_allgst.
    v_subtotal6 = v_subtotal6 + int_bsid-dmbtr.
    WRITE : 173 int_bsid-dmbtr CURRENCY int_bsid-waers.
    ENDIF.
    ENDIF.
    FORMAT COLOR OFF.
    v_cnt = v_cnt + 1.
    ENDLOOP.
    WRITE : /1(206) sy-uline.
    v_subtotal = v_subtotal1 + v_subtotal2 + v_subtotal3
    + v_subtotal4 + v_subtotal5 + v_subtotal6.
    FORMAT COLOR 3 INTENSIFIED.
    WRITE : /1 sy-vline,
    2(85) 'Total'(017) CENTERED CURRENCY int_bsid-waers ,
    87 sy-vline,
    88 v_subtotal1 CURRENCY int_bsid-waers,
    104 sy-vline,
    105 v_subtotal2 CURRENCY int_bsid-waers,
    121 sy-vline,
    122 v_subtotal3 CURRENCY int_bsid-waers,
    138 sy-vline,
    139 v_subtotal4 CURRENCY int_bsid-waers,
    155 sy-vline,
    156 v_subtotal5 CURRENCY int_bsid-waers,
    172 sy-vline,
    173 v_subtotal6 CURRENCY int_bsid-waers,
    189 sy-vline,
    190 v_subtotal CURRENCY int_bsid-waers,
    206 sy-vline.
    FORMAT COLOR OFF.
    WRITE : /1(206) sy-uline.
    CLEAR : v_subtotal,v_subtotal1,v_subtotal2,v_subtotal3,
    v_subtotal4,v_subtotal5,v_gtotal1,v_gtotal2,v_gtotal3,
    v_gtotal4, v_gtotal5,v_gtotal,v_subtotal6,v_gtotal6.
    ENDFORM. " line_selection
    *& Form header1
    Secondary List Header
    FORM header1 .
    Standard header
    clear: v_date1, v_str, v_str1, v_tage.
    write p_allgst to v_date1.
    Move p_tage4 to v_tage.
    concatenate '>' v_tage text-025 into v_str1.
    concatenate
    'Details of Ageing Analysis for Customer Open Invoices as on'(024)
    v_date1 into v_str separated by space.
    CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
    title1 = 'Saudi International Petrochemical Company'(012)
    title2 = v_str.
    FORMAT COLOR 1 intensified.
    WRITE :/1(206) sy-uline.
    WRITE :/1 sy-vline,12 sy-vline ,
    23 sy-vline,59 sy-vline,76 sy-vline,87 sy-vline,
    88(101) 'Invoices Due For(In Days)'(014) CENTERED,
    189 sy-vline,206 sy-vline.
    WRITE : /1 sy-vline, 2(10) 'Doc Number'(021) CENTERED,
    12 sy-vline, 13(10) 'Customer#'(015) CENTERED,
    23 sy-vline, 24(35) 'Customer Name'(016) CENTERED,
    59 sy-vline, 60(16) 'Ref invoice#'(019) CENTERED,
    76 sy-vline, 77(10) 'Inv dt'(020) CENTERED,
    87 sy-vline, 88(101) sy-uline,
    189 sy-vline,190(16) 'Total'(017) CENTERED,
    206 sy-vline.
    WRITE : /1 sy-vline, 12 sy-vline,
    23 sy-vline,59 sy-vline,
    76 sy-vline,87 sy-vline,
    88(16) v_fir CENTERED, 104 sy-vline,
    105(16) v_sec CENTERED, 121 sy-vline,
    122(16) v_thir CENTERED, 138 sy-vline,
    139(16) v_four CENTERED, 155 sy-vline,
    156(16) v_str1 CENTERED,
    172 sy-vline,
    173(16) 'Already Overdue'(018) CENTERED,
    189 sy-vline,
    206 sy-vline.
    format color off.
    WRITE : /1(206) sy-uline.
    ENDFORM. " header1
    REPORT zfi_vendor_ageing
    NO STANDARD PAGE HEADING
    LINE-COUNT 58
    line-size 168
    MESSAGE-ID zh_msg.
    Report Name : Vendor Open Items Ageing Report
    Purpose : This report displays the Vendor Open Items based on
    different Ageing days (Calculated by taking the Base
    Line date and the days mentioned in Payment Terms)
    M O D I F I C A T I O N L O G
    Date | Change Number | Initials | Description
    30-Aug-2004 | DTSK900**** | Anji Reddy | Initial
    D A T A B A S E T A B L E S D E C L A R A T I O N
    TABLES: lfa1, " Vendor Master (General)
    t001, " Company Codes
    rfpdo.
    I N T E R N A L T A B L E S D E C L A R A T I O N S *
    Internal Table for Vendor Open Items Data
    DATA: BEGIN OF int_bsik OCCURS 0,
    lifnr LIKE bsik-lifnr, " Vendor Number
    name1 LIKE lfa1-name1, " Vendor Name
    shkzg LIKE bsik-shkzg, " Dr/Cr Indicator
    belnr LIKE bsik-belnr, " Document Number
    xblnr LIKE bsik-xblnr, " Ref Doc No
    blart LIKE bsik-blart, " Document Type
    zfbdt LIKE bsik-zfbdt, " Base Line Date
    zbd1t LIKE bsik-zbd1t, " Due date1
    zbd2t LIKE bsik-zbd2t, " Due Date2
    zbd3t LIKE bsik-zbd3t, " Due Date3
    waers LIKE bsik-waers, " Currency
    dmbtr LIKE bsik-dmbtr, " Amount in Local Curr
    END OF int_bsik.
    Internal Table for Amounts Sum Up Data
    DATA: BEGIN OF int_final OCCURS 0,
    lifnr LIKE bsik-lifnr, " Vendor Number
    name1 LIKE lfa1-name1, " Vendor Name
    total1 LIKE bsik-dmbtr, " Amount in Local Curr
    total2 LIKE bsik-dmbtr, " Amount in Local Curr
    total3 LIKE bsik-dmbtr, " Amount in Local Curr
    total4 LIKE bsik-dmbtr, " Amount in Local Curr
    total5 LIKE bsik-dmbtr, " Amount in Local Curr
    total6 LIKE bsik-dmbtr, " Amount in Local Curr
    total LIKE bsik-dmbtr, " Amount in Local Curr
    END OF int_final.
    D A T A D E C L A R A T I O N S
    DATA : v_flag, " Flag
    v_gtotal1 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal2 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal3 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal4 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal5 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal6 LIKE bsik-dmbtr, " Amount Totals
    v_gtotal LIKE bsik-dmbtr, " Amount Totals
    v_subtotal1 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal2 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal3 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal4 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal5 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal6 LIKE bsik-dmbtr, " Amount Totals
    v_subtotal LIKE bsik-dmbtr, " Amount Totals
    v_date LIKE bsik-zfbdt, " Due Date
    v_tage1(4), " Age 30 days
    v_tage2(4), " Age 60 days
    v_tage3(4), " Age 90 days
    v_fir(15), " Column Text1
    v_sec(15), " Column Text2
    v_thir(15), " Column Text3
    v_four(17), " Column Text4
    v_fidd(4), " Days field1
    v_sedd(4), " Days field2
    v_thdd(4), " Days field3
    v_fodd(4), " Days field4
    v_str TYPE SY-LISEL, " String
    v_str1(11), " String
    v_tage(3), " String
    v_date1(10). " Date field
    R A N G E D E C L A R A T I O N S
    RANGES: r_date1 FOR bsik-zfbdt, " Date Range 1
    r_date2 FOR bsik-zfbdt, " Date Range 2
    r_date3 FOR bsik-zfbdt, " Date Range 3
    r_date4 FOR bsik-zfbdt. " Date Range 4
    S E L E C T I O N S C R E E N *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr. "Vendor account
    PARAMETERS: p_bukrs LIKE t001-bukrs. "Co. Code
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS: p_allgst LIKE rfpdo-allgstid OBLIGATORY DEFAULT sy-datum.
    "Open items at key date
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    PARAMETERS: p_tage1 LIKE rfpdo1-allgfael DEFAULT '30',
    p_tage2 LIKE rfpdo1-allgfael DEFAULT '60',
    p_tage3 LIKE rfpdo1-allgfael DEFAULT '90',
    p_tage4 LIKE rfpdo1-allgfael DEFAULT '120'.
    SELECTION-SCREEN END OF BLOCK b3.
    A T S E L E C T I O N S C R E E N *
    AT SELECTION-SCREEN.
    Validate the screen fields
    PERFORM validate_flds.
    S T A R T O F S E L E C T I O N *
    START-OF-SELECTION.
    Fetch main data
    PERFORM fetch_data.
    T O P O F P A G E
    Header
    TOP-OF-PAGE.
    PERFORM header.
    E N D O F P A G E
    Footer
    END-OF-PAGE.
    ULINE.
    T O P O F P A G E D U R I N G L I N E S E L E C T I O N *
    Top of Page in Secondary List
    TOP-OF-PAGE DURING LINE-SELECTION.
    PERFORM header1.
    A T L I N E S E L E C T I O N *
    AT LINE-SELECTION.
    Perform Line Selections
    PERFORM line_selection.
    E N D O F S E L E C T I O N
    END-OF-SELECTION.
    List generation
    PERFORM basic_list.
    *& Form validate_flds
    Validation of Selection Screen fields
    FORM validate_flds .
    Validate Vendor Code
    CLEAR lfa1-lifnr.
    SELECT lifnr UP TO 1 ROWS
    INTO lfa1-lifnr
    FROM lfa1
    WHERE lifnr IN s_lifnr AND
    spras = sy-langu.
    ENDSELECT.
    IF sy-subrc 0.
    MESSAGE e000 WITH 'Invalid Vendor Code range'(023).
    ENDIF.
    Validate Company Code
    CLEAR t001-bukrs.
    SELECT bukrs UP TO 1 ROWS
    INTO t001-bukrs
    FROM t001
    WHERE bukrs = p_bukrs AND
    spras = sy-langu.
    ENDSELECT.
    IF sy-subrc 0.
    MESSAGE e021. " Invalid Company Code range
    ENDIF.
    IF ( p_tage1 > p_tage2 ) OR ( p_tage1 > p_tage3 ) OR
    ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 1 greater'(004)
    'than Column# 2 or 3 or 4'(005).
    ENDIF.
    *column 2
    IF ( p_tage2 > p_tage3 ) OR ( p_tage1 > p_tage4 ).
    MESSAGE e999 WITH 'Column 2 greater'(006)
    'than Column# 3 or 4'(007).
    ENDIF.
    *column3
    IF ( p_tage3 > p_tage4 ).
    MESSAGE e999 WITH 'Column 3 greater'(008)
    'than Column#4'(009).
    ENDIF.
    ENDFORM. " validate_flds
    *& Form fetch_data
    Fetching Data from Database Tables
    FORM fetch_data .
    Date Range Population
    r_date1-sign = 'I'.
    r_date1-option = 'BT'.
    r_date1-low = p_allgst.
    r_date1-high = r_date1-low + p_tage1.
    APPEND r_date1.
    r_date2-sign = 'I'.
    r_date2-option = 'BT'.
    r_date2-low = r_date1-high + 1.
    r_date2-high = r_date1-low + p_tage2.
    APPEND r_date2.
    r_date3-sign = 'I'.
    r_date3-option = 'BT'.
    r_date3-low = r_date2-high + 1.
    r_date3-high = r_date1-low + p_tage3.
    APPEND r_date3.
    r_date4-sign = 'I'.
    r_date4-option = 'BT'.
    r_date4-low = r_date3-high + 1.
    r_date4-high = r_date1-low + p_tage4.
    APPEND r_date4.
    Select the Vendor Open Items data from BSIK
    SELECT l~lifnr
    l1~name1
    b~waers
    b~dmbtr
    b~zfbdt
    b~zbd1t
    b~zbd2t
    b~zbd3t
    b~belnr
    b~xblnr
    b~shkzg
    b~blart
    INTO CORRESPONDING FIELDS OF TABLE int_bsik
    FROM lfb1 AS l INNER JOIN lfa1 AS l1
    ON llifnr = l1lifnr
    INNER JOIN bsik AS b
    ON llifnr = blifnr AND
    lbukrs = bbukrs
    WHERE l~lifnr IN s_lifnr AND
    l~bukrs = p_bukrs and
    b~zfbdt le p_allgst.
    IF SY-SUBRC 0.
    MESSAGE i000 WITH 'No Data found'(027).
    ENDIF.
    Removing the date limit to get the due items in the past
    DELETE int_bsik WHERE
    ( blart NE 'RE' AND blart NE 'KR' ) OR
    shkzg NE 'H'.
    SORT int_bsik BY lifnr.
    ENDFORM. " fetch_data
    *& Form header
    Display the Report Columns
    FORM header .
    v_tage1 = p_tage1 + 1.
    v_tage2 = p_tage2 + 1.
    v_tage3 = p_tage3 + 1.
    v_fidd = p_tage1.
    v_sedd = p_tage2.
    v_thdd = p_tage3.
    v_fodd = p_tage4.
    MOVE v_fodd0(4) TO v_fodd1(3).
    v_fodd+0(1) = space.
    CONCATENATE '1 to'(010) v_fidd INTO v_fir.
    CONCATENATE v_tage1 ' to '(011) v_sedd INTO v_sec.
    CONCATENATE v_tage2 ' to '(011) v_thdd INTO v_thir.
    CONCATENATE v_tage3 ' to '(011) space v_fodd INTO v_four.
    Standard header
    clear: v_date1, v_str, v_str1, v_tage.
    write p_allgst to v_date1.
    Move p_tage4 to v_tage.
    concatenate '>' v_tage text-025 into v_str1.
    concatenate
    'Summary of Ageing Analysis for Vendor Open Invoices as on'(013)
    v_date1 into v_str separated by space.
    CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
    title1 = 'Saudi International Petrochemical Company'(012)
    title2 = v_str.
    FORMAT COLOR OFF.
    WRITE : /1(168) sy-uline.
    FORMAT COLOR 1 INTENSIFIED.
    WRITE :/1 sy-vline, 13 sy-vline, 49 sy-vline,
    50(101) 'Invoices Due For(In Days)'(014) CENTERED,
    151 sy-vline, 168 sy-vline .
    WRITE :/1 sy-vline, 2(11) 'Vendor#'(015) CENTERED,
    13 sy-vline ,14(35) 'Vendor Name'(016) CENTERED,
    49 sy-vline,
    50(101) sy-uline,151 sy-vline,
    152(16) 'Total'(017) CENTERED,
    168 sy-vline.
    WRITE : /1 sy-vline,13 sy-vline, 49 sy-vline,
    50(16) v_fir CENTERED, 66 sy-vline,
    67(16) v_sec CENTERED, 83 sy-vline,
    84(16) v_thir CENTERED, 100 sy-vline,
    101(16) v_four CENTERED, 117 sy-vline,
    118(16) v_str1 centered, 134 sy-vline,
    135(16) 'Already Overdue'(018) CENTERED,151 sy-vline,
    168 sy-vline.
    FORMAT COLOR OFF.
    WRITE : /1(168) sy-uline.
    ENDFORM. " header
    *& Form basic_list
    Display the Basic List
    FORM basic_list .
    NEW-PAGE LINE-SIZE 168.
    LOOP AT int_bsik.
    CLEAR v_date.
    IF int_bsik-zbd3t ' '.
    v_date = int_bsik-zfbdt + int_bsik-zbd3t.
    ELSE.
    IF int_bsik-zbd2t ' '.
    v_date = int_bsik-zfbdt + int_bsik-zbd2t.
    ELSE.
    v_date = int_bsik-zfbdt + int_bsik-zbd1t.
    ENDIF.
    ENDIF.
    IF int_bsik-zbd1t = ' '.
    v_date = int_bsik-zfbdt.
    ENDIF.
    IF v_date IN r_date1.
    int_final-total1 = int_final-total1 + int_bsik-dmbtr.
    ELSEIF v_date IN r_date2.
    int_final-total2 = int_final-total2 + int_bsik-dmbtr.
    ELSEIF v_date IN r_date3.
    int_final-total3 = int_final-total3 + int_bsik-dmbtr.
    ELSEIF v_date IN r_date4.
    int_final-total4 = int_final-total4 + int_bsik-dmbtr.
    ELSEif v_date > r_date4-high.
    int_final-total5 = int_final-total5 + int_bsik-dmbtr.
    ELSEif v_date < p_allgst.
    int_final-total6 = int_final-total6 + int_bsik-dmbtr.
    ENDIF.
    AT END OF lifnr.
    v_flag = 1.
    ENDAT.
    IF v_flag = 1.
    int_final-lifnr = int_bsik-lifnr.
    int_final-name1 = int_bsik-name1.
    int_final-total = int_final-total1 + int_final-total2 +
    int_final-total3 + int_final-total4 + int_final-total5 +
    int_final-total6.
    APPEND int_final.
    v_gtotal1 = v_gtotal1 + int_final-total1.
    v_gtotal2 = v_gtotal2 + int_final-total2.
    v_gtotal3 = v_gtotal3 + int_final-total3.
    v_gtotal4 = v_gtotal4 + int_final-total4.
    v_gtotal5 = v_gtotal5 + int_final-total5.
    v_gtotal6 = v_gtotal6 + int_final-total6.
    v_gtotal = v_gtotal + int_final-total.
    WRITE: /1 sy-vline,
    2 int_final-lifnr COLOR 4 INTENSIFIED ON,
    13 sy-vline,
    14 int_final-name1 COLOR 4 INTENSIFIED ON,
    49 sy-vline.
    DATA : v_rem.
    v_rem = sy-tabix MOD 2.
    IF v_rem NE 0.
    FORMAT COLOR 2 INTENSIFIED.
    WRITE : 50 int_final-total1 CURRENCY int_bsik-waers,
    66 sy-vline,
    67 int_final-total2 CURRENCY int_bsik-waers,
    83 sy-vline,
    84 int_final-total3 CURRENCY int_bsik-waers,
    100 sy-vline,
    101 int_final-total4 CURRENCY int_bsik-waers,
    117 sy-vline,
    118 int_final-total5 CURRENCY int_bsik-waers,
    134 sy-vline,
    135 int_final-total6 CURRENCY int_bsik-waers,
    151 sy-vline,
    152 int_final-total CURRENCY int_bsik-waers,
    168 sy-vline.
    ELSE.
    WRITE : 50 int_final-total1 CURRENCY int_bsik-waers,
    66 sy-vline,
    67 int_final-total2 CURRENCY int_bsik-waers,
    83 sy-vline,
    84 int_final-total3 CURRENCY int_bsik-waers,
    100 sy-vline,
    101 int_final-total4 CURRENCY int_bsik-waers,
    117 sy-vline,
    118 int_final-total5 CURRENCY int_bsik-waers,
    134 sy-vline,
    135 int_final-total6 CURRENCY int_bsik-waers,
    151 sy-vline,
    152 int_final-total CURRENCY int_bsik-waers,
    168 sy-vline.
    ENDIF.
    FORMAT COLOR OFF.
    HIDE int_final.
    CLEAR int_final.
    v_flag = 0.
    ENDIF.
    AT LAST.
    WRITE : /1(168) sy-uline.
    FORMAT COLOR 3 INTENSIFIED.
    WRITE : /1 sy-vline, 2(47) 'GRAND TOTAL'(022) CENTERED,
    49 sy-vline, 50 v_gtotal1 CURRENCY int_bsik-waers,
    66 sy-vline, 67 v_gtotal2 CURRENCY int_bsik-waers,
    83 sy-vline, 84 v_gtotal3 CURRENCY int_bsik-waers,
    100 sy-vline,101 v_gtotal4 CURRENCY int_bsik-waers,
    117 sy-vline,118 v_gtotal5 CURRENCY int_bsik-waers,
    134 sy-vline,135 v_gtotal6 CURRENCY int_bsik-waers,
    151 sy-vline,152 v_gtotal CURRENCY int_bsik-waers,
    168 sy-vline.
    HIDE : v_gtotal1,
    v_gtotal2,
    v_gtotal3,
    v_gtotal4,
    v_gtotal5,
    v_gtotal6,
    v_gtotal.
    ENDAT.
    FORMAT COLOR OFF.
    ENDLOOP.
    WRITE : /1(168) sy-uline.
    ENDFORM. " basic_list
    *& Form line_selection
    When double clicked on the line display the seconday list
    FORM line_selection .
    NEW-PAGE LINE-SIZE 206.
    Sy-lsind = 1.
    DATA : v_rem,v_cnt LIKE sy-tabix.
    v_cnt = 0.
    SORT int_bsik BY belnr zfbdt.
    LOOP AT int_bsik WHERE lifnr EQ int_final-lifnr.
    v_rem = v_cnt MOD 2.
    CLEAR v_date.
    IF int_bsik-zbd3t ' '.
    v_date = int_bsik-zfbdt + int_bsik-zbd3t.
    ELSE.
    IF int_bsik-zbd2t ' '.
    v_date = int_bsik-zfbdt + int_bsik-zbd2t.
    ELSE.
    v_date = int_bsik-zfbdt + int_bsik-zbd1t.
    ENDIF.
    ENDIF.
    IF int_bsik-zbd1t = ' '.
    v_date = int_bsik-zfbdt.
    ENDIF.
    IF v_rem NE 0.
    format color 2 intensified.
    WRITE :/1 sy-vline, 2 int_bsik-belnr,
    12 sy-vline,13 int_bsik-lifnr,
    23 sy-vline,24 int_bsik-name1,
    59 sy-vline,60 int_bsik-xblnr,
    76 sy-vline,77 int_bsik-zfbdt,
    87 sy-vline.
    WRITE : 104 sy-vline,121 sy-vline,
    138 sy-vline,155 sy-vline,
    172 sy-vline, 189 sy-vline,
    190 int_bsik-dmbtr CURRENCY int_bsik-waers,
    206 sy-vline.
    IF v_date IN r_date1.
    v_subtotal1 = v_subtotal1 + int_bsik-dmbtr.
    WRITE : 88 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date2.
    v_subtotal2 = v_subtotal2 + int_bsik-dmbtr.
    WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date3.
    v_subtotal3 = v_subtotal3 + int_bsik-dmbtr.
    WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date4.
    v_subtotal4 = v_subtotal4 + int_bsik-dmbtr.
    WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEif v_date > r_date4-high.
    v_subtotal5 = v_subtotal5 + int_bsik-dmbtr.
    WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEif v_date < p_allgst.
    v_subtotal6 = v_subtotal6 + int_bsik-dmbtr.
    WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ENDIF.
    format color off.
    ELSE.
    WRITE :/1 sy-vline, 2 int_bsik-belnr,
    12 sy-vline,13 int_bsik-lifnr,
    23 sy-vline,24 int_bsik-name1,
    59 sy-vline,60 int_bsik-xblnr,
    76 sy-vline,77 int_bsik-zfbdt,
    87 sy-vline.
    WRITE : 104 sy-vline,121 sy-vline,
    138 sy-vline,155 sy-vline,
    172 sy-vline,189 sy-vline,
    190 int_bsik-dmbtr CURRENCY int_bsik-waers,
    206 sy-vline.
    IF v_date IN r_date1.
    v_subtotal1 = v_subtotal1 + int_bsik-dmbtr.
    WRITE : 88 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date2.
    v_subtotal2 = v_subtotal2 + int_bsik-dmbtr.
    WRITE : 105 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date3.
    v_subtotal3 = v_subtotal3 + int_bsik-dmbtr.
    WRITE : 122 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEIF v_date IN r_date4.
    v_subtotal4 = v_subtotal4 + int_bsik-dmbtr.
    WRITE : 139 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEif v_date > r_date4-high.
    v_subtotal5 = v_subtotal5 + int_bsik-dmbtr.
    WRITE : 156 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ELSEif v_date < p_allgst.
    v_subtotal6 = v_subtotal6 + int_bsik-dmbtr.
    WRITE : 173 int_bsik-dmbtr CURRENCY int_bsik-waers.
    ENDIF.
    ENDIF.
    FORMAT COLOR OFF.
    v_cnt = v_cnt + 1.
    ENDLOOP.
    WRITE : /1(206) sy-uline.
    v_subtotal = v_subtotal1 + v_subtotal2 + v_subtotal3
    + v_subtotal4 + v_subtotal5 + v_subtotal6.
    FORMAT COLOR 3 INTENSIFIED.
    WRITE : /1 sy-vline,
    2(85) 'Total'(017) CENTERED CURRENCY int_bsik-waers ,
    87 sy-vline,
    88 v_subtotal1 CURRENCY int_bsik-waers,
    104 sy-vline,
    105 v_subtotal2 CURRENCY int_bsik-waers,
    121 sy-vline,
    122 v_subtotal3 CURRENCY int_bsik-waers,
    138 sy-vline,
    139 v_subtotal4 CURRENCY int_bsik-waers,
    155 sy-vline,
    156 v_subtotal5 CURRENCY int_bsik-waers,
    172 sy-vline,
    173 v_subtotal6 CURRENCY int_bsik-waers,
    189 sy-vline,
    190 v_subtotal CURRENCY int_bsik-waers,
    206 sy-vline.
    FORMAT COLOR OFF.
    WRITE : /1(206) sy-uline.
    CLEAR : v_subtotal,v_subtotal1,v_subtotal2,v_subtotal3,
    v_subtotal4,v_subtotal5,v_gtotal1,v_gtotal2,v_gtotal3,
    v_gtotal4, v_gtotal5,v_gtotal,v_subtotal6,v_gtotal6.
    ENDFORM. " line_selection
    *& Form header1
    Secondary List Header
    FORM header1 .
    Standard header
    clear: v_date1, v_str, v_str1, v_tage.
    write p_allgst to v_date1.
    Move p_tage4 to v_tage.
    concatenate '>' v_tage text-025 into v_str1.
    concatenate
    'Details of Ageing Analysis for Vendor Open Invoices as on'(024)
    v_date1 into v_str separated by space.
    CALL FUNCTION 'Z_STANDARD_HEADER'
    EXPORTING
    title1 = 'Saudi International Petrochemical Company'(012)
    title2 = v_str.
    FORMAT COLOR 1 intensified.
    WRITE :/1(206) sy-uline.
    WRITE :/1 sy-vline,12 sy-vline ,
    23 sy-vline,59 sy-vline,76 sy-vline,87 sy-vline,
    88(101) 'Invoices Due For(In Days)'(014) CENTERED,
    189 sy-vline,206 sy-vline.
    WRITE : /1 sy-vline, 2(10) 'Doc Number'(021) CENTERED,
    12 sy-vline, 13(10) 'Vendor#'(015) CENTERED,
    23 sy-vline, 24(35) 'Vendor Name'(016) CENTERED,
    59 sy-vline, 60(16) 'Ref invoice#'(019) CENTERED,
    76 sy-vline, 77(10) 'Inv dt'(020) CENTERED,
    87 sy-vline, 88(101) sy-uline,
    189 sy-vline,190(16) 'Total'(017) CENTERED,
    206 sy-vline.
    WRITE : /1 sy-vline, 12 sy-vline,
    23 sy-vline,59 sy-vline,
    76 sy-vline,87 sy-vline,
    88(16) v_fir CENTERED, 104 sy-vline,
    105(16) v_sec CENTERED, 121 sy-vline,
    122(16) v_thir CENTERED, 138 sy-vline,
    139(16) v_four CENTERED, 155 sy-vline,
    156(16) v_str1 CENTERED,
    172 sy-vline,
    173(16) 'Already Overdue'(018) CENTERED,
    189 sy-vline,
    206 sy-vline.
    format color off.
    WRITE : /1(206) sy-uline.
    ENDFORM. " header1
    The below link will give Tables & Relations.
    http://www.erpgenie.com/abap/tables.htm
    http://goldenink.com/abap/files_in_sap.html
    http://abap4.tripod.com/SAP_Tables.html
    http://www.geocities.com/sapcircle/Relations.pdf
    regards,
    indranil

  • Need standrad program for vendor aging report

    Hi
      Need standrad program for vendor aging report.
    Please reply me only standrad programs.
    Point are sure.
    Regards,
    kumar

    Hi Pankaj
       sorry to say that this is not my required program.
    I need vendor aging report like s_alr_87012178 tc leads to customer aging report.
    Thanks for your effort.
    points are awarded.
    Regards,
    kumar

  • Report for vendor balances

    Hello,
    I need to run a query or transaction to find the vendor opening and closing balances at the beginning and end of the financial years. Is there any standard report that can provide both these amounts? or any transparent  tables that hold them?
    Thanks a lot!

    Hi,
    Go to SAP Menu >Accounting >Accounts Payable >Information System >Reports for Accounts Payable Accounting >Vendor Balances
    Here you can find variety of reports for vendor.
    Thanks,
    Nirav

  • SAP QUERY report for vendor line items

    Hi
    I have created a SAP QUERY report for vendor line items with fields vendor no.,vendor name,amount,company code and period.But there is one line item i donot know from wher system is getting it picked with is not in that vedor account,when i compare with fbl1n.I checked the document number too...the same doc number is twice in my query report.One with correct amount and another with wrong one.How do i chk.Where did i go wrong in creating query.I used logical database KDF.
    Please advise.

    i chked...how do we get the amount displayed in query...it just displays amount no debit credit symbol... i have selected BSEG-DMBTR field but no -/+ sign,how is it done in query,please suggest.

  • I AM DEVELOPING THE Z-REPORT FOR SHELF AGEING MATERIAL

    HI
    USER WANTS Z-REPORT FOR SHELF AGEING MATERIAL WITH STOCK QTY AND STOCK VALUE.
    I WANT TABLE NAME FOR SHELF AGEING MATERIAL REPORT.
    SPECIALLY, FOR DAYS (REMAINING SHELF LIFE PERIOD FOR  MATERIAL IN DYAS)

    Hi,
    Ask the abaper to write an query from the table S032 there you can find the option of last good receipt date and the last goods issue issue date.
    consider the various good mvt in between these dates calcuate the diffence betwee the current date and the last good issue date, so that you can abel to get the stock list that is not moving for more than 60 days,120 days etc
    You can also use MC46, MC50,  MB5M - expiration date list . In case if that does not solve their requirement then you need take logic from client and you need to develop own report
    pherasath

  • Report for Inventory Ageing

    Our client wants a report for Inventory Ageing. (we are not using batch management)
    Use tried to sell Standard report MC46 but they are not convinced with the results.
    The issue is if the material is not consumed for last 399 days but today if some movement is there in that particular material, then the material is not shown as non moving. Actually the material was not at all used for last 399 days.
    In mc.5 report there are key figures like last consumption, last good issue etc but the same problem is there with it.
    We are trying to develop a customised report.
    Please help.
    Thanks in advance.

    Hi,
    The Stock Aging Report displays the description of material that are stocked for n-number of periods at particular inventory locations( may be trading plant or manufacturing Plant). The details, which are displayed, are about the aging period for the selected items.
    There are reports and T code are
    MC.A ,
    MC.9,
    MM5B,
    MMBE,
    MB5M,
    MC50 - Dead Stock ,
    MC46 - Slow-moving items,
    If the above reports not meet your requirement, you should develop your own ABAP program to meet your specific business requirement.
    This is define in overall stock on value based, suppose a material is received in Feb-month, same material is received in Jan-2007 , DEC-2007  also.The total value of this inventory is say 90 lakhs, ( 30 lakhs of each month) so  system will show inventory aging as below
    stock aging less than 30 days, 90 lakhs
    stock aging more than 30 days but below 60 days 60 lakhs
    stock ageing more than 60 days but below 90 days 30 lakhs
    Assuming that no issue taken place if issue is taken place, it will be deducted by default FIFO method.
    You may have to develop an ABAP report.
    However, look into the path: information system > logistics > inventory managment > material and explore all like MC.9,MC.A,MC.B & MC.C
    Regards,
    Biju K

  • Report for Vendors

    Hello Friends,
    I want one report for vendor for which, Opening Balance, Debit and Credit Totals and Closing balance will be showing.
    Additional Fields will be Reconciliation Account, Posting date from 01.05.2007 to 29.02.2008.
    Our financial period is from January to December and as per IT, it is April to March.
    We run the following reports but it doesnt fulfill our criteria
    F.44 - This report does not fulfill the reporting period which i enter
    S_ALR_87012079 - Transaction Figures: Account Balance - this report does not fulfill the opening balance
    Can anyone help pls?
    Regards,
    Jigar

    hiii Jigar.
    Try S_ALR_87012165 I am sure this will help.
    Regards,
    D RANA

  • Agewise Outstanding Report for Vendors report

    Hi All,
    In SAP, Agewise Outstanding Report for Vendors report coming with Vendor Master Details  along with Address details in the report S_ALR_87012085 - Vendor Payment History with OI Sorted List  which is not really required. Hence we need to remove all un necessary details. We need only a signle line report for each vendor like below.
    Vendor Code Vendor Name  Due - 30  days  Due - 60  days  Due 90 Days  Due  120 days and more than above
    The selection of period option is already available in std SAP. We have to change the output report only. This is rquired for Audit purpose.
    Please help me in the above issue.
    Regards
    Vinu

    Hello,
    The following example I have given is for customers.
    The only difference is in transaction codes. For customer you go to FDI1, for vendor you go to FKI1 (reports).
    For Customer you go to FDI4, for vendor you go to FKI4 for forms.
    Remaining all are the same.
    Hello,
    Go to transaction code FDI4
    Select Form Type RFFRRD20 Line item analysis
    Give your form name and description
    Structure (Two axis) - as defaulted
    Click on Create
    You will have lead column
    Delete the rows 2, 3 and 4
    Double click on column 1
    Enter the customer numbers from 1 to 999999
    First column double click  (A)
    Slelect following values
    Due date analysis 1
    Days for net due date 0 to 30
    Give the short name, medium name and long text for the column.
    Repeat this step in next columns like 31 to 60, 61 to 90, 91 to 120 and 121 to 99999 days etc in other columns and select due date analysis 1. (B,C,D,E)
    Create one more column by way of formula. To create a new column you need to double click on blue line. Put formula add all five columns you have created above. (F = ABCDE)
    You prepare one more column with
    Due date analysis 2 (G)
    Now you prepare one more column add (F+G) = This will be total open items = over due and not due.
    Now go to FDI1 and prepare a report - assign the form created in FDI4 to the report.
    Characteristics you need to select are
    Account Type (Select Account Type as D for customers)
    Currency
    Customer
    Document Type
    Special G/L Ind
    Company Code
    Change the output types and options according to your requirement.
    Refer FDI2 and FDI3 for other standard reports created.
    Refer FDI5 and FDI6 for other standard forms created.
    Save your report and execute.
    Regards,
    Ravi

  • Standard SAP report for vendor hierarchy

    Hi Gurus,
    Does SAP have standard report for vendor hierarchy?  We want to use vendor hierarchy to capture all the expense to a list of vendors and wondering if we can utilize some standard report to see the total supply or we should develop custom reports to handle them?
    Thanks a lot

    Hi,
    Check this link
    http://help.sap.com/saphelp_45b/helpdata/en/12/084635470311d1894a0000e8323352/frameset.htm
    Thanks
    suresh

  • Withholding Tax Report for vendors

    Hello All,
    I want to output a WT ceritificate from the 'Withholding Tax Report for Vendors' ( TX Code:  S_PL0_09000447 and Prog name: RFKQST00 ) . Where in the IMG i can give my customer prog (ZRFKQST00) and its related form  ??
    Can ppl guide me how is the standard prog related to diff country variants ?
    Big Help required. Thanks
    Shehryar Dahar

    Hi Sehryar,
    In SPRO please check Financial Accounting -> Financial Accounting Global settings -> Extended witholding tax ->Reporting -> Assign forms for witholding taxes.
    hope this helps you

  • Report for production aging

    Hi all,
        Is there any standard report for production aging,i have searched forum but not available.
    Regards,
    phani.

    Dear,
    There is no standard report in SAP you need to develop your own custom report.
    Regards,
    R.Brahmankar

  • Report for vendors/customers

    In sap can be get a report for vendors/ customers showing debit column and credit column separately
    what is the transaction code for the report
    thanks in advance
    Joseph David

    Hi,
    I am afraid, such report is not available in SAP. I have not seen such a report. You can get it sign wise + and - for debit / credit or H\S  indicator wise. But column wise debit / credit is not available.
    Pl confirm
    Regards,
    Gov

  • Agewise Reports for Vendors - Transaction Code?

    Agewise reports for Vendors are needed.
    What would be the best way and the Transaction code?

    Hi Bhatia,
    Transaction code F.42 via Information systems > Accounting > Financial accounting > Vendor accounts > Account balances ; you may find the balances and movements for different periods by varying the reporting periods and years.
    Hope this helps.
    Please assign points as way to say thanks

  • I need a code for VENDOR AGEING REPORT

    plz help me i am in urgent need of source code of
    VENDOR AGEING REPORT.
    if any body help me regarding this above report i will be
    great ful to him/her.
    bcoz deadline is today.
    i  need ur urgent help, i treid very much but i failed,
    so hope help from anybody there.

    REPORT  zvender_os NO STANDARD PAGE  HEADING
                                  LINE-SIZE 132
                                  LINE-COUNT 65.
    Tables
    TABLES: bsik,          "open items (A/C: Secondary Index for Customers)
            lfa1,          "customer master
            lfb1,
            rf140,        "temp stru (Work Fields for Corrence(SAPF140*))
            bsak,          "cleared items (A/c Secnd Index for Cust(Clrms))
            skat.
    constants and variables
    TYPE-POOLS: slis.
    DATA: fieldcat             TYPE slis_t_fieldcat_alv,
          fieldcat1             TYPE slis_t_fieldcat_alv,
          fieldcat_ln          TYPE slis_fieldcat_alv,
          layout_in            TYPE slis_layout_alv,
          layout_in1           TYPE slis_layout_alv,
          sortcat              TYPE slis_t_sortinfo_alv,
          sortcat1              TYPE slis_t_sortinfo_alv,
          sortcat_ln           LIKE LINE OF sortcat,
          eventcat1             TYPE slis_t_event,
          eventcat             TYPE slis_t_event,
          eventcat_ln          LIKE LINE OF eventcat,
          col_pos              TYPE i.
    DATA:  targ_month(2)         TYPE n,                        "0001
           targ_year(4)          TYPE n,                        "0001
           targ_mth_abs          TYPE p,                        "0001
           doc_month(2)          TYPE n,                        "0001
           doc_year(4)           TYPE n,                        "0001
           doc_mth_abs           TYPE p,                        "0001
           mth_result            TYPE p,                        "0001
           doc_days              TYPE p,
           targ_days             TYPE p,
           addl_days             TYPE p,
           ext_days              TYPE p,
           v_days(3)             TYPE c,
           v_kkber               LIKE knkk-kkber.
    DATA:
          BEGIN OF inrec OCCURS 1000,                           "0001
            lifnr    LIKE bsik-lifnr,
            belnr    LIKE bsik-belnr,
            gjahr    LIKE bsik-gjahr,
            bldat    LIKE bsik-bldat,
            xblnr    LIKE bsik-xblnr,
            blart    LIKE bsik-blart,
            sgtxt    LIKE bsik-sgtxt,
            shkzg    LIKE bsik-shkzg,
            dmbtr    LIKE bsik-dmbtr,
            zfbdt    LIKE bsik-zfbdt,
            zbd1t    LIKE bsik-zbd1t,
            zbd2t    LIKE bsik-zbd2t,
            zbd3t    LIKE bsik-zbd3t,
            zuonr    LIKE bsik-zuonr,
          END OF inrec.
    DATA:
          BEGIN OF inrect OCCURS 1000,                          "0001
            lifnr    LIKE bsik-lifnr,
            belnr    LIKE bsik-belnr,
            gjahr    LIKE bsik-gjahr,
            bldat    LIKE bsik-bldat,
            xblnr    LIKE bsik-xblnr,
            blart    LIKE bsik-blart,
            sgtxt    LIKE bsik-sgtxt,
            shkzg    LIKE bsik-shkzg,
            dmbtr    LIKE bsik-dmbtr,
            zfbdt    LIKE bsik-zfbdt,
            zbd1t    LIKE bsik-zbd1t,
            zbd2t    LIKE bsik-zbd2t,
            zbd3t    LIKE bsik-zbd3t,
            zuonr    LIKE bsik-zuonr,
          END OF inrect,
          BEGIN OF t_item OCCURS 1000,                          " 0001
            lifnr LIKE bsik-lifnr,
            belnr LIKE bsik-belnr,
            gjahr LIKE bsik-gjahr,
            bldat LIKE bsik-bldat,
            xblnr LIKE bsik-xblnr,
            blart LIKE bsik-blart,
            sgtxt LIKE bsik-sgtxt,
            zfbdt LIKE bsik-zfbdt,
            dmbtr LIKE bsik-dmbtr,
            days(3)  TYPE c,
            zuonr    LIKE bsik-zuonr,
          END OF t_item,
          t_line LIKE t_item OCCURS 1000 WITH HEADER LINE,      " 0001
          BEGIN OF itab OCCURS 1000,
            lifnr    LIKE lfa1-lifnr,
            total    LIKE bsik-dmbtr,
            zfuture  LIKE bsik-dmbtr,
            zcurrent LIKE bsik-dmbtr,
            crbal   LIKE bsik-dmbtr,
            30days   LIKE bsik-dmbtr,
            60days   LIKE bsik-dmbtr,
            90days   LIKE bsik-dmbtr,
            99days   LIKE bsik-dmbtr,
            120days  LIKE bsik-dmbtr,
            180days  LIKE bsik-dmbtr,
            365days  LIKE bsik-dmbtr,
            bzirk    LIKE knvv-bzirk,
            vkbur    LIKE knvv-vkbur,
            vwerk    LIKE knvv-vwerk,
            vkgrp    LIKE knvv-vkgrp,
            klimk    LIKE knkk-klimk,
            cashd    LIKE knkk-cashd,
            grupp    LIKE knkk-grupp,
            erdat    LIKE lfa1-erdat,
            name1    LIKE lfa1-name1,
            name2    LIKE lfa1-name2,
            stras    LIKE lfa1-stras,
            ort01    LIKE lfa1-ort01,
            telf1    LIKE lfa1-telf1,
            psort(10),
            sperr    LIKE lfa1-sperr,
            totsal   LIKE bsik-dmbtr,
            txt50    LIKE skat-txt50,
            gsber    LIKE bsik-gsber,
          END OF itab.
    DATA: sel_tab     TYPE TABLE OF rsparams WITH HEADER LINE,
          p_debit(1) TYPE c,
          p_credit(1) TYPE c.
    DATA: t_variant LIKE disvariant OCCURS 0 WITH HEADER LINE.
    parameters and select-options
    SELECTION-SCREEN BEGIN OF BLOCK blck0 WITH FRAME TITLE text-002.
    PARAMETERS: stida LIKE sy-datum DEFAULT sy-datum OBLIGATORY,
                p_bukrs LIKE t001-bukrs DEFAULT 'PIIL' MEMORY ID buk
    OBLIGATORY.
              P_BUKRS LIKE T001-BUKRS DEFAULT 'CC01' OBLIGATORY.  "0003
    SELECT-OPTIONS: s_lifnr   FOR bsik-lifnr ,
                   s_vkbur FOR knvv-vkbur,
                   s_vkgrp FOR knvv-vkgrp,
                   s_bzirk FOR knvv-bzirk,
                   s_konda FOR knvv-konda,
                   s_kdgrp FOR knvv-kdgrp NO-DISPLAY ,
                   s_kvgr2 FOR knvv-kvgr2 NO-DISPLAY ,
                   s_kkber FOR knkk-kkber NO-DISPLAY ,
                   s_grupp FOR knkk-grupp NO-DISPLAY ,
                   s_ctlpc FOR knkk-ctlpc,
                    s_akont FOR lfb1-akont,
                    s_gsber FOR bsik-gsber.
    PARAMETERS: p_future AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK blck0.
    SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME TITLE text-002.
    PARAMETERS: p_abs RADIOBUTTON GROUP zrad,
                p_due RADIOBUTTON GROUP zrad DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK blck1.
    *SELECTION-SCREEN BEGIN OF BLOCK blck2 WITH FRAME TITLE text-003.
    *PARAMETERS: c_run RADIOBUTTON GROUP zrac DEFAULT 'X',
               c_blk RADIOBUTTON GROUP zrac,
               c_all RADIOBUTTON GROUP zrac.
    *SELECTION-SCREEN END OF BLOCK blck2.
    *SELECTION-SCREEN BEGIN OF BLOCK blck3 WITH FRAME TITLE text-004.
    *PARAMETERS: p_debit AS CHECKBOX DEFAULT 'X' ,
               p_credit AS CHECKBOX DEFAULT 'X' NO-DISPLAY,
    *selection-screen end of block blck3.
    start-of-selection.
    START-OF-SELECTION.
    PERFORM BUILD_EVENTCAT.
      p_debit = 'X'.
      p_credit = 'X'.
      PERFORM get_customer_invoices.
    filter records based on selection criteria
      PERFORM filter_records.
    END-OF-SELECTION.
      PERFORM add_sort_field.
      PERFORM modify_field.
      PERFORM write_report.
    *&      Form  FILTER_RECORDS
          To collect all the required data from DB and store them in
          internal table.
    -->  p1        text
    <--  p2        text
    FORM filter_records.
    delete records based on selection criteria
      LOOP AT itab.
       SELECT vkbur vkgrp vwerk erdat konda kdgrp bzirk kvgr2
         INTO (itab-vkbur, itab-vkgrp, itab-vwerk, knvv-erdat,
               knvv-konda, knvv-kdgrp,itab-bzirk,knvv-kvgr2)
         FROM knvv WHERE lifnr =  itab-lifnr
                   ORDER BY erdat DESCENDING.
    AKS :- Not Required for PI
         CASE itab-vkbur.
           WHEN 'SA1'.
             itab-vkbur = 'SF25'.
           WHEN 'QLD1'.
             itab-vkbur = 'SF23'.
           WHEN 'WA1'.
             itab-vkbur = 'SF26'.
         ENDCASE.
    AKS.
         EXIT.
       ENDSELECT.
       IF itab-vkbur IN s_vkbur AND
          itab-vkgrp IN s_vkgrp AND
          knvv-konda IN s_konda AND
          knvv-kdgrp IN s_kdgrp AND
          itab-bzirk IN s_bzirk AND
          knvv-kvgr2 IN s_kvgr2.
       ELSE.
         DELETE itab.
         CONTINUE.
       ENDIF.
       SELECT SINGLE klimk grupp cashd
         INTO (itab-klimk, itab-grupp, itab-cashd)
         FROM knkk WHERE lifnr =  itab-lifnr
                   AND   kkber IN s_kkber
                   AND   ctlpc IN s_ctlpc
                   AND   grupp IN s_grupp.
       IF SY-SUBRC NE 0.
         DELETE ITAB.
         CONTINUE.
       ENDIF.
        SELECT SINGLE skat~txt50
             INTO (itab-txt50)
             FROM lfb1 INNER JOIN skat
             ON lfb1akont EQ skatsaknr
             WHERE lfb1~lifnr =  itab-lifnr
                       AND   lfb1~akont IN s_akont
                       AND   skat~spras EQ 'EN'.
        IF sy-subrc NE 0.
          DELETE itab.
          CONTINUE.
        ENDIF.
        SELECT SINGLE name1 name2 telf1 erdat stras ort01 sperr
             INTO (itab-name1, itab-name2, itab-telf1,
                     itab-erdat, itab-stras, itab-ort01, itab-sperr )
               FROM lfa1
               WHERE lifnr =  itab-lifnr
        IF sy-subrc NE 0 .
          DELETE itab.
          CONTINUE.
        ENDIF.
    AKS For Filteration of Customer base on Block Area.
       IF c_all NE 'X'.
         IF c_run EQ 'X' AND itab-sperr EQ 'X'.
           DELETE itab.
           CONTINUE.
         ELSE.
           IF c_blk EQ 'X' AND itab-sperr NE 'X'.
             DELETE itab.
             CONTINUE.
           ENDIF.
         ENDIF.
       ENDIF.
        MODIFY itab.
      ENDLOOP.
    ENDFORM.                               " FILTER_RECORDS
    *&      Form  GET_CUSTOMER_INVOICES
          text
    -->  p1        text
    <--  p2        text
    FORM get_customer_invoices.
      DATA:ztotcre  LIKE bsik-dmbtr.
      DATA:ztotsal  LIKE bsik-dmbtr.
      DATA: fsdate LIKE sy-datum.
      DATA: l_perio(4) TYPE c.
      MOVE stida             TO rf140-stida.
      MOVE rf140-stida+4(2)  TO targ_month.
      MOVE rf140-stida+0(4)  TO targ_year.
      MOVE rf140-stida+6(2)  TO targ_days.
      targ_mth_abs           =  ( targ_year * 12 ) + targ_month.
      CALL FUNCTION 'ZGET_PERIOD_FROM_DATE'
        EXPORTING
          i_date  = stida
        IMPORTING
          e_perio = l_perio.
      CONCATENATE l_perio '0401' INTO fsdate.
    select open items.
      IF p_due EQ 'X'.
        SELECT lifnr belnr gjahr bldat xblnr blart sgtxt        " 0001
               shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
               zuonr
          FROM bsik INTO TABLE inrect
          WHERE bukrs =  p_bukrs
          AND   budat LE stida
          AND   lifnr IN s_lifnr
          AND   gsber IN s_gsber
          AND   umskz NE 'T'
          AND   umskz NE 'F'
          AND   umskz NE 'R'
          AND   umskz NE 'P'
          AND   umskz NE 'J'
          AND umskz NE 'L'.
    LOOP AT INREC.
       IF INREC-SHKZG = 'H'.
         INREC-DMBTR  = INREC-DMBTR * -1.
       ENDIF.
       MOVE-CORRESPONDING INREC TO T_ITEM.                     " 0001
       PERFORM COLLECT_INVOICE USING   INREC-lifnr    INREC-DMBTR
                                       INREC-ZFBDT    INREC-ZBD1T
                                       INREC-ZBD2T    INREC-ZBD3T.
       APPEND T_ITEM.
       CLEAR T_ITEM.
    ENDLOOP.
        LOOP AT inrect.
          inrec-lifnr = inrect-lifnr.
          inrec-belnr    = inrect-belnr.
          inrec-gjahr    = inrect-gjahr.
          inrec-bldat    = inrect-bldat.
          inrec-xblnr    = inrect-xblnr.
          inrec-blart    = inrect-blart.
          inrec-sgtxt    = inrect-sgtxt.
          inrec-shkzg    = inrect-shkzg.
          inrec-dmbtr    = inrect-dmbtr.
          CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
            EXPORTING
              date      = inrect-zfbdt
              days      = inrect-zbd1t
              months    = 00
              signum    = '+'
              years     = 00
            IMPORTING
              calc_date = inrec-zfbdt.
          inrec-zbd1t    = inrect-zbd1t.
          inrec-zbd2t    = inrect-zbd2t.
          inrec-zbd3t    = inrect-zbd3t.
          inrec-zuonr    = inrect-zuonr.
          APPEND inrec.
          CLEAR inrec.
        ENDLOOP.
      ELSE.
        SELECT lifnr belnr gjahr bldat xblnr blart sgtxt        " 0001
               shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
               zuonr
          FROM bsik INTO TABLE inrec
          WHERE bukrs =  p_bukrs
          AND   budat LE stida
          AND   lifnr IN s_lifnr
          AND   gsber IN s_gsber
          AND   umskz NE 'T'
          AND   umskz NE 'F'
          AND   umskz NE 'R'
          AND   umskz NE 'P'
          AND   umskz NE 'J'
          AND umskz NE 'L'.
      ENDIF.
      SORT inrec BY lifnr shkzg zfbdt .
      LOOP AT inrec.
        AT NEW lifnr.
    For Customers Credit Balance Transaction to be display in Report
    End of Credit Balance
          ztotcre = 0.
          ztotsal = 0.
        ENDAT.
        IF inrec-shkzg = 'H'.
          inrec-dmbtr = inrec-dmbtr * -1.
          ztotcre = ztotcre + inrec-dmbtr.
        ELSE.
          IF inrec-blart = 'RV'.
            IF inrec-bldat GE fsdate.
              ztotsal = ztotsal + inrec-dmbtr.
            ENDIF.
          ENDIF.
          ztotcre = ztotcre +  inrec-dmbtr.
       endif.
          IF p_debit EQ 'X'.
            IF ztotcre > 0.
              MOVE-CORRESPONDING inrec TO t_item.               " 0001
              PERFORM collect_invoice USING inrec-lifnr    ztotcre
                                          inrec-zfbdt    inrec-zbd1t
                                          inrec-zbd2t    inrec-zbd3t
                                          ztotsal.
              APPEND t_item.
              CLEAR t_item.
              ztotcre = 0.
              ztotsal = 0.
            ENDIF.
          ENDIF.
        ENDIF.
        IF p_credit EQ 'X'.
         AT END OF lifnr.
          IF ztotcre < 0.
            MOVE-CORRESPONDING inrec TO t_item.                 " 0001
            PERFORM collect_invoice USING inrec-lifnr    ztotcre
                                        inrec-zfbdt       inrec-zbd1t
                                        inrec-zbd2t    inrec-zbd3t
                                        ztotsal.
            APPEND t_item.
            CLEAR t_item.
            ztotcre = 0.
            ztotsal = 0.
           APPEND t_item.
           CLEAR t_item.
          ENDIF.
         ENDAT.
        ENDIF.
      ENDLOOP.
    select cleared items
      IF p_due EQ 'X'.
        REFRESH inrect.  CLEAR inrect.
        SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
               shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
               zuonr
          FROM bsak INTO TABLE inrect
          WHERE bukrs =  p_bukrs
          AND   budat LE stida
          AND   augdt >  stida
          AND   lifnr IN s_lifnr
          AND   gsber IN s_gsber
        REFRESH inrec.  CLEAR inrec.
        LOOP AT inrect.
          inrec-lifnr = inrect-lifnr.
          inrec-belnr    = inrect-belnr.
          inrec-gjahr    = inrect-gjahr.
          inrec-bldat    = inrect-bldat.
          inrec-xblnr    = inrect-xblnr.
          inrec-blart    = inrect-blart.
          inrec-sgtxt    = inrect-sgtxt.
          inrec-shkzg    = inrect-shkzg.
          inrec-dmbtr    = inrect-dmbtr.
          CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
            EXPORTING
              date      = inrect-zfbdt
              days      = inrect-zbd1t
              months    = 00
              signum    = '+'
              years     = 00
            IMPORTING
              calc_date = inrec-zfbdt.
          inrec-zbd1t    = inrect-zbd1t.
          inrec-zbd2t    = inrect-zbd2t.
          inrec-zbd3t    = inrect-zbd3t.
          inrec-zuonr    = inrect-zuonr.
          APPEND inrec.
          CLEAR inrec.
        ENDLOOP.
      ELSE.
        REFRESH inrec.  CLEAR inrec.
        SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
               shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
               zuonr
          FROM bsak INTO TABLE inrec
          WHERE bukrs =  p_bukrs
          AND   budat LE stida
          AND   augdt >  stida
          AND   lifnr IN s_lifnr
          AND   gsber IN s_gsber
      ENDIF.
      SORT inrec BY lifnr shkzg zfbdt .
      LOOP AT inrec.
        AT NEW lifnr.
          ztotcre = 0.
          ztotsal = 0.
        ENDAT.
        IF inrec-shkzg = 'H'.
          inrec-dmbtr = inrec-dmbtr * -1.
          ztotcre = ztotcre + inrec-dmbtr.
        ELSE.
          IF inrec-blart = 'RV'.
            IF inrec-bldat GE fsdate.
              ztotsal = ztotsal + inrec-dmbtr.
            ENDIF.
          ENDIF.
          ztotcre = ztotcre +  inrec-dmbtr.
      endif.
          IF p_debit EQ 'X'.
            IF ztotcre > 0.
              MOVE-CORRESPONDING inrec TO t_item.               " 0001
              PERFORM collect_invoice USING inrec-lifnr    ztotcre
                                          inrec-zfbdt    inrec-zbd1t
                                          inrec-zbd2t    inrec-zbd3t
                                          ztotsal.
              APPEND t_item.
              CLEAR t_item.
              ztotcre = 0.
              ztotsal = 0.
            ENDIF.
          ENDIF.
        ENDIF.
        IF p_credit EQ 'X'.
         AT END OF lifnr.
          IF ztotcre < 0.
            MOVE-CORRESPONDING inrec TO t_item.                 " 0001
            PERFORM collect_invoice USING inrec-lifnr    ztotcre
                                        inrec-zfbdt    inrec-zbd1t
                                        inrec-zbd2t    inrec-zbd3t
                                        ztotsal.
            APPEND t_item.
            CLEAR t_item.
            ztotcre = 0.
            ztotsal = 0.
           APPEND t_item.
           CLEAR t_item.
          ENDIF.
         ENDAT.                                                " 0001
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_CUSTOMER_INVOICES
    *&      Form  COLLECT_INVOICE
          text
         -->P_bsik_lifnr  text
         -->P_bsik_DMBTR  text
         -->P_bsik_ZFBDT  text
         -->P_bsik_ZFBDT1  text
         -->P_bsik_ZFBDT2  text
         -->P_bsik_ZFBDT3  text
    FORM collect_invoice USING    pp_lifnr
                                  pp_dmbtr
                                  pp_zfbdt
                                  pp_zbd1t
                                  pp_zbd2t
                                  pp_zbd3t
                                  pp_ztotsal.
      doc_month            =  pp_zfbdt+4(2).
      doc_year             =  pp_zfbdt+0(4).
      doc_mth_abs          =  ( doc_year * 12 ) + doc_month.
      mth_result           =  ( targ_mth_abs    - doc_mth_abs ).
    logic given by Mr. Ashok Singhvi
      doc_days             =  pp_zfbdt+6(2).
      addl_days            =  ( doc_days  -  targ_days ).
      IF addl_days <= 0.
        ADD 1 TO mth_result.
      ENDIF.
      IF NOT pp_zbd3t IS INITIAL.
        MOVE pp_zbd3t TO ext_days.
      ELSEIF NOT pp_zbd2t IS INITIAL.
        MOVE pp_zbd2t TO ext_days.
      ELSEIF NOT pp_zbd1t IS INITIAL.
        MOVE pp_zbd1t TO ext_days.
      ELSE.
        CLEAR ext_days.
      ENDIF.
    CHECK with Andrew whether this is working or not
    if extended payment terms exist, subtract no of mths from mth_result
    IF NOT ext_days IS INITIAL.
       CASE ext_days.
         WHEN 30.
           SUBTRACT 1 FROM mth_result.
         WHEN 60.
           SUBTRACT 2 FROM mth_result.
         WHEN 90.
           SUBTRACT 3 FROM mth_result.
         WHEN 120.
           SUBTRACT 4 FROM mth_result.
       ENDCASE.
    ENDIF.
    change to key date
      IF pp_dmbtr > 0.
        IF p_future = 'X'.                                      " 0001
          IF mth_result      <= 0.
            itab-zcurrent    =  pp_dmbtr.
            t_item-days       = 'CUR'.
          ELSEIF mth_result  =  1.
            itab-30days      =  pp_dmbtr.
            t_item-days       = '30D'.
          ELSEIF mth_result  =  2.
            itab-60days      =  pp_dmbtr.
            t_item-days        = '60D'.
          ELSEIF mth_result  =  3.
            itab-90days      =  pp_dmbtr.
            t_item-days        = '90D'.
          ELSEIF mth_result  >  3 AND mth_result  <=  4 .
            itab-99days      =  pp_dmbtr.
            t_item-days        = '99D'.
          ELSEIF mth_result  >  4 AND mth_result  <=  6 .
            itab-120days      =  pp_dmbtr.
            t_item-days        = '120D'.
          ELSEIF mth_result  >  6 AND mth_result  <=  12 .
            itab-180days      =  pp_dmbtr.
            t_item-days        = '180D'.
          ELSEIF mth_result  >  12 .
            itab-365days      =  pp_dmbtr.
            t_item-days        = '365D'.
          ENDIF.
        ELSE.
          IF mth_result      < 0.
            itab-zfuture     =  pp_dmbtr.
            t_item-days       = 'FUT'.
          ELSEIF mth_result  = 0.
            itab-zcurrent = pp_dmbtr.
            t_item-days       = 'CUR'.
          ELSEIF mth_result  =  1.
            itab-30days      =  pp_dmbtr.
            t_item-days       = '30D'.
          ELSEIF mth_result  =  2.
            itab-60days      =  pp_dmbtr.
            t_item-days       = '60D'.
          ELSEIF mth_result  =  3.
            itab-90days      =  pp_dmbtr.
            t_item-days       = '90D'.
          ELSEIF mth_result  >  3 AND mth_result  <=  4 .
            itab-99days      =  pp_dmbtr.
            t_item-days        = '99D'.
          ELSEIF mth_result  >  4 AND mth_result  <=  6 .
            itab-120days      =  pp_dmbtr.
            t_item-days        = '120D'.
          ELSEIF mth_result  >  6 AND mth_result  <=  12 .
            itab-180days      =  pp_dmbtr.
            t_item-days        = '180D'.
          ELSEIF mth_result  >  12 .
            itab-365days      =  pp_dmbtr.
            t_item-days        = '365D'.
          ENDIF.
        ENDIF.                                                  " 0001
        itab-crbal         = 0.
        itab-total         = pp_dmbtr.
      ELSE.
        IF p_future = 'X'.                                      " 0001
          IF mth_result      <= 0.
            itab-zcurrent    =  pp_dmbtr.
            t_item-days       = 'CUR'.
          ELSEIF mth_result  =  1.
            itab-30days      =  pp_dmbtr.
            t_item-days       = '30D'.
          ELSEIF mth_result  =  2.
            itab-60days      =  pp_dmbtr.
            t_item-days        = '60D'.
          ELSEIF mth_result  =  3.
            itab-90days      =  pp_dmbtr.
            t_item-days        = '90D'.
          ELSEIF mth_result  >  3 AND mth_result  <=  4 .
            itab-99days      =  pp_dmbtr.
            t_item-days        = '99D'.
          ELSEIF mth_result  >  4 AND mth_result  <=  6 .
            itab-120days      =  pp_dmbtr.
            t_item-days        = '120D'.
          ELSEIF mth_result  >  6 AND mth_result  <=  12 .
            itab-180days      =  pp_dmbtr.
            t_item-days        = '180D'.
          ELSEIF mth_result  >  12 .
            itab-365days      =  pp_dmbtr.
            t_item-days        = '365D'.
          ENDIF.
        ELSE.
          IF mth_result      < 0.
            itab-zfuture     =  pp_dmbtr.
            t_item-days       = 'FUT'.
          ELSEIF mth_result  = 0.
            itab-zcurrent = pp_dmbtr.
            t_item-days       = 'CUR'.
          ELSEIF mth_result  =  1.
            itab-30days      =  pp_dmbtr.
            t_item-days       = '30D'.
          ELSEIF mth_result  =  2.
            itab-60days      =  pp_dmbtr.
            t_item-days       = '60D'.
          ELSEIF mth_result  =  3.
            itab-90days      =  pp_dmbtr.
            t_item-days       = '90D'.
          ELSEIF mth_result  >  3 AND mth_result  <=  4 .
            itab-99days      =  pp_dmbtr.
            t_item-days        = '99D'.
          ELSEIF mth_result  >  4 AND mth_result  <=  6 .
            itab-120days      =  pp_dmbtr.
            t_item-days        = '120D'.
          ELSEIF mth_result  >  6 AND mth_result  <=  12 .
            itab-180days      =  pp_dmbtr.
            t_item-days        = '180D'.
          ELSEIF mth_result  >  12 .
            itab-365days      =  pp_dmbtr.
            t_item-days        = '365D'.
          ENDIF.
        ENDIF.                                                  " 0001
        itab-total         = pp_dmbtr.
        itab-crbal         = 0.
      ENDIF.
      itab-lifnr         = pp_lifnr.
      itab-totsal        = pp_ztotsal.
      COLLECT itab.
      CLEAR itab.
    ENDFORM.                    " COLLECT_INVOICE
    *&      Form  ADD_SORT_FIELD
          text
    -->  p1        text
    <--  p2        text
    FORM add_sort_field.
      DATA: l_amount(9)  TYPE n.
      IF p_future = 'X'.
        LOOP AT itab.
          l_amount = 999999999.
          IF     itab-365days > 0.
            l_amount = l_amount - itab-365days.
            CONCATENATE 'A' l_amount INTO itab-psort.
          ELSEIF     itab-180days > 0.
            l_amount = l_amount - itab-180days.
            CONCATENATE 'B' l_amount INTO itab-psort.
          ELSEIF     itab-120days > 0.
            l_amount = l_amount - itab-120days.
            CONCATENATE 'C' l_amount INTO itab-psort.
          ELSEIF     itab-99days > 0.
            l_amount = l_amount - itab-99days.
            CONCATENATE 'D' l_amount INTO itab-psort.
          ELSEIF itab-90days > 0.
            l_amount = l_amount - itab-90days.
            CONCATENATE 'E' l_amount INTO itab-psort.
          ELSEIF itab-60days > 0.
            l_amount = l_amount - itab-60days.
            CONCATENATE 'F' l_amount INTO itab-psort.
          ELSEIF itab-30days > 0.
            l_amount = l_amount - itab-30days.
            CONCATENATE 'G' l_amount INTO itab-psort.
          ELSEIF itab-zcurrent > 0.
            l_amount = l_amount - itab-zcurrent.
            CONCATENATE 'H' l_amount INTO itab-psort.
        ELSEif itab-zfuture > 0.
          L_AMOUNT = L_AMOUNT - ITAB-zfuture.
          CONCATENATE 'F' L_AMOUNT INTO ITAB-PSORT.
          ELSE.
            l_amount = ABS( itab-total ).
            CONCATENATE 'I' l_amount INTO itab-psort.
          ENDIF.
          MODIFY itab.
        ENDLOOP.
      ELSE.
        LOOP AT itab.
          l_amount = 999999999.
          IF     itab-365days > 0.
            l_amount = l_amount - itab-365days.
            CONCATENATE 'A' l_amount INTO itab-psort.
          ELSEIF     itab-180days > 0.
            l_amount = l_amount - itab-180days.
            CONCATENATE 'B' l_amount INTO itab-psort.
          ELSEIF     itab-120days > 0.
            l_amount = l_amount - itab-120days.
            CONCATENATE 'C' l_amount INTO itab-psort.
          ELSEIF     itab-99days > 0.
            l_amount = l_amount - itab-99days.
            CONCATENATE 'D' l_amount INTO itab-psort.
          ELSEIF itab-90days > 0.
            l_amount = l_amount - itab-90days.
            CONCATENATE 'E' l_amount INTO itab-psort.
          ELSEIF itab-60days > 0.
            l_amount = l_amount - itab-60days.
            CONCATENATE 'F' l_amount INTO itab-psort.
          ELSEIF itab-30days > 0.
            l_amount = l_amount - itab-30days.
            CONCATENATE 'G' l_amount INTO itab-psort.
          ELSEIF itab-zcurrent > 0.
            l_amount = l_amount - itab-zcurrent.
            CONCATENATE 'H' l_amount INTO itab-psort.
          ELSEIF itab-zfuture > 0.
            l_amount = l_amount - itab-zfuture.
            CONCATENATE 'I' l_amount INTO itab-psort.
          ELSE.
            l_amount = ABS( itab-total ).
            CONCATENATE 'J' l_amount INTO itab-psort.
          ENDIF.
          MODIFY itab.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " ADD_SORT_FIELD
    *&      Form  WRITE_REPORT
          text
    -->  p1        text
    <--  p2        text
    FORM write_report.
      PERFORM build_fieldcat.
      PERFORM build_sortcat.
      PERFORM build_eventcat.
      PERFORM build_layout.
      PERFORM start_list_viewer.
    ENDFORM.                    " WRITE_REPORT
    *&      Form  BUILD_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat.
    lifnr
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
      fieldcat_ln-ref_tabname        = 'lfa1'.
      fieldcat_ln-fieldname          = 'LIFNR'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      APPEND fieldcat_ln TO fieldcat.
    Name1
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
      fieldcat_ln-ref_tabname        = 'lfa1'.
      fieldcat_ln-fieldname          = 'NAME1'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-seltext_l          = 'Name'.
      APPEND fieldcat_ln TO fieldcat.
    City Details
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
      fieldcat_ln-ref_tabname        = 'lfa1'.
      fieldcat_ln-fieldname          = 'ORT01'.
      fieldcat_ln-seltext_l          = 'City'.
      fieldcat_ln-col_pos            = col_pos.
      APPEND fieldcat_ln TO fieldcat.
    Credit Limit
    ADD 1 TO col_pos.
    CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'KNKK'.
    fieldcat_ln-fieldname          = 'KLIMK'.
    fieldcat_ln-col_pos            = col_pos.
    fieldcat_ln-emphasize = 'C41'.
    APPEND fieldcat_ln TO fieldcat.
    ADD 1 TO col_pos.
    CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
    fieldcat_ln-fieldname          = 'CRBAL'.
    fieldcat_ln-col_pos            = col_pos.
    fieldcat_ln-emphasize = 'C41'.
    fieldcat_ln-do_sum             = 'X'.
    fieldcat_ln-seltext_l          = 'Cr. Bal.'.
    fieldcat_ln-seltext_m          = 'Cr. Bal.'.
    fieldcat_ln-seltext_s          = 'Cr. Bal.'.
    APPEND fieldcat_ln TO fieldcat.
    Total Amount
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
      fieldcat_ln-fieldname          = 'TOTAL'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-seltext_l          = 'Out.St.Amt.'.
      fieldcat_ln-seltext_m          = 'Out.St.Amt.'.
      fieldcat_ln-seltext_s          = 'Out.St.Amt.'.
      fieldcat_ln-ref_tabname        = 'zbsik'.
      fieldcat_ln-ref_fieldname      = 'ZDMBTR'.
      APPEND fieldcat_ln TO fieldcat.
      IF p_future NE 'X'.
    Future
        ADD 1 TO col_pos.
        CLEAR fieldcat_ln.
       fieldcat_ln-ref_tabname        = 'bsik'.
       fieldcat_ln-ref_fieldname      = 'DMBTR'.
        fieldcat_ln-fieldname          = 'ZFUTURE'.
        fieldcat_ln-col_pos            = col_pos.
        fieldcat_ln-do_sum             = 'X'.
        fieldcat_ln-hotspot            = 'X'.
        fieldcat_ln-emphasize = 'C41'.
        fieldcat_ln-seltext_l          = 'Future Due'.
        fieldcat_ln-seltext_m          = 'Future Due'.
        fieldcat_ln-seltext_s          = 'Future Due'.
        APPEND fieldcat_ln TO fieldcat.
      ENDIF.
    Current
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = 'ZCURRENT'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = 'Normal Due'.
      fieldcat_ln-seltext_m          = 'Normal Due'.
      fieldcat_ln-seltext_s          = 'Normal Due'.
      APPEND fieldcat_ln TO fieldcat.
    30 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '30DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '0-30 Days'.
      fieldcat_ln-seltext_m          = '0-30 Days'.
      fieldcat_ln-seltext_s          = '0-30 Days'.
      APPEND fieldcat_ln TO fieldcat.
    60 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '60DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '31-60 Days'.
      fieldcat_ln-seltext_m          = '31-60 Days'.
      fieldcat_ln-seltext_s          = '31-60 Days'.
      APPEND fieldcat_ln TO fieldcat.
    90 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '90DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '61-90 Days'.
      fieldcat_ln-seltext_m          = '61-90 Days'.
      fieldcat_ln-seltext_s          = '61-90 Days'.
      APPEND fieldcat_ln TO fieldcat.
    99 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '99DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '91-120 Days'.
      fieldcat_ln-seltext_m          = '91-120 Days'.
      fieldcat_ln-seltext_s          = '91-120 Days'.
      APPEND fieldcat_ln TO fieldcat.
    *120Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '120DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '121-180 Days'.
      fieldcat_ln-seltext_m          = '121-180 Days'.
      fieldcat_ln-seltext_s          = '121-180 Days'.
      APPEND fieldcat_ln TO fieldcat.
    *180 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '180DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '181-365 Days'.
      fieldcat_ln-seltext_m          = '181-365 Days'.
      fieldcat_ln-seltext_s          = '181-365 Days'.
      APPEND fieldcat_ln TO fieldcat.
    *365 Days
      ADD 1 TO col_pos.
      CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'bsik'.
    fieldcat_ln-ref_fieldname      = 'DMBTR'.
      fieldcat_ln-fieldname          = '365DAYS'.
      fieldcat_ln-col_pos            = col_pos.
      fieldcat_ln-do_sum             = 'X'.
      fieldcat_ln-hotspot            = 'X'.
      fieldcat_ln-emphasize = 'C41'.
      fieldcat_ln-seltext_l          = '>365 Days'.
      fieldcat_ln-seltext_m          = '>365 Days'.
      fieldcat_ln-seltext_s          = '>365 Days'.
      APPEND fieldcat_ln TO fieldcat.
    Last Payment Date
    ADD 1 TO col_pos.
    CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'KNKK'.
    fieldcat_ln-fieldname          = 'CASHD'.
    fieldcat_ln-col_pos            = col_pos.
    APPEND fieldcat_ln TO fieldcat.
    Street Name
    ADD 1 TO COL_POS.
    CLEAR FIELDCAT_LN.
    FIELDCAT_LN-REF_TABNAME        = 'lfa1'.
    FIELDCAT_LN-FIELDNAME          = 'STRAS'.
    FIELDCAT_LN-COL_POS            = COL_POS.
    APPEND FIELDCAT_LN TO FIELDCAT.
    Telephone
    ADD 1 TO COL_POS.
    CLEAR FIELDCAT_LN.
    FIELDCAT_LN-REF_TABNAME        = 'lfa1'.
    FIELDCAT_LN-FIELDNAME          = 'TELF1'.
    FIELDCAT_LN-COL_POS            = COL_POS.
    APPEND FIELDCAT_LN TO FIELDCAT.
    Credit Group
    ADD 1 TO COL_POS.
    CLEAR FIELDCAT_LN.
    FIELDCAT_LN-REF_TABNAME        = 'KNKK'.
    FIELDCAT_LN-FIELDNAME          = 'GRUPP'.
    FIELDCAT_LN-COL_POS            = COL_POS.
    APPEND FIELDCAT_LN TO FIELDCAT.
    *Sales District
    ADD 1 TO col_pos.
    CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'KNVV'.
    fieldcat_ln-fieldname          = 'BZIRK'.
    fieldcat_ln-col_pos            = col_pos.
    fieldcat_ln-seltext_l          = 'S_Distt'.
    fieldcat_ln-seltext_m          = 'S_Distt'.
    fieldcat_ln-seltext_s          = 'S_Distt'.
    APPEND fieldcat_ln TO fieldcat.
    Sales Office
    ADD 1 TO col_pos.
    CLEAR fieldcat_ln.
    fieldcat_ln-ref_tabname        = 'KNVV'.
    fieldcat_ln-fieldname          = 'VKBUR'.
    fieldcat_ln-col_pos            = col_pos.
    fieldcat_ln-seltext_l          = 'S_Off'.
    fieldcat_ln-seltext_m          = 'S_Off'.
    fieldcat_ln-seltext_s          = 'S_Off'.
    APPEND fieldcat_ln TO fieldcat.
    Cust Creat Date
    ADD 1 TO COL_POS.
    CLEAR FIELDCAT_LN.
    FIELDCAT_LN-REF_TABNAME        = 'lfa1'.
    FIELDCAT_LN-FIELDNAME          = 'ERDAT'.
    FIELDCAT_LN-COL_POS            = COL_POS.
    APPEND FIELDCAT_LN TO FIELDCAT.

Maybe you are looking for

  • Output device-adobe doc services

    Hi , i need an output device to be configured for adobe document services in SAP ECC 6.0. this output device is used for adobe forms. tell me which printer need to be configured in SAPD transaction. with regards, ravi valluri.

  • How can I unlock my sons ipod he changed the password and can't remeber what it is

    How can I unlock my sons ipod touch he changed his password and can't remember what it is?

  • PS4 will NOT play 3D Movies

    It was recently confirmed that the PS4 will not be compatible with 3D Blu-Ray movies at launch but COULD be a part of a future update. It will do 3D games but not movies. That is the second huge mistake Sony has made with the PS4.

  • Touch pen tool appearance

    How can I get the touch pen tool to appear on a file if I'm opening an image.  It only appears now when I open a blank work space.

  • Join two text field together.

    I am making a form that supervisors will use to send to me when new employees are hired.  I want to be able to take the two field that I have "First Name" and "Last Name" and join them together.  The only thing is I only want the first letter of thie