Table of Contents:



REPORT ZFVENDORLIST LINE-SIZE 125
       NO STANDARD PAGE HEADING.
*@----------------------------------------------------------------------
*@ Program id    : ZFVendorList
*@
*@ Program Desc  : This Report lists all Vendor Numbers and Names.
*@                 If all Records for that vendor were marked
*@                 for deletion, show only one record.
*@
*@ Transaction Code - ZFVENDORLIST
*@ Input files   : ID - none
*@ Output files  : ID - none
*@
*@ Tables Updated: Table - none
*@
*@
*@ Author      : IJADALOW            LABK933570
*@ Date        : September 11, 2002
*@ Requested by: Christina Tam, Ann Bailey
*@----------------------------------------------------------------------
*@ LABK933584 IJADALOW        September 12, 2002
*@            - Add Selection Parameter for Payment Terms
*@ LABK934757 IJADALOW        April 14, 2003
*@            - Add Columns: Account Memo and Payment Method
*@            - Allow the user to download report to Excel
*@----------------------------------------------------------------------
data: begin of itab occurs 100,
        lifnr like lfb1-lifnr,
        name1 like lfa1-name1,
        bukrs like lfb1-bukrs,
        loevm like lfb1-loevm,
        zterm like lfb1-zterm,
*{LABK934757
        kverm like lfb1-kverm,    "Account Memo
        zwels like lfb1-zwels,    "Payment Method
*}LABK934757
      end of itab.

data: wa_itab like line of itab.
data: wa_itab2 like line of itab.

*{LABK934757
DATA: BEGIN OF it_title OCCURS 0,
        title(15)   TYPE c,
      END OF it_title.
*}LABK934757

INCLUDE ZSMASTER.
tables: lfb1.

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
  SELECT-OPTIONS: s_vendor for lfb1-lifnr.
  SELECT-OPTIONS: s_compny FOR lfb1-bukrs.
  SELECT-OPTIONS: s_terms FOR lfb1-zterm.               "LABK933584
SELECTION-SCREEN END OF BLOCK 1.
*{LABK934757
SELECTION-SCREEN BEGIN OF BLOCK dload WITH FRAME TITLE text-002.
  PARAMETERS: rb_down as checkbox DEFAULT 'X'.
  PARAMETERS: filename LIKE rlgrap-filename
                       DEFAULT 'H:\Data\VendTerm.xls'.
SELECTION-SCREEN END OF BLOCK dload.
*}LABK934757
*/---------------------------------------------------------\*
TOP-OF-PAGE.
  MAC_GENERIC_REPORT_HEADER sy-title '' MAC_C_TRUE MAC_C_FALSE.

start-of-selection.

  select lfb1~lifnr lfa1~name1 lfb1~bukrs lfb1~loevm lfb1~zterm
         lfb1~kverm lfb1~zwels                          "LABK934757
    into table itab
    from lfb1 join lfa1
    on lfb1~lifnr = lfa1~lifnr
    where lfb1~lifnr in s_vendor
      and lfb1~bukrs in s_compny
      and lfb1~zterm in s_terms.                        "LABK933584

  perform display_data.

*{LABK934757
  IF rb_down = 'X'.
     PERFORM download_to_excel.
  ENDIF.
*}LABK934757

*----------------------------------------------------------

form display_data.

  data: del_flag type c,
        first_time type c.

  sort itab by lifnr bukrs.

  FORMAT COLOR COL_heading INTENSIFIED OFF.
  uline.
  write: /01 SY-VLINE NO-GAP,
          03 'Vendor No',
          13 SY-VLINE NO-GAP,
          14 'Vendor Name',
          49 SY-VLINE NO-GAP,
          50 'Company Code',
          62 SY-VLINE NO-GAP,
          63 'Del. Flag',
          72 SY-VLINE NO-GAP,
          73 'Payt Terms',
          83 SY-VLINE NO-GAP,
*{LABK934757
          84 'Account Memo',
          114 SY-VLINE NO-GAP,
          115 'Pay Method',
          125 SY-VLINE NO-GAP.
*}LABK934757
  uline.

  FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
  loop at itab into wa_itab.
    at new lifnr.
      del_flag = 'X'.
      first_time = 'X'.
      loop at itab into wa_itab2 where lifnr = wa_itab-lifnr.
        if wa_itab2-loevm = ' '.

          clear del_flag.
        else.

        endif.
      endloop.
    endat.

    if del_flag = 'X' and first_time = 'X'.
      clear wa_itab-bukrs.
      perform display_line.
      first_time = ' '.
    endif.

    if del_flag = ' ' and wa_itab-loevm = ' '.
      perform display_line.
    endif.

  endloop.
  uline.
endform.

form display_line.

    write: /01 SY-VLINE NO-GAP,
          03 wa_itab-lifnr,
          13 SY-VLINE NO-GAP,
          14 wa_itab-name1,
          49 SY-VLINE NO-GAP,
          50 wa_itab-bukrs,
          62 SY-VLINE NO-GAP,
          63 wa_itab-loevm,
          72 SY-VLINE NO-GAP,
          73 wa_itab-zterm,
          83 SY-VLINE NO-GAP,
*{LABK934757
          84 wa_itab-kverm,
         114 SY-VLINE NO-GAP,
         115 wa_itab-zwels,
         125 SY-VLINE NO-GAP.
*}LABK934757
endform.

*{LABK934757
*&---------------------------------------------------------------------*
*&      Form  DOWNLOAD_TO_EXCEL
*&---------------------------------------------------------------------*
FORM download_to_excel.

  DEFINE lmac_append_title.
    it_title-title = &1.
    append it_title.
  END-OF-DEFINITION.

  REFRESH it_title.

  lmac_append_title: 'Vendor No', 'Vendor Name', 'Company Code',
                     'Del. Flag', 'Payt Terms', 'Account Memo',
                     'Pay Method'.

  mac_ws_download_titled_itab filename itab it_title.
  IF sy-subrc = 0.
    MESSAGE s001(zz) WITH 'Report has been downloaded to '
                           filename.
  ELSE.
    MESSAGE s001(zz) WITH 'Unable to download to ' filename.
  ENDIF.

ENDFORM.                    " DOWNLOAD_TO_EXCEL
*}LABK934757