I need insert /update/modify  ztable from  internal table or work area

I have one simple problem.
TYPES: BEGIN OF t_account,
        acc_no          LIKE zztaccountheader-acc_no,
        cust_id         LIKE zztaccountheader-cust_id,
        acc_type        LIKE zztaccountheader-acc_type,
        od_option       LIKE zztaccountheader-od_option,
        od_limit        LIKE zztaccountheader-od_limit,
        od_issue_date   LIKE zztaccountheader-od_issue_date,
        END OF t_account.
data: lwa_account TYPE  t_account,
     li_account TYPE STANDARD TABLE OF t_account,
bu scerrin i am inputing data :
i want modify updare or insert record into ztable by work area  i put following thing
MOVE : zztaccountheader-acc_no        TO lwa_account-acc_no,
           zztcustomer-cust_id            TO lwa_account-cust_id,
           zztaccountheader-acc_type      TO lwa_account-acc_type,
           zztaccountheader-od_option     TO lwa_account-od_option,
           zztaccountheader-od_limit      TO lwa_account-od_limit,
           zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
    INSERT   zztaccountheader CLIENT SPECIFIED FROM lwa_account .
    CLEAR lwa_account.
  ENDIF.
i am etting error
The type of the database table and work area (or internal table)
"LWA_ACCOUNT" are not Unicode convertible.
please solve it

hi,
decalre like this.
tables : zztaccountheader.
data : t_account like zztaccountheader occurs 0 with header line.
data: lwa_account TYPE t_account,
li_account TYPE STANDARD TABLE OF t_account,
MOVE : zztaccountheader-acc_no TO lwa_account-acc_no,
zztcustomer-cust_id TO lwa_account-cust_id,
zztaccountheader-acc_type TO lwa_account-acc_type,
zztaccountheader-od_option TO lwa_account-od_option,
zztaccountheader-od_limit TO lwa_account-od_limit,
zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
INSERT zztaccountheader CLIENT SPECIFIED FROM lwa_account .
CLEAR lwa_account.
ENDIF.
rgss
anver
if hlped mark points

