Assigning a value to a field-symbol (workarea of type any)

Dear forumers,
I'm having a bit of difficulty in assigning a value to a field-symbol (it should be treated as a workarea of type any), but I'm given a syntax error instead:-
The data object "<LFS_WORKAREA>" has no structure and therefore no component called "LFMON".
What could have gone wrong and how may I resolve this (I must have missed something out)? I will still need <LFS_WORKAREA> to be defined as TYPE ANY.
Please help. I'd appreciate any inputs at all. Thanks.
*&      Form  FORMAT_POST_PERIOD
*       Subroutine to format the posting period data
*      --> PI_MBEW     Material valuation data (internal table)
FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
" Create local field symbols
  FIELD-SYMBOLS:
  <lfs_workarea> TYPE ANY,
  <lfs_lfmon>    TYPE ckmlcr-poper.
" Create local variables
  DATA: lv_index TYPE sy-tabix.
  DATA: lv_lfmon TYPE ckmlcr-poper.
" Format posting periods
  LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
    lv_index = sy-tabix.
    ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
    PERFORM convert_lfmon USING    <lfs_lfmon>
                          CHANGING lv_lfmon.
    MOVE lv_lfmon TO <lfs_workarea>-lfmon.   " the syntax error occurs here  :(
    MODIFY pi_mbew FROM <lfs_workarea>
      INDEX lv_index
      TRANSPORTING lfmon.
    CLEAR: <lfs_workarea>,
           <lfs_lfmon>
           lv_lfmon,
           lv_index.
  ENDLOOP.
ENDFORM.                    " FORMAT_POST_PERIOD

Most of us aren't in it for the points in any case...
For your solution you've redundant code:
*&      Form  FORMAT_POST_PERIOD
*       Subroutine to format the posting period data
*      --> PI_MBEW     Material valuation data (internal table)
FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
  FIELD-SYMBOLS:
  <lfs_workarea> TYPE ANY,
  <lfs_lfmon>    TYPE ckmlcr-poper.
  DATA: lv_lfmon TYPE ckmlcr-poper.
*  DATA: lo_workarea TYPE REF TO data.   "<--Not needed, because the LOOP AT ASSIGNING below does the work
*  CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
*  ASSIGN lo_workarea->* TO <lfs_workarea>.
  LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
    ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
    PERFORM convert_lfmon USING    <lfs_lfmon>
                          CHANGING lv_lfmon.
    <lfs_lfmon> = lv_lfmon.
    CLEAR lv_lfmon.
  ENDLOOP.
ENDFORM.                    " FORMAT_POST_PERIOD
Here's a couple of more efficient solutions, using LOOP AT INTO.
FORM format_post_period  CHANGING    pi_mbew TYPE INDEX TABLE. " <-- Table type a little more specific
                                                               "<--now you can use index operations
  FIELD-SYMBOLS:
  <lfs_workarea> TYPE ANY,
  <lfs_lfmon>    TYPE ckmlcr-poper.
  DATA: lv_lfmon TYPE ckmlcr-poper,
        lv_index TYPE sytabix.
  DATA: lo_workarea TYPE REF TO data.
  CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
  ASSIGN lo_workarea->* TO <lfs_workarea>.
ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
  LOOP AT pi_mbew INTO <lfs_workarea>.
    lv_index = sy-tabix.    
    PERFORM convert_lfmon USING    <lfs_lfmon>
                          CHANGING lv_lfmon.
    <lfs_lfmon> = lv_lfmon.
    MODIFY pi_mbew FROM <lfs_workarea>
       INDEX lv_index. " <--INDEX TABLE, so this is permitted.
    CLEAR lv_lfmon.
  ENDLOOP.
ENDFORM.                    " FORMAT_POST_PERIOD

