Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Checking the Selection Screen Parameters

Dear All,

We are uploading data from various excel sheets into SAP tables. Now at selection screen I just want to check if the location specified exists or not ie. if I have created one variant on one system & then if I am running that report from other system using the variants, since the files does not exists it should throw the error and should return to the selection screen to enter the new parameters.

Please help me in the code, I am attaching my code herewith.

Waiting for ur responses,

Nishu

*********************CODE***************************

tables: bseg, zfi_tbl_qty, t001, tgsb.

data:

t_excel like alsmex_tabline occurs 0 with header line,

l_excelfile(128) type c,

l_excelfile1(128) type c,

l_excelfile2(128) type c,

l_excelfile3(128) type c.

data: begin of t_bukrs_tmp occurs 0,

bukrs like t001-bukrs,

end of t_bukrs_tmp.

data: begin of t_gsber_tmp occurs 0,

gsber like tgsb-gsber,

end of t_gsber_tmp.

ranges: r_bukrs_tmp for t001-bukrs,

r_gsber_tmp for tgsb-gsber.

data: begin of t_type,

bukrs like bseg-bukrs,

gsber like bseg-gsber,

count type i,

end of t_type.

data: l_charlen1 type i,

l_charlen2 type i.

data: t_type2 like t_type occurs 0 with header line,

t_type2_tmp like t_type occurs 0 with header line.

data: l_end_row type i,

l_endrow1 type i,

l_count type i,

v_bukrs like bseg-bukrs.

data : q_count type i value 1,

v_flag type i value 0,

v_gsber like t_type2-gsber.

data: l_var type c.

selection-screen begin of block b1 with frame title text-001.

parameter : p_file1 type rlgrap-filename obligatory,

p_file2 type rlgrap-filename obligatory,

p_file3 type rlgrap-filename obligatory,

p_file4 type rlgrap-filename obligatory.

selection-screen end of block b1.

*perform updation_tbl.

*clearing the contents of database table before uploading a new file everytime

delete from zfi_tbl_qty.

*selection-screen

at selection-screen on value-request for p_file1.

call function 'KD_GET_FILENAME_ON_F4'

exporting

field_name = p_file1

changing

file_name = p_file1.

at selection-screen on value-request for p_file2.

call function 'KD_GET_FILENAME_ON_F4'

exporting

field_name = p_file2

changing

file_name = p_file2.

at selection-screen on value-request for p_file3.

call function 'KD_GET_FILENAME_ON_F4'

exporting

field_name = p_file3

changing

file_name = p_file3.

at selection-screen on value-request for p_file4.

call function 'KD_GET_FILENAME_ON_F4'

exporting

field_name = p_file4

changing

file_name = p_file4.

at selection-screen.

l_excelfile = p_file1.

l_excelfile1 = p_file2.

l_excelfile2 = p_file3.

l_excelfile3 = p_file4.

if l_excelfile = l_excelfile1 or l_excelfile = l_excelfile2 or l_excelfile = l_excelfile3

or l_excelfile1 = l_excelfile2 or l_excelfile1 = l_excelfile3 or l_excelfile2 = l_excelfile3.

message e010(zn) with 'Files with the same name found Please enter again. '.

endif.

start-of-selection.

select bukrs

from t001

into corresponding fields of table t_bukrs_tmp.

loop at t_bukrs_tmp.

r_bukrs_tmp-sign = 'I'.

r_bukrs_tmp-option = 'EQ'.

r_bukrs_tmp-low = t_bukrs_tmp-bukrs.

append r_bukrs_tmp.

endloop.

select gsber

from tgsb

into corresponding fields of table t_gsber_tmp.

loop at t_gsber_tmp.

r_gsber_tmp-sign = 'I'.

r_gsber_tmp-option = 'EQ'.

r_gsber_tmp-low = t_gsber_tmp-gsber.

append r_gsber_tmp.

endloop.

perform upload_table using l_excelfile 5 2 6 4000.

perform upload_table using l_excelfile1 5 2 6 4000.

perform upload_table using l_excelfile2 5 2 6 4000.

perform upload_table using l_excelfile3 5 2 6 4000.

  • if sy-subrc = 0.

message i010(zn) with 'Files Uploaded Successfully.'.

  • if sy-subrc <> 0.

  • message e398(00) with 'Files Not Found'.

    • leave to screen 0.

  • endif.

************Calling the other program

SUBMIT ZFI_REP_IS_CHARGES_POST1.

*and return.

*******************Calling the subroutine.

form upload_table using filename

i_begin_col type i

i_begin_row type i

i_end_col type i

i_end_row type i.

clear : t_excel.

refresh : t_excel.

v_flag = v_flag + 1.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = filename

i_begin_col = 5

i_begin_row = 2

i_end_col = 6

i_end_row = 4000

tables

intern = t_excel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

case v_flag.

when '1'.

perform fill_int_tab.

when '2'.

perform fill_int_tab.

when '3'.

perform fill_int_tab.

when '4'.

perform fill_int_tab.

endcase.

endform. "upload_table

*uploading data from internal table into database table

&----


*& Form fill_int_tab

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_int_tab .

clear : t_type2, q_count.

refresh : t_type2.

describe table t_excel lines l_endrow1.

l_endrow1 = l_endrow1 / 2.

do.

loop at t_excel where row = q_count.

if t_excel-col = 1.

t_type2-gsber = t_excel-value.

elseif t_excel-col = 2.

t_type2-bukrs = t_excel-value.

endif.

endloop.

l_charlen1 = strlen( t_type2-bukrs ).

l_charlen2 = strlen( t_type2-gsber ).

if ( t_type2-bukrs <> ' ' and t_type2-gsber <> ' ' ).

if ( l_charlen1 = 4 and l_charlen2 = 4 ).

append t_type2. clear t_type2.

endif.

endif.

q_count = q_count + 1.

if q_count > l_endrow1.

exit.

endif.

enddo.

t_type2_tmp[] = t_type2[].

clear t_type2.

refresh t_type2.

loop at t_type2_tmp where bukrs in r_bukrs_tmp

and gsber in r_gsber_tmp.

move-corresponding t_type2_tmp to t_type2.

append t_type2.

endloop.

sort t_type2 by bukrs gsber.

loop at t_type2.

clear v_gsber.

l_count = l_count + 1 .

v_gsber = t_type2-gsber.

at end of gsber.

  • at end of bukrs.

zfi_tbl_qty-company_code = t_type2-bukrs.

zfi_tbl_qty-barea = v_gsber.

zfi_tbl_qty-comb = l_count.

if v_flag = 1.

zfi_tbl_qty-type = 'A'. " Item 1

endif.

if v_flag = 2.

zfi_tbl_qty-type = 'B'. " Item 2

endif.

if v_flag = 3.

zfi_tbl_qty-type = 'C'. " Item 3

endif.

if v_flag = 4.

zfi_tbl_qty-type = 'D'. " Item 4

endif.

insert zfi_tbl_qty from zfi_tbl_qty.

clear l_count.

  • endat.

endat.

endloop.

endform. " fill_int_tab

Tags:
Former Member
Former Member replied

Hi,

After calling this FM:

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = filename

i_begin_col = 5

i_begin_row = 2

i_end_col = 6

i_end_row = 4000

tables

intern = t_excel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

*-> try following code:

if sy-subrc = '2'.

message 'File not Found' type 'I'.

leave list-processing.

endif.

Regards,

Kalyan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question