Insert a string at particular location in the internal table

1. I have an internal table t_text of type bcsy_text , this internal table contains a few lines of HTML code
2. I have a variable w_text of type string , this variable contains some text
3. now the internal table t_text contains text:
<!"<font size = "3.5" ><b>Comments:</b></font><br><br>***********<br><br><font size = "3.5" ><b>Thank You</b></font>">
4. The text in the w_text comes from a text area on my module pool screen
5. There is a push button SAVE on the same module pool screen
6. now when I enter text in the text area and press the SAVE button then i want the text in the variable w_text to be inserted into the internal table at the location where i have marked *********** in my HTML code.
How do i achieve this?
<!-- **--> is not part of my HTML code.. i have written it because the HTML formatting appears on the screen if i dont comment it
Edited by: DoshiAnkit on Sep 8, 2010 3:43 PM

Ankit,
You have to first determine which row of the internal table needs to be updated. Once you know which row, read that row into a variable using the READ statement and INDEX option.
Once you have the row in a variable (WA_ROW) , you have to determine the position where you want to insert the w_text contents.
Suppose that position is 123. Then, you can concatenate the first part of the row, w_text contents, and second part of the row into another variable (WA_NEW_ROW).
CONCATENATE wa_row(123)
w_text
wa_row+123
INTO wa_new_row
SEPARATED BY SPACE.
Finally, modify internal table contents with WA_NEW_ROW using the INDEX option.

