Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need sample pgm to delete entries

Former Member
0 Likes
510

Hi experts ,

iam some prblm with transaction data .. so i want to delete these entries fro the table . what my question is ??

A program should take input from flat file consisting of same structure as of table XYZ table . NOW IT HAS TO DELETE ALL THE FLAT FILE ENTRIES FROM THE XYZ TABLE USING gUI_UPLOAD fUNCTION Module ??

Regs ,

Narayana Murthy

Hi experts ,

iam some prblm with transaction data .. so i want to delete these entries fro the table . what my question is ??

A program should take input from flat file consisting of same structure as of table XYZ table . NOW IT HAS TO DELETE ALL THE FLAT FILE ENTRIES FROM THE XYZ TABLE USING gUI_UPLOAD fUNCTION Module ??

Regs ,

Narayana Murthy

2 REPLIES 2
Read only

Former Member
0 Likes
472

Hi

Do u want to delete all the data after uploading???. If u want to upload u can tryu this way

you can use this FM

ALSM_EXCEL_TO_INTERNAL_TABLE 

to upload data

TYPE-POOLS: truxs.
 
DATA: i_text_data       TYPE truxs_t_text_data,
      v_filename_string TYPE string.
 
DATA: BEGIN OF itab OCCURS 0,
        Name(30),
        Phone(15),
        Fax(500).
DATA: END OF itab.
 
PARAMETERS: p_file LIKE rlgrap-filename.
 
START-OF-SELECTION.
 
  v_filename_string = p_file.
 
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                      = v_filename_string
      filetype                      = 'ASC'
      has_field_separator           = 'X'
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
      dat_mode                      = ''
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      data_tab                      = i_text_data
    EXCEPTIONS
      file_open_error               = 1
      file_read_error               = 2
      no_batch                      = 3
      gui_refuse_filetransfer       = 4
      invalid_type                  = 5
      no_authority                  = 6
      unknown_error                 = 7
      bad_data_format               = 8
      header_not_allowed            = 9
      separator_not_allowed         = 10
      header_too_long               = 11
      unknown_dp_error              = 12
      access_denied                 = 13
      dp_out_of_memory              = 14
      disk_full                     = 15
      dp_timeout                    = 16
      OTHERS                        = 17.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
 
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_field_seperator          = 'X'
*     I_LINE_HEADER              =
      i_tab_raw_data             = i_text_data
      i_filename                 = p_file
    TABLES
      i_tab_converted_data       = itab
    EXCEPTIONS
      conversion_failed          = 1
      OTHERS                     = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

reward all helpfull answers

Regards

Pavan

Read only

Former Member
0 Likes
472

Hi ,

Here is a sample one n u can make changes to it as u like it

here the file should be of comma seperated.

REPORT ZDELETEPRINTFILE line-size 150.

tables : zprintfiletab.

data:begin of t_printfile occurs 0,

sno(4) type n,

title(70) type c,

contents(70) type c,

printfileno(3) type n,

end of t_printfile.

data : begin of itab occurs 0 ,

string(225) type c,

end of itab.

DATA FILENAME LIKE RLGRAP-FILENAME.

*File should be comma seperated type

FILENAME = 'C:\testing4.csv'.

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_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at itab.

clear t_printfile.

split itab at ',' into t_printfile-title

t_printfile-contents

t_printfile-printfileno.

move sy-tabix to t_printfile-sno.

append t_printfile.

endloop.

sort t_printfile by printfileno.

  • zprintfiletab is a databse table

loop at t_printfile.

delete zprintfiletab from t_printfile .

endloop.