Similar Messages

  • Modify ztable from internal table

    Hi,
    I have a Ztable in which i have 4 diff fields....1 2 3 4
       and an internal table in whch i have same number of fields...
    Internal table :
        1 2 3 4
        a w x 9
        a w x 10
        a w x 11
        a w x 13
        a w x 12
    When I am using Modify it only appends last record into ztable as below:
    Ztable :  1 2 3 4
               a w x 12
    Internal table has 6 records and z table should be appended with 6 records too...
      if varid-report  = 'ZFINRR1001' and
        varid-VARIANT = 'CITI - ZBA' or
         varid-VARIANT = 'WACHOVIA - ZBA'.
      Modify ZV12_SWEEP from t_data_new.
    endif.
    Any suggestions will be aprreciated!
    Regards,
    Kittu

    >
    Kittu wrote:
    >  When I am using Modify it only appends last record into ztable 

    >   Modify ZV12_SWEEP from t_data_new.
    Hi,
    You only get last record appended because your MODIFY statement uses t_data_new as a working area and not as a table.
    To append the content of your internal table, use the FROM TABLE option as below :
    MODIFY zv12_sweep FROM TABLE t_data_new.
    Regards.
    Nicolas

  • Insert or Modify statement from internal table to database table

    Hi All,
    I have three tables wakh, wrf and wakp. I have an internal table with 5 columns col1, col2, col3, col4 and col5.
    The value in Col1 is my article no and the articleno. is in the table wakh. The value in col2 is my ccode and it is in the table wrf. The rest three columns col3, col4 and col5 are unit, qty and price and they are in the wakp table. Now when my articleno is equal to ccode I need to update the col3, col4 and col5 values  in the wakp. wakp has around 20 columns.
    Can anyone of you guys please give me the code for this issue. Your help is highly appreciated and thanks for all for your time.
    Cheers,
    Cheng

    Hi Rob,
    let me explain you the whole process what i am trying to do. I have a screen where there are 3 fields. In my first field I have a promoiton no. As soon as the user enters the promotion no. its description will be populated in my second field. If the promotion is not maintained then it will throw an error. In my third field User will upload an excel sheet which has 5 columns articleno, colorcode, salesunit, qty, mdprice. Here articleno is coming from wakh and colorcode is in wrf_charval table and the rest three fields are coming from wakp table. So for the article no. which is in col1. and for its corresponding colorcode which is in col3 i need to update col3, col4, col5 values.
    With my below code I am able to upload the excel into internal table and display it. So instead of displaying I need to update in the database. Can you please let me know how I need to attach the function module within my code and update accordingly.
    REPORT  ZTest.
    tables : wakh, wakt.
    Parameter: PromoID type wakh-aktnr, PromoDec type wakt-aktkt, p_file LIKE rlgrap-filename
                   DEFAULT 'c:\test.xls' OBLIGATORY.   " File Name
    *FileName type string.
    *file_nm type localfile.
    TYPES:   BEGIN OF t_datatab,
             col1(25)  TYPE c,
             col2(30)  TYPE c,
             col3(30)  TYPE c,
             col4(30)  TYPE c,
             col5(30)  TYPE c,
             END OF t_datatab.
    DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
          wa_datatab TYPE t_datatab.
    Data : p_table type t_datatab occurs 0 with header line.
    DATA : gd_scol   TYPE i VALUE '1',
           gd_srow   TYPE i VALUE '2',
           gd_ecol   TYPE i VALUE '5',
           gd_erow   TYPE i VALUE '65536'.
    DATA: it_tab TYPE filetable,
          gd_subrc TYPE i.
    field-symbols : <fs>.
    AT selection-screen on PromoID.
    select single * from wakh where aktnr = PromoID.
      if sy-subrc EQ 0.
    select aktkt from wakt into PromoDec where aktnr eq PromoID.
    endselect.
    else.
    message A000(ZI) with 'Promotion ID is not Maintained.'.
    endif.
    *Title : Excel Uploading
    *Selection screen definition
    *SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *PARAMETERS:  p_file LIKE rlgrap-filename
                  DEFAULT 'c:\test.xls' OBLIGATORY.   " File Name
    *SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      REFRESH: it_tab.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title     = 'Select File'
          default_filename = '*.xls'
          multiselection   = ' '
        CHANGING
          file_table       = it_tab
          rc               = gd_subrc.
      LOOP AT it_tab INTO p_file.
       so_fpath-sign = 'I'.
       so_fpath-option = 'EQ'.
       append so_fpath.
      ENDLOOP.
    START-OF-SELECTION.
      PERFORM upload_excel_file TABLES   it_datatab
                                 USING   p_file
                                         gd_scol
                                         gd_srow
                                         gd_ecol
                                         gd_erow.
    END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3,
                wa_datatab-col4,
                wa_datatab-col5.
      ENDLOOP.
    *&      Form  UPLOAD_EXCEL_FILE
          upload excel spreadsheet into internal table
         -->P_TABLE    Table to return excel data into
         -->P_FILE     file name and path
         -->P_SCOL     start column
         -->P_SROW     start row
         -->P_ECOL     end column
         -->P_EROW     end row
    FORM upload_excel_file TABLES   p_table
                           USING    p_file
                                    p_scol
                                    p_srow
                                    p_ecol
                                    p_erow.
      DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
    Has the following format:
                Row number   | Colum Number   |   Value
         i.e.     1                 1             Name1
                  2                 1             Joe
      DATA : ld_index TYPE i.
    Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                = p_file
          i_begin_col             = p_scol
          i_begin_row             = p_srow
          i_end_col               = p_ecol
          i_end_row               = p_erow
        TABLES
          intern                  = LT_INTERN
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'Error Uploading file'.
        EXIT.
      ENDIF.
      IF lt_intern[] IS INITIAL.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'No Data Uploaded'.
        EXIT.
      ELSE.
        SORT lt_intern BY row col.
        LOOP AT lt_intern.
         MOVE lt_intern-col TO ld_index.
         assign component ld_index of structure
         p_table to <fs>.
    move : lt_intern-value to <fs>.
        MOVE lt_intern-value TO p_table.
          AT END OF row.
            APPEND p_table.
            CLEAR p_table.
          ENDAT.
        ENDLOOP.
      ENDIF.
      ENDFORM.
    Thanks for your valuable time.
    Cheng

  • Update ztable from internal table

    I want to update the Ztable from internal table datas.
    what is the syntax to update.
    Its urgent send with coding example is better

    Hi
    PARAMETERS: p_carrid TYPE sflight-carrid,
                percent(1) TYPE p DECIMALS 0.
    DATA sflight_tab TYPE TABLE OF sflight.
    FIELD-SYMBOLS <sflight> TYPE sflight.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab
           WHERE carrid = p_carrid AND
                 fldate = sy-datum.
    IF sy-subrc = 0.
      LOOP AT sflight_tab ASSIGNING <sflight>.
        <sflight>-price =
          <sflight>-price * ( 1 - percent / 100 ).
      ENDLOOP.
    ENDIF.
    <b>UPDATE sflight FROM TABLE sflight_tab.</b>
    Thanks
    Vijay
    PLZ reward points if helpful

  • Internal table and work area

    Hi,
           can anybody explain the concepts of Internal table and work area.Thanks in advance.

    hai,
    This may help u.
    WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.
    Each row in a table is a record and each column is a field.
    While adding or retrieving records to / from internal table we have to keep the record temporarily.
    The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    e.g.
    data: begin of itab occurs 10,
    ab type c,
    cd type i,
    end of itab. " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    Internal tables are used for storing records which are obtained as a result when we use select statement on database. internal tables are run time entities and doesn't occupy any memory. they are dynamic.
    internal tables are of types.
    1. internal tables with header line. [header and body]
    2. internal tables with out header line. [only body]
    Workarea is the concept which is mainly useful when working with internal tables with out header line.
    at any point of time we can access only one record through header of a internal table. every thing should be done [inserting,modifying, reading ] through header only.
    ex: data: itab like standard table of mara with header line.
    for internal tables with out header line we will create a work area [explicit header] as type of table for storing data into internal table.
    ex: data: itab like mara,
    wa like mara.
    more about internal table types:
    Standard table:
    The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.
    You should usually access a standard table with index operations.
    Sorted table:
    The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.
    Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.
    Hash table:
    The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.
    You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).
    Hashed tables
    This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index.
    The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always
    have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for
    processing large amounts of data.
    TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.
    TYPES: BEGIN OF LINE,
    COLUMN1 TYPE I,
    COLUMN2 TYPE I,
    COLUMN3 TYPE I,
    END OF LINE.
    DATA ITAB TYPE HASHED TABLE OF SPFLI
    WITH UNIQUE KEY CARRID CONNID.
    with regards,
    B.Sowjanya,
    reward points if helpful.

  • Internal table declaration - work area and body

    Hi all
    I have declared my internal table in my program as
    data : itab_wa type ZRESULT_LINE,
           itab    type ZRESULT_ROW.
    Where ZRESULT_LINE and ZRESULT_ROW are the structure and table types.
    Now I want to add
    data: TCOLOR TYPE SLIS_T_SPECIALCOL_ALV.
    in my internal table declaration. How can I do this. Please remember I need to have work area and body in my internal table as I have used work area and body in my code.
    Waiting..............
    Message was edited by: Raju Boda

    HI,
    See the Declarion types of workarea and Internal tables
    * Table declaration (old method)
    DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF tab_ekpo.
    *Table declaration (new method)     "USE THIS WAY!!!
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
          wa_ekpo TYPE t_ekpo.                    "work area (header line)
    * Build internal table and work area from existing internal table
    DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
          wa_datatab LIKE LINE OF tab_ekpo.
    * Build internal table and work area from existing internal table,
    * adding additional fields
    TYPES: BEGIN OF t_repdata.
            INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
    TYPES: bukrs  TYPE ekpo-werks,
           bstyp  TYPE ekpo-bukrs.
    TYPES: END OF t_repdata.
    DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
          wa_repdata TYPE t_repdata.                 "work area (header line
    you need to maintain same structure for both workarea as well Internal table
    Regards
    Sudheer

  • Get the fieldnames of a generic internal table or work area

    Hi All,
           I have one generic work area which I have created in the below manner...
    * ET_DATA itself is a generic table of type ANY...can have any internal table data in it.
    * Create dynamic internal table
      CREATE DATA lv_new_table LIKE et_data.
      ASSIGN lv_new_table->* TO <fs_dyn_table>.
    * Create dynamic work area and assign to fieldsymbol.
      CREATE DATA lv_new_line LIKE LINE OF <fs_dyn_table>.
      ASSIGN lv_new_line->*   TO <fs_dyn_wa>.
    Now...I need to get the field names of this dynamic internal table or work area..
    I have already searched in forum...got many answers..but none them gives me the output.
    Please note that I require the field names and not field position..
    Awaiting your suggestions on how to get field names of this dynamic work area...

      create data wa_ref like line of it_data.
      assign wa_ref->* to <p_data>.
      desc_table ?= cl_abap_tabledescr=>describe_by_data( it_data ).
      desc_struc ?= desc_table->get_table_line_type( ).
      describe field <p_data> type rtty components ncom.
    This one is working in our environment without any error. it_data is an importing parameter in the signature of a method of type any table.

  • Internal table with work area

    hi all,
    data: BEGIN OF it_summ OCCURS 0.
      INCLUDE STRUCTURE yapn_summary.
      data: END OF it_summ.
    data : wa_demo1 type yapn_summary.
    clear wa_demo1.
            wa_demo1-sumr = 'hai'.
    append wa_Demo1 to it_summ.
    WRITE: it_summ-sumr.
    its not get output..
    i want to display for hai using it_summ.
    donot use work area.
    how to change it.?
    reply me soon,
    s.suresh.

    You can't write out an internal table - you can only write out a line (or components of a line) of an internal table.  So you MUST use a work area.  If you use OCCURS 0 then you've a table with a headerline, and so don't need a workarea.  However, later versions of ABAP discourage tables with headerline, and it is preferred to define a specific work area.  So, either:
    data: BEGIN OF it_summ OCCURS 0.
    INCLUDE STRUCTURE yapn_summary.
    data: END OF it_summ.
    clear it_summ.
    it_summ-sumr = 'hai'.
    append wa_Demo1 to it_summ.
    LOOP AT it_summ.
      WRITE: it_summ-sumr.
    ENDLOOP.
    Now, you see here that at some points it_summ refers to the table, and at others to the header-line.  This is ambiguous, and therefore BAD.  It's better to define the table and work area seperately.
    data: it_summ TYPE STANDARD TABLE OF yapn_summary WITH NON-UNIQUE KEY table_line.
    data : wa_demo1 type yapn_summary.
    clear wa_demo1.
    wa_demo1-sumr = 'hai'.
    append wa_Demo1 to it_summ.
    LOOP AT it_summ INTO wa_demo1.
      WRITE: wa_demo1-sumr.
    ENDLOOP.
    matt

  • Regarding modifying database from internal table

    Hi ABAP Experts,
    I am facing an issue regarding modifying DB table from itab.
    All the records of itab are not getting reflected in DB table using Modify statement.
    Syntax is as follows -
    Locking DB table using enque FM
    MODIFY abc FROM TABLE i_abc.
    Unlocking DB table using deques FM
    Please suggest what could be wrong with this. Helpful suggestion will be appreciated.
    Thanks in adv,
    Akash

    Hi,
    First Delete entries from the table(hope it is a custom table),
    for example
    DELETE  FROM <DatabaseTable name> WHERE <primarykey = 'somevalue'>.
    'After deleting those records.....then use insert statement
    IF sy-subrc = 0.
       INSERT <DatabaseTable name> FROM TABLE  <InternalTable name> ACCEPTING DUPLICATE KEYS.
      ENDIF.
    Thanks & REgards

  • How to update/modify the ALV internal table once it is displayed

    Hi All,
    I have a alv grid report using fm reuse_alv_grid_dispaly. My requirement is to create sales order using bapi (up to here it is working fine) and once the SO is created update the function module tables field with the created sales order.
    Example:
    My alv grid display before creating SO:
    Customer Material    SalesOrder
    1000001  material1 
    My alv grid display after creating SO:
    Customer Material    SalesOrder
    1000001  material1  3025642
    How can I achieve this functionality. Because the field catalog is already displayed, how can I modify/update it by adding the sales order number to it. Experts, suggest me.
    Thanks.

    FORM callback_ucomm USING ucomm LIKE sy-ucomm
                                   selfield TYPE slis_selfield.
    CASE ucomm.
        WHEN 'CRE'.
    * Logic to create sales order here...
    * Show the Sales order column
        CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
          IMPORTING
            et_fieldcat   = gt_fieldcat
          EXCEPTIONS
            no_infos      = 1
            program_error = 2
            OTHERS        = 3.
        if sy-subrc eq 0.
          read table gt_fieldcat into gs_fieldcat with key fieldname = 'VBELN'.
          if sy-subrc eq 0.
            gs_fieldcat-no_out = space.
            gs_fieldcat-tech   = space.
            modify gt_fieldcat from gs_fieldcat index sy-tabix transporting no_out tech.
          endif.
          CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
            EXPORTING
              it_fieldcat          = gt_fieldcat[].
        endif.
    ENDFORM.

  • Error: you cannot create an internal table as work area

    Hi, My code is as follows and when i perform a check it gives the above mentioned error in the select statement.
    TYPES: BEGIN OF t_vbrk,
            vbeln            TYPE vbrk-vbeln,
            vtweg            TYPE vbrk-vtweg,
          END OF t_vbrk.
    DATA vbrktab TYPE TABLE OF t_vbrk.
    SELECT      vbeln
                    vtweg
             FROM   vbrk
             INTO  vbrktab
             FOR ALL ENTRIES IN xxcvb
             WHERE  vbeln       = xxcvb-vbeln.
          INSERT TABLE vbrktab.
        ENDSELECT.
    where xxcvb is another internal table with some key values.

    Hi
    I don't know how you've defined XXCVB, but u should write:
    TYPES: BEGIN OF T_VBRK,
             VBELN TYPE VBRK-VBELN,
             VTWEG TYPE VBRK-VTWEG,
           END OF T_VBRK.
    DATA: VBRKTAB    TYPE TABLE OF T_VBRK,
          WA_VBRKTAB TYPE T_VBRK.
    SELECT VBELN VTWEG FROM VBRK INTO TABLE VBRKTAB
      FOR ALL ENTRIES IN XXCVB
         WHERE VBELN = XXCVB-VBELN.
    LOOP AT VBRKTAB INTO WA_VBRKTAB.
    ENDLOOP.
    Max

  • Smartform Table; Internal table to work area

    Hi,
    I have created smartform with one table,in that internal table values are not moving into workarea,can anyone solve my issue.

    Hi Bose,
    If you are populating internal table values in progarm and passing this internal table to smartforms
    here is the syntax and declaration to follow
    data : itab_final type standard table of type_final (some type) with header line .
    Pass this under tables in your Z program,
    CALL FUNCTION  'smartform name'
           EXPORTING
              archive_index      = toa_dara
              archive_parameters = arc_params
              vbdkl              = vbdkl
              vbdpl              = vbdpl
              makt               = makt
              qals               = qals
              vbco3              = vbco3
            TABLES
              g_final            = g_final
            EXCEPTIONS
              FORMATTING_ERROR   = 1
              INTERNAL_ERROR     = 2
              SEND_ERROR         = 3
              USER_CANCELED      = 4
              OTHERS             = 5.
    In Smartforms,
    Declare this internal table in form interface under tables as,
    G_FINAL     TYPE     Z_TT_FINAL_COA(table type)
    And work area in global data as,
    WA_G_FINAL     TYPE     ZFINAL_COA (structure)
    Now it can be used used in table control  under data column as
    G_FINAL          INTO                  WA_G_FINAL
    Regards,
    Sagar.

  • Update ztable from database table directly

    hi all,
    can u tell me the possible ways to update a ztable from database table directly.
    i mean is there anyway to update ztable whenever entry is created in database table .
    i dont want to update using insert,modify statements.
    points will be rewarded to all hlpful answers.

    A slightly dirty solution:
    Use SAP functions for reading from CDHEADER and CDPOS tables [with enough filters such that you extract minimum records possible] to read changes to MARA table fields since last run of your program. Use this information to update your ZTABLE. I would recommend having a table maintainance generator on ZTABLE. The actual update should be by a BDC by calling transaction SM30 for ZTABLE maintainance. Now the program may be set up as a batch job running 1ce an hour. You get updates to the extent of 1 hour latency.
    Alternatively, you may look if an opportunistic BADI / user Exit is there alongside MM01/02 transactions - assuming the latter are the only ones updating MARA. In this BADI you may write the code to update ZTABLE- again, look to do it by BDC call transaction sm30 to maintain ZTable. To lighten up the code -load on BADI you may simply raise a custom event and move on. You will configure a job that runs your program when that particular event is raised. This will need the 'burden' of figuring out the changes, though.
    An elegant way would be to fire a MATMAS fIDOC for every change to Material, capture that and turn back the changes to ZTABLE. This will facilitate the delta load.

  • Create XML file on application server (unix directory) from internal table

    Hallo everybody,
    I have got the following problem:
    I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.
    This takes place in 3 steps:
    1.     Collect the data in an internal table
    2.     Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'
    3.     Download the data
    If I download the converted data, which are in an internal table, to the presentation server via the function module ‘WS_DOWNLOAD’ and open it with the Internet Explorer, everything is ok.
    If I download the converted data to the application server, i.e. into a unix directory via
    ‘open dataset’, ‘loop at internal table, ‘transfer working area to file’, ‘close dataset’
    and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that aren’t supposed to be there. That’s what my colleagues told me, for I haven’t got access to the server.
    I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately I’I am not an expert in working with classes so sample coding would have to be rather detailed.
    Here’s some more information about how I work with the conversion function module:
      call function 'SAP_CONVERT_TO_XML_FORMAT'
           exporting
                i_field_seperator    = lv_field_seperator
               i_line_header        = lv_line_header
               i_filename           = lv_xml_file
               i_appl_keep          = ' '
                i_xml_doc_name       = lv_xml_doc_name
           importing
                pe_bin_filesize      = lv_result
           tables
                i_tab_sap_data       = gt_data
           changing
                i_tab_converted_data = lt_tab_converted_data
           exceptions
                conversion_failed    = 1
                others               = 2.
    lv_field_seperator = ‘X’.
    lv_xml_doc_name = ‘Personalstammdaten Publikation’
    lv_result: type i
    gt_data: fields: PERNR, PERSG, PERSK etc.
      types:
      begin of truxs_xml_line,
        data(256) type x,
      end of truxs_xml_line.
      types:
      truxs_xml_table type table of truxs_xml_line.
    data:
    lv_tab_converted_data type truxs_xml_line,
    lt_tab_converted_data type truxs_xml_table
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
      transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file
    lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml
    Hope the information is detailed enough! Otherwise let me know. Thank you in advance.
    Message was edited by: Johannes Schwehm

    Hi Raja,
    tried the "TEXT" mode, but that didn't help.
    There are still characters after the last tag, that are not supposed to be there including a date that is not
    the creation date of the file.
    Thank you for your help.
    Regards
    Johannes

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