Similar Messages

  • Assigning value to Field - Symbol ( which is type of internal table field )

    Hi All,
      I am facing problem to assign the value to a field symbol. My requirement is creating a dynamic internal table and populate values into that internal table, so that i can display the values .
      I am having a structure with fields like status , Plant1 name , Plant2 name.....Plant n .
      So i declared an internal table it_tab with this structure.
      I am having one more table which having number of records for Plant1 ,Plant 2 ,....Plant n based on some condition.
      I need to count the number of records for Plant1 and i need to put in the internal table it_tab.
      For this i created field-symbol .
    Here, t_deployment table will have the plants 1,2,3...and
         t_devobject will have some records for these plants.
    LOOP AT T_DEPLOYMENT. 
    clear w_count.
    LOOP AT T_DEVOBJECT WHERE ZDEPLOYMENT = T_DEPLOYMENT-DOMVALUE_L AND
                              ZADSTATUS = '10'.
    w_count = w_count + 1.
    ENDLOOP.
    concatenate 'it_tab-' t_deployment-domvalue_l into var_bet_name.
    assign var_bet_name to <bet_var_name>.
    now my internal table field i.e. it_tab-plant1 came into <bet_var_name> . But i want to assign a value for it.
    at last what i need is it_tab-plant1 = w_count.
    whaterver the w_count has value that needs to assign to it_tab-plant1. But i don't want to assign directly it it_tab-plant1. I want to assign dynamically. Because tommorrow some more plants added to t_deployments , i don't want to make changes to my program. It should take care....w/o changing the program.
    I tried the following statement.
    (<bet_var_name>) = w_count. But its not working.
    Please let me know how i can get this.
    Thanks in Advance.
    Pavan.

    Hi pavan,
    As ur requirement is creating a dynamic internal table,
    try the following way,
    remember the fieldcat should be of type LVC not SLIS.
    BUILD LT_LVCFIELDCAT in a way that, the value from the internal table becomes the fieldname
    ex:-
    loop at it_models INTO WA_MODELS.
        LS_LVCFIELDCAT-FIELDNAME = WA_models-MODEL.
        LS_LVCFIELDCAT-SELTEXT = WA_models-MODEL.
    append ls_lvcfieldcat to lt_lvcfieldcat.
    endloop.
    DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
    FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVCFIELDCAT
        IMPORTING
          EP_TABLE        = DREF.
      ASSIGN dref->*  TO <TEMP_TAB>.
    now basing on the fieldcatalog <temp_tab> is build.
    NOW FILL <TEMP_TAB>.
    WHILE FILLING, ASSIGN COMPONENT IDX/NAME.....
    this statement will be very usefull.
    i hope this will be help full.
    pls reward the points if it helps u.
    regards
    Hyma

  • Field symbol for order type

    Hi all.
    i have a condition on which i need to use the field symbol in which depending on the condition,my subscreen should be displayed.
    i have SAPLMEGUI as a main standard program and MEPO_TOPLINE-BSART is a field which is attached to this std program.
    Also,if this BSARt becomes UB(order type in purchase orders) then only it should go to subscreen.i tried doing it like below,but not getting solution.
    please help.
    data: GV_OKCODE_FIELD type char35 VALUE '(SAPLMEGUI)MEPO_TOPLINE-BSART'
    FIELD-SYMBOLS <MEPO_TOPLINE-BSART> TYPE ANY.
    ASSIGN GV_OKCODE_FIELD TO <MEPO_TOPLINE-BSART>.
    IF <MEPO_TOPLINE-BSART> = 'UB'.
    endif.

    Hello,
    You can try something like this:
    FIELD-SYMBOLS: <FS> TYPE BSART.
    ASSIGN COMPONENT BSART OF STRUCTURE MEPO_TOPLINE TO <FS>.
    IF <FS> = 'UB'.
    " Your Code
    ENDIF.
    BR,
    Suhas

  • How to assign ranges ( select-option)to field symbol

    Hi ,
    I have following scenario
    ranges : r_test1 for agr_1251,
                 r_test2 for agr_1251.
    In runtime i am getting which range i have to populate in a field v_rname.for now let it me v_rname  = 'r_test2'
    i want to assign (v_rname ) to <field -symbol> ie is range to field symbol.
    and i want to update the <field -symbol>-sign ='I'
                                        <field -symbol>-LOW ='some value'
                                        append <field -symbol>.
    This is the logic i want to follow,  for this how should i have to declare the field symbol ? I couldn't assign a range to field symbol . Please help me.
    thanks
    Murali

    Try this
    FIELD-SYMBOLS : <field_symbol>  TYPE ANY TABLE.
    ASSIGN (v_rname) to <field_symbol>.
    <field -symbol>-sign ='I'
    <field -symbol>-LOW ='some value'
    append <field -symbol>.
    This should work because your range is a table.
    Hope this helps you.

  • How to update the value inside a field symbol ?

    ASSIGN COMPONENT 'MENGE' OF STRUCTURE <fs_line> TO <fs_field>.
    <fs_field> = itab_stpo-menge.
    COLLECT <fs_line> INTO <fs_table>.
    .processing some code......
    ASSIGN COMPONENT 'MENGE' OF STRUCTURE <fs_line> TO  <fs_field>.
    <fs_field> = ( itab_stpo-menge * itab_plpo-vgw03 ).
    COLLECT <fs_line> INTO <fs_table>.
    Hi, guys,
    May i know is there a way to update the value in inside a field symbol?
    I feel hard to figure out the way to solve this situation. Kindly give me some help or perhaos tell me other altenative way to do it also can.
    Thanks in advance.
    Edited by: Jiansi Lim on Apr 25, 2008 8:09 PM

    hi check this...
    For a structured data object s, you can use the statement
    ASSIGN COMPONENT comp OF STRUCTURE s TO FS.
    Here the comp is the component name or its index number in the structure.
    Find the following sample code -
    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>.
    The output is:
    11 22 33
    33
    I need to update one field in Internal table
    regards,
    venkat

  • Assigning a value to screen field

    Hi,
      Anybody knows how to assign a value to a field in a standard transaction without using parameter ID.
    Pionts will be awarded.
    Thanks,
    lakshmi.

    Thank you so much Rich & eswar. here is my problem.
    Actually I am updating this field based on the contract starts date and material group using one user exit.But this field is geting updated whenever there is a change to this field.it is not geting updated in other cases that is "it is geting updated if you are changing the contents of the filed or giving a new value".
    But I want this field updated all the times.
        So I thought I will assign a dummy value to this filed before I update it.For this We need a parameter id. but it is not there. So I am searching for other solution.
      Can you please help me.
    Regards,
    Lakshmi

  • Move values of one field symbol to other field symbol of different structur

    Hi all,
    i need to move values of one field symbol to other field symbol of different structure.
    I need to perform operations like MOVE-CORRESPONDING on two field symbols of different structure.
    How can i achieve this?
    field symbol 1 have 2 field and field symbol2 have 4 fields....
    Best Regards,
    Vijay.

    Hi,
    You can use -
    MOVE-CORRESPONDING <struct1> to <struc2>.
    In this case it will move the contents of the components from struct1 to struct2 that has identical names.
    You can refer this link also-
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3260358411d1829f0000e829fbfe/content.htm
    Regards,
    Sujit

  • Assigning a Value to a Text Symbol: DEFINE

    Hi all,
    I am printing some text in the form. The text is in the database table and is retrieved. say the field name is fld06 in the table ztfin. Previously it is code as &zfin-fld06& in the form edotir. Now my requiremnet is to dispay some other text where ever I have to print ztfin-fld06. I have used the define statement in this way :
    /: DEFINE &ztfin-fld06& = 'Data Fattura'
    But when I look at the output the text is not replaced nor it is realised while I am debugging. Can anyone tellme where I am going wrong ?
    Regards,
    Varun.
    Message was edited by: varun sonu

    hi
    chk this out
    <b>DEFINE: Value assignment to text symbols
    Text symbols receive their value through an explicit assignment. This assignment can be made interactively in the editor via the menu options Include &#61614;&#61472;&#61614;&#61472;Symbols &#61614;&#61472;&#61614;&#61472;Text. This lists all the text symbols of a text module, as well as those of the allocated layout set.
    The contents defined in this way are lost if the transaction is exited. To continue printing the text module, you would have to enter the symbol values again.The DEFINE command allows you to anchor this value assignment firmly in the text, to also have it available when you next call up the text. Furthermore, you can allocate another value to a text symbol in
    the course of the text.
    Syntax:
    /: DEFINE &symbolname& = ‘value’
    Example:
    /: DEFINE &re& = ‘Your correspondence of 3/17/94’
    Example:
    /: DEFINE &symbol1& = ‘xxxxxxx’
    /: DEFINE &symbol2& = ‘yyy&symbol1&’
    /: DEFINE &symbol1& = ‘zzzzzzz’
    Result: &symbol2& &#61614;&#61472;yyyzzzzzzz
    The assigned value may have a maximum of 60 characters. It can also contain further symbols. When a symbol is defined using the control command DEFINE, symbols which occur in the value are not immediately replaced by their value. They are only replaced when the target symbol is output. If the operator := is used in the DEFINE statement, all symbols which occur in the value which is to be assigned are immediately replaced by their current values. The resulting character string is only then assigned to the target symbol when all occurring symbols have been replaced. The length of the value is limited to 80 characters. The target symbol must be a text symbol, as at present.
    Syntax:
    /: DEFINE &symbolname& := ‘value’</b>
    <i>u can also write a perform...endperform to change the value of a field to ur required text.</i>

  • Modifying value of dynamic field-symbol

    I have a requirement in which i need to access columns of a dynamic internal table , manipulate and update back to the dynamic internal table
    Names of the columns are also not fixed. This i am determing at the runtime.
    Following is the code used :
    Loop at <dyn_table> assigning <dyn_wa>.
    lv_field = p_fields " This is the field i am taking from the selection screen which needds to be manipulated.
    ASSIGN COMPONENT lv_field OF STRUCTURE <dyn_wa> TO <fs_value>.
    refresh itab.
    split <fs_value> at ',' into table itab.
    loop at itab.
    assign other fields of the source package to new splited table.
    ASSIGN <dyn_wa> TO <dyn_wa1>.
    I have to assign the valuein itab to the third field in field symbols.
    ( so the code would be added here)*******************
    append <dyn_wa1> to <dyn_table1>.
    endloop.
    endloop.
    Kindly suggest some solution for this above requiremnt.
    Regards,
    Amruta

    Hello,
    Just try to use the below codes in appropriate place and let me know if further issues..
    LOOP AT itab.
      ASSIGN COMPONENT 3 OF STRUCTURE <dyn_wa1> to <fs_value>.
      CLEAR : <fs_value>.
      <fs_value> = itab-field name.
      APPEND <dyn_wa1> TO <dyn_table1>.
    ENDLOOP.
    Thanks!

  • Not allows to assign default value to input field using values in datastore

    Hi Masters,
    Consider that I have one input field in a form. I should assign default value to it. I should assign to it, the value which i have stored in a datastore. When i run the application, if i give default value as 123 ,then it is working fine i.e., it is showing 123 in the textfield in form , but if i give the default value as STORE@ProductId, then it is not displaying that value in the form.
    Please help me out.
    Thanks & Regards,
    Kaushik Sreeram

    Hi,
    i faced this problem and here's what i concluded:
    There's no way you can set default value for input field dynamicly, since the default value of input control is caculated only once (i think on initializing of the iView). The input control and the data store are initialized at the same time, STORE@productID is empty that time...
    If you don't need to recieve value through the input field you're trying to initialize, but just to display the value from the store - I suggest you try using another control - Expression Box. It's value is calculated continiously, just like the Label's, and you can refere to it later.
    Regards,
    Yulia

  • Transfer Rule Routine: Assign Date Value into Blank Field

    Can anyone help me with regards to writing some ABAP code in a transfer rule so that I can assign "99991231" value into a date characteristics if it is blank?
    Many thanks for advance.

    I would like to check if the value of EXPIRYDATE is blank in data source. If its value is blank, assign '99991231' to it. Otherwise, it will get the value of EXPIRYDATE in transfer rule. I have rewritten the routine as follows. But there is no effects on the result.
    if TRAN_STRUCTURE-EXPIRYDATE IS INITIAL.
      RESULT = '99991231'.
    else.
      RESULT = TRAN_STRUCTURE-EXPIRYDATE.
    endif.
    Many thanks in advance.

  • Is it possible to pass a field symbol as parameter from any method of view?

    Hi
    Is it possible to pass a field symbol as an importing parameter to teh globally declared attribute??

    While it is true that you can pass field symbols, they must be fully typed at the time you pass them  and they will be passed by value, not by reference. If you want to pass generically typed variables use a data reference (TYPE REF TO) instead.

  • Dump GETWA_NOT_ASSIGNED while assigning value to a field symbol

    LOOP AT <table> INTO <struct>.
        CLEAR l_uom.
        lf_fieldname = '<struct>-UOM'.
        ASSIGN (lf_fieldname) TO <uom>.
        l_uom  = <uom> .
    ENDLOOP.

    I need to put the contents of lf_fieldname into <uom>.......when lf_fieldname is <struct>-UOM.....
    so
    assign lf_fieldname to <uom> is of no use...........and hence v use
    assign (lf_fieldname) to <uom>
    my problem is since i dont knw till the run time if UOM field is present in the table or not, and whn it's not, no mem_area is referenced in the bkgrnd and hence i get an error...........i need to knw if v have a provision to chk if (lf_fieldname) has ne value or not....
    Please help....:)
    Regards,
    Aparna.

  • Data from field symbol into an internal table or workarea

    Hi Experts,
    I have field symbol in which i get the data. I want to get this data into an internal table of type any or into an work area. How is this possible.
    My declaration for field symbol is as follow:
    FIELD-SYMBOLS: <l_t_data> TYPE any.
    DATA l_r_data TYPE REF TO data.
        CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
        ASSIGN l_r_data->* TO <l_t_data>.
    I get the data in this field symbol <l_t_data>. by passing into a funtion module. and I get the data into it. Now i have to assign the values of this field symbol to any internal table or to a work are how do i do it. Please help.
    Regards,
    Prashant.

    Not exactly sure what you need here, but.....
    FIELD-SYMBOLS: <l_t_data> TYPE TABLE.   "<<-- Change this
    FIELD-SYMBOLS: <l_s_data> TYPE ANY.      "<<---Add This
    DATA l_r_data TYPE REF TO data.
    CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
    ASSIGN l_r_data->* TO <l_t_data>.
    Loop at <l_t_data> assigning <l_s_data>.
    * Do what ever using <l_s_data>
    Endloop.
    Regards,
    Rich Heilman
    Edited by: Rich Heilman on Feb 28, 2008 2:42 PM

  • Obtain List of Field Symbols Declared and Assigning from ITAB DATA

    Hi Gurus,
    3 simple problems (apparently , appreciate responses.
    Problem 1
    How to get the list of names of <field-symbols> of type table declared in an abap program?
    Problem 2
    Create DATA "XXXX" TYPE TABLE OF ty_fcat. Where "XXX" name is obtained from an internal table with data names...Can i use the read the statement on the internal table and creat the DATA?
    Problem 3
    Matching the name of the field-symbol obtained from the abap program with a "name" stored in an ITAB. If the name matches do the following:-
      CREATE DATA 'XXXX' TYPE TABLE OF ty_fcat. (remember 'XXXX' is obtained by reading internal table.
      ASSIGN 'XXXX->* TO <ITAB> (obtained from the abap program)
    Appreciate guidance on this matter. thank you!!!! God Bless!
    Edited by: Salman Akram on Sep 27, 2010 4:03 PM
    Edited by: Rob Burbank on Sep 27, 2010 2:59 PM

    Hi Salman,
    1) Once you assign some table to your field symbol, its dynamic type will be the same as the table assigned.
    So you use the same approach as described in your last thread.
    "suppose you have a table assigned to <tab>
    "describe it by name
    lr_tabdescr ?= cl_abap_typedescr=>describe_by_data( <tab> ).
    lr_strucdescr ?= lr_tabdescr->GET_TABLE_LINE_TYPE( ).
    "and get its line type components
    it_components = lr_strucdescr->get_components( ).
    loop at it_components.
    "show all component names
      write: it_components-name.
    endloop.
    2) This statement has such form
    data lr_data type ref to data.
    CREATE DATA lr_data TYPE ...
    In here lr_data must be data reference  (no its name). TYPE can be provided dynamically in form of ('SOME_DDIC_TYPE'). So in your case this statement is not correct. You can't provide lr_data dynamically.
    So this one you will have to elaborate a bit in order we could understand what you want to achieve.
    3) Here I totally don't know what you mean. I think this relates somehow to first two points. So please tell us what is the requirement from the scratch, maybe this will shed more light on your issue.
    BTW: Please post such questions in ABAP General as this is not DDIC related issue.
    Regards
    Marcin

