2022 Dec 16 7:26 PM
I had written the following code and added radio buttons as per the requirement but it is throwing a dump when I run it. Is my radio button coding wrong because before adding the selection screen the report was executing fine.
data : lv_dir type eps2filnam.
lv_dir = '/SCADA'.
types: begin of ty_text,
* text(550),
string type string,
end of ty_text.
data:it_text type table of ty_text with header line.
data : wa type ty_text.
types : begin of ty_final,
plant_name type name1,
datee type datum,
product(20), "TYPE zide_pp_prdct,
inputt(4), "TYPE zide_pp_inp,
outputt(4), "TYPE zide_pp_out,
by_product(4)," TYPE zide_pp_bypr,
end of ty_final.
selection-screen: begin of block b1 with frame title text-001.
parameters: rb1 radiobutton group rb,
rb2 radiobutton group rb.
selection-screen: end of block b1.
*data: it_itab TYPE ty_final,
* wa_itab TYPE ty_final.
data : final type table of ty_final,
wfinal type ty_final.
data : it_files type table of eps2fili,
wa_files type eps2fili.
call function 'EPS2_GET_DIRECTORY_LISTING'
exporting
iv_dir_name = lv_dir
tables
dir_list = it_files
exceptions
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
others = 8.
data : p_file_n type localfile .
read table it_files into wa_files index 1. "reading recent file
*if rb1 = 'X'.
if sy-subrc = 0.
p_file_n = wa_files-name.
endif.
*ELSE.
if rb1 = 'X'.
lv_dir = '/SCADA/SOFTOIL'.
else.
lv_dir = '/SCADA/LAURIC'.
endif.
* CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
* EXPORTING
* iv_dir_name = lv_dir
* tables
* dir_list = it_files
* EXCEPTIONS
* INVALID_EPS_SUBDIR = 1
* SAPGPARAM_FAILED = 2
* BUILD_DIRECTORY_FAILED = 3
* NO_AUTHORIZATION = 4
* READ_DIRECTORY_FAILED = 5
* TOO_MANY_READ_ERRORS = 6
* EMPTY_DIRECTORY_LIST = 7
* OTHERS = 8
* .
** DELETE IT_FILES[] FROM 2.
*
** READ TABLE it_files INTO wa_files INDEX 1. "reading recent file
* IF sy-subrc = 0.
* p_file_n = wa_files-name.
* ENDIF.
*ENDIF.
data: begin of it_tab occurs 0,
rec(1000) type c,
end of it_tab.
data: wa_tab(1000) type c,
it_itab type table of zita_pp_iffco,
wa_itab type zita_pp_iffco,
t1(40) type c,
t2(10) type c,
t3(20) type c,
t4(4) type c,
t5(4) type c,
t6(4) type c,
t7(4) type c,
t8(2) type c,
t9(2) type c,
t10(8) type c.
clear: t1, t2, t3, t4, t5, t6, t7, t8, t9, t10.
concatenate lv_dir '/' wa_files-name into p_file_n. " Added By Amir and Uzair
data : t_csv type standard table of xstring ,"TRUXS_T_TEXT_DATA,
w_csv like line of t_csv.
data: flag(1).
*OPEN DATASET p_file_n FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
if p_file_n is not initial. " Added By Amir and Uzair
open dataset p_file_n for input in text mode encoding default with smart linefeed.
*OPEN DATASET p_file_n FOR INPUT IN BINARY MODE .
if sy-subrc = 0.
do.
* READ DATASET p_file_n INTO w_csv.
read dataset p_file_n into wa_tab.
if sy-subrc <> 0.
exit.
endif.
if flag ne 'X'.
flag = 'X'.
continue.
endif.
split wa_tab at ',' into: t1 t2 t3 t4 t5 t6.
wa_itab-plant_name = t1.
* wa_itab-datee = t2.
* WRITE t2 to wa_itab-datee.
t7 = t2+6(4).
t8 = t2+3(2).
t9 = t2+0(2) .
concatenate t7 t8 t9 into t10.
wa_itab-datee = t10.
wa_itab-product = t3.
wa_itab-inputt = t4.
wa_itab-outputt = t5.
wa_itab-by_product = t6.
append wa_itab to it_itab.
clear wa_itab.
* APPEND it_tab .
clear: t1, t2, t3, t4, t5, t6, t7, t8, t9, t10.
enddo.
endif.
close dataset p_file_n.
endif.
if it_itab[] is not initial.
modify zita_pp_iffco from table it_itab.
if sy-subrc = 0.
commit work.
message 'Table uploaded Succesfully' type 'I'.
else.
message 'Table not updated or data already exist' type 'W'.
endif.
endif.
*endif.
2022 Dec 16 8:20 PM
Couple of tips: