06-06-2014 8:46 AM
hi experts
ım usıng TEXT_CONVERT_XLS_TO_SAP' to upload excel file to ztable.
in my codes ı need to delete line depend some conditions before upload to final table.
when ı execute the program its just upload my excel file to it_datatab
after that with loopin it_datatab to wa_datatab ıt starts to upload to ztable.
ı have to delete some lines when ıt upload to it_datatab.
how can ı delete lines from it_datatab depend some conditions?
any help will be apprciated..
thank u
here is my code:
tables : zmahsup_imei, mara .
type-pools: truxs.
parameters: p_file type rlgrap-filename.
types: begin of t_datatab,
col1 type gernr,
col2 type mara-normt,
col3 type zmahsup_imei-dmbtr,
col4 type zmahsup_imei-waers,
end of t_datatab.
data: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
data: it_raw type truxs_t_text_data.
* At selection screen
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
start-of-selection.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
***********************************************************************
* END-OF-SELECTION.
end-of-selection.
break-point.
loop at it_datatab into wa_datatab.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_datatab-col1
importing
output = wa_datatab-col1
.
zmahsup_imei-imei = wa_datatab-col1.
zmahsup_imei-normt = wa_datatab-col2.
zmahsup_imei-dmbtr = wa_datatab-col3.
zmahsup_imei-waers = wa_datatab-col4.
insert zmahsup_imei.
endloop.
break-point.
if sy-subrc = 0 .
commit work and wait.
message 'Dosya yükleme işlemi başarı ile tamamlanmıştır' type 'I'.
else.
message 'Dosya yükleme işlemi sırasında hata oluştur,excel dosyasını kontrol ediniz' type 'E'.
endif.
06-06-2014 8:50 AM
Hi Kutay,
You can use Delete Keywords, before going to upload.
DELETE it_datatab where (put your condition here).
Regards,
Thangam.P
06-06-2014 8:50 AM
Hi Kutay,
You can use Delete Keywords, before going to upload.
DELETE it_datatab where (put your condition here).
Regards,
Thangam.P
06-06-2014 8:57 AM
ı try to check ımeı number and price in my z table
if my excel ınclude same ımeı number it will check price and if price is diffrent on my excel
it has to be change the prıce what it is in my exce.
delete keyword is actually better for specific filterin
ı need more ınformatıon actually
06-06-2014 9:10 AM
when you need to check? after insert into table or what?. where u comparing imei number?
06-06-2014 9:36 AM
ı need to check ıt before upload to ztable
so ı will use it_datatab to check
ım always maintainin my ztable and sometimes whıle ım uploading new data to it
it may ınclude same imeı whıch ıs on already ztable
so ı have to check ıf excel has same imei whıch ıs already uploaded before into ztable?
06-06-2014 10:33 AM
K Kutay. please follow below steps.
tables ztable.
loop at it_datatab into wa_datatab.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_datatab-col1
importing
output = wa_datatab-col1
.
zmahsup_imei-imei = wa_datatab-col1.
zmahsup_imei-normt = wa_datatab-col2.
zmahsup_imei-dmbtr = wa_datatab-col3.
zmahsup_imei-waers = wa_datatab-col4.
select * from ztable where imei = wa_datatab-col1.
if sy-subrc ne 0. " if already exist in ztable mean sy-subrc will be 0 so you no need to upload.
insert zmahsup_imei.
endif.
endloop.
break-point.
if sy-subrc = 0 .
commit work and wait.
06-06-2014 2:08 PM
this is working thank u
ı have another ıssue..
after checking same imei in z table and modifying it
i need to insert unique rows into z table
how can ı arrange this in code?
ı tried to do this;
select * from it_datatab where it_datatab-col1 ne zmahsup_imei-imei....
but select doesnt work for ''type standard table of''
any suggestions will be appreciate...
06-06-2014 3:00 PM
Hi Kutay,
Please explain one more time regarding above thread.
Regards,
Thangam.P
06-06-2014 3:08 PM
your code snippet is working what u send me before..
and now ı have to insert ımeı whıch are not in z table
to do that ı just trıed " select * it_datatab where it_datatab-col1 ne zmahsup_imei-imei"
but it doesnt work
06-07-2014 5:26 AM
Hi Kutay
i have little bit confuse regarding it_datatab. whether it_datatab is internal table or Database table? and also u said my above coding is working well for imei number insertion. then why u are asking again?
Regards,
Thangam.P
06-11-2014 12:33 PM
it_datatab is internal table which ım filling it with text_convert_xls_sap
ı want to delete some lines depend on where conditions
how can ı achieve this?
06-11-2014 2:02 PM
Hi Kutay,
Provide like below
DELETE it_datatab where (put your condition here).
06-11-2014 2:09 PM
there is one issue about it.
I have ztable with the name ztsozlesme_excel and this table include same imei number with the it_datatab and also has field with the name mahsuplasma.
mahsuplasma field is filled with 'x' .
ı want to delete lines from it_datatab depend on ztsozlesme_excel table
if ztsozlesme excel-imei eq it_Datatab eq
and ztsozlesme_Excel-mahsuplasma = x
delete lines from itab.
this is summary of what ı have to do in code.
so how can ı achieve this in right ways..?