Only first record in internal table in output

Hi,
I have a requirement.
I loop at an internal table and that tabl (list_selected_records) records.
Loop at list_of_selected_nodes into wa_selected_nodes.
node = wa_selected_nodes-node_id.
node_level = wa_selected_nodes-node_level.
read table ex_list_of_texts
into wa_list_of_texts
with key node_id = node
binary search.
IF sy-subrc eq 0.
node_text = wa_list_of_texts-text.
ENDIF.
node_level = node_level - 1.
Selecting Text for Node selected (Business Scenario)
READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
BINARY SEARCH.
if sy-subrc = 0.
SELECT SINGLE TEXT FROM TTREET into texts WHERE ID EQ wa_all_nodes-tree_id
AND SPRAS EQ 'EN '.
IF NOT TEXTS IS INITIAL.
wa_final-texts = texts.
append wa_final to it_final.
CLEAR WA_FINAL.
endif.
endif.
endloop.
This is my code.
Now from the select single stmt i fetch a text and add it to be internal table . Once i fetch a one record the loop should be ended and a new iteration for for a second guid should start.
Once one record , first record is fetched for texts, only that shd appear in alv output but not other. but the loop should contnue for other fields. Please help
Thanks in Advance.
SS

Hi Swarna,
Use control event AT-NEW inside the loop. This event will triger only once for every new node_id.
Loop at list_of_selected_nodes into wa_selected_nodes.
AT-NEW node_id.
node = wa_selected_nodes-node_id.
node_level = wa_selected_nodes-node_level.
read table ex_list_of_texts
into wa_list_of_texts
with key node_id = node
binary search.
IF sy-subrc eq 0.
node_text = wa_list_of_texts-text.
ENDIF.
node_level = node_level - 1.
Selecting Text for Node selected (Business Scenario)
READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
BINARY SEARCH.
if sy-subrc = 0.
SELECT SINGLE TEXT FROM TTREET into texts WHERE ID EQ wa_all_nodes-tree_id
AND SPRAS EQ 'EN '.
IF NOT TEXTS IS INITIAL.
wa_final-texts = texts.
append wa_final to it_final.
CLEAR WA_FINAL.
endif.
endif.
ENDAT.
endloop.
Thanks & Regards,
Parameswaran.K

