Question to ASSIGN COMPONENT 3 OF STRUCTURE LFC1 TO FS .

Hi,
i do this in abap (ECC6):
FIELD-SYMBOLS: <FS> TYPE ANY.
ASSIGN COMPONENT 3 OF STRUCTURE LFC1 TO <FS>.
WRITE: / <FS>.
it works as i need.
Is it possible to get the fieldname of the 3. field of structure LFC1?
thanks.
regards, Dieter

Hi,
You can via a couple of method calls....
report  zdescribe.
data: gs_t001 type t001.
data: go_struct type ref to cl_abap_structdescr,
      gt_comp   type abap_component_tab,
      gs_comp   type abap_componentdescr.
start-of-selection.
  go_struct ?= cl_abap_typedescr=>describe_by_data( gs_t001 ).
  gt_comp = go_struct->get_components( ).
  loop at gt_comp into gs_comp.
    write: / gs_comp-name.
  endloop.
Darren

Similar Messages

  • ASSIGN COMPONENT x OF STRUCTURE not assigning !

    Hello,
    the problem is that the component PAKET is not getting assigned to my field symbol (<l_str_applparam> type any) and i don't understand why. The PAKET field is type INT4 and the value is 1111.  The importing structure i_str_applparam is also type any.
    See coding below:
      DATA: l_sel_tab TYPE TABLE OF rsparams,
                  l_rcl_type TYPE REF TO cl_abap_typedescr,
                  l_comp_table TYPE abap_component_tab,
                  l_rcl_struc TYPE REF TO cl_abap_structdescr,
                  l_tab_fields TYPE abap_compdescr_tab.
      m_var_beschreibung = i_var_beschreibung.
      DATA l_var_ddic_header TYPE x030l.
      l_rcl_struc ?= cl_abap_typedescr=>describe_by_data( i_str_applparam ).
      l_var_ddic_header = l_rcl_struc->get_ddic_header( ).
      CREATE DATA m_str_applparam TYPE (l_var_ddic_header-tabname).
      FIELD-SYMBOLS: <l_str_applparam> TYPE ANY.
      GET REFERENCE OF i_str_applparam INTO m_str_applparam.
      LOOP AT l_sel_tab INTO l_wrk_sel
        WHERE kind = 'P'.
        CASE l_wrk_sel-selname.
          WHEN 'PA_PAKET'.
            IF l_wrk_sel-low IS NOT INITIAL.
              ASSIGN COMPONENT 'PAKET' OF STRUCTURE m_str_applparam TO <l_str_applparam>.
              CHECK <l_str_applparam> IS ASSIGNED.  ?? NOT ASSIGNED ??
              <l_str_applparam> = l_wrk_sel-low.
            ENDIF.
        ENDCASE.
    Thank you in advance,
    Ioan Constantin.

    Hello Uwe,
    thank you for the first answer. I have another tiny question: i am not allowed to change the values of the import structure and i want to save them in my class, is there a simpler way to save the data besides the loop below ??
      DATA: l_var_ddic_header TYPE x030l.
      l_rcl_struc ?= cl_abap_typedescr=>describe_by_data( i_str_applparam ).
      l_var_ddic_header = l_rcl_struc->get_ddic_header( ).
      CREATE DATA m_str_applparam TYPE (l_var_ddic_header-tabname).
      FIELD-SYMBOLS: <l_str_applparam> TYPE ANY,
                     <l_str_m_applparam> TYPE ANY,
                     <l_var_comp> TYPE ANY,
                     <l_var_m_comp> TYPE ANY.
      ASSIGN i_str_applparam to <l_str_applparam>.
      ASSIGN m_str_applparam->* TO <l_str_m_applparam>. "m_str_applparam is a class attribute
      DATA l_wrk_rcl_struc TYPE abap_compdescr.
      LOOP AT l_rcl_struc->components INTO l_wrk_rcl_struc.
        ASSIGN COMPONENT l_wrk_rcl_struc-name OF STRUCTURE <l_str_applparam> TO <l_var_comp>.
        ASSIGN COMPONENT l_wrk_rcl_struc-name OF STRUCTURE <l_str_m_applparam> TO <l_var_m_comp>.
      <l_var_m_comp> = <l_var_comp>.
      ENDLOOP.
    Regards,
    Ioan.

  • Assign Component with dynamic structure.

    Hi,
    I like to get a field from a structure which i read from a customizing table. I think with a snippet it is easy to understand:
      FIELD-SYMBOLS:  <fs_value>         TYPE  Any.
    DATA: lv_field type text30,
           lv_structure type  but000,
           lv_Structure_name type text30.
    select single *
      into lv_structure
      from but000.
    lv_field = 'PARTNER'.
    lv_Structure_name = 'LV_STRUCTURE'.
    ASSIGN COMPONENT lv_field OF STRUCTURE lv_Structure_name TO <fs_value>.
    But this doesn't wok, because it seems, that this statement try to get the fieldname from the variable 'lv_Structure_name'.
    If i replace lv_Structure_name with lv_Structure than it works, but this is not what I like.
    Any ideas
    Stefan

    Hi,
    with a little addition of a second fs:
    FIELD-SYMBOLS: <fs_value> TYPE ANY.
    FIELD-SYMBOLS: <fs_struc> TYPE ANY.
    DATA: lv_field TYPE text30,
    lv_structure TYPE but000,
    lv_structure_name TYPE text30.
    SELECT SINGLE *
    INTO lv_structure
    FROM but000.
    lv_field = 'PARTNER'.
    lv_structure_name = 'LV_STRUCTURE'.
    ASSIGN (lv_structure_name) TO <fs_struc>.
    ASSIGN COMPONENT lv_field OF STRUCTURE <fs_struc> TO <fs_value>.
    it will work.
    regards
    Jörg

  • Assign values to bapi structure dynamically

    Hi,
    I have to use the BAPI, BAPI_MATERIAL_SAVEDATA to extend the material to different plant specific views. I have to use the structure BAPI_MARC and other structures in order to do this. But the values to be passed to the structure BAPI_MARC are not fixed. These values will be maintained in a custom table against the structure name and field name for a particular plant.
    In the program I have to extract the structure name and field name for a corresponding plant from custom table and fill the corresponding value in BAPI structure BAPI_MARC.
    Now, internal table in the program is having these details.
    How can I fill the bapi structure BAPI_MARC based on this information.
    For example, if in custom table, value 0001 is maintained against the field PUR_GROUP, I have to fill the field PUR_GROUP in strcutre BAPI_MARC with 0001.
    Hope I am clear in explaining the problem. Please let me know how to aciheve this?
    Best Regards,
    Kumar.

    Hi,
    I have tried to implement that in a sample program first. Please have a look at the code below.
    DATA: BEGIN OF line,
            col1 TYPE i,
            col2 TYPE i,
            col3 TYPE i,
          END OF line.
    DATA comp(4) TYPE c VALUE 'COL3'.
    FIELD-SYMBOLS: <f1> TYPE ANY, <f3> TYPE ANY.
    ASSIGN line TO <f1>.
    ASSIGN COMPONENT comp OF STRUCTURE <f1> TO <f3>.
    IF <f3> IS ASSIGNED.
    ENDIF.
    I checked in the debugging mode and the value of <f3> in debugging mode is 0, but not line-col3.
    Best Regards,
    Kumar

  • Please explain,  the job of the  "ASSIGN COMPONENT ".

    Please read this popular example appended below. I am newbie to ABAP.
    At the end of the execution the code is printing 33. Don't get it.
    Please explain,  the job of the  "ASSIGN COMPONENT ". How or why it is printing value 33.  What is the meaning of the statement, "ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>." ?
    DATA: BEGIN OF LINE,
    COL1 TYPE I VALUE '11',
    COL2 TYPE I VALUE '22',
    COL3 TYPE I VALUE '33',
    END OF LINE.
    DATA COMP(5) VALUE 'COL3'.
    FIELD-SYMBOLS: <F1>, <F2>, <F3>.
    ASSIGN LINE TO <F1>.
    ASSIGN COMP TO <F2>.
    DO 3 TIMES.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
    WRITE <F3>.
    ENDDO.
    ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
    WRITE / <F3>.
    11 22 33
    33

    DATA: BEGIN OF LINE,
    COL1 TYPE I VALUE '11',
    COL2 TYPE I VALUE '22',
    COL3 TYPE I VALUE '33',
    END OF LINE.
    DATA COMP(5) VALUE 'COL3'.
    FIELD-SYMBOLS: <F1>, <F2>, <F3>.
    ASSIGN LINE TO <F1>.
    ASSIGN COMP TO <F2>.      "here you are assigning the column name which is COL3 to <f2>.
    DO 3 TIMES.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
    WRITE <F3>.
    ENDDO.
    ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
    ASSIGN 'COL3' of structure <f1> to <f3>. "it is equal to above statement.
    WRITE / <F3>.
    11 22 33
    33
    ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>. means
    assigining  COL3  value of the structure <f1> to <f3>, so value is 33 , it will be assigned to <f3> .it prints 33.

  • ASSIGN Component ... (field symbol stuff)

    Hi,
    I want to validate certain fields (KNA1, BUKRS, KOART, FNAME) which are
    entered by the user in the transaction XK01.  They are being captured in a structure, lets say X_LFA1.
    To validate this fields I am being asked to use field symbols using component assign.
    Can someone tell me how do I do this ?

    Tushar,
    Its still not clear to me what exactly you are trying to do.
    Is it like you just want to see if those fields exist in the table or not? If yes, you can do like this.
    parameter : p_field -- field entered by the user
    data : wa_ztable like ztable.
    field-symbols : <fs_any> type any.
    Assign component p_field of structure wa_ztable to <fs_any>.
    if sy-subrc = 0.
    Success.
    endif.
    Regards,
    Ravi

  • Help - assign component

    Hi,
    i need your ideas for an assign component issue.
    data definition:
    *table
    it1_tab: (all fields are char1: field1, field2, ...field99)
    *local fields
    lv_fieldx1 type string.
    lv_fieldx2 type string.
    lv_fieldx99 type string.
    Now i need to check "field1 of table with localfield1" and "field2 of table with localfield2"  ...until field99).
    Example with IF step.
    if it_tab-field1 = 'X'.
    lv_fieldx1 = '1'.
    else.
    lv_fieldx1 = '0'.
    endif.
    if it_tab-field2 = 'X'.
    lv_fieldx2 = '1'.
    else.
    lv_fieldx2 = '0'.
    endif.
    if it_tab-field99 = 'X'.
    lv_fieldx99 = '1'.
    else.
    lv_fieldx99 = '0'.
    endif.
    I think there is a better way by using assign component in a Do step ?
    any ideas ?
    Regards,
    Gordon

    something like (may contain errors):
    DATA : lv_index(2) TYPE n.
    DATA : lv_fieldname1 TYPE fieldname.
    DATA : lv_fieldname2 TYPE fieldname.
    FIELD-SYMBOLS : <lv_field1> TYPE ANY.
    FIELD-SYMBOLS : <lv_field2> TYPE ANY.
    LOOP AT itab.
    DO 99 TIMES.
    lv_index = sy-index.
    CONCATENATE 'FIELD' lv_index INTO lv_fieldname1.
    CONCATENATE 'LV_FIELDX' lv_index INTO lv_fieldname2
    ASSIGN COMPONENT (lv_fieldname1) OF STRUCTURE itab TO <lv_field>.
    ASSIGN (lv_fieldname2) TO <lv_field2>.
    IF <lv_field1> IS NOT ASSIGNED OR
    <lv_field2> IS NOT ASSIGNED.
    CONTINUE.
    ENDIF.
    IF <lv_field> EQ 'X'.
    <lv_field2> = 'X'.
    ELSE.
    <lv_field2> = ' '.
    ENDIF.
    ENDDO.
    ENDLOOP.
    There will be definetly one more problem: The genrated field names will look like this: field01, field02, field03... There are two solutions: 1. You change the declaration accordingly 2. You cut the leading zeros from lv_index

  • Deep structure - assign component

    hi,
    I have a structure like:
    data: begin of wa_xxx,
            rec like bkpf,
            iba(10) TYPE c,
            bba(10) TYPE c,
          END OF wa_xxx.
    Now I would like to assign the strucutre like:
    field-symbols: <fs_1> like wa_xxx
    loop....
    assign component sy-tabix of structure <fs_1> to <fs_2>.
    endloop.
    The first compoment is rec, but I need <fs_1>-rec-...(fields of the structure)
    How can I do this? Any Idea?
    thanks
    markus

    Hi Markus,
    I'm not sure exactly what you mean but here's some code:
    types: begin of ty_xxx,                        
            rec like bkpf,                         
            iba(10) TYPE c,                        
            bba(10) TYPE c,                        
          END OF ty_xxx.                           
    data t type table of ty_xxx.                   
    data d type ty_xxx.                            
    field-symbols: <el> type any, <str> type ty_xxx.  
    you can assign the whole structure to a field-symbol...                                               
    loop at t assigning <str>.   
    you can refer                   directly to eleemnets within the filed-symbol structure...
    if <str>-bba is initial. endif.                
    do.         
    you can loop through the individual components of the field symbol structure                                  
    assign component sy-tabix of structure <str> to <el>.  
    if sy-subrc <> 0.                              
    exit.                                          
    endif.  
    you can operate on the current element within the structure
    if <el> is initial. endif.                                                                               
    enddo.                                                                               
    endloop.

  • Assigning part of a string dynamically to a component of a structure

    Hello,
    I want to take part of a string
    example: value = string+10(7)
    and assign this value to a structure. But I only have the fieldnames of the structure. I need something like the following
    Assign value TO COMPONENT (fieldname) of structure
    Thanks.
    Regards, Lars.

    do you have a set structure name you're dealing with or is that dynamic?
    If it's the first scenario and, say, you were dealing with mara and field matnr you could do this:
    data l_string.
    field-symbols <field> type any.
    l_string = in_string+10(18).
    assign l_string to <field> casting type matnr.
    (or assign l_string to <field> casting like mara-matnr).
    now <field> is a 'matnr' type field.
    If it's more complex please give some more info as I'm sure what you want can be done.

  • Using Data Reference As A Component In Dictionary Structure

    Dear Experts,
    As we all know, we can define a generically typed data reference by using the statement below:
    DATA ref_data  TYPE REF TO data
    Also, as we all know, we can create a structure in global dictionary with a component of type of reference to data by checking the RType check box when defining the structure. My question is, what component type should I use (choose from the Component Type column when defining the structure) if I want the structure's component as a generically typed data reference?
    Regards,
    Haris

    Create a data element as a reference type, and use the name "Data".  Create the field with the type of the data element.
    matt

  • Assign component

    Hi,
    I'm trying to compare 2 internal tables to match any mis matches and it works. Now i want to get the original field name and write that infront of the data..
    For example now i can get   
    3000150     6000150  mismatch
    But i want to get the field name infront of the data, for example
    Sales order       3000150     6000150  mismatch
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB_OD_HEADER TO <FS1>.
    Can you tell me how to get the table field name it reads, not the index ?
    Thanks
    Keshi

    Hi,
    If you want to compare two internal tables and to extract differences, do like this:
    Down load two internal tables into two different text files usin GUI_DOWNLOAD.
    And then compare these two files using the DOS command comp.
    i.e, COMP file1.txt file2.txt /a >> file3.txt.
    This is the option list for compare command:
    COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]
      data1      Specifies location and name(s) of first file(s) to compare.
      data2      Specifies location and name(s) of second files to compare.
      /D         Displays differences in decimal format.
      /A         Displays differences in ASCII characters.
      /L         Displays line numbers for differences.
      /N=number  Compares only the first specified number of lines in each file.
      /C         Disregards case of ASCII letters when comparing files.
      /OFF[LINE] Do not skip files with offline attribute set.
    To compare sets of files, use wildcards in data1 and data2 parameters.
    Reward if helpful
    Regards,
    Sandhya.M

  • Assign component in loop

    HI  All
    I doing the following loop and the table it_mapping can be with lot of records
    There is a way that i can do the loop for just the relevant field (something that similar to LOOP and Where )
    since for instance table ls_mapping can be with 10000 records and in structure <ls_attributes> i have just
    2 fields that are the same (the loop run dynamically since  <ls_attributes> can be differnt in every run of the program )
    LOOP AT it_mapping INTO ls_mapping.
        ASSIGN COMPONENT ls_mapping-target_field OF STRUCTURE <ls_attributes>
        TO <lo_attr>.
        IF sy-subrc = 0.
          <lo_attr> = ls_mapping-field_value.
        ENDIF.
      ENDLOOP.
    Regards
    Alex

    Hi friend,
    here ls_mapping contains fields same fields are available to <ls_attributes> fieldsymbol
    then only when pass the value to <lo_attr> then automattically value comes then u can insert into the internal table that must declare as fieldsymbol.
    TYPES:BEGIN OF TY_MAPPING,
    FLD1 TYPE STRING,
    VAL TYPE STRING,
    END OF TY_MAPPING.
    DATA:LS_MAPPING TYPE TY_MAPPING,
    IT_MAPPING TYPE STANDARD TABLE OF TY_MAPPING.
    FIELD-SYMBOLS:<LT_ATTRIBUTES> TYPE STANDARD TYPE OF (LS_MAPPING).
    ASSIGN LT_ATTRIBUTES ->* <LS_ATTRIBUTES>.
    LOOP AT it_mapping INTO ls_mapping.
        ASSIGN COMPONENT ls_mapping-target_field OF STRUCTURE <ls_attributes>
        TO <lo_attr>.
        IF sy-subrc = 0.
          <lo_attr> = ls_mapping-field_value.
    APPEND <LS_ATTRIBUTES> TO <LT_ATTRIBUTES>.
        ENDIF.
      ENDLOOP.
    I think it will be excuted.
    thanks&regards.
    murali

  • Assign component - dynamic field

    Hey experts,
    I want to do this:
    ASSIGN COMPONENT (wa_dd08l-fieldname) of structure  <wa_deleted> to <ls_id>
    but the (wa_dd08l-fieldname) is incorrect, I can't put there those parentheses.
    The <wa_deleted> is a dynamic field symbol and I need to get the ID from it, I have the fieldname of the ID in wa_dd08l-fieldname, but
    I can't use it in ASSIGN COMPONENT, so how could I get the value of the fieldname (wa_dd08l-fieldname) from <wa_deleted>?
    Regards,
    Robert    

    Why do you want to use the parenthesis?
    ASSIGN COMPONENT (wa_dd08l-fieldname) of structure  <wa_deleted> to <ls_id>
    ASSIGN COMPONENT wa_dd08l-fieldname of structure  <wa_deleted> to <ls_id>
    Max

  • A question about assigning a default value

    Hi guys, I have a question about assigning a default value to a Numeric Decision CO. This Co needs 2 parameters to compare with each other. I wanna assign para1 during runtime and para2 during design time, but I have no idea how to assign a default value to para2 during design time. Can anyone help me solve this question? Thx a lot.
    BTW I`m searching an article about Time-off example`s "details". I have read several articles about time-off example, but those are not detailed enough. I wanna know about all details of COs. Can anyone forward such article to me, plz.  Thx again.^^

    Hi,
    You can assign a default value to the parameter of a callable object.
    First attach your CO to an Action.At the action level you can assign default values to the CO Parameters.
    Select the action in the design time.
    Select the parameters tab for that action.
    Select the required paramter. At the top, you can find Default value tab, with that you can assign default value.
    I think you can achieve your requirements with Business logic CO better.
    [Business Logic CO|http://help.sap.com/saphelp_nwce10/helpdata/en/44/3d3936c5c14a8fe10000000a1553f6/content.htm]
    Thanks

  • How to include the not assigned nodes in Hierarchy structure

    Hi Experts,
    I am running a report which has got Hierarchy variable type. After execution of the query some of the nodes appear always under "not assigned".
    Please let me know is it possible to include these not assigned node under hierarchy structure.If so how to do that?
    Regards
    Kumar

    Hi Subbiah.
    You can also supress the "not assigned" nodes in the hierarchy maintanence by choosing: Hierarchy attributes -> Supress unassigned nodes.
    Hope it helps.
    BR
    Stefan

Maybe you are looking for