Similar Messages

  • INSERT works for only last record of the Internal table ...??

    I am trying to insert data from an internal table JTAB to a Databse Table
    in CRM. The name of the databse table in CRM is CRMD_PARTNER
    For this i first declared an internal table JTAB with same structure as that of
    the databse table CRMD_PARTNER
    DATA: BEGIN OF JTAB OCCURS 0,
         INCLUDE STRUCTURE CRMD_PARTNER,
          END OF JTAB.
    Then I filled my JTAB with the required entries. For filling the JTAB i am
    getting data from couple of other tables and filling the internal table JTAB
         loop at ktab.
    here i am filling values in JTAB and then i say APPEND JTAB.
            endloop.
         Till here every thing works well and my internal table JTAB has all values that
    I need to insert to the CRMD_PARTNER table. Also my JTAB has vales for all primary key fields.
    Now I write a condition like below.
    if not jtab[] inital.
    MODIFY CRMD_PARTNER from TABLE JTAB.
    COMMIT WORK.
    endif.
    Here comes the problem...once this code is executed and once program totally executes...
    i always see that only last record in JTAB is being inserted to the databse table CRMD_PARTNER.
    When i check in the debugger ..i see that the loop is being executed only once
    and the SY-TABIX of JTAB is being always set to the length of JTAB and
    that is why only last  record is being inseretd to the table CRMD_PARTNER.
    Now what should i do ..to insert all records of JTAB to CRMD_PARTNER table?
    is there a way i can restet the SY-TABIX and make the modify statement work for all records of JTAB?
    Finally i hardcoded the values in JTAB then i dont have any problem and all records of JTAB are being
    inserted into the database table.
    only if i am dynamically fetching the values into JTAB(by Putting in loop..endloop statements and
    pushing values to JTAB and APPENDING JTAB ) i have a problem .
    in this case also my JTAB is being correctly filled with values ..but when i try to
    insert theses values to CRMD_PARTNER with MODIFY stmt ..only always last record is being inserted.
    i tried with INSERT instead of MODIFY and i am getting runtime error.
    kindly pease help.
    Regards,
    Jessica Sam

    yes a@s i am really struggling from last 3 days.
    I actually want to create a sales order in CRM and want to
    assign ship to party for each line item in a sales order in CRM
    for that i used the standard bapi BAPI_BUSPROCESSND_CREATEMULTI and i am able
    to create an order successfully, but i see that the ship toparty
    that i give at header is being copied to each line item.
    but this is not what is expected.
    So finally i tracked in which table the ship to party gets stored in each line item
    and then tried to insert the records directly into databse. and it worked
    but only if i am hardcoding..but not when i am dynamically fecthing the values into JTAB for insertion,
    Can yoy help ..if you have any idea why insert/modify is processing only last record?
    any help will be highly appreciated.
    Regards,
    Jessica Sam

  • How to insert some strings in a query with the clausule 'in' in a procedure

    Hello fellows.
    Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
    I tell us my problem with an example:
    I want to use this select but introducing a variable instead the 'value1', 'value2':
    select * from table1 where field1 in ('value1', 'value2');
    if I declare the variable var1 as:
    TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
    and I use it as:
    select * from table1 where field1 in (TC_VAR1);
    It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
    select * from table1 where field1 in ('value1, value2');
    If I use the data type TABLE, I don't know how to use well:
    TYPE varchar2_table IS TABLE OF VARCHAR2(10);
    tb_var varchar2_table;
    select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
    A curious case is that if I have a sql script (for example script1.sh) with this query:
    select * fromt able1 where field1 in (&1)
    and I invoke this script as
    script1.sh "'''value1'',''value2'''". It works
    Can anybody helps me?.
    Thanks.

    Thanks to all. Really.
    First, sorry for my English. It's horrible. Thank to all for understand it (my English).
    I've resolved my problem with these links:
    ORA-22905: cannot access rows from a non-nested table item
    and
    http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
    At last, I have used someting like this:
    DECLARE
    number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
    BEGIN
    FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
    UNION ALL
    SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
    NULL;
    END LOOP;
    END;
    but first I had to create the type NUM_ARRAY like this:
    CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
    THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
    Edited by: user12249099 on 08-sep-2011 7:37
    Edited by: user12249099 on 08-sep-2011 7:37

  • How to insert record inside the internal table in below code

    Hi all,
    My requirement is to find the sub-total and need to insert in between the internal table.
    You can see the output ....where I want the sub-total F2 when 1 & 2 combindely , 3 , 4& 5 combindely .Please check it and let me know is it possible
    when i am using modification  it is not creating extra row inside the table instead it is modifying one row and putting the total there.
    For ex: the origianl output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
    D      3          1
    E      4          1
    C      5          1
    We want to display all the total of f2 of 1-2 , 3 , 4-5
    so expcected output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
         *              3  ->This is the sub-total of 1& 2 of f2
    D      3          1
            *           1 ->this is the sub-total of 3
    E      4          1
    C      5          1
          *             2 -> this is the sub-total of 4 & 5
    = space
    But coming output is
    A 1          1
    B 1          1
    *             3 -> it is modifying the F row and inserting the total .Total is comong correct but is shoule insert  instead of modifying the record!!
      *           1
    E  4          1
    *             2
    Please help how to insert the row total at the end of the chage of field
    Please find the below code ..Due to space problem i am attaching below
    Sas

    Here is the solution ....i Got the answer Thanks for your helping hands friends
    REPORT  YTEST_MODIFY.
    DATA: BEGIN OF ITAB OCCURS 1,
    TOT TYPE C,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF ITAB.
    DATA: BEGIN OF JTAB OCCURS 1,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF JTAB.
    START-OF-SELECTION.
      ITAB-F1 = 'A'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'B'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'C'.
      ITAB-F2 =  5.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'D'.
      ITAB-F2 =  3.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'E'.
      ITAB-F2 =  4.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'F'.
      ITAB-F2 =  2.
      ITAB-F3 =  1.
      APPEND ITAB.
      SORT ITAB BY F2.
      LOOP AT ITAB.
        WRITE:/1 ITAB-F1 ,
              8 ITAB-F2 ,
              10 ITAB-F3 .
      ENDLOOP.
      LOOP AT ITAB.
        IF ITAB-F2 = 1 OR ITAB-F2 = 2.
          ITAB-TOT = 1.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 3.
          ITAB-TOT = 3.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 4 OR ITAB-F2 = 5.
          ITAB-TOT = 4.
          MODIFY ITAB.
        ENDIF.
      ENDLOOP.
      SKIP 2.
      SORT ITAB BY TOT.
      DATA : L_SUM(2) TYPE C,
             L_ROW(2) TYPE C.
      LOOP AT ITAB.
        MOVE-CORRESPONDING ITAB TO JTAB.
        APPEND JTAB.
        L_SUM = L_SUM + ITAB-F3 .
        AT END OF TOT.
          CLEAR JTAB.
          JTAB-F3 = L_SUM .
          APPEND JTAB.
          CLEAR L_SUM.
        ENDAT.
      ENDLOOP.
      LOOP AT JTAB.
        WRITE:/1 JTAB-F1 ,
              8 JTAB-F2 ,
              10 JTAB-F3 .
      ENDLOOP.
    *  DATA: a TYPE i , b .
    *  LOOP AT itab.
    *    IF b = 0.
    *      a = a + itab-f3.
    *    ENDIF.
    *    AT END OF tot.
    *      MOVE space TO itab-f1.
    *      MOVE space TO itab-f2.
    *      MOVE a TO itab-f3.
    *      MODIFY itab .
    *      CLEAR a.
    *      b = 1.
    *    ENDAT.
    *    b = 0.
    *  ENDLOOP.
    *  LOOP AT itab.
    *    MOVE-CORRESPONDING itab TO jtab.
    *    APPEND jtab.
    *  ENDLOOP.
    *  ULINE.
    *  LOOP AT jtab.
    *    WRITE: / jtab-f1 , jtab-f2 , jtab-f3.
    *  ENDLOOP.

  • Conversion of a string output and store them into the internal table fields

    Hi,
    I'm writing a program in which I'm populating the values generated in TCODE- 'AL11' I'm able to retrieve the data in string format but I've to break the string and put the values in an internal table. The internal table has fields of various lengths and no specific position where I can use a delimiter and use the Split command.
    Kindly provide me suggestions how I can break the string and assign the values in the fields of the internal table.
    Regards,
    Sreedhar.

    Hi,
    Take the screen fields length and create an internal table.
    loop the internal table and first split the string at delimeter( use  cl_abap_char_utilities)
    CONSTANTS:
      c_delimiter        TYPE c VALUE
                              cl_abap_char_utilities=>horizontal_tab,
      c_delimiter_enter  TYPE c VALUE
                              cl_abap_char_utilities=>cr_lf.
    loop at itab into fs.
        SPLIT w_str  AT c_delimiter_enter INTO w_str w_dummy .
                                          " SPLITTING AT 'ENTER KEY'
          SPLIT w_str  AT c_delimiter INTO
                                          " SPLITTING AT 'TAB'
      fs-f1,
    fs-f2.
    append fs to itab.
    clear fs.
    endloop.

  • Difference betwen the internal tables

    Hai friends,
               Pls give me the types  of internal tables and their   differences .and its usage by example.
      regrds,
    Prashanth.

    Internal tables
    Definition
    Data structure that exists only at program runtime.
    An internal table is one of two structured data types in ABAP. It can contain any number of identically structured rows, with or without a header line.
    The header line is similar to a structure and serves as the work area of the internal table. The data type of individual rows can be either elementary or structured.
    Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.
    Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects . A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.
    Internal Tables as Data Types
    Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.
    Line type
    The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
    Key
    The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
    If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line . The default key of an internal table whose line type is an internal table, the default key is empty.
    The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
    Table type
    The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
    Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.
    Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique or non-unique. When you define the table, you must specify whether the key is to be unique or not. Standard tables and sorted tables are known generically as index tables.
    Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.
    Generic Internal Tables
    Unlike other local data types in programs, you do not have to specify the data type of an internal table fully. Instead, you can specify a generic construction, that is, the key or key and line type of an internal table data type may remain unspecified. You can use generic internal tables to specify the types of field symbols and the interface parameters of procedures. You cannot use them to declare data objects.
    Internal Tables as Dynamic Data Objects
    Data objects that are defined either with the data type of an internal table, or directly as an internal table, are always fully defined in respect of their line type, key and access method. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table.
    Choosing a Table Type
    The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed.
    Standard tables
    This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    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.
    Special Features of Standard Tables
    Unlike sorted tables, hashed tables, and key access to internal tables, which were only introduced in Release 4.0, standard tables already existed several releases previously. Defining a line type, table type, and tables without a header line have only been possible since Release 3.0. For this reason, there are certain features of standard tables that still exist for compatibility reasons.
    Standard Tables Before Release 3.0
    Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:
    DATA: BEGIN OF  .
    The effect of the OCCURS addition is to construct a standard table with the data type
    They can also be replaced by the following statements:
    Standard Tables From Release 4.0
    When you create a standard table, you can use the following forms of the TYPES and DATA statements. The addition INITIAL SIZE is also possible in all of the statements. The addition WITH HEADER LINE is possible in the DATA statement.
    Standard Table Types
    Generic Standard Table Type:
    TYPES  TYPE|LIKE TABLE OF  TYPE|LIKE TABLE OF 
                           WITH   TYPE|LIKE TABLE OF  TYPE|LIKE TABLE OF  TYPE|LIKE TABLE OF 
                           WITH   .
    Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the program declared using the TYPES statement, or a table type in the ABAP Dictionary.
    You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).
    The optional addition WITH HEADER line declares an extra data object with the same name and line type as the internal table. This data object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate this by placing brackets after the table name ([]). Otherwise, ABAP interprets the name as the name of the header line and not of the body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.
                      TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
    DATA: ITAB TYPE VECTOR,
          JTAB LIKE ITAB WITH HEADER LINE.
    MOVE ITAB TO JTAB.   <-  Syntax error!
    MOVE ITAB TO JTAB[].
    The table object ITAB is created with reference to the table type VECTOR. The table object JTAB has the same data type as ITAB. JTAB also has a header line. In the first MOVE statement, JTAB addresses the header line. Since this has the data type I, and the table type of ITAB cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since both operands are table objects.
    Declaring New Internal Tables
    You can use the DATA statement to construct new internal tables as well as using the LIKE or TYPE addition to refer to existing types or objects. The table type that you construct does not exist in its own right; instead, it is only an attribute of the table object. You can refer to it using the LIKE addition, but not using TYPE. The syntax for constructing a table object in the DATA statement is similar to that for defining a table type in the TYPES statement.
    DATA ]
    As when you define a table type, the type constructor
    of an internal table as follows:
    UNIQUE KEY  belong to the key as long as they are not internal tables or references, and do not contain internal tables or references. Key fields can be nested structures. The substructures are expanded component by component when you access the table using the key. The system follows the sequence of the key fields.
    UNIQUE KEY TABLE LINE
    If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line as the key. If you try this for a table whose line type is itself a table, a syntax error occurs. If a table has a structured line type, it is possible to specify the entire line as the key. However, you should remember that this is often not suitable.
    UNIQUE DEFAULT KEY
    This declares the fields of the default key as the key fields. If the table has a structured line type, the default key contains all non-numeric columns of the internal table that are not and do not contain references or internal tables. If the table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.
    Specifying a key is optional. If you do not specify a key, the system defines a table type with an arbitrary key. You can only use this to define the types of field symbols and the interface parameters of procedures. For exceptions, refer to Special Features of Standard Tables.
    The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
    ·     You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
    ·     You must always specify the UNIQUE option when you create a hashed table.
    Initial Memory Requirement
    You can specify the initial amount of main memory assigned to an internal table object when you define the data type using the following addition:
    INITIAL SIZE , the system calculates a new value so that n times the line width is around 12KB.
    Examples
    TYPES: BEGIN OF LINE,
      COLUMN1 TYPE I,
      COLUMN2 TYPE I,
      COLUMN3 TYPE I,
    END OF LINE.
    1. TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
    The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component COLUMN1.
    2. 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.
    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
    TYPES: BEGIN OF DEEPLINE,
    FIELD TYPE C,
    TABLE1 TYPE VECTOR,
    TABLE2 TYPE ITAB,
    END OF DEEPLINE.
    TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE
    WITH DEFAULT KEY.
    The program defines a table type VECTOR with type hashed table, the elementary line type I and a unique key of the entire table line. The second table type is the same as in the previous example. The structure DEEPLINE contains the internal table as a component. The table type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal table are themselves internal tables. The key is the default key - in this case the column FIELD. The key is non-unique, since the table is a standard table.
    Specifying the Type of Formal Parameters
    Formal parameters can have any valid ABAP data type. You can specify the type of a formal parameter, either generically or fully, using the TYPE or LIKE addition. If you specify a generic type, the type of the formal parameter is either partially specified or not specified at all. Any attributes that are not specified are inherited from the corresponding actual parameter when the subroutine is called. If you specify the type fully, all of the technical attributes of the formal parameter are defined with the subroutine definition.
    The following remarks about specifying the types of parameters also apply to the parameters of other procedures (function modules and methods).
    If you have specified the type of the formal parameters, the system checks that the corresponding actual parameters are compatible when the subroutine is called. For internal subroutines, the system checks this in the syntax check. For external subroutines, the check cannot occur until runtime.
    By specifying the type, you ensure that a subroutine always works with the correct data type. Generic formal parameters allow a large degree of freedom when you call subroutines, since you can pass data of any type. This restricts accordingly the options for processing data in the subroutine, since the operations must be valid for all data types. For example, assigning one data object to another may not even be possible for all data types. If you specify the types of subroutine parameters, you can perform a much wider range of operations, since only the data appropriate to those operations can be passed in the call. If you want to process structured data objects component by component in a subroutine, you must specify the type of the parameter.
    Specifying Generic Types
    The following types allow you more freedom when using actual parameters. The actual parameter need only have the selection of attributes possessed by the formal parameter. The formal parameter adopts its remaining unnamed attributes from the actual parameter.
         Check for actual parameters
    No type specificationTYPE ANY     The subroutine accepts actual parameters of any type. The formal parameter inherits all of the technical attributes of the actual parameter.
    TYPE C, N, P, or X     The subroutine only accepts actual parameters with the type C, N, P, or X. The formal parameter inherits the field length and DECIMALS specification (for type P) from the actual parameter.
    TYPE TABLE     The system checks whether the actual parameter is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE     The system checks whether the actual parameter is an internal table. The formal parameter inherits all of the attributes (line type, table type, key) from the actual parameter.
    TYPE INDEX TABLE     The system checks whether the actual parameter is an index table (standard or sorted table). The formal parameter inherits all of the attributes (line type, table type, key) from the actual parameter.
    TYPE STANDARD TABLE     The system checks whether the actual parameter is a standard internal table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
    TYPE SORTED TABLE     The system checks whether the actual parameter is a sorted table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
    TYPE HASHED TABLE     The system checks whether the actual parameter is a hashed table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
    Note that formal parameters inherit the attributes of their corresponding actual parameters dynamically at runtime, and so they cannot be identified in the program code. For example, you cannot address an inherited table key statically in a subroutine, but you probably can dynamically.
    TYPES: BEGIN OF LINE,
            COL1,
            COL2,
          END OF LINE.
    DATA: WA TYPE LINE,
          ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
          KEY(4) VALUE 'COL1'.
    WA-COL1 = 'X'. INSERT WA INTO TABLE ITAB.
    WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB.
    PERFORM DEMO USING ITAB.
    FORM DEMO USING P TYPE ANY TABLE.
      READ TABLE P WITH TABLE KEY (KEY) = 'X' INTO WA.
    ENDFORM.
    The table key is addressed dynamically in the subroutine. However, the static address
    READ TABLE P WITH TABLE KEY COL1 = 'X' INTO WA.
    is syntactically incorrect, since the formal parameter P does not adopt the key of table ITAB until runtime.
    Assigning Internal Tables :
    Like other data objects, you can use internal tables as operands in a MOVE statement
    MOVE , including the data in any nested internal tables. The original contents of the target table are overwritten.
    If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in an assignment, you must place two brackets () after the table name.
    DATA: BEGIN OF line,
            col1(1) TYPE c,
            col2(1) TYPE c,
          END OF line.
    DATA: etab LIKE TABLE OF line WITH HEADER LINE,
          ftab LIKE TABLE OF line.
    line-col1 = 'A'. line-col2 = 'B'.
    APPEND line TO etab.
    MOVE etab[] TO ftab.
    LOOP AT ftab INTO line.
      WRITE: / line-col1, line-col2.
    ENDLOOP.
    The output is:
    A B
    The example creates two standard tables ETAB and FTAB with the line type of the structure LINE. ETAB has a header line. After filling ETAB line by line using the APPEND statement, its entire contents are assigned to FTAB. Note the brackets in the statement.
    DATA: ftab TYPE SORTED TABLE OF f
               WITH NON-UNIQUE KEY table_line,
          itab TYPE HASHED TABLE OF i
               WITH UNIQUE KEY table_line,
          fl   TYPE f.
    DO 3 TIMES.
      INSERT sy-index INTO TABLE itab.
    ENDDO.
    ftab = itab.
    LOOP AT ftab INTO fl.
      WRITE: / fl.
    ENDLOOP.
    The output is:
    1.000000000000000E+00
    2.000000000000000E+00
    3.000000000000000E+00
    FTAB is a sorted table with line type F and a non-unique key. ITAB is a hashed table with line type I and a unique key. The line types, and therefore the entire tables, are convertible. It is therefore possible to assign the contents of ITAB to FTAB. When you assign the unsorted table ITAB to the sorted table FTAB, the contents are automatically sorted by the key of FTAB.
    In Unicode systems, the following conversion is not allowed:
    DATA: BEGIN OF iline,
            num TYPE i,
          END OF iline,
          BEGIN OF fline,
            num TYPE f,
          END OF fline,
          itab LIKE TABLE OF iline,
          ftab LIKE TABLE OF fline.
    DO 3 TIMES.
      iline-num = sy-index.
      APPEND iline-num TO itab.
    ENDDO.
    ftab = itab.
    loop AT ftab INTO fline.
      WRITE: / fline-num.
    ENDLOOP.
    In a non-Unicode system, the output may look something like this:
            6.03823403895813E-154
            6.03969074613219E-154
            6.04114745330626E-154
    Here, the line types of the internal tables ITAB and FTAB are structures each with one component of type I or F. The line types are convertible, but not compatible. Therefore, when assigning ITAB to FTAB, the contents of Table ITAB are converted to type C fields and then written to FTAB. The system interprets the transferred data as type F fields, so that the results are meaningless. In Unicode systems, you are not allowed to convert numeric fields to fields of type C.
    Initializing Internal Tables
    Like all data objects, you can initialize internal tables with the
    CLEAR .
    statement. This statement restores an internal table to the state it was in immediately after you declared it. This means that the table contains no lines. However, the memory already occupied by the memory up until you cleared it remains allocated to the table.
    If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets () after the table name.
    CLEAR , LT, <).
    If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets () after the table name.
    The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA: ITAB LIKE TABLE OF LINE,
                 JTAB LIKE TABLE OF LINE.
    DO 3 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
      APPEND LINE TO ITAB.
    ENDDO.
    MOVE ITAB TO JTAB.
    LINE-COL1 = 10. LINE-COL2 = 20.
    APPEND LINE TO ITAB.
    IF ITAB GT JTAB.
    WRITE / 'ITAB GT JTAB'.
    ENDIF.
    APPEND LINE TO JTAB.
    IF ITAB EQ JTAB.
    WRITE / 'ITAB EQ JTAB'.
    ENDIF.
    LINE-COL1 = 30. LINE-COL2 = 80.
    APPEND LINE TO ITAB.
    IF JTAB LE ITAB.
    WRITE / 'JTAB LE ITAB'.
    ENDIF.
    LINE-COL1 = 50. LINE-COL2 = 60.
    APPEND LINE TO JTAB.
    IF ITAB NE JTAB.
    WRITE / 'ITAB NE JTAB'.
    ENDIF.
    IF ITAB LT JTAB.
    WRITE / 'ITAB LT JTAB'.
    ENDIF.
    The output is:
    ITAB GT JTAB
    ITAB EQ JTAB
    JTAB LE ITAB
    ITAB NE JTAB
    ITAB LT JTAB
    This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB.
    Sorting Internal Tables
    You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
    SORT  ASCENDING .
    The statement sorts the internal table  ASCENDING
                 BY  ASCENDING
                     ASCENDING .
    The table is now sorted by the specified components : ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.
    DATA: BEGIN OF LINE,
             COL1 TYPE I,
             COL2 TYPE I,
          END OF LINE.
    DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
                                        INITIAL SIZE 10.
    DATA: LIN TYPE I,
          INI TYPE I,
          KND TYPE C.
    DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.
    WRITE: / LIN, INI, KND.
    DO 1000 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.
    WRITE: / LIN, INI, KND.
    The output is:
             0         10  H
         1,000         10  H
    Here, a hashed table ITAB is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.
    INSERT LINE INTO TABLE ITAB.
    LINE-TEXT = 'Moller'.
    CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
    INSERT LINE INTO TABLE ITAB.
    LINE-TEXT = 'Miller'.
    CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
    INSERT LINE INTO TABLE ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB BY XTEXT.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB AS TEXT.
    PERFORM LOOP_AT_ITAB.
    FORM LOOP_AT_ITAB.
      LOOP AT ITAB INTO LINE.
        WRITE / LINE-TEXT.
      ENDLOOP.
      SKIP.
    ENDFORM.
    This example demonstrates alphabetical sorting of character fields. The internal table ITAB contains a column with character fields and a column with corresponding binary codes that are alphabetically sortable. The binary codes are created with the CONVERT statement (see Converting to a Sortable Format). The table is sorted three times. First, it is sorted binarily by the TEXT field. Second, it is sorted binarily by the XTEXT field. Third, it is sorted alphabetically by the TEXT field. Since there is no directly corresponding case in English, we have taken the results from a German text environment:
    Miller
    Moller
    Muller
    Möller
    Miller
    Moller
    Möller
    Muller
    Miller
    Moller
    Möller
    Muller
    After the first sorting, 'Möller' follows behind 'Muller' since the internal code for the letter 'ö' comes after the code for 'u'. The other two sorts are alphabetical
    The binary sort by XTEXT has the same result as the alphabetical sorting by the field TEXT.
    Regards,
    Amit
    Reward all helpful replies.

  • Upload an XML file into the Internal table

    Hi Guys,
    I want to know, how to upload an xml file into the Internal table through ABAP programming

    you just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
    for the first one you can simply use gui_upload
    and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
    Regards
    Raja

  • Value not moved to work are of the internal table

    HI
    I have one internal table declared with occurs 2500.
    i am selecting the values from a z table into this internal table.
    now i want to move the values in the table to another internal table for download.here except one field all the other fields are moving to the new internal table.When i debugged i could see the value in the internal table but its not getting moved to work area of that internal table (or the header line).
    I could not see the value when i use itab[]-field in debugger mode instead when i use itab[1]-field i could see that field value.
    please do suggest.

    There is no need to move your data from one internal table to another with fixed structure. All you need to do is take each row's components skipping the column you don't want to download and concatenate this to some string. Then append to string table and download it. Sample:
    "let's say your column is on 3rd place in the table
    data l_row_string type string.
    data lt_string_tab type table of string.
    Loop at itab assigning <wa>.
      do.
        check sy-index ne 3. "skip this column
        assign component sy-index of structure <wa> to <comp>.
        if sy-subrc = 0.
          CONCATENATE l_row_string <comp> INTO l_row_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
        else.
          "no more component in row
          append l_row_string to lt_string_tab.
          clear l_row_string.
          exit.     
        endif.
    enddo.
    endloop.
    Now all you need is to downlaod your lt_string_tab as your text file (extension TXT).
    Regards
    Marcin

  • Problem in changing the internal table contents of a standard program

    Dear All,
    I am making changes to internal table LT_PPDIT of standard program SAPLHRPT in the user exit EXIT_SAPLACC4_001 while payroll posting to accounting with tcode PC00_M99_CIPE. But though the changed value of LT_PPDIT is visible within the exit still the value of LT_PPDIT when we come outside exit is the same as what was before entering exit.
    Please suggest is there any way of modifying internal table of a standard program in the user exit.
    Regards,
    Kanupriya

    Hi,
    I think the internal table is getting refreshed or something like that after the user exit.
    Try debugging after the user exit and put breakpoints at clear and modify statements.
    Then you ll find out where its regaining the oringinal value after getting changes.
    After locating that point try finding some enhancmenent point there and including your code so that your value of internal able gets modified.
    Regards,
    Subhashini

  • Mapping corresponding field in the internal table

    Hi guys I need help with putting XML value into the appropriate fields in the internal table struc. I attempted to use if else condition to map the element name (cname)over to the fields but those internal table within an internal table post an issue of when to append and so on ... I am using FM SMUM_XML_PARSE and the output in to this table type smum_xmltb (containing all the XML Element and Values) I want to map it to its corresponding field in the internal table (defined below)
    Pls pardon this newbie here as this is very new to me. Hope to hear fr u all soon and points will be given! ")
    XML->>
    <?xml version="1.0" encoding="iso-8859-1"?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <BOOKLIST>
    <DATE>2006-09-25</DATE>
    <TIME>16:27:20</TIME>
    <BOOK_RECORD>
    <BOOK_NUM>0012345678</BOOK_NUM>
    <SHORT_DESC>OMS BOOK</SHORT_DESC>
    <BOOK_GROUP>
    <BOOK_CATEGORY>
    <CATEGORY_ID>03</CATEGORY_ID>
    <CATEGORY_DESC>BOOK group 3</CATEGORY_DESC>
    </BOOK_CATEGORY>
    <BOOK_CATEGORY>
    <CATEGORY_ID>02</CATEGORY_ID>
    <CATEGORY_DESC>BOOK group 2</CATEGORY_DESC>
    </BOOK_CATEGORY>
    </BOOK_GROUP>
    </BOOK_RECORD>
    <BOOK_RECORD>
    <BOOK_NUM>0012345679</BOOK_NUM>
    <SHORT_DESC>SAP BOOK</SHORT_DESC>
    <BOOK_GROUP>
    <BOOK_CATEGORY>
    <CATEGORY_ID>01</CATEGORY_ID>
    <CATEGORY_DESC>BOOK group 1</CATEGORY_DESC>
    </BOOK_CATEGORY>
    <BOOK_CATEGORY>
    <CATEGORY_ID>09</CATEGORY_ID>
    <CATEGORY_DESC>BOOK group 9</CATEGORY_DESC>
    </BOOK_CATEGORY>
    </BOOK_GROUP>
    </BOOK_RECORD>
    </BOOKLIST>
    </asx:values>
    </asx:abap>
    INTERNAL TABLE ->>
    TYPES: BEGIN OF ADD_CATEGORY,
    CATEGORY_ID(10),
    CATEGORY_DESC(40),
    END OF ADD_CATEGORY,
    ADD_T_CATEGORY TYPE ADD_CATEGORY OCCURS 0.
    TYPES: BEGIN OF ADD_BOOK_GRP,
    BOOK_CATEGORY TYPE ADD_T_CATEGORY,
    END OF ADD_BOOK_GRP,
    ADD_T_BOOK_GRP TYPE ADD_BOOK_GRP OCCURS 0.
    TYPES: BEGIN OF ADD_BOOK,
    BOOK_NUM(10) TYPE C,
    SHORT_DESC(40) TYPE C,
    BOOK_GROUP TYPE ADD_T_BOOK_GRP,
    END OF ADD_BOOK,
    ADD_T_BOOK TYPE ADD_BOOK OCCURS 0.
    TYPES: BEGIN OF TYPE_DATA,
    DATE TYPE SY-DATUM,
    TIME TYPE SY-TIMLO,
    BOOK_RECORD TYPE ADD_T_BOOK,
    END OF TYPE_DATA.
    DATA: I_DATA TYPE TYPE_DATA OCCURS 0 WITH HEADER LINE.

    hi,
    here is the code sample using ixml library .
    just create a report program and copy paste the following code.
    REPORT  y_test_xml.
    DATA: l_ixml                                 TYPE REF TO if_ixml,
            l_ixml_sf                              TYPE REF TO if_ixml_stream_factory,
            l_istream                              TYPE REF TO if_ixml_istream,
            l_ostream                              TYPE REF TO if_ixml_ostream,
            l_booklist                   TYPE REF TO if_ixml_element,
            l_document                             TYPE REF TO if_ixml_document,
            l_parser                               TYPE REF TO if_ixml_parser,
            l_root_element                         TYPE REF TO if_ixml_element,
            l_book_record                            TYPE REF TO if_ixml_element,
            l_date TYPE REF TO if_ixml_element ,
                    l_time TYPE REF TO if_ixml_element ,
            l_book_group                            TYPE REF TO if_ixml_element,
            l_book_cat                            TYPE REF TO if_ixml_element ,
            others                                  TYPE REF TO if_ixml_element ,
            link                                    TYPE REF TO if_ixml_element ,
            description                            TYPE REF TO if_ixml_element ,
            xml                                    TYPE xstring ,
            size TYPE  i ,
             l_xml  TYPE REF TO cl_xml_document  .
    DATA: xml_out TYPE string ,
          temp_string TYPE string .
    TYPES: BEGIN OF add_category,
    category_id(10),
    category_desc(40),
    END OF add_category,
    add_t_category TYPE add_category OCCURS 0 .
    TYPES: BEGIN OF add_book_grp,
    book_category TYPE add_t_category,
    END OF add_book_grp,
    add_t_book_grp TYPE add_book_grp OCCURS 0.
    TYPES: BEGIN OF add_book,
    book_num(10) TYPE c,
    short_desc(40) TYPE c,
    book_group TYPE add_t_book_grp,
    END OF add_book,
    add_t_book TYPE add_book OCCURS 0.
    TYPES: BEGIN OF type_data,
    date TYPE sy-datum,
    time TYPE sy-uzeit,
    book_record TYPE add_t_book,
    END OF type_data.
    DATA: i_data TYPE type_data OCCURS 0 WITH HEADER LINE.
    DATA: itab LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA: cat_wa TYPE add_category ,
          bk_gp_wa TYPE add_book_grp ,
          bk_rec_wa TYPE add_book ,
          bk_wa LIKE LINE OF i_data .
    DATA: cat_tab TYPE STANDARD TABLE OF add_category ,
          bk_gp_tab TYPE STANDARD TABLE OF add_book_grp ,
          bk_rec_tab TYPE STANDARD TABLE OF add_book .
    MOVE: '03' TO cat_wa-category_id  ,
          ' BK GP 3' TO cat_wa-category_desc .
    APPEND cat_wa TO cat_tab .
    MOVE: '02' TO cat_wa-category_id  ,
          ' BK GP 2' TO cat_wa-category_desc .
    APPEND cat_wa TO cat_tab .
    bk_gp_wa-book_category  = cat_tab.
    APPEND bk_gp_wa TO bk_gp_tab .
    MOVE: '0012345678' TO bk_rec_wa-book_num ,
          'OMS book' TO bk_rec_wa-short_desc .
    bk_rec_wa-book_group = bk_gp_tab .
    APPEND bk_rec_wa TO bk_rec_tab .
    CLEAR:bk_gp_tab, cat_tab .
    REFRESH :bk_gp_tab, cat_tab .
    MOVE: '01' TO cat_wa-category_id  ,
          ' BK GP 1' TO cat_wa-category_desc .
    APPEND cat_wa TO cat_tab .
    MOVE: '09' TO cat_wa-category_id  ,
          ' BK GP 9' TO cat_wa-category_desc .
    APPEND cat_wa TO cat_tab .
    bk_gp_wa-book_category  = cat_tab.
    APPEND bk_gp_wa TO bk_gp_tab .
    MOVE: '00123456789' TO bk_rec_wa-book_num ,
          'SAP book' TO bk_rec_wa-short_desc .
    bk_rec_wa-book_group = bk_gp_tab .
    APPEND bk_rec_wa TO bk_rec_tab .
    MOVE: sy-datum TO bk_wa-date ,
          sy-uzeit TO bk_wa-time .
    bk_wa-book_record = bk_rec_tab .
    APPEND bk_wa TO i_data .
    CLEAR: cat_wa , bk_gp_wa ,bk_rec_wa , bk_wa .
    l_ixml = cl_ixml=>create( ).
    l_ixml_sf = l_ixml->create_stream_factory( ).
    l_document = l_ixml->create_document( ).
    l_root_element = l_document->create_element( name = 'asx:abap' ).
    l_root_element->set_attribute( name = 'xmlns:asx' value = 'http://www.sap.com/abapxml' ) .
    l_root_element->set_attribute( name = 'version' value = '1.0' ).
    l_document->append_child( new_child = l_root_element ).
    others = l_document->create_simple_element( parent = l_root_element name = 'asx:values' ).
    l_booklist = l_document->create_simple_element( parent = others name = 'BOOKLIST' ).
    LOOP AT i_data INTO bk_wa .
      CLEAR temp_string .
      MOVE: bk_wa-date TO temp_string .
      l_date = l_document->create_simple_element( parent = l_booklist name = 'DATE' value = temp_string  ).
      CLEAR temp_string .
      MOVE: bk_wa-time TO temp_string .
      l_time = l_document->create_simple_element( parent = l_booklist name = 'TIME' value = temp_string ).
      LOOP AT bk_wa-book_record INTO bk_rec_wa .
        l_book_record = l_document->create_simple_element( parent = l_booklist name = 'BOOK_RECORD' ) .
        CLEAR temp_string .
        MOVE: bk_rec_wa-book_num TO temp_string .
        l_date = l_document->create_simple_element( parent = l_book_record name = 'BOOK_NUM' value = temp_string ).
        CLEAR temp_string .
        MOVE: bk_rec_wa-short_desc TO temp_string .
        l_time = l_document->create_simple_element( parent = l_book_record name = 'SHORT_DESC' value = temp_string ).
        l_book_group = l_document->create_simple_element( parent = l_book_record name = 'BOOK_GROUP' ).
        LOOP AT bk_rec_wa-book_group INTO bk_gp_wa .
          LOOP AT bk_gp_wa-book_category INTO cat_wa .
            l_book_cat = l_document->create_simple_element( parent = l_book_group name = 'BOOK_CATEGORY' ).
            CLEAR temp_string .
            MOVE: cat_wa-category_id TO temp_string .
            l_date = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_ID' value = temp_string ).
            CLEAR temp_string .
            MOVE: cat_wa-category_desc TO temp_string .
            l_time = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_DESC' value = temp_string ).
          ENDLOOP .
        ENDLOOP .
      ENDLOOP .
    ENDLOOP .
    l_ostream = l_ixml_sf->create_ostream_xstring( xml ).
    l_document->render( ostream = l_ostream ).
    CREATE OBJECT l_xml.
    CALL METHOD l_xml->parse_xstring
      EXPORTING
        stream = xml.
    l_xml->render_2_string(
      EXPORTING
        pretty_print = 'X'
      IMPORTING
       RETCODE      = RETCODE
        stream       = xml_out
        size         = size
    CALL METHOD l_xml->display.
    to read the xml data to abap itab you could parse node by node or write a XSLT to map it to your itab or use the following method. (add the following code to the earlier program)
    data: result_xml type standard table of smum_xmltb .
    data: return type standard table of bapiret2 .
    after the statement
    l_document->render( ostream = l_ostream ).
    add
    converting xml to itab
    call function 'SMUM_XML_PARSE'
    exporting
    xml_input = xml
    tables
    xml_table = result_xml
    return = return .
    now check the result_xml itab.
    rgds
    anver

  • Problem in the internal table of open dataset statement

    Hi abapers,
    I am using the open dataset command to download my file at application server into an internal table.
    But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
    The open dataset command does not allow the internal table to have string components.
    Is there any workaround by which i can download all the text components of the file without truncating them .
    Regards,
    Aditya

    try to use field symbols:-
    FORM download_file  .
      DATA: l_file TYPE  rlgrap-filename,
            l_line TYPE string.
      DATA: v_excel_string(1000) TYPE c,
              v_len TYPE i,
              v_zover TYPE i .
      FIELD-SYMBOLS: <f>     TYPE ANY .
      CLEAR wa_fin.
    *--- Seting File path
      CONCATENATE p_cfile v_file sy-datum INTO l_file.
    *--- Open data set
      OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT it_down INTO wa_down.
          CLEAR : v_excel_string, v_zover, v_len.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
            IF sy-subrc <> 0.
              EXIT. "exits do loop and process next record in itab
            ENDIF.
            DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
            v_excel_string+v_zover(v_len) = <f> .
            v_zover = v_zover + v_len .
          ENDDO.
          TRANSFER v_excel_string TO l_file.
          CLEAR : v_excel_string,
                  wa_down       ,
                  v_zover       .
        ENDLOOP.
    *--- Close data set
        CLOSE DATASET l_file.
        IF sy-subrc = 0.
    *--- Success Message
         MESSAGE s000(000) WITH text-018.
        ENDIF.
      ELSE.
    *--- Error unable to open file.
        MESSAGE e000(000) WITH text-017.
      ENDIF.
    ENDFORM.                    " DOWNLOAD_FILE
    Thanks ,
    Ruchi Tiwari

  • Confused with the internal table

    Hello,
    I am getting confused again by the usage of work space for an internal table.
    Say for example I have a internal table itab that is defined as:
    DATA:ITAB TYPE STANDARD TABLE OF Txxx.
    Then I define a work space for the internal table.
    DATA:WS_ITAB LIKE ITAB.
    Now say for example, I would like to fill in some data to this internal table, can I do:
    WS_ITAB-FIELD1 = 3.
    APPEND WS_ITAB INTO ITAB INDEX 1.
    where FIELD1 is a valid field in Txxx?
    If not, how should I accomplish my goal? Thanks a lot!

    Yes, you have the right idea.  When working with work areas it is a good idea to define them like line of itab. This way, anytime itab changes, the wa will also be updated.
    DATA: ITAB TYPE STANDARD TABLE OF Txxx.
    <b>data: wa like line of itab</b>.
    You can add a line to your internal table by filling the work area and appending to the internal table.
    wa-fld1 = 'A'.
    wa-fld2 = 'B'.
    wa-fld3 = 'C'.
    append wa to itab.
    You can insert into a specific index by using INSERT.
    Insert wa into itab index 1.
    Regards,
    Rich heilman

  • REUSE_ALV_GRID_DISPLAY - the internal table are different showed table

    Hello
    I'm using  REUSE_ALV_GRID_DISPLAY. The internal table-filed X = 1000. The same field on ALV list is showed as 1000 000.
    The field is :
    SORTAMOUNT          CURR     12     decimal 5     
    Following the code (i not used particular option):
      REFRESH lt_fieldcat.
      CLEAR   lt_fieldcat.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
         EXPORTING
           i_program_name     =  'ZFI_FLASH_FILES'
           i_internal_tabname =   'ZFI_FLASH_FILES'
         i_inclname         = sy-repid
           i_inclname         = 'ZFI_FLASH_FILES'
          i_structure_name   = 'ZFI_FLASH_FILES'
         CHANGING
           ct_fieldcat        = lt_fieldcat
         EXCEPTIONS
           OTHERS             = 1.
      IF sy-subrc NE 0.
        REFRESH lt_fieldcat.
        CLEAR   lt_fieldcat.
      ENDIF.
      LOOP AT lt_fieldcat INTO ls_slis_fieldcat.
        CASE ls_slis_fieldcat-fieldname.
          WHEN 'UNITCODE'.
            MOVE 'Code IC' TO ls_slis_fieldcat-seltext_s.
          WHEN 'ACCCODE'.
            MOVE 'Code Account' TO ls_slis_fieldcat-seltext_s.
          WHEN 'DIM1CODE'.
            MOVE 'Brand-code' TO ls_slis_fieldcat-seltext_s.
          WHEN 'DIM2CODE'.
            MOVE 'Product-type-code' TO ls_slis_fieldcat-seltext_s.
          WHEN 'DIM3CODE'.
            MOVE 'Pays FH' TO ls_slis_fieldcat-seltext_s.
          WHEN 'CURRCCODE'.
            MOVE 'Devise' TO ls_slis_fieldcat-seltext_s.
          WHEN 'SORTAMOUNT'.
            MOVE 'Cumul' TO ls_slis_fieldcat-seltext_s.
            MOVE '5' TO ls_slis_fieldcat-decimals_out.        "@6I
        ENDCASE.
        MODIFY lt_fieldcat FROM ls_slis_fieldcat.
      ENDLOOP.
      alv_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
               i_callback_program = 'ZFI_FLASH_FILES'
              i_grid_title       = 'Fichier Flash'
               i_structure_name   =   'ZFI_FLASH_FILES'
               is_layout          = alv_layout
              i_callback_user_command = 'USER_COMM'
               it_fieldcat        = lt_fieldcat
              i_default          = 'X'
              i_save             = 'A'
              it_sort            = i_sort
               i_save             = 'A'
               is_variant         = ls_variant
            it_events          = event_tb
               is_print           = alv_print
          TABLES
               t_outtab           =  t_datatab
          EXCEPTIONS
               program_error      = 1
               OTHERS             = 2.
    Any idea ?

    Solved by refreshing with sync transaction.
    Thank you
    regards
    Roberto

  • Reg: Downloading the internal table into excel file.

    Hi,
    My requirement is i am collecting data in the internal table and i have to download the contents in an excel file and i have declared like this.
    PARAMETERS : x_test    TYPE string
                          DEFAULT 'C:\temp\file.txt'.
    I have given the default file path  like this and i am using the function module .
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                    =
          FILENAME                      = OUTPUT_PATH
          FILETYPE                      = 'DAT'
    IMPORTING
      FILELENGTH                      =
        TABLES
          DATA_TAB                        = INT_INPUT
      FIELDNAMES                      =
       EXCEPTIONS
         FILE_WRITE_ERROR                = 1
         NO_BATCH                        = 2
         GUI_REFUSE_FILETRANSFER         = 3
         INVALID_TYPE                    = 4
         NO_AUTHORITY                    = 5
         UNKNOWN_ERROR                   = 6
         HEADER_NOT_ALLOWED              = 7
         SEPARATOR_NOT_ALLOWED           = 8
         FILESIZE_NOT_ALLOWED            = 9
         HEADER_TOO_LONG                 = 10
         DP_ERROR_CREATE                 = 11
         DP_ERROR_SEND                   = 12
         DP_ERROR_WRITE                  = 13
         UNKNOWN_DP_ERROR                = 14
         ACCESS_DENIED                   = 15
         DP_OUT_OF_MEMORY                = 16
         DISK_FULL                       = 17
         DP_TIMEOUT                      = 18
         FILE_NOT_FOUND                  = 19
         DATAPROVIDER_EXCEPTION          = 20
         CONTROL_FLUSH_ERROR             = 21
         OTHERS                          = 22.
    My requirement is i dont want to change my extension as .txt from .exl to my parameter addition and in the function module the file type should be 'dat' only and in the runtime i want to change the file name which i have given in the .
    PARAMETERS : x_test    TYPE string
                          DEFAULT 'C:\temp\file.txt' this file.txt into datas.xls.
    it would be grateful if some one share some valuable views to wards this query
    Thanks and Regards,
    Keny

    Hi,
    Use this code.
    It will ask for the file name...there u can change.
      data : l_filename type string,
             l_filetype type char10,
             l_path type string,
             l_fullpath type string.
      l_filetype = 'DAT'.
    *Get the file name
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
        EXPORTING
          FILE_FILTER          = '*.DAT'
          INITIAL_DIRECTORY    = 'C:\'
        CHANGING
          FILENAME             = l_filename
          PATH                 = l_path
          FULLPATH             = l_fullpath
        EXCEPTIONS
          CNTL_ERROR           = 1
          ERROR_NO_GUI         = 2
          NOT_SUPPORTED_BY_GUI = 3
          others               = 4.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      check l_fullpath is not initial.
    *Download file
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
          FILENAME                = l_fullpath
          FILETYPE                = l_filetype
        CHANGING
          DATA_TAB                = t_data_sum[]
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          NOT_SUPPORTED_BY_GUI    = 22
          ERROR_NO_GUI            = 23
          others                  = 24.
      IF sy-subrc NE 0.
        MESSAGE e398(00) WITH sy-subrc ' Error downloading file' '' ''.
      ENDIF.
    Regards
    Sandeep REddy

  • How to submit a report ,Passing the internal tables from parent report

    How to submit a report ,Passing the internal tables from the parent report ?

    The SUBMIT statement executes a report from within a report. i.e. you could have a drill-down which
    calls another report. Can only execute reports of type '1'.
    *Code used to execute a report
    SUBMIT Zreport.
    *Code used to populate 'select-options' & execute report
    DATA: seltab type table of rsparams,
          seltab_wa like line of seltab.
      seltab_wa-selname = 'PNPPERNR'.
      seltab_wa-sign    = 'I'.
      seltab_wa-option  = 'EQ'.
    load each personnel number accessed from the structure into
    parameters to be used in the report
      loop at pnppernr.
        seltab_wa-low = pnppernr-low.
        append seltab_wa to seltab.
      endloop.
      SUBMIT zreport with selection-table seltab
                                    via selection-screen.
    *Code used to populate 'parameters' & execute report
    SUBMIT zreport with p_param1 = 'value'
                    with p_param2 = 'value'.
    Other additions for SUBMIT
    *Submit report and return to current program afterwards
    SUBMIT zreport AND RETURN.
    *Submit report via its own selection screen
    SUBMIT zreport VIA SELECTION-SCREEN.
    *Submit report using selection screen variant
    SUBMIT zreport USING SELECTION-SET 'VARIANT1'.
    *Submit report but export resultant list to memory, rather than
    *it being displayed on screen
    SUBMIT zreport EXPORTING LIST TO MEMORY.
    Once report has finished and control has returned to calling
    program, use function modules LIST_FROM_MEMORY, WRITE_LIST and
    DISPLAY_LIST to retrieve and display report.
    *Example Code (Retrieving list from memory)
    DATA  BEGIN OF itab_list OCCURS 0.
            INCLUDE STRUCTURE abaplist.
    DATA  END OF itab_list.
    DATA: BEGIN OF vlist OCCURS 0,
            filler1(01)   TYPE c,
            field1(06)    TYPE c,
            filler(08)    TYPE c,
            field2(10)    TYPE c,
            filler3(01)   TYPE c,
            field3(10)    TYPE c,
            filler4(01)   TYPE c,
            field4(3)     TYPE c,
            filler5(02)   TYPE c,
            field5(15)    TYPE c,
            filler6(02)   TYPE c,
            field6(30)    TYPE c,
            filler7(43)   TYPE c,
            field7(10)    TYPE c,
          END OF vlist.
    SUBMIT zreport EXPORTING LIST TO MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = itab_list
      EXCEPTIONS
        not_found  = 4
        OTHERS     = 8.
    CALL FUNCTION 'LIST_TO_ASCI'
      EXPORTING
        list_index         = -1
      TABLES
        listasci           = vlist
        listobject         = itab_list
      EXCEPTIONS
        empty_list         = 1
        list_index_invalid = 2
        OTHERS             = 3.
    IF sy-subrc NE '0'.
      WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.
    ENDIF.
    Submit report as job
    *Submit report as job(i.e. in background)
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum
                sdlstrttm        = sy-uzeit
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    Insert process into job
    SUBMIT zreport and return
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.

Maybe you are looking for