Need help in processing internal table

Hi all,
Im facing a  problem in processing an internal table..especially with MODIFY.
The internal table is having following records.(t_vttp)
TKNUM       VBELN      KUNNR       NAME1                             LAND1
0000975179|0071004839|0000022946|HUNTSMAN APC LIMITED               |SA   |
0000975180|0071004845|0000022946|                                   |     |
In the above, there are two delviry documents with same customers.
The customer data is coming from different internal table.
  LOOP AT t_vttp.
    READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
    IF sy-subrc = 0.
      t_vttp-name1 = wa_kna1_temp-name1.
      t_vttp-land1 = wa_kna1_temp-land1.
      MODIFY t_vttp INDEX sy-tabix TRANSPORTING name1 land1.
    ENDIF.
  ENDLOOP.
Here for second record,,the customer name and country is nt getting populated to t_vttop.
Pls correct where it is going wrong.
Thanks,
Priya

Hi Try the follwoing code with a little modification in your code.
LOOP AT t_vttp.
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX sy-tabix  TRANSPORTING name1 land1.
append t_vttp.
ENDIF.
clear: wa_kna1_temp, t_vttp.
ENDLOOP
Also Please debugg your code and check if you are getting values.
also check the value of t_vttp-kunnr in debugging for the second run of your loop.
thanks
lalit

