Skip to Content
author's profile photo Former Member
Former Member

upload excel to ztable how to deleting specs. lines

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jun 06, 2014 at 07:50 AM

    Hi Kutay,

    You can use Delete Keywords, before going to upload.

    DELETE it_datatab where (put your condition here).

    Regards,

    Thangam.P

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Thangam Perumal

      ı 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?

  • Posted on Jun 06, 2014 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Thangam Perumal

      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

  • Posted on Jun 07, 2014 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Thangam Perumal

      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..?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.