Skip to Content
-1
Jan 28, 2019 at 12:48 PM

How to delete,update and modify for custom table from radio button?

412 Views

REPORT ZDEMO12.
tables : zabhi1.
type-pools : truxs,slis.

* Selection screen

PARAMETERS : p_file type rlgrap-filename DEFAULT 'c:\users\abhishek.jagtap\downloads\export_vbap.TXT'.
PARAMETERS: p_update RADIOBUTTON GROUP g1 DEFAULT 'X',
p_delete RADIOBUTTON GROUP g1,
p_modify RADIOBUTTON GROUP g1.
*parameters :
types : begin of ty_zabhi1,
vbeln type zabhi1-vbeln,
posnr type zabhi1-posnr,
matnr type zabhi1-matnr,
matkl type zabhi1-matkl,
makt type zabhi1-makt,
pstyv type zabhi1-pstyv,
kunnr type zabhi1-kunnr,
land1 type zabhi1-land1,
name1 TYPE zabhi1-name1,
ort01 type zabhi1-ort01,
end of ty_zabhi1.

data : it_zabhi1 type STANDARD TABLE OF ty_zabhi1,
wa_zabhi1 type ty_zabhi1,
wa_zabhi type zabhi1
.

data : it_type TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
* STATIC = ' '
* MASK = ' '
* FILEOPERATION = 'R'
* PATH =
CHANGING
file_name = p_file.

* LOCATION_FLAG = 'P'
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

START-OF-SELECTION.
* Uploading the data in the file into internal table

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
I_FILENAME = p_file
tables
i_tab_converted_data = it_zabhi1[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

end-of-SELECTION.



* Uploading the data into the database table

loop at it_zabhi1 into wa_zabhi1.
wa_zabhi-vbeln = wa_zabhi1-vbeln.
wa_zabhi-posnr = wa_zabhi1-posnr.
wa_zabhi-matnr = wa_zabhi1-matnr.
wa_zabhi-matkl = wa_zabhi1-matkl.
wa_zabhi-makt = wa_zabhi1-makt.
wa_zabhi-pstyv = wa_zabhi1-pstyv.
wa_zabhi-kunnr = wa_zabhi1-kunnr.
wa_zabhi-land1 = wa_zabhi1-land1.
wa_zabhi-name1 = wa_zabhi1-name1.
wa_zabhi-ort01 = wa_zabhi1-ort01.
MODIFY zabhi1 FROM wa_zabhi.
Clear : wa_zabhi , wa_zabhi1.
endloop.



LOOP AT it_zabhi1 INTO wa_zabhi1.
write / wa_zabhi1.
ENDLOOP.