Maybe you are looking for

  • Arch64 RAM issues [Solved]

    So I thought everything was fine until an application told me I had 4gb of RAM which is a far cry from the installed 16gb. I did plenty of digging around and narrowed it down to a couple possibilities, but first my investigation: I started with free:

  • ITunes in Vista RC1 - can't find My Music folder

    I installed iTunes 7.0.1 in Vista (64 bit)& launced iTunes. I get an iTunes error message saying "The folder 'iTunes' cannot be found or created, and is required. The default location is inside the 'My Music' folder." I can't even open iTunes to dire

  • How to include vi dependencies in application builder?

    I have a small project in which I am trying to build an application.  I am having issues with the build including all dependencies.  In the project explorer "Items" tab, there are 7 files listed (1 dll and 6 vi's).  When I build the application, and

  • WM_CREATETIME error?

    I'm testing 10g to see if it can work as a Bitemporal Database and I've got a problem with the WM_CREATETIME field. When I update a table with a new ValidTime, the system overwrites the create time of the previous history record, effectively losing t

  • Is it possible to create table of contents without having paragraph style ?

    Hi all I have designed my magazine for school project in indesign including 20 pages ,now I wanted to make table of contents but I have difficultly to make I watched some tutorial online but it seems that I had to make paragraph style . actually I do