Assign string  to various fields of internal table

hello,
i have  one string : lt_str  TYPE STANDARD TABLE OF string.
And there is one structure as:
begin of ty_data
field1
field2
field 3
end of ty_data.
* table declaration:
gt_data  TYPE STANDARD TABLE OF ty_data   WITH HEADER LINE.
In old ECC we have write like gt_data = lt_str. Now we are shifting it to new version but it is not working in ECC 6.0.It is giving unicode error regarding conversion.
In our case there are many structure like ty_data  but we want unique solution to gt_data = lt_str.
so how can i do it?

Hi Tushar,
Please refer below link for all commoun Unicode conversion error.
http://wiki.scn.sap.com/wiki/display/SI/UCCHECK+(Unicode+Complaince)+-+Common+Errors+and+Solutions
Move string to Structure:
call method cl_abap_container_utilities=>read_container_c
exporting
  im_ container = data_string
importing
  ex_ value = struc_umsetz
exceptions
illegal_parameter_type = 1
others = 2.
Regrads,
Jyoti Singh

Similar Messages

  • Assign function code to a field in internal table

    Hi all,
    Can we assign a function code to one field in internal table so that we can use it as an user command in list display.
    For ex:
    data : begin of itab occurs 0,
              check(1) type C,
              num type I,
             end of itab.
    I am preparing a list display using WRITE statements.
    I'ld like to update the checked value of check box as soon as the user selects a  check box. So I would like to assign a function code to this check box. Then I can use AT user-command.

    Hi,
    dinesh's apporach is not bad, but
    1. the structure' name cannot be part of the component
    2. you need to make sure the component-name always is in upper case.
    Try adapting the following code:
    data: begin of wa_test,
              field01 type string,
              field02 type string,
              field03 type string,
           end of wa_test.
    data:  l_fieldname  type string,
           l_counter    type string.
    field-symbols: <testc> type string.
    do 3 times.
      l_counter = sy-index.
      concatenate 'field0' l_counter into l_fieldname.
      translate l_fieldname to upper case.
      assign component l_fieldname of structure wa_test to <testc>.
      if <testc> is assigned.
        <testc> = 'any value'.
      endif.
    enddo.
    write / wa_test-field01.
    best regards

  • How to handle field symbols internal table values?

    HI all,
              I declared field string as below.The below code is working fine.
    Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
              wa_itab like line of ITAB.
    field-symbol : <fs> type ITAB.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
    If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
    Data : BEGIN OF ITAB1 OCCURS 0,
             FIELD1 LIKE YAPOPLN-FIELD1,
             FIELD2 LIKE YAPOPLN-FIELD2,
             END OF ITAB1.
    field-symbol : <fs> LIKE ITAB1 OR  <FS> TYPE ANY.
    DATA :WA_ITAB1 LIKE LINE OF ITAB1.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
    .'FS' is not an internal table or defined in TABLES.
    Can anyone help me in this regard?
    Thanks,
    Balaji

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • How to move field symbol internal table to internal table with header line?

    Dear all,
    hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
    as i know field symbol internal table is without header line..
    so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
    Please advise...
    Thanks
    Regard,
    ToToRo.
    Edited by: @ToToRo@ on Aug 20, 2009 6:16 AM

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • How To select maximum Value in a specifieid field in internal table.

    How To select maximum Value in a specifieid field in internal table?

    Step : 1
    Sort itab by <Field1> descending.
    Just sort the internal table by the field.
    STEP: 2
    Then read the table at index 1.
    Read table itab index 1.               
    ITAB-FIELD = MAX .                  " Max field will come in the first row of the internal table.
    Regards,
    Gurpreet

  • How to add the contents of a field of internal table.

    Hello Everybody,
    How to sum up the individual field from a internal table. Like i have a internal table that has menge field , I need to sum up the menge field for each matnr..
    exm : for each matnr there are 5 menge entries, I need to add all the menge fields and shud be put against the matnr .
    Thanks,

    Hi Khaleel,
    One more option is using the "collect" statement.....
    imagine in the internal table itab..we have 2 fields only..
    MATNR,MENGE,
    we have 2 internal tables itab1 and itab2...
    loop at itab1.
    collect itab1 to itab2.
    endloop.
    Action performed is ...for the same MATNR...menge gets added and saved as a single record...When matnr changes...new record is Appended
    another case is we have 3 fields in internal table
    MATNR,UNIT,MENGE
    imagine we hane the records
    Material1 KG  100
    Material1 LT   20
    Material1 LT   200
    MAterial2 KG 100
    in this case...the output will be
    Material1 KG 100
    Material1 LT  220
    MAterial2 KG 100
    Reason is that the fields before the addable value is checked for similarity..
    here field UNIT is also checked and also MATNR before adding up....
    Hope it gave you some alternative idea to proceed with....
    Reward if helpful
    Regards
    Byju

  • Read contents of changing fields from internal table

    Hi Folks,
    Please help me in my query below:
    Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
    In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
    Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
    The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
    So how can I read the particular field from internal table as the field to be read is dynamic.
    Note: using case is not feasible.
    Thanks in advance.
    Regards,
    Shardul

    @Hartmut P
    As Rob said i want to get the value of the field from internal table. the code is something like this.
    I_KNA1 contains records for customers.
    Suppose values of Z-table are in internal table I_TEMP_TABLE.
    Entries in I_TEMP_TABLE are as follows
    TABNAME      FIELDNAME
    KNA1                 NAME1
    The value of FIELNAME in Z-table can be changed
    Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
    Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
    IF SY-SUBRC EQ 0.
       CASE WA_TEMP_TABLE-FIELDNAME.
            WHEN 'NAME1'.
                 V_VAR = WA_KNA1-NAME1.
             WHEN 'PSTLZ'
                  V_VAR = WA_KNA1-PSTLZ.
    ENDIF.
    But using case is not appropriate as KNA1 contains 176 fields.

  • Populate dynamic table fields from internal table

    Hi,
    Im trying to populate an dynamic table , but it's giving me a few errors witch i can't solve ...
    Basically i have an internal table with te following types :
    DATA: BEGIN OF tab_docs41 OCCURS 0,
          conta TYPE bsis-hkont,
          banco TYPE t012t-text1,
          ano_3 TYPE i,
          ano_2 TYPE i,
          ano_1 TYPE i,
          jan TYPE  i,
          fev TYPE  i,
          mar TYPE  i,
          abr TYPE  i,
          mai TYPE  i,
          jun TYPE  i,
          jul TYPE  i,
          ago TYPE  i,
          set TYPE  i,
          out TYPE  i,
          nov TYPE  i,
          dez TYPE  i,
          total TYPE i,
          montante TYPE betrag11,
    END OF tab_docs41.
    and the following fieldcatalog , for the dynamic table :
    DATA : ls_fieldcat TYPE lvc_s_fcat.
      DATA: lv_period TYPE i.
      DATA str_period TYPE string.
      SUBTRACT 3 FROM ano.
      MOVE ano TO str_period.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname = 'CONTA'.
      ls_fieldcat-seltext = 'Conta do Razão'.
      ls_fieldcat-datatype = 'HKONT'.
    *  ls_fieldcat-intlen = '10'.
      APPEND ls_fieldcat TO p_fieldcat.
    Since the internal table, tab_docs41 it's allready filled how can i pass the tab_docs41 values to the corresponding fields of the dynamic table (the move-corresponding it's not working..)
      ASSIGN fs_data->* TO <fs_1>.
      CREATE DATA new_line LIKE LINE OF <fs_1>.
    *  ASSIGN new_line->*  TO <fs_2>.
    *** Next step is to create a work area for our dynamic internal table.
      LOOP AT tab_docs41.
       ASSIGN COMPONENT 'CONTA' OF STRUCTURE  tab_docs41 TO <fs2>.
    But this last step it's not working ...
    Can anyone help me please ?
    Point's will be rewarded
    Best Regards
    Thanks in advance
    João Martins

    Looks like you have used the method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic internal table.
    You have to change the last part of the code:
    FIELD-SYMBOLS:
    <itab> TYPE STANDARD TABLE,
    <wa> TYPE ANY,
    <val> TYPE ANY .
    ASSIGN fs_data->* TO <itab>.
    CREATE DATA new_line LIKE LINE OF <itab>.
    ASSIGN new_line->*  TO <wa>.
    LOOP AT tab_docs41.
      ASSIGN COMPONENT 'CONTA' OF STRUCTURE <wa> TO <val>.
      <val> = tab_docs41-conta.
      ASSIGN COMPONENT 'BANCO' OF STRUCTURE <wa> TO <val>.
      <val> = tab_docs41-banco.
      APPEND <wa> to <itab>.
    ENDLOOP.
    BR,
    Suhas

  • Reading the data from field symbol internal table //

    Hi,
    There are 2 internal tables defined as Fieldsymbols (type any) and I need to retrive data from second internal table based on a field value in first internal table.
    Let's assue the name internal table 1 is <it_itab1>, 2nd internal table name is <it_itab2> and the work areas are <wa_itab1> and <wa_itab2>.
    The existing logic :
    LOOP at <it_itab1> ASSIGNING <wa_itab1>.
      ASSIGN COMPONENT 'XYZ' OF STRUCTURE <wa_itab1> TO l_field6.
      LOOP AT <it_itab2> ASSIGNING <wa_itab2>.
        ASSIGN COMPONENT 'XYZ' OF STRUCTURE <wa_itab2> TO <p_field7>.
        IF <p_field7> = l_field6.
    do the required business.
        ELSE.
          *     do the required business.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
    The requirement of reading second internal table was achieved by putting loop on the internal table but its giving considerable effect on performance !!
    Is there any way to use READ statement in my case OR any way of putting WHERE condition on loop statement of second internal table ??
    Thank you !!

    Use the below Logic.
    Loop at Itab1 into wa_itab1.
        Loop at itab2 into wa_itab2 where p_field7 = wa_itab1-xyz or I_field6.
    do the required business.
        endloop.
        Loop at itab2 into wa_itab2 where p_field7 <> wa_itab1-xyz or I_field6.
    do the required business.
        endloop.
    endloop.
    Hope it is useful...

  • Length of value of c field in internal table

    Hi experts,
    how do I find out the lenght of the value which is an CHARACTER field in an internal table.
    I get a .XLS file from the customer. To check where the real entries starts I need to know the length of one field in the internal table.
    How do I do this?
    I tried it with DESCRIBE, but it doesn't work because the c field is interpreted hexadecimal.
    Example:
    all fields in my table are c(30), the value in one column is max. 3 letters. I want to find out the row where the entry in this field is 3 letters long.
    Edited by: Heiko Kany on Sep 3, 2008 8:49 AM

    Hi Heiko,
    You can find the length using the STRLEN function as given below;
    DATA : ipstr TYPE string.
    DATA : len TYPE i VALUE 0.
    ipstr = 'Sample String'.
    len = STRLEN( ipstr )
    After execution len will contain 13.
    Regards
    Karthik D

  • Replace field in internal table

    Hi gurus,
    I have an internal table in which I need to replace a field with a different value.  I have tried the REPLACE __ IN TABLE __ WITH statement, but it did not seem to work. 
    Also, I cannot use a SORT TABLE statement because the record needs to be at a certain index in the table.
    Any suggestions?  <REMOVED BY MODERATOR>
    Thanks in advance!
    Edited by: Alvaro Tejada Galindo on Aug 14, 2008 3:03 PM

    Hi.  If you know the exact field in the exact row of the table, you could do something like this.   This is direct access to the field without having to use the MODIFY statement.
    REPORT  zrich_0001.
    TYPES: BEGIN OF ttab,
           fld1 TYPE c,
           fld2 TYPE c,
           fld3 TYPE c,
           END OF ttab.
    DATA: itab TYPE TABLE OF ttab.
    DATA: wa LIKE LINE OF itab.
    FIELD-SYMBOLS: <wa> LIKE LINE OF itab.
    * fill ITAB with data.
    wa-fld1 = 'A'.
    wa-fld2 = 'B'.
    wa-fld3 = 'C'.
    APPEND wa TO itab.
    wa-fld1 = 'D'.
    wa-fld2 = 'E'.
    wa-fld3 = 'F'.
    APPEND wa TO itab.
    wa-fld1 = 'G'.
    wa-fld2 = 'H'.
    wa-fld3 = 'I'.
    APPEND wa TO itab.
    * Now access FLD2 of row 2, and change the value to X
    READ TABLE itab ASSIGNING <wa> INDEX 2.
    IF sy-subrc  = 0.
      <wa>-fld2 = 'X'.
    ENDIF.
    Regards,
    Rich Heilman

  • Reg Modification of a field in internal table.

    Hi
    i have requirement like this. I have a header and an items in a report. In header, i need to display the no. of . items(count). In my report i am displaying the records before moving to internal table(Direct write). Also i want to download that report into a CSV file.
    Regards
    Ravi

    hi,
    Check out this sample code
    report ztest.
    data: begin of itab occurs 0,
    fld1(10) type c,
    fld2(10) type c,
    fld3(10) type c,
    end of itab.
    data: begin of iout occurs 0,
    rec(1000) type c,
    end of iout.
    parameters: p_file type localfile default 'C:\test.csv'.
    data: file type string.
    start-of-selection.
        * Build the ITAB
    itab-fld1 = 'A'.
    itab-fld2 = 'B'.
    itab-fld3 = 'C'.
    append itab.
    itab-fld1 = 'D'.
    itab-fld2 = 'E'.
    itab-fld3 = 'F'.
    append itab.
    itab-fld1 = 'G'.
    itab-fld2 = 'H'.
    itab-fld3 = 'I'.
    append itab.
        * Build the output internal table from ITAB
        * Concatenate all fields into IOUT-REC
    loop at itab.
    concatenate itab-fld1 itab-fld2 itab-fld3 into iout-rec
    separated by ','.
    condense iout-rec no-gaps.
    append iout.
    endloop.
        * Now Download
    file = p_file.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = file
    tables
    data_tab = iout
    exceptions
    others = 22.

  • Looping over fields from internal table

    In a FM I have to check records of two ITABs against each other. Most fields can be checked 1:1 but some must be checked according to some business logic.
    I first want to check field-by-field and then I want to deal with exceptions.
    Question: How can I loop over fields in an ITAB in such a manner that I can compare fields?

    Hi, you can loop thru the columns(fields) of an internal table like so.
    field-symbols: <fs>.
    loop at itab.
    do.
    * Here you can use the field name instead of SY-INDEX
       assign component sy-index of structure itab to <fs>.
       if sy-subrc <>.
       exit.
       endif.
    * Now that you have access to the field via field symbol, you can compare
    * this value.
    Write:/ <fs>.
    enddo. 
    endloop.
    Regards,
    Rich Heilman

  • Field-symbols : internal table

    Dear experts,
    I am trying to put contents of internal table from a standard transaction in this way but i am not getting.
    Further i get last record successfully if i try to follow the code of this link
    http://www.sapdevelopment.co.uk/enhance/enhance_fsymbol.htm
    The code that i use is :
    types: begin of t_type,
    tabix type i,
    color type c,
    selfl type c,
    vbeln like lips-vbeln,
    posnr like lips-posnr,
    kschl like nast-kschl,
    nacha like nast-nacha,
    parvw like nast-parvw,
    pname like kna1-name1,
    pcity like lfa1-ort01,
    vstel type c,
    lfdat like mkpf-budat,
    wadat like mkpf-budat,
    end of t_type.
    data :   pgm(40) value '(SAPLKKBL)T_OUTTAB[]'.
             field-symbols: <fs> type standard table.
    data: i_get type t_type occurs 0 with header line.
    assign (pgm) to <fs>.
    append lines of <fs> to i_get[].
    But not getting,the datatype i have created is only by looking at fields in memory map.Its not exactly of T_OUTPUT[] as it can't be referred

    Hi aditya,
    Please try defining field symbol as of generic type ( TYPE ANY).
    or try this way.
    data :
    pgm(40)
    t_pgm like standard table of pgm.
    field-symbols: <fs> type ANY
    data: i_get type t_type occurs 0 with header line.
    t_pgm =  (SAPLKKBL)T_OUTTAB[].
    Loop at t_pgm into pgm.
    assign pgm to <fs>.
    append <fs> to i_get[].
    ENDLOOP.
    Hope this would help you.
    Good luck
    Narin

  • ASSIGN to add new lines to internal tables

    Hello,
    within our code, I have found several occurrences of the obsolete ASSIGN LOCAL COPY which I would like to replace with up-to-date coding. Particularly, we have the following code segment:
    DATA: ct_table TYPE INDEX TABLE.
    FIELD-SYMBOLS: <ls_new_row> TYPE ANY,
                   <lv_field>   TYPE ANY.
    ASSIGN LOCAL COPY OF INITIAL LINE OF ct_table TO <ls_new_row>.
    ASSIGN COMPONENT '1' OF STRUCTURE <ls_new_row> TO <lv_field>.
    <lv_field> = ...
    ASSIGN COMPONENT '2' OF STRUCTURE <ls_new_row> TO <lv_field>.
    <lv_field> = ...
    INSERT <ls_new_row> INTO TABLE ct_table.
    What is the most efficient non-obsolete code equivalent for this?
    --Florian

    You might also use the command INSERT INITIAL LINE INTO TABLE itab ASSIGNING <fs>.
    You will encounter problems with this solution if the internal table has key components as the system will not allow you to change these in this setup after the insertion.

Maybe you are looking for

  • IPod touch not detected in iTunes.

    Here it goes, I was having some issues with my iTouch so I tried to restore today. After restore was complete iTunes automatically quitted and when i restarted iTunes it said cannot connect to iPhone exxor EX-000065 or something but it was 65 in the

  • Stupid Placement or lack of buttons...

    A couple things have been bothering me about OS X these past couple of days. I don't know if anyone else cares, but I just need to find a place to complain! 1. Why did they make the radio buttons smaller? I just noticed how hard it was for me to clic

  • Duplicate Check while creating new BP

    Dears, I am a CRM Consultant and working on a CRM VMS integration scenario, wherein BP(End customer) is created in VMS system and this will be replicated to SAP CRM system which has duplicate check active.  However we would like to perform the duplic

  • I visit a website which has podcasts.when I click listen icon on a page, it opens a small new window where mp3 file streams.

    But I want to open mp3 file in new tab on the page.Normally when I click a link on any website, links open in new tab. but on this site (elspod.com) there are icons not links .the site is elspod.com

  • Need help adding printer

    When I installed Tiger I chose to not install any printers, now I need to add an HP 895cse. The driver on HP's site is not working so I need to install the one from the tiger CD. Can someone tell me exactly how to do this? Thanks