Similar Messages

  • Need help reading an internal table

    Howdy,
    I have an internal table (itab_knvh) that contains all the entries from table KNVH for a specified sales area.
    Now I have another internal table (itab_kunnr) that contains all the customers that I need data for.
    How can I read all the entries from itab_knvh where the 'date from' value (datab) is greater than today's date?
    At the moment I have:
    <b>  LOOP AT itab_kunnr.
        <i>READ TABLE itab_knvh WITH KEY kunnr = itab_kunnr-kunnr.</i>
        IF sy-subrc = 0.
          IF itab_knvh-datab GE p_validh.
            WRITE:/ itab_kunnr.
          ENDIF.
        ENDIF.
      ENDLOOP.</b>
    but I don't think this will work if more than one customer entry exists in itab_knvh.
    So is there a way of writing:
    READ TABLE itab_knvh WITH KEY kunnr = itab_kunnr-kunnr
                                  datab GE sy-datum.
    Any ideas???

    Hi Steve,
    If you have written <i>exactly</i> the same SELECT statement as you have posted here, then it is in error.
    Try this one out, instead.
    select single hkunnr
                  datab
                  hzuor 
             from knvh
             into (itab_hier_output-old_kunnr,
                   itab_hier_output-old_datab,
                   itab_hier_output-old_hzuor)
            where kunnr = itab_kunnr-kunnr
              and datbi = itab_hier_output-new_datab.
    Regards,
    Anand Mandalika.

  • Need help to find internal table.

    hello friends,
    i am working on a smart form i am given a transaction code, vf03 and a custom program and a custom function module,
    i tried to use /h to do the debugging through vf03, but i could not understand where the control was going it was all roaming inthe standard code,
    what all i need to do is to reach the internal table in the smartform, and do some modifications.
    now how do i reach the internal table.
    thank you.

    if you know smartform print program,then use se38 transaction-> use smart form print program and keep break point here.
    Now run VF03 transaction and see it
    Thanks
    Seshu

  • Need help in reading internal table data

    Hi All,
    I have two internal tables, it_cdhdr and it_cdpos. Data as follows:
    it_cdhdr:
    Objectclass     ObjectId          Changenr         Udate      Change_ind
    EINKBELEG    4500057161    0003273002    20131129    U
    EINKBELEG    4500057161    0003273001    20131129    U
    EINKBELEG    4500057161    0003272995    20131129    U
    EINKBELEG    4500057161    0003178904    20131030    U
    EINKBELEG    4500057161    0003178903    20131030    U
    it_cdpos
    Objectclas       ObjectId          Changenr      Tabname   Fname Value_new Value_old
    EINKBELEG    4500057161    0003178903    EKKO    FRGKE         A                B
    EINKBELEG    4500057161    0003178903    EKKO    FRGZU          X
    EINKBELEG    4500057161    0003178903    EKKO    PROCSTAT    05                03
    EINKBELEG    4500057161    0003178903    EKKO    RLWRT       800.00            0.00
    EINKBELEG    4500057161    0003178904    EKET    MENGE      1000.000         800.000
    EINKBELEG    4500057161    0003178904    EKKN    MENGE       500.000          400.000
    EINKBELEG    4500057161    0003178904    EKKN    NETWR            500.00        400.00
    EINKBELEG    4500057161    0003178904    EKKO    FRGKE          B                 A
    EINKBELEG    4500057161    0003178904    EKKO    FRGZU          X
    EINKBELEG    4500057161    0003178904    EKKO    PROCSTAT    03                 05
    EINKBELEG    4500057161    0003178904    EKKO    RLWRT       1000.00              800.00
    EINKBELEG    4500057161    0003178904    EKPO    BRTWR       1000.00            800.00
    EINKBELEG    4500057161    0003178904    EKPO    MENGE      1000.000           800.000
    EINKBELEG    4500057161    0003178904    EKPO    NETWR      1000.00            800.00
    EINKBELEG    4500057161    0003272995    EKKO    FRGKE        A                       B
    EINKBELEG    4500057161    0003272995    EKKO    FRGZU        X
    EINKBELEG    4500057161    0003272995    EKKO    PROCSTAT    05    03
    EINKBELEG    4500057161    0003273001    EKET    MENGE          2000.000          1000.000
    EINKBELEG    4500057161    0003273001    EKKN    MENGE          1000.000           500.000
    EINKBELEG    4500057161    0003273001    EKKN    NETWR           1000.00            500.00
    EINKBELEG    4500057161    0003273001    EKKO    FRGKE    B    A
    EINKBELEG    4500057161    0003273001    EKKO    FRGZU        X
    EINKBELEG    4500057161    0003273001    EKKO    PROCSTAT    03    05
    EINKBELEG    4500057161    0003273001    EKKO    RLWRT             2000.00             1000.00
    EINKBELEG    4500057161    0003273001    EKPO    AEDAT    20131129    20131030
    EINKBELEG    4500057161    0003273001    EKPO    BRTWR           2000.00           1000.00
    EINKBELEG    4500057161    0003273001    EKPO    MENGE          2000.000          1000.000
    EINKBELEG    4500057161    0003273001    EKPO    NETWR           2000.00           1000.00
    EINKBELEG    4500057161    0003273002    EKKO    FRGKE    A    B
    EINKBELEG    4500057161    0003273002    EKKO    FRGZU    X
    EINKBELEG    4500057161    0003273002    EKKO    PROCSTAT    05    03
    As per requirement, the main focus is on Changes to EKKN and EKPO tables and I have to get the latest changes.
    If you observe in above it_cdpos internal table data, it has two records,
    EINKBELEG    4500057161    0003178904    EKKN    NETWR            500.00        400.00
    EINKBELEG    4500057161    0003178904    EKPO    NETWR      1000.00            800.00
    EINKBELEG    4500057161    0003273001    EKKN    NETWR           1000.00            500.00
    EINKBELEG    4500057161    0003273001    EKPO    NETWR           2000.00           1000.00
    Now I have read only the latest changenr data. Say 0003273001 , in this case.
    My question is how do I know, the latest changenr has EKKN table changes, if you look at it_cdpos data above, the latest one is 0003273002, which doesnt have EKKN changes.
    Kindly let me know how to read latest EKKN or EKPO data from IT_CDPOS table.
    Thanks in advance,
    Rgs,
    Priya

    Hi Priya ,
    I guess your requirement is to find the latest change number ,that has got change in both ekkn and ekkpo .
    1- Sort it_cdhdr descending .
    Loop at it_chdr into w_cdhdr
      read table it_cdpos into w_cdpos with key changenr = w_cdhdr Tabname = ekkn .
       if sy-subrc=0 .
         read table it_cdpos into w_cdpos with key changenr = w_cdhdr Tabname = ekkpo .
           if sy-subrc=0 .
            "use convenient  way to return change number (using varaiable)"
             exit .
           endif .
       endif.
      endloop .
    By this way change number send will be the latest having both ekkn and ekkpo . If what i assumed is wrong ,then sorry for that . 

  • Search Help values to Internal table

    Dear Friends,
    Is it possible to export Search Help values to Internal table?
    On screen, when user click on Search button, the SAP standard search help will call (Customer Search). After entering values, some result get displayed and this result need to export to the internal table.
    Thanks in stack
    Nilesh

    Hi:
    try this:
    DATA : wa_shlp TYPE shlp_descr,
               it_records LIKE ddshretval OCCURS 0 WITH HEADER LINE.
    wa_shlp-SHLPNAME = 'MAT0M'.   "one of elementary search help name from mara-matnr.
    wa_shlp-SHLPTYPE = 'SH'.
    CALL FUNCTION 'F4IF_SELECT_VALUES'
         EXPORTING
           shlp                   = wa_shlp
      MAXROWS                = 0
      SORT                   = ' '
      CALL_SHLP_EXIT         = ' '
    IMPORTING
      MAXROWS_EXCEEDED       =
        TABLES
      RECORD_TAB             =
      RECDESCR_TAB           =
          return_tab            = it_records
    LOOP AT it_records.
      WRITE:/ it_records.
    ENDLOOP.
    Follows is how to get the search help name:
    CALL FUNCTION 'DD_SHLP_GET_HELPMETHOD'
      EXPORTING
        tabname                 = 'MARA'
        fieldname               = 'MATNR'
        langu                   = sy-langu
      NO_CHKTAB_MAPPING       =
      GET_ENTITYTAB           = ' '
       CHANGING
         shlp                    = wa_shlp
      callcontrol             = callcontrol
      EXCEPTIONS
        field_not_found         = 1
        no_help_for_field       = 2
        OTHERS                  = 3
    CALL FUNCTION 'F4IF_EXPAND_SEARCHHELP'
       EXPORTING
         shlp_top = wa_shlp
       IMPORTING
         shlp_tab = shlps.
    好运,
    启明星

  • Help on Delete Internal table records

    Hi,
    I have a internal table with some records in it.
    I need to delete the contents of this based on the condition as below.
    if product_search-Resp_product_company is not initial.
    SORT i_equi BY zzrefeng.
    DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.
    endif.
    when i execute this all the records are getting deleted irrespective of the condition mentioned.
    Can anyone help me on this.
    Regards,
    Ram

    Hi,
    Need to delete the records if <b>ZZREFENG</b> does not have the value of <b>product_search-Resp_product_company</b> .
    Here I have product_search-Resp_product_company value as FI14. And also the internal table contains some records with ZZREFENG = FI14.
    I need to delete the internal table records if ZZREFENG <> FI14. But when i execute the statement it is deletng all the records even ZZREFENG = FI14 records also.
    Regards,
    Ram

  • Need a logic for Internal table processing

    Hi,
    I have a requirement...an internal table contains three fields material no, bin no, and Quantity
    Mat. No    |         Bin No        |              Quantity
    a              |              x1         |                   10
    a              |              x1         |                   10
    a              |              x2         |                   20
    b              |              x3         |                   10 
    c              |              x3         |                   20
    c              |              x4         |                   30
    c              |              x4         |                   40
    In this I need to append the records to new internal table say itab1 where multiple entries exist for some material no like mat no 'a' and 'c'  and
    if the material no. exist only once in the table, it has to be moved to another new internal table say itab2.
    Pls suggest some logic that does not have performance issues.
    Thanks in advance
    Saravana

    Hi there,
    a solution in brief...
    data: wa_itab1_a like itab1,
             wa_itab2_b like itab1,
             lv_tabix       type sytabix.
    sort itab1 by matnr.
    loop at itab1.
      wa_itab1_a = itab1.
      at new matnr.
        lv_tabix = sy-tabix + 1.
        clear wa_itab2_b.
        READ TABLE itab1 into wa_itab2_b
                            INDEX lv_tabix.
        if wa_itab2_b-matnr ne wa_itab1_a-matnr.
          append wa_itab1_a to itab2.
          delete itab1 where matnr = wa_itab1_a-matnr.
        endif.
      endat.
    endloop.
    Regards
    George Zervas
    Edited by: gzervas on Oct 20, 2010 12:08 PM

  • Need urgent help on dynamic internal table.

    Hi experts,
    I got an editable dynamic internal table. When the value in 1 of the editable field has been changed, I will fire the the DATA_CHANGED event. In this event, I can get the row ID where the changes occur, but the problem is, how can I select back the data from the dynamic internal table using the row ID since index is not permitted to be used? I need to get the rest of the records form the ROW and then perform a database update accordingly. How can I select from the dynamic internal table given the row ID? THanks in advance.

    Hi
    I suppose it depends on the kind of internal table assigned to fieldsymbol, this sample works fine:
    FIELD-SYMBOLS: <FS> TYPE TABLE,
                   <WA> TYPE ANY.
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD,
          END   OF ITAB.
    DO 10 TIMES.
      ITAB-FIELD = 'a'.
      APPEND ITAB.
    ENDDO.
    ASSIGN ITAB[] TO <FS>.
    READ TABLE <FS> ASSIGNING <WA> INDEX 1.
    WRITE <WA>.
    It can't use the index with internal table of kind HASHED.
    Max

  • Need to make the internal table structure dynamic

    Hi ,
    I need to upload data from an excel file, the columns in the excel keep on varying
    E.g the number of columns in one excel file can be 10, in the second excel file it can be 15.
    So in order to upload the data into an internal table the structre of internal table needs to be dynamic and change according to the number of fields in the input file .
    Is it possible by using field symbols or is there any other method to do the same
    Thanks.
    Nishant
    Edited by: nishant patel on Sep 17, 2009 10:48 AM

    Hi Nishant,
    According to ur requirement, dynamic internal table can be created like below. But database table name has to passed dynacimally.
        DATA: ftab TYPE STANDARD TABLE OF ddfield,
              ftab_wa TYPE ddfield,
              fcat_itab TYPE lvc_t_fcat,
              fcat_wa TYPE lvc_s_fcat,
              poi_itab TYPE REF TO data.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
        CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
          EXPORTING
            tabname  = p_table  " Pass database table name dynamically
          TABLES
            ddfields = ftab.
        LOOP AT ftab INTO ftab_wa.
          fcat_wa-fieldname = ftab_wa-fieldname.
          fcat_wa-ref_field = ftab_wa-fieldname.
          fcat_wa-ref_table = p_table.
          APPEND fcat_wa TO fcat_itab.
        ENDLOOP.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog           = fcat_itab
          IMPORTING
            ep_table                  = poi_itab
          EXCEPTIONS
            generate_subpool_dir_full = 1
            OTHERS                    = 2.
        ASSIGN poi_itab->* TO <itab>.  " <itab> is dynamic internal table
    Might help u.
    Thanks.
    Edited by: Sap Fan on Sep 17, 2009 1:19 PM

  • Want to have F4 help from an internal table in Module Pool.

    Hi,
    I have a input/output field in a Module pool program. I want to attach an F4 help on this from an internal table.
    Please suggest me some techniques.
    Thanks in advance..

    Hi all,
    This is the piece of  code I have written...But I am getting the message "No Values Found"-
    DECLARATION
    TYPES:
         BEGIN OF ty_shipto,
         ship_to TYPE kunnr,
         END OF ty_shipto.
    DATA:
            tb_shipto TYPE TABLE OF ty_shipto,
           wa_shipto TYPE ty_shipto.
    REFRESH:
            tb_shipto.
    CLEAR:
           wa_shipto.
    TABLE TB_SHIPTO IS FILLED
    SELECT spart
        FROM mara
        INTO CORRESPONDING FIELDS OF TABLE mara_it
        FOR ALL ENTRIES IN vlcvehicle_it
        WHERE matnr = vlcvehicle_it-matnr.
      LOOP AT vlcvehicle_it INTO vlcvehicle_ls.
        MOVE-CORRESPONDING vlcvehicle_ls TO wa_vehinfo.
        APPEND wa_vehinfo TO tb_vehinfo.
      ENDLOOP.
      LOOP AT mara_it INTO mara_ls.
        MOVE-CORRESPONDING mara_ls TO wa_vehinfo.
        APPEND wa_vehinfo TO tb_vehinfo.
      ENDLOOP.
      LOOP AT vlcvehicle_it INTO vlcvehicle_ls.
        MOVE vlcvehicle_ls-vhcle TO va_vhcle.
        CALL FUNCTION 'ZCN_SD_GET_VLC_BRAND'
          EXPORTING
            in_vhcle          = va_vhcle
          IMPORTING
            out_distr_channel = va_vtweg.
        MOVE va_vtweg TO wa_vtweg.
        MOVE-CORRESPONDING wa_vtweg TO wa_vehinfo.
        APPEND wa_vehinfo TO tb_vehinfo.
      ENDLOOP.
      CLEAR:
           va_vtweg.
      IF tb_vehinfo[] IS NOT INITIAL.
        LOOP AT tb_vehinfo INTO wa_vehinfo.
          MOVE wa_vehinfo-kunnr TO va_kunnr.
          IF va_kunnr IS NOT INITIAL.
            MOVE va_kunnr TO va_kunnr_final.
          ENDIF.
          MOVE wa_vehinfo-zvkorg TO va_vkorg.
          IF va_vkorg IS NOT INITIAL.
            MOVE va_vkorg TO va_vkorg_final.
          ENDIF.
          MOVE wa_vehinfo-spart  TO va_spart.
          IF va_spart IS NOT INITIAL.
            MOVE va_spart TO va_spart_final.
          ENDIF.
          MOVE wa_vehinfo-vtweg  TO va_vtweg.
          IF va_vtweg IS NOT INITIAL.
            MOVE va_vtweg TO va_vtweg_final.
          ENDIF.
        ENDLOOP.
      ENDIF.
      SELECT kunn2
        FROM knvp
        INTO TABLE tb_shipto
        WHERE kunnr = va_kunnr_final  AND
              vkorg = va_vkorg_final  AND
              spart = va_spart_final  AND
              vtweg = va_vtweg_final  AND
              parvw = 'WE'.
    POV- TXT_SHIPTO_NVAL_NAR IS THE FIELD NAME IN DYNPRO
    PROCESS ON VALUE-REQUEST.
      FIELD:
           txt_shipto_nval_nar     MODULE f4_help_shipto_nar.
    MODULE f4_help_shipto_nar INPUT.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield         = 'SHIP_TO'
          dynpprog         = sy-repid
          callback_program = sy-repid
          dynpnr           = sy-dynnr
          dynprofield      = 'TXT_SHIPTO_NVAL_NAR'
        TABLES
          value_tab        = tb_shipto
          return_tab       = return_tab.
    ENDMODULE.                 " M_F4_HELP_NVAL_SHIPTO  INPUT
    The code is runnig error free but I am unable to see any popup.
    Message displayed: "No Values Found". But, I have checked in debugging that the table TB_SHIPTO contains some values when the FM is called.
    Please point out the mistake.
    Thanks in advance.

  • Process internal table

    Hi experts,
    I need help, I don't know how can I do that, I've an internal table like below..
    date                   status            hour
    06/08/10             01                 9:00
    06/08/10             03                 9:15
    06/08/10             01                 9:20
    06/08/10             02                 9:50
    07/08/10             01                 12:00
    07/08/10             02                 12:00
    08/08/10             01                 12:00
    From that internal table I need these which the date is unique and has the maxim hour, for that table I will need that entries:
    06/08/10             02                 9:50
    07/08/10             02                 12:00
    08/08/10             01                 12:00
    Can anybody help me? I don't know how can I do that
    Thanks in advanced,
    Regards,
    Rebeca

    Hi,
        Please sort and then use delete adjacent duplicates.
        Sort itab by date hour descending.
        delete adjacent duplicates from itab comparing date.
    Regards,
    Srini.

  • Need help estimating processing power required to support new process

    Hi,
    I am putting up a new server spec for a new project. I need help estimating processor power I need.
    Here are, in short, the steps of the main process:
    - Load the data:
    Incoming file contains 160 mln rows. The SIZE of this file is 250 GB. The file has about 60 columns, out of that I upload 50 into my table.
    Record length is 1500 bytes, in the table.
    - Validation/calculations:
    After the upload I validate EACH row in this table against 20 rules that are defined in the RULES table.
    It is all math, like this column plus that column must be equal to this number, and validate the third column against this number.
    - Output stage:
    Records that pass validation go to one table, those that didn't go to the other table.
    Then the first table (with good records) is extracted to a file. Those from the "wrong" table are also get inserted into "review" table
    This whole process should take about 5-6 hrs.
    This file contains 6 month of data.
    Some times, I will run validation against 2 year worth of data, means validate two "annual" tables, each one is 500 GB in size. According to the requirements, this process should take no more than 1 day.
    For this process I write hardware spec for a new server.
    I have a hard time figuring out how much processor power I need for this process? to validate this much data in that much time.
    Is there any formula or a guideline to tell what processor I need? I was looking at this one, but I wish I could estimate before I buy and try (and possibly fail, and have a biiiiig problems)
    Intel Xeon E5-2640 (6 core, 2.50 GHz, 15MB, 95W)
    Number of processors: 2
    RAM: 16GB
    Any help is very appreciated.
    Thanks in advance
    Edited by: 933238 on Jun 13, 2012 12:25 PM
    Edited by: 933238 on Jun 13, 2012 12:28 PM

    Hello Ajay,
    Please have a look to these blogs (the second one should be particularly interesting regarding your request) :
    /people/kamran.ellahi2/blog/2006/01/13/setting-up-sap-service-desk-123-and-go
    /people/dolores.correa/blog/2007/10/06/service-desk-support-team-determination
    Hope this helps.
    BR.
    Stéphane.

  • How to process internal table

    Hi friends/experts,
    My case is:
    1. A dialog screen 100 to display/ update some fields of an internal table itab, Records are processed one by one on the screen
    2. Need UPDATE, DELETE, PREV. NEXT buttons to process records.
    I have made the screen with fields and buttons. What I like to know is how to code DELETE, PREV. and NEXT buttons. Could you kindly provide a sample to do that?
    Thanks.
    Yu

    Hi,
      check this sample code..
    ***Create a global variable for storing the current index that is getting displayed..
    ***I am assuming V_CURRENT_INDEX TYPE SYINDEX.
    CASE SY-UCOMM.
      WHEN 'NEXT'.
    INcrement the index.
        V_CURRENT_INDEX = V_CURRENT_INDEX + 1.
        DESCRIBE TABLE ITAB.
        IF V_CURRENT_INDEX  > SY-TFILL.
    If the current index is greater than the number of rows.
    set the sy-tfill.
          V_CURRENT_INDEX = SY-TFILL.
          MESSAGE S208(00) WITH 'Last record reached'.
          LEAVE SCREEN.
        ENDIF.
    Read the internal table with the current index.
          READ TABLE ITAB INDEX V_CURRENT_INDEX.
    Move the values to the screen variables from the header line of ITAB.
      WHEN 'PREV'.
    Decrement the counter.
        V_CURRENT_INDEX = V_CURRENT_INDEX - 1.
        IF V_CURRENT_INDEX  <  0.
    If the current index is Lesser than zero set 1.
          V_CURRENT_INDEX = 1.
          MESSAGE S208(00) WITH 'First record reached'.
          LEAVE SCREEN.
        ENDIF.
    Read the internal table with the current index.
          READ TABLE ITAB INDEX V_CURRENT_INDEX.
    Move the values to the screen variables from the header line of ITAB.
    ENDCASE.
    Thanks,
    Naren

  • Need help in processing an excel into SAP

    Hi All..
    Im uploading an excel file from presentation server to SAP...
    Now the problem is hw to know how many records are there in the excel file..
    Have coded like below...
    w_max = '65536'.
      w_counter_lo = '2'.    "Start on row 1 because of header row
      w_increment  = '9999'. "Increment by 9999 each loop
      w_counter_hi = w_counter_lo + w_increment.
    WHILE w_counter_hi <= w_max AND w_counter_lo <= w_max.
        " Clear the work area and the internal table to prevent duplicate rows
        CLEAR it_import_table.
        CALL FUNCTION 'ZPM_EXCEL_TO_INTERNAL_TABLE'
          EXPORTING
            filename                = p_file
            i_begin_col             = '1'
            i_begin_row             = w_counter_lo "we have a header row
            i_end_col               = '5'
            i_end_row               = w_counter_hi
          TABLES
            intern                  = it_import_table
          EXCEPTIONS
            inconsistent_parameters = 1
            upload_ole              = 2
            OTHERS                  = 3.
        "Increment our range
        w_counter_lo = w_counter_hi + 1.
        w_counter_hi = w_counter_lo + w_increment.
        "We SHOULD NOT scan any more than our max, so set our top end of the range
        "to the total number of rows to scan if the w_Counter_hi exceeds the max.
        IF w_counter_hi > w_max.
          w_counter_hi = w_max.
        ENDIF.
      ENDWHILE.
    Considering the excel file would contain not more than 65536 records have coded like above...
    But the problem is sometimes the file may contain lesser records say 10000 records even then also the while ..endwhile executes to check the last record( until 65536 records)..
    pls help me to handle this..
    Thanks,
    Priya

    w_max = '65536'.
      w_counter_lo = '2'.    "Start on row 1 because of header row
      w_increment  = '9999'. "Increment by 9999 each loop
      w_counter_hi = w_counter_lo + w_increment.
    before reading your file you want to know how many rows are there in excel file. put this code here.
    TYPES:
       truxs_t_text_data(4096) TYPE c OCCURS 0.
      DATA:
         lv_var TYPE  truxs_t_text_data.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
        I_FIELD_SEPERATOR          =
        I_LINE_HEADER                   =
          i_tab_raw_data                   = lv_var
          i_filename                            = p_file  * path of file
        TABLES
          i_tab_converted_data        = t_record
      EXCEPTIONS
        conversion_failed            = 1
        OTHERS                           = 2 .
    here you will get all records in t_record internal table.
    IF sy-subrc <> 0.
        MESSAGE 'Error in Uploading the specified file.' TYPE 'I'.
    ELSE.
        DESCRIBE TABLE t_record LINES w_counter_hi
    ENDIF.
    refresh t_record.
    So, now you have no of lines in w_counter_hi variable.
    WHILE w_counter_hi <= w_max AND w_counter_lo <= w_max.
        " Clear the work area and the internal table to prevent duplicate rows
        CLEAR it_import_table.
        CALL FUNCTION 'ZPM_EXCEL_TO_INTERNAL_TABLE'
          EXPORTING
            filename                = p_file
            i_begin_col             = '1'
            i_begin_row             = w_counter_lo "we have a header row
            i_end_col               = '5'
            i_end_row               = w_counter_hi
          TABLES
            intern                  = it_import_table
          EXCEPTIONS
            inconsistent_parameters = 1
            upload_ole              = 2
            OTHERS                  = 3.
        "Increment our range
        w_counter_lo = w_counter_hi + 1.
        w_counter_hi = w_counter_lo + w_increment.
        "We SHOULD NOT scan any more than our max, so set our top end of the range
        "to the total number of rows to scan if the w_Counter_hi exceeds the max.
        IF w_counter_hi > w_max.
          w_counter_hi = w_max.
        ENDIF.
      ENDWHILE.
    Regards,
    PD

  • Need information on Dynamic internal table

    Hi All,
    I need some information on dynamic internal table.
    I want what are the field names and the values in dynamic internal table.
    Is there any function module, which tells us the field names and values of corresponding fields from a dynamic internal table ?
    Thank you very much in advance.

    Hi,
    Program to display/edit database tables dynamically.
    REPORT  zdyn_table_display.
    PARAMETERS: p_table TYPE tabname OBLIGATORY,
                p_rows  TYPE I.
    * Creation of dynamic internal table
    DATA: lv_dref             TYPE REF TO data.
    FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
    DATA: lv_table  TYPE  string.
    START-OF-SELECTION.
    * Dynamic internal table.
      CREATE DATA lv_dref       TYPE TABLE OF (p_table).
      ASSIGN lv_dref->* TO <fs_table>.
      IF sy-subrc  EQ 0.
    *    EXIT.
      ENDIF.
    data i type i.
    * Get the data
      SELECT  *
            FROM (p_table)
            UP TO p_rows ROWS
            INTO TABLE <fs_table>.
      CONCATENATE 'Table contents : ' p_table INTO lv_table.
    * display the table control.
      CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
        EXPORTING
          header            = lv_table
          tabname           = p_table
          no_button         = space
        TABLES
          table             = <fs_table>
        EXCEPTIONS
          no_more_tables    = 1
          too_many_fields   = 2
          nametab_not_valid = 3
          handle_not_valid  = 4
          OTHERS            = 5.
      IF sy-subrc  EQ 0.
        EXIT.
      ENDIF.
    Getting internal table definition 
    Try this...
    DATA : l_descr_ref TYPE REF TO cl_abap_structdescr.
    l_descr_ref ?= cl_abap_typedescr=>describe_by_data( itab ).
    Now l_descr_ref->components holds the entire list of fields in itab.
    Thanks & Regards,
    ShreeMohan

Maybe you are looking for