Append data to table1 from data in table 2 if conditiona are met

I need to append text from one table to another if the field in not empty and only for spacific file numbers.
This is what I have so far but I'm missing something.....
SQL> update apprj a
2 set a.comment = a.comment || 'Part of the file is in'|| b.deadbox
3 where a.apno in ('1a',
4 '1b',
5 '1c')
6 and
7 a.apkey in
8 (select b.apkey
9 from sub b
10 where b.deadbox is not null)
11 ;
set a.comment = a.comment || 'Part of the file is in'|| b.deadbox
ERROR at line 2:
ORA-01747: invalid user.table.column, table.column, or column specification
Any ideas? Thanks as always

What version of oracle are you using? What version of sqlplus? The error is coming from sqlplus, so it is possible you have a really old version of sqlplus. If your version of sqlplus matches your database version, then you also have a really old version of Oracle. As I recall, the merge command was introduced in 9i.
If you are using something earlier, then you may need to use something like:
update apprj a
set a.comment = a.comment || (select 'Part of the file is in'|| b.deadbox
                              from sub b
                              where a.apkey = b.apkey and
                                    b.deadbox is not null)
where a.apno in ('1a', '1b', '1c') and
      exists (select 1 from sub b
              where a.apkey = b.apkey and
                    b.deadbox is not null)or if sub.apkey is declared unique (or can be declared unique), then:
update (select a.apkey, a.comment, b.deadbox
        from apprj a, sub b
        where a.apkey = b.apkey and
              b.deadbox is not null and
              a.apno in ('1a', '1b', '1c'))
set commment = comment||'Part of the file is in'||b.deadbox;Note that prior to 10G, the merge statement requires both a when matched and a when not matched clause.
John