Similar Messages

  • Regarding Select query to select only 1000 records in Internal Table.

    Hello Friends,
    Please explain me to how to Select only 1000 records from data base table?
    For Example
    SELECT *  INTO TABLE ITAB                          OR            SELECT * INTO ITAB 
         FROM EKKO                                                                  FROM EKKO
    WHERE EBLEN IN S_EBLEN.                                            WHERE EBLEN IN S_EBLEN
    (Currently i am using)                                                       UP TO 1000 ROWS.
                                                                                    ENDSELECT.  (I do not want to use)
                                                                                    In this case Internal table may be store more then 1000 records. But i want to select first 1000 records.
    Please explain me.
    Regards
    Amit

    Hi,
    TABLES : ekko.
    selection-screen begin of block b1 with frame title text_t01.
    SELECT-OPTIONS: S_EBELN for ekko-EBELN.
    selection-screen end of block b1.
    DATA itab TYPE STANDARD TABLE OF ekko.
    SELECT *
      FROM ekko
      INTO TABLE itab
      UP TO 1000 ROWS
      WHERE EBELN IN S_EBELN.
    Thanks,
    Sri.

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • Inserting records from internal table to database table

    Hi all,
    i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
    1) insert one by one record from internal table
    loop at itab.
    insert ztable from wa.
    endloop.
    2) insert total records at a time
    INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or let me know if any other statement is there with high performance.
    i internal table contains nearly 40000 records.
    thanks.

    Hi,
    Insert the entire table at atime rather than a record so as to increase the performance.
    you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or
    MODIFY ZPRODUCT FROM TABLE GI_AFPO.
    Regards,
    Raj.

  • Client proxy.. passing internal table to output.

    Hi friends,
    I have created a proxy-JDBC scnario..
    For this i created a datatype with 2 fields..
    DT_Proxy_Outbound as complex type and 2 elements..and after that i have created a proxy class
    ZCO_MI_PROXY_OUTBOUND (Proxy class)
      ZMT_PROXY_OUTBOUND(structure)
    and i have writen a code in abap report to pass data to output parameter..
    but output parameter is of line type not a table type...
    so it is taking onley one value but not entire internal table to output parameter.
    i am including mycode here.
    REPORT  ZTEST_ABAP_PROXY.
    DATA PRXY TYPE REF TO ZCO_MI_PROXY_OUTBOUND.
    DATA: BEGIN OF I_MARA OCCURS 0,
      MATNR LIKE MARA-MATNR,
      ERNAM LIKE MARA-ERNAM,
      END OF I_MARA.
    CREATE OBJECT PRXY.
    DATA IT TYPE  ZMT_PROXY_OUTBOUND OCCURS 0 WITH HEADER LINE.
    TRY.
        SELECT MATNR ERNAM INTO TABLE I_MARA FROM MARA UP TO 10 ROWS.
        LOOP AT I_MARA.
          IT-MT_PROXY_OUTBOUND-MATNR = I_MARA-MATNR.
          IT-MT_PROXY_OUTBOUND-ERNAM = I_MARA-ERNAM.
          APPEND IT.
        ENDLOOP.
        CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
          EXPORTING
            OUTPUT = IT.
        COMMIT WORK.
      CATCH CX_AI_SYSTEM_FAULT .
        DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .
        CREATE OBJECT FAULT.
        WRITE :/ FAULT->ERRORTEXT.
    ENDTRY.
    where should i change structure so that output can accept total internal table rather than line item.
    Thnaks and Regards
    Vijay

    Hi Vijay,
    Try using the following code. I have used the variable ZDT_PROXY_OUTBOUND_TAB , which should appear in the zproxy transaction. The name may not be exactly correct, so please check and change accordingly. Check parameters of execute- asynchronous method. double click on associated type of output (ZMT..). You will get controller and Message type MT...Click on component type - ZDT.., you will get controller and a recordset( the name you have mentioned in your data type sender side). The corresponding component type would be the table ZDT_PROXY_OUTBOUND_TAB. Hope you understand and change accordingly.
    REPORT  ZTEST_ABAP_PROXY.
    TABLES : MARA.
    DATA PRXY TYPE REF TO ZCO_MI_PROXY_OUTBOUND.
    DATA: BEGIN OF I_MARA OCCURS 0,
      MATNR LIKE MARA-MATNR,
      ERNAM LIKE MARA-ERNAM,
      END OF I_MARA.
    DATA : REC_OUTPUT TYPE ZDT_PROXY_OUTBOUND_TAB,
         WA_REC_OUTPUT LIKE LINE OF REC_OUTPUT,
         MARA_OUTPUT TYPE ZMT_PROXY_OUTBOUND.
    CREATE OBJECT PRXY.
    TRY.
        SELECT MATNR ERNAM INTO TABLE I_MARA FROM MARA UP TO 10 ROWS.
        LOOP AT I_MARA.
          WA_REC_OUTPUT-MATNR = I_MARA-MATNR.
          WA_REC_OUTPUT-ERNAM = I_MARA-ERNAM.
          INSERT WA_REC_OUTPUT INTO TABLE REC_OUTPUT.
          CLEAR : WA_REC_OUTPUT, I_MARA.
        ENDLOOP.
         MARA_OUTPUT-MT_PROXY_OUTBOUND-RECORDSET = REC_OUTPUT.
        CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
          EXPORTING
            OUTPUT = MARA_OUTPUT.
        COMMIT WORK.
      CATCH CX_AI_SYSTEM_FAULT .
        DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .
        CREATE OBJECT FAULT.
        WRITE :/ FAULT->ERRORTEXT.
    ENDTRY.
    -Regards,
    Shamly

  • Computation only works for FIRST record in detail table

    Hi,
    I am having a weird problem. I have a master/detail form with page computations that work only for the very first record inserted into the detail table. If i try to enter a second or a third record the fields DO NOT get updated with the return values.
    This is driving me nuts and i am on a deadline with this project. HELP!!!!!
    Here is the code for all the computations below. Interestingly enough, only the name computation works for every new detail record. The others work only for the first.
    -- Calulate Social Security PL/SQL Function
    DECLARE
    p_is16to62ssrate NUMBER(6,2);
    p_u16o62ssrate NUMBER(6,2);
    p_dob DATE;
    p_base_date DATE := SYSDATE;
    p_age NUMBER(3);
    p_totalss NUMBER(9,2);
    BEGIN
    SELECT is16to62ssrate, u16o62ssrate
    INTO p_is16to62ssrate, p_u16o62ssrate
    FROM SSC3_RATES
    WHERE ratescheduleid = 1;
    SELECT dob
    INTO p_dob
    FROM SSC3_EMPLOYEES
    WHERE ssno = :P25_SSNO;
    p_age := TRUNC(MONTHS_BETWEEN(p_base_date,p_dob)/12);
    IF (p_age >= 16) OR (p_age <=62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
    ELSIF (p_age < 16) OR (p_age > 62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
    ELSE
    p_totalss := 0.00;
    END IF;
    RETURN p_totalss;
    END;
    -- Calculate Levy PL/SQL Function
    DECLARE
    -- declare local variables to hold rates from rates table
    p_hsdlarate NUMBER(6,2);
    p_hsdlbrate NUMBER(6,2);
    p_hsdlcrate NUMBER(6,2);
    p_hsdldrate NUMBER(6,2);
    p_hsdlaminearnings NUMBER(8,2);
    p_hsdlamaxearnings NUMBER(8,2);
    p_hsdlbminearnings NUMBER(8,2);
    p_hsdlbmaxearnings NUMBER(8,2);
    p_hsdlcminearnings NUMBER(8,2);
    p_hsdlcmaxearnings NUMBER(8,2);
    p_hsdldminearnings NUMBER(8,2);
    p_hsdldmaxearnings NUMBER(8,2);
    p_totalwages NUMBER(8,2);
    p_totallevy NUMBER(8,2);
    BEGIN
    -- Load rate info from table into variables
    SELECT hsdlarate, hsdlbrate, hsdlcrate, hsdldrate, hsdlaminearnings,
    hsdlamaxearnings, hsdlbminearnings, hsdlbmaxearnings,
    hsdlcminearnings, hsdlcmaxearnings, hsdldminearnings,
    hsdldmaxearnings
    INTO p_hsdlarate, p_hsdlbrate, p_hsdlcrate, p_hsdldrate,
    p_hsdlaminearnings, p_hsdlamaxearnings, p_hsdlbminearnings,
    p_hsdlbmaxearnings, p_hsdlcminearnings, p_hsdlcmaxearnings,
    p_hsdldminearnings, p_hsdldmaxearnings
    FROM SSC3_RATES
    WHERE ratescheduleid = 1;
    -- Assign total wages to variable
    p_totalwages := :P25_TOTALWAGES;
    -- Determine applicable levy payment and rate
    IF (p_totalwages < p_hsdlamaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlarate/100));
    ELSIF (p_totalwages >= p_hsdlbminearnings) AND (p_totalwages <= p_hsdlbmaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlbrate/100));
    ELSIF (p_totalwages >= p_hsdlcminearnings) AND (p_totalwages <= p_hsdlcmaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlcrate/100));
    ELSIF (p_totalwages >= p_hsdldminearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdldrate/100));
    END IF;
    RETURN p_totallevy;
    END;
    -- Calculate Total Wages PL/SQL Function
    DECLARE
    t_wages NUMBER(8,2);
    BEGIN
    t_wages := (:P25_WEEK1_WAGE + :P25_WEEK2_WAGE + :P25_WEEK3_WAGE + :P25_WEEK4_WAGE + :P25_WEEK5_WAGE + :P25_BONUS + :P25_OTHER);
    RETURN t_wages;
    END;
    -- Calculate Employee Name PL/SQL Function
    DECLARE
    p_firstname VARCHAR2(20);
    p_lastname VARCHAR2(20);
    p_name VARCHAR2(40);
    p_join VARCHAR2(2) := ', ';
    BEGIN
    SELECT firstname, lastname
    INTO p_firstname, p_lastname
    FROM SSC3_EMPLOYEES
    WHERE ssno = :P25_SSNO;
    p_name := Initcap(p_lastname||p_join||p_firstname);
    RETURN p_name;
    END;
    Regards
    Glenroy Skelton

    Hi,
    The first thing that strikes me is the following IF test:
    IF (p_age >= 16) OR (p_age <=62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
    ELSIF (p_age < 16) OR (p_age > 62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
    ELSE
    p_totalss := 0.00;
    END IF;The first test will be true for every number as all numbers are greater than 16 or less than 62. I'd suggest changing the OR to an AND or use BETWEEN
    Andy

  • Want last record in internal table

    Hi All,
    I have two internal table. in one internal table all data are available. now i want last record on first internal table and store in second internal table.... so give me some logic or sample code......
    Thanks
    zeni

    get the latest record from an internal table.
    if you are using function module RH_READ_INFTY_1001 then <itab
     > will always contain all the records betweebn specified period (taken from selection screen), but to retrieve the latest, sort the records by ENDDA and you will get it on top, then use INDEX 1 for that record only, and store the record in a <work_area>, finally get that record from <work_area> to <itab> it self. thats way your <itab> will hold only latest record.  
    (you can store <work_area> in <work_area_2> and then pass the record in to <itab>
    or, you can store the <work_area> to a different <itab_2>).
       call function RH_READ_INFTY_1001
       tables
          i1001         = it_hrp1001
      sort  it_hrp1001 by endda descending.
      read table it_hrp1001 into wa_hrp1001 INDEX 1.
      refresh it_hrp1001.
      append wa_hrp1001 to it_hrp1001.

  • How to upload the flat file records into internal table by position?

    Hi
    I have a flat file which has 7 records in each row and they are NOT provided with CSV or Tab demilited...
    They are continous text without spaces....
    but i know the fixed length of each field Eg : 1st field 7 char and seconc field 3 char and so on...
    How can i upload this file into internal table by reading positions of each field...I know we can use GUI_UPLOAD and Read dataset and Open dataset...
    But please let me know to read the file with the fixed postions and load into internal table...
    Thanks in advance
    MM

    Hi
    As per my knowledge i dont think thr is some function module or so to read with a fixed positions.
    You can use the below method if you think this is the best way.
    Suppose your file has
    types : begin of ty_itab,
                field1 type char7,
                field2 type char3,
                field3 type chat3,
                field4 type char3,
                end of ty_itab.
    types : begin of ty_upload,
                 str type string,
                end of ty_upload.
    data : it_itab type standatd table of ty_itab,
              it_upload type standard table ot ty_upload,
              wa_itab type ty_itab,
              wa_upload type ty_upload.
    use gui_upload.get the data in it_upload.
    here you know that u have first 16 charcters makes a first row n then next 16 charcters next row
      Loop at it_upload into wa_upload.
       v_len =  strlen ( wa_upload ).
       v_len = v_len / 16.
        You get number of rows per record ,if it is decimal value make it final value if 3.9 make to 4.
        do v_len times.
          wa_itab = wa_upload.
          By this only first 16 characters are moved and respective fields will get a value.or else u can use offset
           wa_upload+0(16).
          append wa_itab to it_itab.
          Now shift 16 characters using shift command in wa_upload.
        enddo.
      endloop.
    Hope this syntax help you to resolve your issue.May be something i have missed .Right now i don't have sap system to send you the full correct syntax code.
    Cheers
    Joginder

  • How to get multiple records from internal table through BDC

    PERFORM DYNPRO USING:
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_OKCODE'  '=NEWC',
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_CURSOR'  'PLPTU-PLWRK(01)',
      ' '  'BDC_OKCODE'  '=TAKE',
      ' '  'PLPTU-PLWRK(01)' '2531'. (2531 is a plant)
    This is the recording used to get plant via BDC of MS31.
    Using this code i can get only single plant...
    If i want to get multiple plants from an internal table,how i can change this code?
    Since it is a recording i cant put this code in LOOP..ENDLOOP.
    Suggest any method for doing this....
    Awaiting for ur reply...

    Hi,
    While recording also record the scroll down button.
    The you can place different plant in the BDC using loop and endloop
    Regards
    Arun

  • Regarding how to delete the record in internal table

    Hi experts ,
    how to delete the record in intarnal table after validating the data,
    if record contains invalid fields?
    i am giving my code see this and give me the answer?
    loop at it_data into wa_data .
    Validate  Cost Center
        READ TABLE it_kostl INTO wa_kostl WITH KEY kostl = wa_data-kostl BINARY SEARCH.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-004.
        ENDIF.
    Validate source file material ( material number )
    loop at it_mara into wa_mara .
      read table it_ausp into wa_ausp with key atwrt = wa_data-i_matnr .
               if sy-subrc NE 0 .
       PERFORM update_error_log USING wa_data
                                           text-002.
    delete it_data-objek .
         else.
      read table it_mara into wa_mara with key  matnr = wa_ausp-objek .
           if sy-subrc EQ 0 .
           wa_data-objek = wa_mara-matnr.
           wa_data-matkl = wa_mara-matkl.
         ENDIF.
         Modify it_data from wa_data  .
      endif.
    *endloop.
    Validate unit of measure (unit)
        READ TABLE it_t006 INTO wa_t006 WITH KEY msehi = wa_data-unit .
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-003.
        endif.
    Validate delivery location ( storage location )
        READ TABLE it_lgort INTO wa_lgort WITH KEY del_loc = wa_data-del_loc.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-001.
             if wa_data-flag ='x' .
          delete it_data from  wa_data .
        endif.
        ENDIF.
    endloop.

    Hi Naren,
    First get the index number of the IT_data table and store it in one variable whose declaration like this.
    data: tabix type sy-tabix.
    while reading the internal table it_data set the tabix variable.
    tabix = sy-tabix.
    Instead of  the above use below one.
    Delete it_data-objek
    Use the Below statement it will delete  the row from the internal table.
    Delete it_data-objek index tabix
    Thanks,
    Chidanand

  • Excel attachment contains only 1st row of Internal Table.

    Hello,
    I have designed a Vendor Ledger report and want to send the same as an excel attachment. I have made use of function module SO_NEW_DOCUMENT_ATT_SEND_API1 wherein I pass the parameters.
    The program works perfectly fine as I am receiving email along with the excel attachment. Also, the excel attachment opens without any errors. Also, the alignment of columns and data is perfect.
    But the problem is if my internal table is having 10 rows, I get only the first row of  the internal table in the excel sheet.
    I also put a break point just before calling the function module to send email, I could see that the internal table which contains the attachment is having all 10 rows.
    I really don't know what's going wrong in this.
    Request you to please help.
    Regards,
    Danish.

    Hi,
    Hi this is my code. Also, one thing I found that if i remove the Report Name i.e. "Vendor Ledger" , I get more than 1 row in my excel sheet. I feel there is some problem with the document size attributes.
    * Header for exception report
      CONCATENATE 'CC' 'Vendor' 'Stat' 'Name' 'Doc.No' 'FY' 'DDate' 'PDate'
                  'AssNo.' 'Doc.Tp' 'G/L' 'LAmt' 'LCurr' 'DAmt'
                  'D/C' 'Cl.Doc' 'TaxCd' 'TaxAmt'
                  INTO it_attachment SEPARATED BY
                  cl_abap_char_utilities=>horizontal_tab.
      CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO it_attachment.
      APPEND it_attachment.
    * Split Internal table data using horizontal tab.
      CLEAR it_main.
      LOOP AT it_main.
        CLEAR: lc_amt, dc_amt, tax_amt.
        lc_amt = it_main-lc_amount.
        dc_amt = it_main-amt_doccur.
        tax_amt = it_main-w_tax_base.
        CONCATENATE it_main-comp_code
                    it_main-vendor
                    it_main-status
                    it_main-name1
                    it_main-doc_no
                    it_main-fisc_year
                    it_main-doc_date
                    it_main-pstng_date
                    it_main-alloc_nmbr
                    it_main-doc_type
                    it_main-sp_gl_ind
                    lc_amt
                    it_main-loc_currcy
                    dc_amt
                    it_main-db_cr_ind
                    it_main-clr_doc_no
                    it_main-w_tax_code
                    tax_amt
                INTO it_attachment SEPARATED BY
                cl_abap_char_utilities=>horizontal_tab.
        CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO it_attachment.
        APPEND it_attachment.
      ENDLOOP.
    * Create Mail Body and Attachment.
      psubject = 'Vendor Ledger'.
      lv_message = 'Dear Sir/Madam,'.
      APPEND lv_message TO it_message.
      lv_message = ' '.
      APPEND lv_message TO it_message.
      lv_message = 'Attachment contain Vendor Ledger for Testing.'.
      APPEND lv_message TO it_message.
      lv_message = ' '.
      APPEND lv_message TO it_message.
      lv_message = ' '.
      APPEND lv_message TO it_message.
      lv_message = 'This is a System Generated Mail. Please do not reply.'.
      APPEND lv_message TO it_message.
    **Perform for populating mail characteristic info
      CLEAR gd_doc_data.
    * Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      READ TABLE it_attachment INDEX w_cnt.
      gd_doc_data-doc_size = 1.
      gd_doc_data-obj_name  = 'Danish'. "'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    * Describe the body of the message
      CLEAR it_packing_list.
      REFRESH it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES it_packing_list-body_num.
      it_packing_list-doc_size = it_packing_list-body_num * 255.
      it_packing_list-doc_type = 'RAW'.
      APPEND it_packing_list.
    **Describe the attachment info
      CLEAR it_packing_list.
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_attachment LINES  it_packing_list-body_num.
      it_packing_list-doc_type = 'XLS'.
      it_packing_list-obj_name = 'File'.
      it_packing_list-obj_descr = 'File'.
      it_packing_list-doc_size = it_packing_list-body_num * 255.
      APPEND it_packing_list.
      REFRESH it_receivers.
      CLEAR it_receivers.
      it_receivers-receiver = 'Email Address'.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      APPEND it_receivers.
    **Function Module to send mail
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = gd_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_packing_list
          contents_bin               = it_attachment
          contents_txt               = it_message
          receivers                  = it_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    Regards,
    Danish.

  • Delete records in internal table

    Hi,
    I have two internal tables  itab1 and itab2.
    I need to delete records from itab1 comparing the data from itab2. I tried to use the read statement within the main table.
    My problem is itab2  and itab1 has multiple records and all the records need to be checked from itab2 with itab1 before deleting the records from itab1.
    itab1 and itab2 have a common field 'runid' between them.
    How can this be accomplished?
    Thanks,
    VG

    >
    Venkat.O wrote:
    > Hi VG,
    > Try this way.
    >
    > data: tabix type sy-tabix.
    > loop at itab1.
    >   tabix = sy-tabix.
    >  _LOOP at itab2 where runid = itab1-runid._
    _>  if sy-subrc NE 0._
    >   delete itab1 index tabix.
    >  endif.
    > endloop.
    >
    > Thanks
    > Venkat.O
    Venkat, inside a loop a IF SY-SUBRC NE 0 doesn't make sense because you are in the loop only after the condition in WHERE clause is satisfied (which means SY-SUBRC is always 0). Also you are missing another ENDLOOP.

  • To find the duplicate record in internal table

    Hi,
    i have a requirement to fine the duplicate record with 3 fields.
    i am getting a flat file with 15 fields  .
    i need to check the duplaicate records of  3 fields . if i get any 2nd same record of 3 fields , the records will go to other internal table.
    for ex :
    1. aaa  bbb ccc ddd  eee  fff  ggg   hhh
    2. aaa  bbb ccf  dde edd  ffg ggh   hhj
    3. aaa  bbb cce ddd  ees ffh  ggu  hhk
    in that 1st record and 3rd record are same (aaa bbb ddd)
    i need to find 3rd record
    please help me
    regrards
    srinivasu

    hi,
    itab2[] = itab1[].
    sort itab1 by f1 f2 f3.
    sort itab2 by f1 f2 f3.
    delete itab2 index 1.   "to delete the first record in itab2.
    loop at itab1 into ws_itab1.
      loop at itab2 into ws_itab2.
       if ws_itab1-f1 = ws_itab2-f1 and
         ws_itab1-f2 = ws_itab2-f2 and
        ws_itab1-f3 = ws_itab2-f3.
         ws_itab3 = ws_itab2.
         append ws_itab3 into itab3.   "Third internal table.
       endif.
    endloop.
    delete itab2 index 1.   
    endloop.
    ITAB3 will have all the duplicate records.
    Regards,
    Subramanian

  • Duplicate records in Internal table

    Hi All,
    I want to find out the duplicate entry in the internal table. I have used,
    Delete Adjacent duplicates from itab.
    It is straight away deleting the record.
    I want the user to correct that duplicate record.
    May be some error message.
    I have tried, with read,
    Read table itab with key bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr comparing bzirk vkorg kunnr matnr.
    But it's giving sy-subrc = 0 for the first record also.
    Even, I have tried like, but it's giving syntax error.
    Loop at itab where bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr.
    Endloop.
    Any method in case on Table control entries.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP Consultant

    Hi,
    Create a new internal table and assign the all the records of itab1 to itab2.
    1.Sort Itab2.
    2.delete adjacent duplicates.
    3. loop at itab2.
         loop at itab1 where <conditon you want....>
         count = count + 1.
         endloop.
          if count GT 1.
            append the iatb2 records for user correction....
          endif.
       endloop.
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

Maybe you are looking for

  • Decimal places in Pur docs - URGENT

    Hi We have requirement in our project where we need to accomodate 4 decimal places in the PRICE field instead of the 2. For example we load an item from catalogs or external supplier site, where the price is 75.3492 the price gets rounded off to 75.3

  • How to use group by in tabular form

    Hi all i have a tabular form and i need to issue the goods not more then five and in 1 row i will issue only 1 qty so i use only five rows . but by mistake i will use 6 rows then it is wrong how to restrict it please guide Thanks and Regards vikas

  • Problem with formatting failure caption...

    This might be a bug or a bad Captivate file. Project file (one of 17) has sucess and failure captions. Set the Failure as adobe red/ verdana 12. On day 1 I do this and all is well. On day 3 I open this file and find the failure caption set to adobe r

  • How to connect MyLink in Bluetooth settings

    How do I get MyLink in Bluetooth setting to conect on my iPhone 5S

  • Account Entries Relsted to SD CIN

    Dear All, When i make invoice and post to account it gives right entries like Customer A/c Debited & Sales A/c , Cenvat Suspense A/c , VAT A/c Credited.   But when i creat Excise Invoice in J1IIN with reference to same Billing Document, after creatio