Make your own free website on Tripod.com

Table of Contents:



REPORT zfequipment_code .
*@----------------------------------------------------------------------
*@ Program id    :  zfequipment_code
*@
*@ Program Desc  : This program updates the zequipment_code database
*@                 table from a data delimited file...
*@
*@ Transaction Code - none
*@ Input files   : ID - none
*@ Output files  : ID - none
*@
*@ Tables Updated: Table - none
*@
*@
*@ Author      : IJADALOW - LABK934440
*@ Date        : Feb. 14, 2003
*@ Requested by: Christina Tam
*@----------------------------------------------------------------------
*@----------------------------------------------------------------------
INCLUDE zsmaster.

DATA: BEGIN OF itab OCCURS 0.
DATA:   mandt(3) TYPE c,
        ecode(5) TYPE c,
        edesc(40) TYPE c,
        etype(5) TYPE c,
        esubtype(5) TYPE c,
        rep_cost(17) TYPE c,
        t_reven(17) TYPE c,
        waers(5) TYPE c,
        serv_line_name(20) TYPE c.
DATA: END OF itab.


DATA: BEGIN OF itab2 OCCURS 0.
        INCLUDE STRUCTURE zequipment_code.
DATA: END OF itab2.

data: l_dec type i,
      first_rec value 'X'.

SELECTION-SCREEN BEGIN OF BLOCK dload WITH FRAME TITLE text-101.
PARAMETERS: filename LIKE rlgrap-filename
                         DEFAULT 'H:\SAPworkdir\class.xls'.
SELECTION-SCREEN END OF BLOCK dload.

SELECTION-SCREEN BEGIN OF BLOCK upd WITH FRAME TITLE text-102.
SELECTION-SCREEN: SKIP.
PARAMETERS: update RADIOBUTTON GROUP rad1 DEFAULT 'X'.
PARAMETERS: replace RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK upd.


START-OF-SELECTION.

  CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
            filename            = filename
            filetype            = 'DAT'
       TABLES
            data_tab            = itab
       EXCEPTIONS
            conversion_error    = 1
            file_open_error     = 2
            file_read_error     = 3
            invalid_table_width = 4
            invalid_type        = 5
            no_batch            = 6
            unknown_error       = 7
            OTHERS              = 8.

  CASE sy-subrc.
    WHEN 0.

    WHEN 1.
      WRITE / 'Conversion Error while reading file'.
    WHEN 2.
      WRITE: / 'Error in opening the file'.
    WHEN 3.
      WRITE / 'Error in reading the file'.
    WHEN OTHERS.
      WRITE / 'Error occurred while uploading the file.'.
  ENDCASE.

  LOOP AT itab.
    TRANSLATE itab-rep_cost USING '" '.
    TRANSLATE itab-t_reven USING '" '.
    TRANSLATE itab-rep_cost USING ', '.
    TRANSLATE itab-t_reven USING ', '.
    CONDENSE: itab-rep_cost NO-GAPS,
              itab-t_reven NO-GAPS.

   if itab-rep_cost na '0123456789'.
     write: / 'Skipped row ', sy-tabix.
     continue.
   endif.
    clear first_rec.
    MOVE-CORRESPONDING itab TO itab2.
    APPEND itab2.
  ENDLOOP.

  IF replace = 'X'.
    DELETE FROM zequipment_code CLIENT SPECIFIED WHERE mandt = '500'.
  ENDIF.

  MODIFY zequipment_code FROM TABLE itab2.

  IF sy-subrc = 0.
    WRITE: / 'Table was updated successfully.'.
  ELSE.
    WRITE: / 'Table was not updated successfully.'.
  ENDIF.