Maybe you are looking for

  • Imac 10, 1 won't read certain CDs

    my imac , iMac10,1; Intel Core 2 Duo won't read certain bought CDS and spits them out. We can hear a whirring noise-- but not the clicking sound of the tracks being read-- and then, the CD comes out. all software updates have been performed. please h

  • I installed OSX 10.9.4 and now Finder and Photoshop don't work; how can I fix this?

    Now that I have installed OSX 10.9.4 I can't get the Finder to work, or Photoshop.  How can I fix this?

  • Aborting Sql Queries

    hello all i have a query. i want to abort a query running in a thread with a help of another thread my programs looks like this public class test           public static void main(String args[]) throws Exception                String driverName = "or

  • My iPhone 'Cannot connect to iTunes store' when updating apps?

    On my iPhone, when i need to update my apps i enter my email & password and it comes up saying 'Cannot connect to iTunes store'. How do i fix this? It's not my phone, i've tried on my sisters touch & dad's iPhone also.. same result. And when I log on

  • Preparing for Shipment- MacBook Pro 15'- How long??

    I'm wondering how long does it take to switch the order status to "shipping" from "Preparing for Shipment"? I ordered it on August 22 and they said they will deliver to me on Aug. 27th. Can they ship over labor weekend?? Being patient *****!!