Here is a simple example of deleting field from database using upload option.
Upload the filed with data to be deleted from the database.
step 1. create excel file.
step 2. upload excel file.
step 3. create internal table.
step 4. use delete command referring internal table.
TYPES:BEGIN OF ty_upload,
matnr TYPE mara-matnr,END OF ty_upload.
DATA:
lt_upload TYPE TABLE OF ty_upload,
wa_ls_upload TYPE ty_upload,
lv_filename TYPE string,
lv_path TYPE rlgrap-filename,
lt_data TYPE truxs_t_text_data.
PARAMETERS:p_fpath TYPE ibipparms-path.
*------to provide search help to get the file path-----*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fpath.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FPATH'
IMPORTING
file_name = p_fpath.
START-OF-SELECTION.
*---------upload excel file--------*
lv_path = p_fpath.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = lt_data
i_filename = lv_path
TABLES
i_tab_converted_data = lt_upload[]
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.
IF lt_upload[] IS NOT INITIAL.
LOOP AT lt_upload INTO wa_ls_upload.
DELETE FROM mara WHERE matnr = wa_ls_upload-matnr.
if sy-subrc = 0.
WRITE: /'Invoice no.', wa_ls_upload-matnr,'Delete succesfully'.
else.
WRITE: /'Invoice no.', wa_ls_upload-matnr,'FAIL !!!'.
endif.
CLEAR:wa_ls_upload.
ENDLOOP.
ENDIF.
No comments:
Post a Comment