Similar Messages

  • How to read the data from an internal table,when column names are known

    Hi All
    I have a specific requirement. I got an internal table with many fields (let it be my_tab).  Some of the fieldnames (column names in internal table my_tab) are stored in separate internal table(let it be my_fields).
    I need to store/read data corresponding to the fields (whose name is stored in my_fields) from my_tab.
    I am able to build dynamic table (referred by field-symbol) with respect to the given field names in my_fields.
    But i am unable to read the data corresponding to the fieldnames from my_tab.
    Please provide  me some pointer in this regard.
    Regards
    Swetabh Shukla

    HI All
    Thanks for the prompt response. I got solution for my question. Please check below thread. For quick reponse i posted my question in one more category. Thanks to all of you.
    How to read internal table w.r.t. fieldnames stored in other table

  • Regarding appending data in table type

    Hello Experts,
    Actually, I have one structure and in that I am using one table type .
    e.g. in the main structure, fields are as follows,
      po_number   po_line_item_no  gr_details
    here gr_details is table type having following fields.
      gr_number gr_qty gr_date
    As we all know that one po can have multiple GR,
    I want to append entries in the above structure in such a way that for one po entry , in the same record , multiple Gr entries should come.
    I am doing one program , in it is mendatory.
    can anyone please revert back on the same with High Priority ( Coding in Program to append values as per explained above ).
    Best Regards,
    Rashmi.

    Hi!
    For the same PO entry multiple GRs in same record is not possible. But you can have multiple GR entries in your internal table with same PO details.
    For eg. If you have one PO with 4 GRs then you will have 4 lines in internal table that belong to same PO but different GRs. In this case PO details would be redundant.
    To read these values into internal table
    1. You can read the GR details into corresponding columns of internal table and then update the PO columns for these records.
    2. The other bit diffcult way could be to read all PO details into internal table. Then loop at internal table for each PO find out the no. of GRs. If it has N no of GRs then add (N-1) rows with same PO details and different GR details and update the N the GR detail into the existing row of the internal table. If it has only 1 GR then update the existing line. If PO has no GR then delete the table line.
    Reward points for all the useful answers.

  • Delete duplicate entriess from the internal table its urgent pls help.

    Hi friends,
    Hope everybody is doing good,Here is m query on delete duplicate data from the intenal table.
    I have an internal table which contain data in the following format.
    Doc No Comp Cod Vendor Assignment
    1500000009 JM11 00000000
    1500000008 JM11 20070212(Repeating)
    1500000007 JM11 20070212
    1500000006 JM11 00000000
    1500000005 JM11 00000000
    1500000004 JM11 00000000(Repeating)
    1500000003 JM11 00000000 (Repeating)
    1500000002 JM11 00000000
    1500000001 JM11 20050302
    1500000000 JM11 00000000
    1500000003 JM11 10000088
    1500000001 JM11 10000088
    1500000030 JM11 10006260
    1500000010 JM11 10006269
    1500000008 JM11 10006269
    1500000006 JM11 10006269
    1500000004 JM11 10006269
    if you see the document numbers,there are some document number which are repeating here,there are some document numer which contain vendor number but not the assignments,some of the document numbers contain the assignments but not the vendors.
    If my internal table contain this kind of data with repeted document numbers than i want the document number which contains only the vendor number.
    Pls help me with the appropriate logic,its urgent.
    Thanks a lot
    mrutyun^

    Hi,
    <u><b>Deleting Adjacent Duplicate Entries</b></u>
    To delete adjacent duplicate entries use the following statement:
    DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
    [COMPARING <f1> <f2> ...
    |ALL FIELDS].
    The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are
    duplicate if they fulfill one of the following compare criteria:
      Without the COMPARING addition, the contents of the key fields of the table must be
    identical in both lines.
      If you use the addition COMPARING <f1> <f2> ... the contents of the specified fields <f1>
    <f2> ... must be identical in both lines. You can also specify a field <fi> dynamically as
    the contents of a field <ni> in the form (<ni>). If <ni> is empty when the statement is
    executed, it is ignored. You can restrict the search to partial fields by
    specifying offset and length.
      If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines
    must be identical.
    You can use this statement to delete all duplicate entries from an internal table if the table is
    sorted by the specified compare criterion.
    If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.
    Examples
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.
    DO 4 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    LINE-COL1 = 1.
    DELETE TABLE ITAB: FROM LINE,
    WITH TABLE KEY COL1 = 3.
    LOOP AT ITAB INTO LINE.
    WRITE: / LINE-COL1, LINE-COL2.
    ENDLOOP.
    The output is:
    2    4
    4   16
    The program fills a hashed table with a list of square numbers. The DELETE
    statement delete the lines from the table where the key field COL1 has the contents 1 or 3.
    Regards,
    Bhaskar

  • Appending data from one table to another

    Hello
    How to append data from one table t1 to another table t2.
    t1 and t2 have the same structures .
    t2 contains already data so i don't want do delete it and create it as select * from t1.
    If there is a mean to add t1 content without altering t2 content.
    Thanks in advance

    insert into t2
      select * from t1

  • Urgent - Append data to internal table from Application server

    Hi All,
    I encountered the problem while read the input file from Application server...then append it to internal table. I manage to read the input file from presentation and append the data to internal table.
    Below are my coding which cause me not able the append data from Application server. Please kindly help me to solving/correct my coding. Thanks in advance .
    PARAMETERS : p_inpfl LIKE rlgrap-filename.  "Material Input File
    SELECTION-SCREEN BEGIN OF LINE.
    Application Server
    SELECTION-SCREEN COMMENT 1(19) text-002 FOR FIELD rb_ux.
    SELECTION-SCREEN POSITION 33.
    PARAMETERS: rb_ux RADIOBUTTON GROUP g1.
    Presentation Server
    SELECTION-SCREEN COMMENT 40(21) text-003 FOR FIELD rb_pc.
    SELECTION-SCREEN POSITION 65.
    PARAMETERS: rb_pc RADIOBUTTON GROUP g1 DEFAULT 'X'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN  SKIP.
    SELECTION-SCREEN END OF BLOCK b01.
    FORM f_Input_file.
      CLEAR: v_f_exists.
      CHECK NOT p_inpfl IS INITIAL.  "input file exist
      IF NOT rb_pc IS INITIAL.  " Pc check
        PERFORM f_read_tab_delimited_file TABLES i_input
                               USING    c_09
                                        p_inpfl
                                        rb_ux
                               CHANGING v_ifile_str_with_tab
                                        v_f_exists
                                        v_ifile_record_count
                                        v_message.
        IF v_f_exists EQ '1' .
      UPLOAD FILE could not be read
          MESSAGE e546 .
        ENDIF .
        IF v_ifile_record_count EQ 0 .
      Zero records in upload file
          MESSAGE e547 .
        ENDIF.
      ELSE.
        OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.
        DO.
          READ DATASET p_inpfl INTO i_input.
          IF sy-subrc EQ 0.
            APPEND i_input.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        CLOSE DATASET p_inpfl.
      ENDIF.

    Hi,
    Refere the following code for the poulating internal from the application server.
    PARAMETERS :  pr_sfile TYPE  filename-fileintern,
    Here give the logical file name from the application serevr.
    data :        w_param_1 LIKE  filename-fileintern,
                   x_file(500),
                   w_move_file LIKE  epsf-epsfilnam,
                   w_from_dir  LIKE epsf-epsdirnam,
                   w_path LIKE rlgrap-filename,
                  input_line(1000),
                  w_path LIKE rlgrap-filename,
                  w_file LIKE rlgrap-filename,
                  w_dir LIKE  rlgrap-filename,
                  w_dir1 LIKE epsf-epsdirnam,
                  w_file1 LIKE  epsf-epsfilnam,
    **************Start of the code***************
      MOVE '*' TO w_param_1.
      PERFORM get_file_name USING pr_sfile w_param_1.
        LOOP AT it_file WHERE name CP w_file1.
          CLEAR : x_file, w_path,
                  w_move_file, w_from_dir.
          REFRESH : it_input,
                    it_input_err.
       IF w_flag IS INITIAL.
          CONCATENATE w_dir it_file-name INTO x_file.
          CONDENSE  x_file.
    TO Move file from sever for backup storing the file name and path
          w_path = x_file.
          CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
            EXPORTING
              full_name     = x_file
            IMPORTING
              stripped_name = w_move_file
              file_path     = w_from_dir
            EXCEPTIONS
              x_error       = 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.
    ********here it_input will be the structure of the file present on the application server
          PERFORM read_file TABLES it_input
                            USING  x_file.
          CLEAR it_input_err.
          REFRESH it_input.
        ENDLOOP.
    *******************end of the code****************
    *&      Form  read_file
          text
         -->P_X_FILE  text
    FORM read_file  TABLES it_tab
                    USING  x_file.
      OPEN DATASET x_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        WRITE : / text-006.
      ELSE.
        DO.
          READ DATASET x_file INTO input_line.
          IF sy-subrc = 0.
            CLEAR: it_input, count.
            DO.
              ADD 1 TO count.
              ASSIGN COMPONENT count OF STRUCTURE it_tab TO <fs>.
              IF sy-subrc = 0.
                SPLIT input_line AT separator INTO <fs> input_line.
              ELSE.
                EXIT.
              ENDIF.
            ENDDO.
            APPEND it_tab.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
      ENDIF.
      CLOSE DATASET x_file.
    *&      Form  get_file_name
          text
         -->P_P_SFILE  text
         -->P_W_PARAM_1  text
    FORM get_file_name USING    p_sfile
                                w_param_1.
                               CHANGING x_file.
      CALL FUNCTION 'FILE_GET_NAME'
        EXPORTING
          client           = sy-mandt
          logical_filename = p_sfile
          parameter_1      = w_param_1
        IMPORTING
          file_name        = x_file
        EXCEPTIONS
          file_not_found   = 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.
      w_path = x_file.
      CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
        EXPORTING
          full_name     = w_path
        IMPORTING
          stripped_name = w_file
          file_path     = w_dir
        EXCEPTIONS
          x_error       = 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.
      w_dir1 = w_dir.
      w_file1 = w_file.
      CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
        EXPORTING
          dir_name               = w_dir1
          file_mask              = w_file1
        TABLES
          dir_list               = it_file
        EXCEPTIONS
          invalid_eps_subdir     = 1
          sapgparam_failed       = 2
          build_directory_failed = 3
          no_authorization       = 4
          read_directory_failed  = 5
          too_many_read_errors   = 6
          empty_directory_list   = 7
          OTHERS                 = 8.
      IF sy-subrc <> 0.
        WRITE : / text-006.
      ENDIF.
    Hope this will help you.

  • Appending data from amultiple internal tables

    Hi Experts,
    I need to append data from more than one internal tables to one internal table. But the internal tables has different structure.
    For example, I have internal tables I_A550 table which has field KNUMH, and I_A573 which has same filed KNUMH. Same way I have 25 tables, and all have KNUMH field.
    Now I have taken an internal table I_AXXX which has only one field KNUMH. I need to transfer data from all those 25 tables to I_AXXX.
    I wrote code as below.
    LOOP AT I_A550
       MOVE I_A550-KNUMH to I_AXXX-KNUMH.
       APPEND I_AXXX.
    ENDLOOP.
    LOOP AT I_A573.
        MOVE I_A573-KNUMH to I_AXXX-KNUMH.
        APPEND I_AXXX.
    ENDLOOP.
    But instead of writing 25 loops, is there any way we can simplify this?
    Thanks in advance.

    Hi,
    Just use field-symbols for your purpose as follows:-
    See the example below
    TYPES: BEGIN OF y_t_final,
           matnr TYPE matnr,
           END OF y_t_final.
    TYPES: y_tt_final TYPE STANDARD TABLE OF y_t_final.
    data : WA_mara type mara,
           wa_mard type mard.
    DATA : itab  TYPE STANDARD TABLE OF mara.
    DATA : itab1 TYPE STANDARD TABLE OF mard.
    DATA : it_final TYPE STANDARD TABLE OF y_t_final.
    DATA : wa_final TYPE y_t_final.
    wa_mara-matnr = '1'.
    append wa_mara to itab.
    wa_mard-matnr = '2'.
    append wa_mard to itab1.
    PERFORM f_loop USING  itab
                   CHANGING it_final.
    PERFORM f_loop USING  itab1
                   CHANGING it_final.
    The code inside the perform is as follow:-
    FORM f_loop  USING    p_itab TYPE ANY TABLE
                 CHANGING p_it_final TYPE y_tt_final.
      FIELD-SYMBOLS : <fs>     TYPE ANY TABLE,
                       <wa>    TYPE ANY,
                       <field> TYPE ANY.
      DATA: l_data TYPE REF TO data.
      ASSIGN p_itab TO <fs>.
      IF <fs> IS ASSIGNED.
        CREATE DATA l_data LIKE LINE OF <fs>.
        ASSIGN l_data->* TO <wa>.
        IF <wa> IS ASSIGNED.
          LOOP AT <fs> INTO <wa>.
            ASSIGN component 'MATNR' of structure <wa> TO <field>.
            IF <field> IS ASSIGNED.
              MOVE <field> TO wa_final-matnr.
              append wa_final to p_it_final.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDFORM.
    I hope you can understand the concept.
    Regards,
    Ankur Parab

  • How to append data from an internal table to an external table.

    HI everyone,
    I am trying to update an DB table type 'c'from the data captured in my internal table. can any one tell me as to how to do this.the contents of the DB table needs to be erased completly before i send in new data.
    Regards,
    Vj

    Assuming that you table has 1 character field(?) besides the MANDT field
    MANDT
    FIELD
    you need to update this db table with values from ITAB which I assume has one field of type c.
    To first delete all of the data from DB table.
    * Yes there are other ways of doing this.
    tables: ztable.
    select * from ztable.
    delete ztable.
    endselect.
    Then simply LOOP your internal table and update the table.
    loop at itab.
      ztable-field = itab-field.
      insert ztable.
    endloop.
    Regards,
    Rich Heilman

  • Copy data from 4 internal tables

    Hi Experts,
    I need to split a database field into 2 separate fields on the frontend and display it in an alv report.
    For this i used 4 internal tables. first one for regular fields and rest 3 of them for the split fields.
    Now the problem is, if i use 1 loop and insert workarea in it, the second record overwrites the first and if i use 3 internal tables, the looping is improper and it gives me duplicate entries in the report.
    delete adjacent duplicate is also not working.
    i am pasting the code. kindly help.
    thx
    *& Report  YVENDRALVRPTFINAL
    REPORT  YVENDRALVRPTFINAL.
      TYPE-POOLS: SLIS.
        DATA: program LIKE sy-repid.
        DATA: fcat TYPE slis_fieldcat_alv.
        DATA: fieldcat TYPE TABLE OF slis_fieldcat_alv.
        DATA: layout TYPE slis_layout_alv.
        Tables: LFA1,
                LFB1,
                T002T.
    DATA: Begin of itab1 occurs 0,
               LIFNR LIKE LFA1-LIFNR,
               BUKRS LIKE LFB1-BUKRS,
               KTOKK LIKE LFA1-KTOKK,
               ANRED LIKE LFA1-ANRED,
               NAME1 LIKE LFA1-NAME1,
               SORTL LIKE LFA1-SORTL,
             STRAS LIKE LFA1-STRAS, " HOUSE and STREET NUMBER
             STRAS1 LIKE LFA1-STRAS," STREET NUMBER
               PSTLZ LIKE LFA1-PSTLZ,
               ORT01 LIKE LFA1-ORT01,
               REGIO LIKE LFA1-REGIO,
               LAND1 LIKE LFA1-LAND1,
               SPTXT LIKE T002T-SPTXT,
             TELF1 LIKE LFA1-TELF1,
             TELF2 LIKE LFA1-TELF2,
             TELFX LIKE LFA1-TELFX,
             TELTX LIKE LFA1-TELTX,
               SMTP_SRCH LIKE ADR6-SMTP_SRCH,
               STCEG LIKE LFA1-STCEG,
               BRSCH LIKE LFA1-BRSCH,
          END OF itab1.
    DATA: wrkarea1 LIKE LINE OF itab1.
          DATA: Begin of itab2 occurs 0,
               LIFNR LIKE LFA1-LIFNR,
               BUKRS LIKE LFB1-BUKRS,
               KTOKK LIKE LFA1-KTOKK,
               ANRED LIKE LFA1-ANRED,
               NAME1 LIKE LFA1-NAME1,
               SORTL LIKE LFA1-SORTL,
             STRAS LIKE LFA1-STRAS, " HOUSE and STREET NUMBER
             STRAS1 LIKE LFA1-STRAS," STREET NUMBER
               STR LIKE LFA1-STRAS,
               HOU LIKE LFA1-STRAS,
               PSTLZ LIKE LFA1-PSTLZ,
               ORT01 LIKE LFA1-ORT01,
               REGIO LIKE LFA1-REGIO,
               LAND1 LIKE LFA1-LAND1,
               SPTXT LIKE T002T-SPTXT,
              *TELF1 LIKE LFA1-TELF1,
             PHONE  LIKE LFA1-TELF1,
               PHONE_EXT  LIKE LFA1-TELF1,
              *TELFX LIKE LFA1-TELFX,
               FAX LIKE LFA1-TELFX,
               FAX_EXT LIKE LFA1-TELFX,
             * TELTX LIKE LFA1-TELTX,
               SMTP_SRCH LIKE ADR6-SMTP_SRCH,
               STCEG LIKE LFA1-STCEG,
               BRSCH LIKE LFA1-BRSCH,
          END OF itab2.
          DATA: wrkarea2 LIKE LINE OF itab2.
         DATA:    STREET1 TYPE STRING,
                  HOUSE1 TYPE STRING,
                  PHONE1 TYPE STRING,
                  PHONE_EXT1 TYPE STRING,
                  FAX1 TYPE STRING,
                  FAX_EXT1 TYPE STRING.
         DATA:  BEGIN OF ADRDTL,
                HOU TYPE LFA1-STRAS,
                STR TYPE LFA1-STRAS,
                PHONE TYPE LFA1-TELF1,
    *PHONE_EXT  TYPE LFA1-TELF1,
    *FAX TYPE LFA1-TELFX,
    *FAX_EXT  TYPE LFA1-TELFX,
    *END OF ADRDTL.
           DATA: BEGIN OF itabhs occurs 0,
                 HSESTREET LIKE LFA1-STRAS,
                 END OF itabhs.
           DATA: wahs LIKE LINE OF itabhs.
            DATA:  BEGIN OF itabph occurs 0,
                   PHONENPHEXT TYPE LFA1-TELF1,
                   END OF itabph.
            DATA: waph LIKE LINE OF itabhs.
            DATA:  BEGIN OF itabfx occurs 0,
                   FAXNFAXEXT TYPE LFA1-TELFX,
                   END OF itabfx.
            DATA: wafx LIKE LINE OF itabhs.
          DATA: THREE LIKE LINE OF itab2,
                 FOUR LIKE LINE OF itab2.
              DATA:  THREE TYPE  LFA1-STRAS,
              FOUR  TYPE  LFA1-STRAS.
    SELECT-OPTIONS vendor FOR LFA1-LIFNR.
    *parameter vendor type LFA1-LIFNR.
      DATA:  wa LIKE LFA1-STRAS,
             wa1 LIKE LFA1-STRAS,
             wa2 LIKE LFA1-STRAS.
      DATA: BEGIN OF itabhsnew occurs 0,
                 STR LIKE LFA1-STRAS,
                 HOU LIKE LFA1-STRAS,
           END OF itabhsnew.
      DATA: wahsnew LIKE LINE OF itabhsnew.
      DATA: BEGIN OF itabphnew occurs 0,
                 PHONE LIKE LFA1-TELF1,
                 PHONE_EXT LIKE LFA1-TELF1,
           END OF itabphnew.
      DATA: waphnew LIKE LINE OF itabphnew.
      DATA: BEGIN OF itabfxnew occurs 0,
                 FAX LIKE LFA1-TELFX,
                 FAX_EXT LIKE LFA1-TELFX,
           END OF itabfxnew.
      DATA: wafxnew LIKE LINE OF itabfxnew.
    START-OF-SELECTION.
    SELECT LFA1STRAS FROM LFA1 INTO TABLE itabhs where LFA1LIFNR IN vendor.
    LOOP at itabhs into wahs.
    SPLIT wahs AT SPACE INTO STREET1 HOUSE1 .
    MOVE STREET1 TO wahsnew-STR.
    MOVE HOUSE1 TO wahsnew-HOU.
    INSERT wahsnew INTO TABLE itabhsnew.
    ENDLOOP.
    SELECT LFA1TELF1 FROM LFA1 INTO TABLE itabph where LFA1LIFNR IN vendor.
    LOOP at itabph into waph.
    SPLIT waph AT '-' INTO PHONE1 PHONE_EXT1.
    MOVE PHONE1 TO waphnew-PHONE.
    MOVE PHONE_EXT1 TO waphnew-PHONE_EXT.
    INSERT waphnew INTO TABLE itabphnew.
    ENDLOOP.
    SELECT LFA1TELFX FROM LFA1 INTO TABLE itabfx where LFA1LIFNR IN vendor.
    LOOP at itabfx into wafx.
    SPLIT wafx AT '-' INTO FAX1 FAX_EXT1.
    MOVE FAX1 TO wafxnew-FAX.
    MOVE FAX_EXT1 TO wafxnew-FAX_EXT.
    INSERT wafxnew INTO TABLE itabfxnew.
    ENDLOOP.
    *MOVE STREET1 TO ADRDTL-STR.
    *MOVE HOUSE1 TO ADRDTL-HOU.
    *MOVE PHONE1 TO ADRDTL-PHONE.
    *MOVE PHONE_EXT1 TO ADRDTL-PHONE_EXT.
    *MOVE FAX1 TO ADRDTL-FAX.
    *MOVE FAX_EXT1 TO ADRDTL-FAX_EXT.
    SELECT LFA1LIFNR  LFB1BUKRS LFA1KTOKK LFA1ANRED LFA1~NAME1
    LFA1SORTL LFA1PSTLZ LFA1ORT01 LFA1REGIO
    LFA1~LAND1
    T002T~SPTXT
    LFA1TELF1 LFA1TELF2 LFA1TELFX LFA1TELTX
    ADR6~SMTP_SRCH
    LFA1STCEG LFA1BRSCH
    FROM LFA1
    INNER JOIN T002T ON LFA1SPRAS = T002TSPRSL AND T002T~SPRAS = 2
    INNER JOIN LFB1 ON LFA1LIFNR = LFB1LIFNR
    INNER JOIN ADR6 ON LFA1ADRNR = ADR6ADDRNUMBER
    INTO TABLE itab1 WHERE LFB1~LIFNR IN vendor.
    LOOP AT itab1 INTO wrkarea1.
    MOVE-CORRESPONDING wrkarea1 TO wrkarea2.
    *MOVE STREET1 TO wrkarea2-STR.
    *MOVE HOUSE1 TO wrkarea2-HOU.
    *MOVE PHONE1 TO wrkarea2-PHONE.
    *MOVE PHONE_EXT1 TO wrkarea2-PHONE_EXT.
    *MOVE FAX1 TO wrkarea2-FAX.
    *MOVE FAX_EXT1 TO wrkarea2-FAX_EXT.
    *MOVE ADRDTL-STR TO wrkarea2-STR.
    *MOVE ADRDTL-HOU TO wrkarea2-HOU.
    *MOVE ADRDTL-PHONE TO wrkarea2-PHONE.
    *MOVE ADRDTL-PHONE_EXT TO wrkarea2-PHONE_EXT.
    *MOVE ADRDTL-FAX TO wrkarea2-FAX.
    *MOVE ADRDTL-FAX_EXT TO wrkarea2-FAX_EXT.
    *MOVE-CORRESPONDING wahs TO wrkarea2.
    *MOVE-CORRESPONDING waph TO wrkarea2.
    *MOVE-CORRESPONDING wafx TO wrkarea2.
    *MOVE-CORRESPONDING wahsnew TO wrkarea2.
    *MOVE-CORRESPONDING waphnew TO wrkarea2.
    *MOVE-CORRESPONDING wafxnew TO wrkarea2.
    *MOVE itabhsnew TO itab2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabhsnew INTO wahsnew.
    MOVE-CORRESPONDING wahsnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabphnew into waphnew.
    MOVE-CORRESPONDING waphnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabfxnew into wafxnew.
    MOVE-CORRESPONDING wafxnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    *loop at itabhsnew.
    *itab2-HOU = itabhsnew-HOU.
    *itab2-str = itabhsnew-str.
    *append itab2.
    *endloop.
    *LOOP AT itabhsnew.
    *itab2-HOU = itabhsnew-HOU.
    *itab2-str = itabhsnew-str.
    *append itab2.
    *ENDLOOP.
    *delete adjacent duplicates FROM itab2 COMPARING HOU STR PHONE PHONE_EXT FAX FAX_EXT.
    *LOOP AT itab2.
    *INSERT wrkarea2 INTO TABLE itab2.
    *endloop.
    *WRITE: THREE.
    *new-line.
    *WRITE: four.
    *new-line.
    *WRITE: five.
    program = SY-REPID.
    *PERFORM SELECT.
    *loop at itab2.
    *write:/    itab2-LIFNR,
              itab2-BUKRS,
              itab2-KTOKK,
              itab2-ANRED,
              itab2-NAME1,
              itab2-SORTL,
              itab2-HOU,
              itab2-STR,
              itab2-PSTLZ,
              itab2-ORT01,
              itab2-REGIO,
              itab2-LAND1,
              itab2-SPTXT,
              itab2-TELF1,
    *itab2-PHONE,
    *itab2-PHONE_EXT,
              itab2-TELF2,
              itab2-TELFX,
    *itab2-FAX,
    *itab2-FAX_EXT,
              itab2-TELTX,
              itab2-SMTP_SRCH,
              itab2-STCEG,
              itab2-BRSCH.
    *endloop.
    PERFORM CATALOG.
    PERFORM LAYOUTMAIN.
    PERFORM DISPLAY.
    LFA1STRAS LFA1STRAS
    *FORM SELECT.
    SELECT LFA1LIFNR  LFB1BUKRS LFA1KTOKK LFA1ANRED LFA1~NAME1
    *LFA1SORTL LFA1PSTLZ LFA1ORT01 LFA1REGIO
    *LFA1LAND1 T002TSPTXT LFA1TELF1 LFA1TELF2 LFA1TELFX LFA1TELTX
    *ADR6SMTP_SRCH LFA1STCEG LFA1~BRSCH
    *FROM LFA1
    *INNER JOIN T002T ON LFA1SPRAS = T002TSPRSL AND T002T~SPRAS = 2
    *INNER JOIN LFB1 ON LFA1LIFNR = LFB1LIFNR
    INNER JOIN ADR6 ON LFA1ADRNR = ADR6ADDRNUMBER
    *INTO TABLE itab1 WHERE LFA1~LIFNR IN vendor.
    *LOOP AT itab2.
    *MOVE itab1 TO itab2.
    *APPEND itab2.
    *MOVE-CORRESPONDING ADRDTL TO itab2.
    *APPEND itab2.
    *MOVE-CORRESPONDING ADRDTL TO itab2.
    *APPEND itab2.
    *ENDLOOP.
    *LOOP AT itab1 INTO wrkarea1.
    *MOVE-CORRESPONDING wrkarea1 TO wrkarea2.
    *ENDLOOP.
    *MOVE-CORRESPONDING adrdtl TO wrkarea2.
    *LOOP AT itab2.
    *INSERT wrkarea2 INTO TABLE itab2.
    *ENDLOOP.
    *ENDFORM.
    FORM CATALOG.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='LIFNR'.
    fcat-seltext_m = 'Vendor Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFB1'.
    fcat-fieldname ='BUKRS'.
    fcat-seltext_m = 'Company Code'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='KTOKK'.
    fcat-seltext_m = 'Account Group'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='ANRED'.
    fcat-seltext_m = 'Title'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='NAME1'.
    fcat-seltext_m = 'Name'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='SORTL'.
    fcat-seltext_m = 'Search Term'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='HOU'.
    fcat-seltext_m = 'Street'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='STR'.
    fcat-seltext_m = 'House Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PSTLZ'.
    fcat-seltext_m = 'Postal Code'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='ORT01'.
    fcat-seltext_m = 'City'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='REGIO'.
    fcat-seltext_m = 'Region or State'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='LAND1'.
    fcat-seltext_m = 'Country'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='SPTXT'.
    fcat-seltext_m = 'Language'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PHONE'.
    fcat-seltext_m = 'Telephone'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PHONE_EXT'.
    fcat-seltext_m = 'Extension'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='FAX'.
    fcat-seltext_m = 'Fax Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='FAX_EXT'.
    fcat-seltext_m = 'Extension'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'ADR6'.
    fcat-fieldname ='SMTP_SRCH'.
    fcat-seltext_m = 'E-Mail'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='STCEG'.
    fcat-seltext_m = 'VAT Registration Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='BRSCH'.
    fcat-seltext_m = 'Industry Type'.
    APPEND fcat TO fieldcat.
    ENDFORM.
    FORM LAYOUTMAIN.
    layout-zebra = 'X'.
    *layout-edit= 'X'.
    *layout-zebra = 'X'.
    *layout-zebra = 'X'.
    ENDFORM.
    FORM DISPLAY.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
        I_CALLBACK_PROGRAM                = 'program'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
        I_GRID_TITLE                      = 'VENDOR DETAILS'
      I_GRID_SETTINGS                   =
        IS_LAYOUT                         = layout
        IT_FIELDCAT                       = fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
       I_DEFAULT                          = 'X'
       I_SAVE                             = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = itab2.
    EXCEPTIONS
      PROGRAM_ERROR                     = 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.
    ENDFORM.

    HI,
    " By taking two internal table
    LOOP AT ITAB.
      IT_FINAL-FIELD1 = ITAB-FIELD(10).
      IT_FINAL-FIELD2 = ITAB-FIELD+10(10).
      APPEND IT_FINAL.
      CLEAR IT_FINAL.
    ENDLOOP.
    " By taking one internal table
    LOOP AT ITAB.
      ITAB-FIELD2 = ITAB-FIELD1(10).
      ITAB-FIELD3 = ITAB-FIELD1+10(10).
      MODIFY ITAB INDEX SY_TABIX.
    ENDLOOP.

  • How to extract data from a pool table?

    Hello,
    I want to create an generic extractor for table T030, but this is a pool/cluster table and it is not possible to create a view for such a table.
    Do somebody know how to solve this problem? Does there exist function modules to read the data from a pool data?
    Thanks
    Theodor

    Function Module would be your best bet..considering thats the best way as far as performance is taken into consideration.
    But there is a work around too...
    If the other table u use in the join is not a clusture table then u can create a view on that table and u can add append structure to this  with fields from the clusture table and use an exit to populate it.
    Try it Will Work...used this technique when I used KONV.* This Procedure does not decrease performance considerably.
    at least in my case as thre were only a few fields i needed from pool table
    Hope this Helps
    Anand Raj

  • Reading Data from a SQL table to a Logical file on R/3 appl. Server

    Hi All,
    We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
    I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
    I am new to ABAP , please let me know the steps to be done to acheive this .
    Regards
    - Ajay

    Hi,
    You can find lot of information about Datasets in SCN just SEARCH once.
    You can check the code snippet for understanding
    DATA:
    BEGIN OF fs,
      carrid TYPE s_carr_id,
      connid TYPE s_conn_id,
    END OF fs.
    DATA:
      itab    LIKE
              TABLE OF fs,
      w_file  TYPE char255 VALUE 'FILE',
      w_file2 TYPE char255 VALUE 'FILE2'.
    SELECT carrid connid FROM spfli INTO TABLE itab.
    OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                            " Server to write data
    LOOP AT itab INTO fs.
      TRANSFER fs TO w_file. "" Writing the data into the Application server file
    ENDLOOP.
    CLOSE DATASET w_file.
    OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                          " server to read data
    FREE itab.
    DO.
      READ DATASET w_file INTO fs.
      IF sy-subrc EQ 0.
        APPEND fs TO itab.
        OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
                                                           " application server
        TRANSFER fs TO w_file2.
        CLOSE DATASET w_file2.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    Regards
    Sarves

  • Datapump : How to append data in an existing table

    Hello Everyone,
    We are new to Datapump.
    We try to extract data from one user/schema and to append it into another user/schema.
    First we tried Tt use the parameter table_exists_action=append during the importation but we receive this error (but the rows are appended):
    ORA-39152: Table "XXXXX"."YYYYY_ZZZ" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
    Which I don't expect since the utility have been told to, indeed, append data.
    Next we tried to use CONTENT=DATA_ONLY on exportation and importation but the importation never end.
    How can we append data into a table's user/schema without having an error?
    Best regards.
    Carl

    IGNORE=Y during the import.it does the same operation. if the table already exists,it ignores and proceed with importing/appending data to the tables. same way, they do have indexes=n and constraints=n option.
    both export/import have equivalent options for fitering to our requirement and datapump has one step above classic import in which you can filter upto metadata object as well.

  • How to scan data from one internal table to another

    Hi All,
    let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
    i am very thankful to you all in advance.
    Thanks & Regards,
    Nagarjuna.

    if u want to copy data from itab1 to itab2  then use
    itab2[] = itab1[].
    if u want to compare whether both itab1 and itab2 are same or not,use
    if itab1[] = itab2[].
    *--same
    else.
    *--not same
    endif.
    if u want to compare itabs based on primary key....
    loop at itab1.
    read table itab2 with key f1 = itab1-f1.
    if sy-subrc <> 0.
    *--not same....
    endif.
    endloop.
    if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
    append lines of itab1 from 1 to 3 to itab2.
    if internal tables don't have same structure,
    say only fields f1 and f2 are common,then
    loop at itab1.
    itab2-f1 = itab1-f1.
    itab2-f2 = itab1-f2.
    append itab2.
    clear itab2.
    endloop.
    if there are many common fields then...
    loop at itab1.
    move-corresponding itab1 to itab2.
    append itab2.
    clear itab2.
    endloop.
    Please don't forget to reward points....!!!
    Regards
    vasu

  • How to download data from an internal table to a text

    Hi All,
    I want to download data  from an internal table to a text file.
    The fields should be pipe(|) separated. I have tried GUI_DOWNLOAD but it is not taking the field separator.
    The sample of the desired data that i require should be this way:-
    13456TR|M|COUP|MATERIAL|KGS
    Thanks in advance.
    Regards
    Satish.

    Hi,
    Try this..
    REPORT  zc1download message-id zc1dwnmsg.
    *& Declaration Section for the Tables *
    TABLES: makt.
    *& Declaration Section for the Internal Tables
    DATA: intab TYPE TABLE OF makt,
          wa_intab LIKE LINE OF intab,
          no_of_rec TYPE i,
          count TYPE i.
    DATA: BEGIN OF f_intab,
            str(255) TYPE c,
          END OF f_intab.
    DATA: t_intab LIKE TABLE OF f_intab,
          w_intab LIKE LINE OF t_intab,
          temp(255) TYPE c.
    FIELD-SYMBOLS: <f> TYPE ANY.
    *& Selection ScreenSection for the file download
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: file TYPE rlgrap-filename MEMORY ID file,
                tab RADIOBUTTON GROUP rad1 DEFAULT 'X',
                others RADIOBUTTON GROUP rad1,
                delimit TYPE c.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      IF file IS INITIAL. " check to ensure file.
        MESSAGE i001.
        EXIT.
      ENDIF.
      IF others = 'X'.    " check to ensure delimiter.
        IF delimit = ' '.
          MESSAGE i002.
          EXIT.
        ENDIF.
      ENDIF.
      SELECT * FROM makt INTO TABLE intab.
      IF tab = 'X'.       " default delimiter tab is used
          CALL FUNCTION 'WS_DOWNLOAD'
          EXPORTING
            filename                = file
            filetype                = 'DAT'
            mode                    = 'A'
          TABLES
            data_tab                = intab
          EXCEPTIONS
            file_open_error         = 1
            file_write_error        = 2
            invalid_filesize        = 3
            invalid_type            = 4
            no_batch                = 5
            unknown_error           = 6
            invalid_table_width     = 7
            gui_refuse_filetransfer = 8
            customer_error          = 9
            no_authority            = 10
            OTHERS                  = 11.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ELSE.             " If user defind delimiter is to be used
                  Counts the number of fields                *
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
          IF sy-subrc <> 0.
            EXIT.
          ELSE.
            count = count + 1.
          ENDIF.
        ENDDO.
        LOOP AT intab INTO wa_intab.
          DO count TIMES. " Adding the delimiter in required places
            ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
            CONCATENATE temp delimit <f> INTO temp.
          ENDDO.
          SHIFT temp.
          APPEND temp TO t_intab.
          CLEAR temp.
        ENDLOOP.
        CALL FUNCTION 'WS_DOWNLOAD'
          EXPORTING
            filename                = file
            filetype                = 'ASC'
            mode                    = 'A'
          TABLES
            data_tab                = t_intab
          EXCEPTIONS
            file_open_error         = 1
            file_write_error        = 2
            invalid_filesize        = 3
            invalid_type            = 4
            no_batch                = 5
            unknown_error           = 6
            invalid_table_width     = 7
            gui_refuse_filetransfer = 8
            customer_error          = 9
            no_authority            = 10
            OTHERS                  = 11.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDIF.
      WRITE:/ 'The Data has been tranfered to :', file.
    Cheers
    Kathir!~

  • How to move data from 2 internal table to 1 internal table

    Can any body send me code that how to move data from 2 internal table into one internal table.
    Moderator message : Read ABAP documentation. Thread locked.
    Edited by: Vinod Kumar on Jun 13, 2011 11:45 AM

    Hi Mohdarif92;
    I don't know your full needs. But general method should be as below code.
    Please check exam below code.
    Best regards.
    data : begin of gt_result.
                ... like mkpf-...
                ... like mkpf-...
                ... like mseg-...
                ... like mseg-...
              end of gt_result
    select *
    into table gt_mkpf
    from mkpf where ...
    select *
    into table mseg
    from mseg where ...
    loop at gt_mkpf.
         loop at gt_mseg where ... = mkpf-...
            move-corresponding gt_mkpf to gt_result.
            move-corresponding gt_mseg to gt_result.
            append gt_result
         endloop.
    endloop.

Maybe you are looking for

  • Tv screen view frozen can't get to menu

    My Apple TV is showing a frozen view of 1/2 a screen picture and the rest lines. I can reset the Apple but can never get the picture off the screen to see the menu. Have tried reset, unplugging and factory restore and still have same view on tv scree

  • Passing username and password in JInitiator

    Is there any way to pass my username and password in embed or object tag so that I don't have to type it when I am connected to the oracle application.

  • Linux applicatio​n fonts

    Reposted from erroneous post on Labwindows/CVI - sorry I am having the problem of different font behaviour when transferring applications from windows to linux.  After trying various things without much success I am left with some questions:- 1     

  • OHJ Default Window Size

    I have set specific dimensions for an Oracle Help window to be displayed and have amended the *.hs file of the wintype from "False" to "True". When a context sensitive topic is launched from a Help button the OHJ window is displayed the correct size.

  • "sniffer_gpu quit unexpectedly" error happens every time I open Photoshop CC

    I get the "sniffer_gpu quit unexpectedly" error every time I open Photoshop CC on my 15" Retina MacBook Pro. I'm running Mac OS X 10.8.4, and I have no updates available for Photoshop from the Creative Cloud menu bar icon. The odd thing is this: Phot