Read Dynamic Field Symbol

Hello ,
I have a field symbol where i am not aware of fields (Column Name) , i mean column names are Dynamic.
Problem is i need to read this field symbol value , how can i do it . It will always have 1 record
Example
Field Symbol looks something like this
<FS> Column Name dynamic -
>
A B C
Record
1 2 3
So now i have to refer to Second Column (i.e. is B in this case) , how should i do
What i tried .
1. <FS>-(Column Name in variable in brackets) - It doesnt work , Error Message unable to interpret the number B
2. <FS>[1] - Error out.

For a structured data object <s>, you can use the statement
<b>
ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
</b>
to assign one of its components <comp> to the field symbol <FS>. You can specify the
component <comp> either as a literal or a variable. If <comp> is of type C or a structure which
has no internal tables as components, it specifies the name of the component. If <comp> has any
other elementary data type, it is converted to type I and specifies the number of the component.
In the assignment is successful, SY-SUBRC is set to 0. Otherwise, it returns 4.

Similar Messages

  • How to read dynamic field symbol

    hi all,
       ASSIGN (tabname) TO <fs_tab>.
       in above code i am passing dynamic table to fs_tab
      can anyone tell me how can i read this field symbol........
      in other words i want to read dynamic field symbols

    Hi,
    you could do without the field-symbols:
    select from variable table
    grtz,
    Koen

  • Read dynamic field symbol Work Area before append to dynamic table

    Hi experts:
    I have a dynamic work area but before doing an append to the dynamic table, I need to do some validation on some fields of the work area in order to decide to append it or not, but I don't know how...
    More or less this is the example
    loop at so_kschl.
        field = so_kschl-low.
        if <t_dyntable>-field = 0. "if the value of this field in dinamic table is 0.
    don't append
        else.
           APPEND <fs_dyntable> TO <t_dyntable>.  
        endif.
    endloop.
    Thank you very much for your help.
    Miriam

    Check this example, you read the component of the dynamic work area and assign it to a field-symbols. In this case, I validate that the entry is always 'a'.
    DATA: i_lvc TYPE lvc_t_fcat WITH HEADER LINE,
          i_table TYPE REF TO data,
          l_style TYPE lvc_fname,
          l_warea TYPE REF TO data,
          l_name(7) VALUE 'VARCHAR'..
    FIELD-SYMBOLS: <fs> TYPE table,
                  <fs2> TYPE ANY,
                  <fs3> TYPE ANY.
    PARAMETERS p_char TYPE c LOWER CASE.
    START-OF-SELECTION.
      i_lvc-fieldname = 'Varchar'.
      i_lvc-inttype = 'C'.
      i_lvc-intlen = 1.
      APPEND i_lvc.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
      it_fieldcatalog = i_lvc[]
      IMPORTING
      ep_table = i_table
      e_style_fname = l_style.
      ASSIGN i_table->* TO <fs>.
      CREATE DATA l_warea LIKE LINE OF <fs>.
      ASSIGN l_warea->* TO <fs2>.
      <fs2> = p_char.
      ASSIGN COMPONENT l_name OF STRUCTURE <fs2> TO <fs3>.
      IF <fs3> = 'a'.
        WRITE: 'Component VARCHAR is a'.
    *  APPEND <fs2> TO <fs>.
      ELSE.
        WRITE: 'Component VARCHAR is not a'.
      ENDIF.

  • Read Data from the dynamic Field Symbol with key ?

    Dear All,
    I've  2 dynamic internal tables in the form of field symbols.
    Now,I want to loop the item field symbol, read the header field symbol content and then move the corresponding into a final field symbol.
    How to read the field symbol with key ?
    When I'm trying to give the key clause in the paranthesis it's giving a syntax error.
    Any clues ?
    FYI .....
    * Get the Dynamic Field and Value for the Date/Year and convert it into Year value
      LOOP AT <fs_t_son> ASSIGNING <wa_son>.
        ASSIGN COMPONENT gwa_znrows_def-fieldname OF STRUCTURE <wa_son> TO <fs_year>.
        IF sy-subrc = 0.
          CLEAR gv_string.
          MOVE <fs_year> TO gv_string.
          CLEAR gv_year.
          gv_year = gv_string.
          <fs_year> = gv_year.
        ELSE.
    * When the Date/year Field is not in the Table then -->
    * Get the Dynamic Field and Value
          ASSIGN COMPONENT gwa_znrows_def-kfldname OF STRUCTURE <wa_rson> TO <fs_value>.
    * Populate field for Dynamic Where condition
          CLEAR gv_value.
          CONCATENATE '''' <fs_value> '''' INTO gv_value.
          CONCATENATE gwa_znrows_def-kfldname '=' gv_value INTO gt_where SEPARATED BY space.
          APPEND gt_where.
          CLEAR gt_where.
          READ TABLE <fs_t_rson> ASSIGNING <wa_rson> ( gt_where ).  "Key clause
        ENDIF.  " if sy-subrc = 0.  "Assign
      ENDLOOP.
    Thanks & regards,
    Deepu.K

    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table itab is assigned to the generic field symbol <fs>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table itab until runtime. In the program, the type specification ANY TABLE only indicates that <fs> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <fs>  would not have been possible from a syntax point of view.

  • Reading a field symbol whose structure is dynamic

    Hi Experts,
    I have used the concept of dynamic internal tables to select data from COSS/COSP for e.g.database tables.Field symbol of type " ANY TABLE" has been used to select data , as the dynamic structure is assigned directly to the field symbol.
    To calculate the values of various fields I need to read the this field symbol for diferent line items , but I get a compilation error saying " Key not Found ". I understand that I am not able to read the field symbol because its structure is of type 'ANY TABLE' .How do I read this field symbol ?
    The field symbol gets the structure of dynamic internal table as formed initially by using class concept.Is their any way in which I could get the structure of this field symbol or any other way to read it?
    Thanks in advance.
    Regards
    Reetwika

    Hi Ritwika,
    Even if u use the concept if dynamic internal table, u can read the each of the field of ur structure,
    if u know the name of the field.
    for example:
    MATNR being one of the field of internal table
    field-symbols : <fs> type any.
    loop at <fs_it> into <fs_wa>.
    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_wa> to <fs_matnr>.
    " in this case matnr field value will be assigned to the field symbol <fs_matnr>, so it can be used further.
    endloop.
    " do reply if still confused.
    Rohit G
    Edited by: Rohit Gaharwar on Aug 12, 2009 11:51 AM

  • 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!

  • Dynamic Field Symbols with Structures

    Hello,
    I am stuck on a piece of code and looking for some help.  I am trying to figure out how to assign values in a structure of a dynamically defined field symbol to the structure inside another dynamically defined field symbol.  Here is my code and some comments.  Basically I am uploading data via a flatfile and placing it into a dynamically defined field symbol.
    DATA:   
    lr_area     TYPE REF TO cl_sem_planarea_attributes, 
    lr_t_data   TYPE REF TO data, 
    lr_s_data   TYPE REF TO data, 
    lr_s_chas   TYPE REF TO data, 
    lr_s_kyfs   TYPE REF TO data.
    FIELD-SYMBOLS:      
    <lt_data> TYPE STANDARD TABLE,    
    <ls_data> TYPE ANY,    
    <ls_chas> TYPE ANY,    
    <ls_kyfs> TYPE ANY.
    DATA: ls_chasel TYPE upc_ys_chasel,     
    ls_charng TYPE upc_ys_charng.
    FIELD-SYMBOLS:
    <f> TYPE ANY,              
    <chas> TYPE TABLE,              
    <kyfs> TYPE ANY. 
    CALL METHOD cl_sem_planarea_attributes=>get_instance   
    EXPORTING       i_area      = i_area   
    RECEIVING       er_instance = lr_area. 
    CHECK sy-subrc = 0. 
    CREATE DATA lr_s_data TYPE (lr_area->typename_s_data). 
    ASSIGN lr_s_data->*   TO <ls_data>. 
    CREATE DATA lr_t_data TYPE (lr_area->typename_t_data). 
    ASSIGN lr_t_data->*   TO <lt_data>. 
    CREATE DATA lr_s_chas TYPE (lr_area->typename_s_chas). 
    ASSIGN lr_s_chas->*   TO <ls_chas>. 
    CREATE DATA lr_s_kyfs TYPE (lr_area->typename_s_kyfs). 
    ASSIGN lr_s_kyfs->*   TO <ls_kyfs>. 
    LOOP AT gt_file INTO ls_file.   
    CLEAR <ls_data>.   
    MOVE-CORRESPONDING ls_file TO <ls_kyfs>. " Map key figures   
    MOVE-CORRESPONDING ls_file TO <ls_chas>. " Map chars
    *    MOVE-CORRESPONDING ls_file TO <ls_data>. " Map data
    *        ASSIGN COMPONENT 'ls_chas' OF STRUCTURE <ls_Data> TO <chas> .
    *        IF sy-subrc = 0.
    **          <chas> = <ls_chas>.
    *MOVE-CORRESPONDING <ls_chas> to <chas>.
    *        ENDIF.     
    <chas> = <ls_chas>.     
    LOOP AT <chas> INTO ls_chasel.     
    READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.     
    IF sy-subrc = 0 AND ls_charng-option = 'EQ'.       
    ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <ls_chas> TO <ls_data>.       
    IF sy-subrc = 0.         
    <ls_data> = ls_charng-low.       
    ENDIF.     
    ENDIF.   
    ENDLOOP.   
    COLLECT <ls_data> INTO <lt_data>. 
    ENDLOOP.
    Ls_chasel has 2 components:
    Chanm (a char 30 which contains the component’s name)
    T_CHARNG (a table with values for chanm)
    Ls_data has 2 components:
    S_chas (a structure with a list of components and values – same list as would have)
    S_kyfs (a structure with a list of components and values – same list as would have)
    Lt_data is a table of ls_data
    I need to get the data in ls_chas into the ls_chas structure of ls_data and the ls_kyfs data into the ls_kyfs structure of ls_chas and append ls_chas to lt_data.  Anything that is commented out is something I tried that didn't work.  RIght now I get a dump at the 'loop at <chas> into ls_chasel' that the field symbol is not assigned.
    Thanks for your help!

    It looks like the the original poster didn't completely understand all he was doing. (This is why I always recommend getting an ABAP programmer in for what is, essentially, advanced ABAP programming, rather than someone "kind of familiar" with ABAP trying it - we're often available at very reasonable rates ).
    It seems he's using ito_chasel to set the fixed values (which is in fact quite smart!). What isn't required, so far as I can tell without implementing, are any of the statements involving <ls_kyfs> or <ls_chas>.
    The following should be sufficient (with the necessary declarations etc. - but really: omit <ls_kyfs> and <ls_chas> - I'm sure they're not needed and they confuse things).
    " Go through the data from the flat file
    LOOP AT gt_file INTO ls_file.
      CLEAR <ls_data>.
      " Transfer the characteristics
      MOVE-CORRESPONDING ls_file TO <s_chas>.
      " Transfer the key figure
      MOVE-CORRESPONDING ls_file TO <s_kyfs>.
      " Go through the fixed characteristic selections from the package
      LOOP AT ito_chasel INTO ls_chasel.
        " We only care about the first value (if there is one).
        READ TABLE ls_chasel-s_charng INTO ls_charng INDEX 1.
        " Check there is a first value and that it is fixed
        CHECK sy-subrc IS INITIAL AND ls_charng EQ 'EQ'.
        " Get access to that characteristic
        FIELD-SYMBOLS <fixed_value> TYPE ANY.
        ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <s_chas> TO <fixed_value>.
        " Make sure that it exists in the data structure
        CHECK sy-subrc IS INITIAL.
        " Set the value
        <fixed_value> = ls_charng-low.
      ENDLOOP.
      COLLECT <ls_data> INTO <lt_data>.
    ENDLOOP.

  • Change this code to dynamic(field symbols)

    hi,
    i do this code and it working o.k. but i wont to change it to dynamic code like field symbols what is the best way to do that?
    i reward
    Regards
    LOOP AT  pro_tab into wa_pro.
          CASE wa_pro-period+0(2).
            WHEN '01'.
              MOVE wa_pro-epop TO wa_tr-month1.
            WHEN '02'.
              MOVE wa_pro-epop TO wa_tr-month2.
            WHEN '11' .
              MOVE wa_pro-epop TO wa_tr-month11.
              WHEN '12' .
              MOVE wa_pro-epop TO wa_tr-month12.
          ENDCASE.
          AT LAST.
            APPEND wa_tr TO tr_tab.
          ENDAT.
        ENDLOOP.

    Hi Ricardo.
    Try this sample code and make changes to urs.
    DATA: v_field(30) TYPE c.
    DATA: BEGIN OF itab OCCURS 0,
           period(2),
           month01(3),
           month02(3),
           month03(3),
           month04(3),
           month05(3),
          END OF itab.
    FIELD-SYMBOLS : <fs> TYPE ANY.
    FIELD-SYMBOLS : <fs1> TYPE ANY.
    itab-period = '01'.
    APPEND itab.
    itab-period = '02'.
    APPEND itab.
    itab-period = '03'.
    APPEND itab.
    itab-period = '04'.
    APPEND itab.
    itab-period = '05'.
    APPEND itab.
    LOOP AT itab.
      UNASSIGN <fs1>.
      ASSIGN itab-period TO <fs1>.
      CONCATENATE 'ITAB-' 'MONTH' itab-period INTO v_field.
      UNASSIGN <fs>.
      ASSIGN (v_field) TO <fs>.
      CASE itab-period.
        WHEN <fs1>.
          IF <fs> IS NOT ASSIGNED.
            <fs> = 0.
          ELSE.
            <fs> = <fs1>.
          ENDIF.
      ENDCASE.
    ENDLOOP.
    LOOP AT itab.
      WRITE: itab-period, itab-month01, itab-month02, itab-month03,
      itab-month04, itab-month05.
    ENDLOOP.
    <b>Assign Points if useful.</b>

  • Dynamic field symbol

    Hello :i would like to ask one favor , how can i define a field symbol, that can recieve a dynamic variable
    segment of code:
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = it_dynamic.
      ASSIGN it_dynamic->* TO <dyn_table>.
    CREATE DATA wa_dynamic LIKE line of <dyn_table>.
      ASSIGN wa_dynamic->* TO <dyn_wa>. " this one 'wa_dynamic'  i need to sent to <dyn_wa>
    thanks a lot

    HI
    GOOD
    Generic Type Specification
    The following types allow you more freedom when using actual parameters. The data object only needs to have the selection of attributes specified.
    Typing
    Check for data object
    No type specification
    TYPE ANY
    All types of data object are accepted. The field symbol adopts all of the attributes of the data object.
    TYPE C, N, P, or X
    Only data objects with type C, N, P, or X are accepted. The field symbol adopts the field length and DECIMALS specification (type P) of the data object.
    TYPE TABLE
    The system checks whether the data object is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE
    The system checks whether the data object is an internal table. The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE INDEX TABLE
    The system checks whether the data object is an index table (standard or sorted table). The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE STANDARD TABLE
    The system checks whether the data object is a standard internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE SORTED TABLE
    The system checks whether the actual parameter is a sorted internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE HASHED TABLE
    The system checks whether the actual parameter is a hashed internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    If you specify a type generically, remember that the attributes inherited by the field symbol from the program are not statically recognizable in the program. You can, at most, address them dynamically.
    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.
    If you adopt a structured type generically (a structure, or a table with structured line type), the individual components cannot be addressed in the program either statically or dynamically. In this case, you would have to work with further field symbols and the method of assigning structures component by component.
    Specifying the Type Fully
    When you use the following types, the technical attributes of the field symbols are fully specified. The technical attributes of the data objects must correspond to those of the field symbol.
    Typing
    Technical attributes of the field symbol
    TYPE D, F, I, or T
    The field symbol has the technical attributes of the predefined elementary type
    TYPE <type>
    The field symbol has the type <type>. This is a data type defined within the program using the TYPES statement, or a type from the ABAP Dictionary
    TYPE REF TO <cif>|DATA
    The field symbol is a reference variable for the class or interface <cif>, or for a data object.
    TYPE LINE OF <itab>
    The field symbol has the same type as a line of the internal table <itab> defined using a TYPES statement or defined in the ABAP Dictionary
    LIKE <f>
    The field symbol has the same type as an internal data object <f> or structure, or a database table from the ABAP Dictionary
    When you use a field symbol that is fully typed, you can address its attributes statically in the program, since they are recognized in the source code. If you fully specify the type of a field symbol as a reference or structured data object, you can address it as you would the data object itself, once you have assigned an object to it. So, for example, you could address the components of a structure, loop through an internal table, or create an object with reference to a field symbol.
    REPORT demo_field_symbols_type .
    DATA: BEGIN OF line,
             col1(1) TYPE c,
             col2(1) TYPE c VALUE 'X',
           END OF line.
    FIELD-SYMBOLS <fs> LIKE line.
    ASSIGN line TO <fs>.
    MOVE <fs>-col2 TO <fs>-col1.
    The field symbol <FS> is fully typed as a structure, and you can address its components in the program.
    Attaching a structure to a field symbol
    The STRUCTURE addition forces a structured view of the data objects that you assign to a field symbol.
    FIELD-SYMBOLS <FS> STRUCTURE <s> DEFAULT <f>.
    The structure <s> is either a structured local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a data object that must be assigned to the field symbol as a starting field. However, this assignment can be changed later using the ASSIGN statement.
    When you assign a data object to the field symbol, the system only checks that it is at least as long as the structure. You can address the individual components of the field symbol. It has the same technical attributes as the structure <s>.
    If <s> contains components with type I or F, you should remember the possible effects of alignment. When you assign a data object to a field symbol with a structure, the data object must have the same alignment, otherwise a runtime error may result. In such cases, you are advised to assign such data objects only to structured field symbols, which retain the same structure as the field symbol at least over the length of the structure.
    The STRUCTURE is obsolete; you should no longer use it. Field symbols defined using the STRUCTURE addition are a mixture of typed field symbols and a utility for casting to either local or ABAP Dictionary data types. If you want to define the type of a field symbol, include the TYPE addition in a FIELD-SYMBOLS statement. If you want to use casting, include the CASTING addition in an ASSIGN statement.
    Example using the obsolete STRUCTURE addition:
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             col1(2),
             col2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
                   <f2> STRUCTURE line2 DEFAULT wa.
    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
           / <f2>-col1, <f2>-col2.
    Example using the correct syntax (TYPE and CASTING):
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             COL1(2),
             COL2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> LIKE line1.
    ASSIGN wa TO <f1> CASTING.
    FIELD-SYMBOLS: <f2> LIKE line2.
    ASSIGN wa TO <f2> CASTING.
    WRITE: / <f1>-col1, <F1>-col2, <F1>-col3,
           / <f2>-col1, <F2>-col2.
    In both cases, the list appears as follows:
    012 34 56789
    01 2345/67/89
    This example declares two field symbols to which different structures are attached. The string WA is then assigned to each of them. The output shows that the field symbols assign the strings component by component according to the type of the components.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
    THANKS
    MRUTYUN

  • Read line + field symbol

    Hi expets.
    I have some doubt related to Read Line, iknow it's use but it fails when i m using field symbol.
    1->
    Do w_lines times.
    Read line sy-index field value <fs_customer>-name1.
    enddo
    Here it makes dump because i m using fied symbol. Its type is correct .
    But when i use int. table or structure it's wrks fine
    2-> when i try to hide a field sybmol it shows dump. what can i do?
      actually in a loop i_customer assigning <fs_customer>
      write: /<fs_customer>-name1..etc...
    hide : <fs_customer>-kunnr.
    here it makes dump when i hide
    3-> Problem is-
    I have two reports on same screen.1 for Customer and another for Vendor.
    both have check boxes.
    I want to read them from Screen output and for Customer name i have to get the Customer no. for the selected check box.
    Same is with the venodr report n same screen.
    wen slect Vendor name check box get vendor no.
    My issue is that how i should read two reports on same screen for check boxes.
    I mean i will make a DO ...ENDDO . and on it i will read for sy-line-1 times.
    then hw i will separate that whetehr this read is for Customer or Vendor.
    Do i need to set  some flag and then hide that flag.
    and supoose if Flag eq C at read then its custoer and as it will be V then its Vendor,
    All teh Vendor report is Below thw Customer.
    Please tell me the advantage of Field symbol over heaer lines of table./
    thanks in Advance.

    Loop to get the unselected checkbox
      DO l_line_lockbx TIMES.
      Read the lines on Screen -for LOCK BOX
        READ LINE sy-index FIELD VALUE g_check
                                                         <fs_lockbx>-name1 .
        IF  sy-subrc EQ 0 .
      If Check Box is not selected-Store in a separate table
        if g_check eq c_x.
        clear l_name_lockbx.
        move <fs_lockbx>-name1 to l_name_lockbx.
      Read table to get the Detail when ceck box not selected
        read table i_lockbx with key name1 = l_name_lockbx
                                    binary search
                                    assigning <fs_lockbx>.
          IF  sy-subrc EQ 0.
          MOVE : <fs_lockbx>-serial     TO <fs_rcvlad>-serial ,
                       <fs_lockbx>-rcvlad    TO <fs_rcvlad>-rcvlad ,
                       <fs_lockbx>-docnum TO <fs_rcvlad>-docnum .
          APPEND <fs_rcvlad> TO i_rcvlad.
          CLEAR :<fs_rcvlad>  ,
                       <fs_lockbx> ,
                         g_check     .
         endif.            " IF  sy-subrc EQ 0
        ENDIF.             " if g_check ne c_x.
      ENDDO.               " DO l_line_lockbx TIMES.

  • Dynamic Field-Symbol assignment - Short Dump

    Create three programs as mentioned:
    REPORT  zforms.
    *&      Form  form_fs_assign
    *       text
    FORM form_fs_assign.
      FIELD-SYMBOLS <fs> TYPE table.
      DATA: fs_itab LIKE STANDARD TABLE OF tab_matnr WITH HEADER LINE.
      break-point.
      ASSIGN ('(ZPROGRAM1)ITAB[]') TO <fs>.
      IF sy-subrc EQ 0.
        fs_itab[] = <fs>[].
        LOOP AT fs_itab.
          WRITE / fs_itab-matnr.
        ENDLOOP.
      ELSE.
        Write:/ sy-repid, 'field-symbol not assigned'.
      ENDIF.
    ENDFORM.                    "form_fs_assign
    REPORT zprogram1.
    DATA: itab LIKE STANDARD TABLE OF tab_matnr WITH HEADER LINE.
    itab-matnr = '1111'.
    APPEND itab.
    itab-matnr = '2222'.
    APPEND itab.
    WRITE:/ sy-repid.
    PERFORM form_fs_assign IN PROGRAM zforms.
    SUBMIT zprogram2.
    REPORT zprogram2.
    break-point.
    *-- enter (ZPROGRAM1)ITAB[] in the variable and press enter
    * the yellow icon stating that it doesn't exist appears
    * but when the following form is called, it does checks
    * the <fs> assign and doesnt gives any runtime error
    * while in Pricing routine, the similar situation
    * does gives the error
    PERFORM form_fs_assign IN PROGRAM zforms.
    *Execute zprogram1 and debug, works fine..*
    *Execute zprogram2, (ZPROGRAM1)ITAB[] doesn't exist, still it doesn't leads to short dump*
    *BUT, a very similar situation in a Pricing Requirment Routine leads to a short dump:*
    *Runtime Error          GETWA_NOT_ASSIGNED*
    *ShrtText    Field symbol has not yet been assigned.*
    *Pricing Routine Code Snippet:*
    *-- {3. -
    determine qualifying prior invoices in memory----
    FIELD-SYMBOLS: <fs_vbrk> TYPE table.
                FIELD-SYMBOLS: <fs_vbpa> TYPE table.
                FIELD-SYMBOLS: <fs_komv> TYPE table.
                DATA g_it_vbrk LIKE STANDARD TABLE OF vbrkvb WITH HEADER LINE.
                DATA g_it_vbpa LIKE STANDARD TABLE OF vbpavb WITH HEADER LINE.
                DATA g_it_komv LIKE STANDARD TABLE OF konv WITH HEADER LINE.
                DATA: l_vbrk_lines TYPE i.
                ASSIGN ('(SAPLV60A)XVBRK[]') TO <fs_vbrk>. <- "Error occurs here
                ASSIGN ('(SAPLV60A)XVBPA[]') TO <fs_vbpa>.
                ASSIGN ('(SAPLV60A)XKOMV[]') TO <fs_komv>.
                g_it_vbrk[] = <fs_vbrk>.
                g_it_vbpa[] = <fs_vbpa>.
                g_it_komv[] = <fs_komv>.
                DESCRIBE TABLE g_it_vbrk LINES l_vbrk_lines.
                READ TABLE g_it_vbrk INDEX l_vbrk_lines.
    ** remember to make vkorg and vtweg check for vbrk invoices
                DELETE g_it_vbrk WHERE vbeln = g_it_vbrk-vbeln.
                DELETE g_it_vbpa WHERE vbeln = g_it_vbrk-vbeln OR parvw <> 'WE'.
                DELETE g_it_komv WHERE knumv = g_it_vbrk-vbeln OR kschl <> 'ZF02' OR kbetr = 0.

    Hello friends,
    Rich,
    The piece of code you suggested didn't work, and still led to the short dump.
    Naimesh,
    I agree that XVBRK is not declared globally, and if it is a Table, and declared as global work area using Tables, we could have used it directly using ASSIGN (VBRK)...
    But, since its not the case, I am not able to do so...
    Still, my requirement remains the same. I have to get the invoices created (in memory) but not saved during a collective billing run.
    And the required data is available in the (SAPLV60A)XVBRK internal table, from which I am able to retrieve it for the first time, but clicking on the conditions tab in the item details leads to this short dump, becs (SAPLV60A)XVBRK[] isn't available at that moment. Still, if it is not available I suppose it should just set the sy-subrc to 4 instead of ending into a short-dump.
    Jürgen Hartwig,
    I know ZPROGRAM 1 can't work in ZPROGRAM 2, but it doesnt leads to the short dump either, does it? But in case of pricing it gives the run time error, this is exception I want to handle!
    XVBRK is not declared globally, but since SAPLV60A calls a perform in SAPLV61A, it remains in the ABAP stack and we can access it using (SAPLV60A)XVBRK[] kind of assignment.
    When the same is called during Item Conditions display, its PBO is in the stack but not other forms (in which it might have defined).
    Rich, is there a way to get all the variables available in scope at any instance during runtime?
    Well, Jürgen, I though it Germany it was called "schmutzig zuweisen" :-)... by the way, the same method has been used at several places in standard SAP programs with the sy-subrc check.
    Reference Data:
    when the assignment happens successfully, the ABAP Stack looks similar to:
    Call | Program   | Subroutine
    10   | SAPLV61A  | some_subrountine
    09   | SAPLV61A  | some_subrountine
    08   | SAPLV61A  | some_subrountine
    07   | SAPLV60A  | some_subrountine
    06   | SAPLV60A  | some_subrountine
    05   | SAPLV60A  | some_subrountine
    04   | SAPLV60A  | some_subrountine
    03   | SAPLV60A  | some_subrountine
    02   | SAPLV60A  | some_XKOMV_AUBE..subrountine
    01   | SAPLV60A  | PAI_some_subrountine
    when the assignment doesnt happens, the ABAP Stack looks similar to:
    04   | SAPLV61A  | some_subrountine
    03   | SAPLV61A  | some_subrountine
    02   | SAPLV61A  | some_subrountine
    01   | SAPLV60A  | PBO_some_subrountine

  • Internal - dynamic - field-symbols

    All,
    This is my requirement
    data in itab is
    NAME     ,  COUNT ,  STRTDATE,  ENDDATE, durinmin.
    a         123      10/1/08    10/1/08    12
    a         123      10/2/08    10/5/08    30
    a         123      10/3/08    10/8/08    15
    b         123      10/1/08    10/1/08    12
    b         123      10/2/08    10/5/08    30
    b         123      10/3/08    10/8/08    15
    to be displayed like
    name   count   10/1/08     10/2/08  10/3/08
    a     123      12          30        15
    b     123      12          30        15
    This is how I am coding...
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    data begin of itab
    NAME     ,
      COUNT     ,
      STRTDATE,
      ENDDATE,
    durinmin(6),
    end of itab.
    build catalog
    form build_cat_for_table.
      data : fname(6) value 'Day'.
      data : cntr(3) type n, ctext(10).
      wa_fieldcat-fieldname = 'NAME'.
      wa_fieldcat-inttype = 'C'.
      wa_fieldcat-outputlen = '32'.
      wa_fieldcat-coltext = 'Name'.
      wa_fieldcat-seltext = wa_fieldcat-coltext.
      APPEND wa_fieldcat TO t_fieldcat1.
      wa_fieldcat-fieldname = 'Wtavgtime'.
      wa_fieldcat-inttype = 'C'.
      wa_fieldcat-outputlen = '6'.
      wa_fieldcat-coltext = 'Wt Avg Time'.
      wa_fieldcat-seltext = wa_fieldcat-coltext.
      APPEND wa_fieldcat TO t_fieldcat1.
    *now add all the dates.
      loop at dtrange.
        cntr = 1.
        concatenate fname cntr into fname.
        ctext = dtrange-ddate.
        wa_fieldcat-fieldname = fname.
        wa_fieldcat-inttype = 'C'.
        wa_fieldcat-outputlen = '6'.
        wa_fieldcat-coltext = ctext.
        wa_fieldcat-seltext = wa_fieldcat-coltext.
        cntr = cntr + 1.
        clear fname.
        APPEND wa_fieldcat TO t_fieldcat1.
      endloop.
    endform.
    form fill_data.
    data : fname(6) value 'Day'.
      data : cntr(3) type n, ctext(10).
      CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
      it_fieldcatalog = t_fieldcat1
      IMPORTING
      ep_table = r_dyn_table
      EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS = 2.
      IF sy-subrc ne 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      ASSIGN r_dyn_table->* TO <t_dyn_table>.
      CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
      ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    loop at itab.
      ASSIGN COMPONENT 'NAME' OF STRUCTURE <wa_dyn_table> TO <w_field>.
      <w_field> = itab-name.
      ASSIGN COMPONENT 'Wtavgtime' oF STRUCTURE <wa_dyn_table> TO <w_field>.
      <w_field> = itab-wtavgtime.
    cntr = 0.
      do.
        cntr = 1.
        concatenate fname cntr into fname.
      assign component fname of structure <wa_dyn_table> to <w_field>.
      <w_field> = itab-
      enddo.
    endform.
    This is where I am stucked how to put the dates as the columns while displaying and then put the duration in the rows corresponding to the columns.
    Any help is appriciated.
    THERE ARE LOT OF EXAMPLES on forum but some how I am not able to grasp it in my code, may be my knowledge of field symbols falling short. I guess I need to use Header / field groups but not clicking me .
    Thanks in advance.

    Hi,
    I changed ur code a little.... i dont know whether it will work or not...
    But it will give u some idea...
    1. when preparing the Fieldcatalog.
    *now add all the dates.
    LOOP AT dtrange.
    *  cntr = 1.
    *  CONCATENATE fname cntr INTO fname.
      fname = dtrange-ddate.    "---u may need to change this (but give a date here)
      ctext = dtrange-ddate.
      wa_fieldcat-fieldname = fname.
      wa_fieldcat-inttype = 'C'.
      wa_fieldcat-outputlen = '6'.
      wa_fieldcat-coltext = ctext.
      wa_fieldcat-seltext = wa_fieldcat-coltext.
      cntr = cntr + 1.
      CLEAR fname.
      APPEND wa_fieldcat TO t_fieldcat1.
    ENDLOOP.
    2. When adding values...
    SORT itab BY name.
    LOOP AT itab.
      ASSIGN COMPONENT 'NAME' OF STRUCTURE <wa_dyn_table> TO <w_field>.
      <w_field> = itab-name.
      ASSIGN COMPONENT 'Wtavgtime' OF STRUCTURE <wa_dyn_table> TO <w_field>.
      <w_field> = itab-wtavgtime.
      cntr = 0.
    *  DO.
    *    cntr = 1.
    *    CONCATENATE fname cntr INTO fname.
    *    ASSIGN COMPONENT fname OF STRUCTURE <wa_dyn_table> TO <w_field>.
      fname = itab-strtdate.                  "---same thing here
      ASSIGN COMPONENT fname OF STRUCTURE <wa_dyn_table> TO <w_field>.
      IF <w_field> IS ASSIGND.
        <w_field> = itab-durinmin.
      ENDIF.
      AT END OF name.
        MODIFY <t_dyn_table> FROM <wa_dyn_table>.
      ENDAT.
    *  ENDDO.
    ENDLOOP.

  • Regarding reading a field symbols with a key

    Hi
    i have a scenario where i need to delete some duplicates from previous selection
    i' m selecting some 1000 records from one table. now in my second selection i' m reading records from 1001 to 2000.
    now i need to compare the last record(1000th) and compare the record with this second selection(1001 to 2000). in this scenario i' m using all feild symbols. here is the code
            SELECT * FROM (pa_tab)
                   INTO TABLE <lt_dyntable>
                   UP TO pa_ind ROWS
                   WHERE (lt_conditions_temp).
    initially <lt_dyntable> contains 1000 records
    if lv_dbcnt GT 1000.
    read table <lt_dyntable> assigning <ls_dyntable> with key
    <ls_dyntable> = <ls_check>.-----ERROR
    endif.
    this i have written to get the last record.
          LOOP AT <lt_dyntable> assigning <ls_dyntable>.
          ENDLOOP.
    i have stored the last record in this check. as the table <lt_dyntable> should be refreshed.
    move <ls_dyntable> to <LS_CHECK>.
    the code which i mentioned is giving me an error.
      <ls_dyntable> TYPE ANY,
      <ls_check> type any.
    let me know where i' m doing the error.
    Thanks & Regards,
    T.Subhashini.

    Hi,
    I think it is looking for a field <ls_dyntable> in your internal table <lt_dyntable>
    read table <lt_dyntable> assigning <ls_dyntable> with key
    <b><ls_dyntable> = <ls_check>.-----</b>ERROR
    Try this..
    READ TABLE <lt_dyntable> assigning <ls_dyntable> INDEX 1.
    IF <ls_dyntable> = <ls_check>.
    ENDIF.
    Thanks,
    Naren

  • Creating dynamic internal table(Not field symbol table)

    Hi Experts,
    I am facing problem creating Intarnal table
    I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
    I have written----
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
         it_fieldcatalog           = it_fldcat
          it_fieldcatalog           = me->gt_fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = lt_new_table
       e_style_fname             =
        EXCEPTIONS
         generate_subpool_dir_full = 1
         OTHERS                    = 2.
        ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
        CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
        ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
    above logic creating dynamic field symbol table.... But I want create normal internal table.
    Thanks,
    Rajasekhar

    Hi
    What do you mean?
    It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
    Max

  • I can't use my field-symbols in my select statement...

    Hello experts,
    I am have been having problems with my report for the past days. My problem is,
    I declared a dynamic field symbol so that I can use it in my select statement
    instead of the standard internal table. But it is giving me a dump. Below is my code:
    REPORT zfr_forex_rev_acctg
           NO STANDARD PAGE HEADING
           LINE-COUNT 0
           LINE-SIZE 100.
    Data dictionary tables                       *
    TABLES: bsis,
            bsas,
            tcurr,
            t001.
    FIELD-SYMBOLS: <fs_dyntable> TYPE STANDARD TABLE,
                   <fs_dynline>  TYPE ANY,
                   <fs_fld>      TYPE ANY,
                   <fs_data>     TYPE REF TO data,
                   <fs_1>        TYPE ANY,
                   <fs_2>        TYPE ANY TABLE.
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        METHODS: build_table,
                 get_data,
                 combine_data,
                 display_header,
                 display_results.
      PRIVATE SECTION.
        TYPES: BEGIN OF t_bsis_bsas,
                zuonr  TYPE bsis-zuonr,
                gjahr  TYPE bsis-gjahr,
                belnr  TYPE bsis-belnr,
                bldat  TYPE bsis-bldat,
                waers  TYPE bsis-waers,
                blart  TYPE bsis-blart,
                dmbtr  TYPE bsis-dmbtr,
                wrbtr  TYPE bsis-wrbtr,
                hkont  TYPE bsis-hkont,
                amount TYPE bsis-wrbtr,
               END OF t_bsis_bsas.
        DATA: it_bsis_bsas TYPE STANDARD TABLE OF t_bsis_bsas,
              v_counter TYPE i.
      data declarations for internal table
        DATA: lt TYPE lvc_t_fcat,
              ls TYPE lvc_s_fcat,
              fldname(50) TYPE c,
              it_ddfields TYPE TABLE OF ddfield,
              wa_ddfields LIKE LINE OF it_ddfields.
    ENDCLASS.
    CLASS lcl_main IMPLEMENTATION.
    METHOD build_table
      METHOD build_table.
        DATA: lv_from    TYPE bsis-gjahr,
              lv_asof    TYPE bsis-gjahr,
              lv_check   TYPE i,
              lt_data TYPE REF TO data,
              lt      TYPE lvc_t_fcat.
        FIELD-SYMBOLS: <fs_year> TYPE gjahr.
        ASSIGN lv_asof TO <fs_year>.
        lv_from = p_year.
        lv_asof = p_asof+0(4).
        v_counter = lv_asof - lv_from.
        wa_ddfields-fieldname = 'ZUONR'.
        wa_ddfields-position  = '0001'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000018'.
        wa_ddfields-decimals  = '00000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'GJAHR'.
        wa_ddfields-position  = '0002'.
        wa_ddfields-datatype  = 'NUMC'.
        wa_ddfields-leng      =  '000004'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BELNR'.
        wa_ddfields-position  = '0003'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BLDAT'.
        wa_ddfields-position  = '0004'.
        wa_ddfields-datatype  = 'DATS'.
        wa_ddfields-leng      =  '000008'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'WAERS'.
        wa_ddfields-position  = '0005'.
        wa_ddfields-datatype  = 'CUKY'.
        wa_ddfields-leng      =  '000005'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BLART'.
        wa_ddfields-position  = '0006'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000002'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'DMBTR'.
        wa_ddfields-position  = '0007'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'WRBTR'.
        wa_ddfields-position  = '0008'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'HKONT'.
        wa_ddfields-position  = '0009'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'AMOUNT'.
        wa_ddfields-position  = '0010'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        DATA: lv_position TYPE i.
        lv_position = 0011.
        WHILE lv_check < v_counter.
         <fs_year> = lv_asof.
          wa_ddfields-fieldname = <fs_year>.
          wa_ddfields-position  = lv_position.
          wa_ddfields-datatype  = 'NUMC'.
          wa_ddfields-leng      =  '000004'.
          wa_ddfields-decimals  = '000000'.
          APPEND wa_ddfields TO it_ddfields.
          lv_asof = lv_asof - 1.
          ADD 1 TO: lv_check, lv_position.
        ENDWHILE.
        CLEAR lv_position.
        lv_position = 1.
        LOOP AT it_ddfields INTO wa_ddfields.
          ls-col_pos   = lv_position.
          ls-row_pos   = lv_position.
          ls-fieldname = wa_ddfields-fieldname.
          APPEND ls TO lt.
          ADD 1 TO lv_position.
        ENDLOOP.
        CLEAR lv_position.
        ASSIGN lt_data TO <fs_data>.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
          it_fieldcatalog = lt
         IMPORTING
          ep_table = <fs_data>
         EXCEPTIONS
          generate_subpool_dir_full = 1
         OTHERS = 2.
        IF sy-subrc <> 0.
        ENDIF.
        ASSIGN <fs_data>->* TO <fs_1>.
        ASSIGN <fs_1> TO <fs_2>.
        ASSIGN <fs_1> TO <fs_dyntable>.
      ENDMETHOD.
    METHOD get_data
      METHOD get_data.
    *get records from BSIS
        SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
        FROM bsis
        INTO  CORRESPONDING FIELDS OF TABLE <fs_dyntable>
        WHERE bukrs = p_bukrs
          AND hkont IN s_hkont
          AND budat <= p_asof.
    *get records from BSAS
        SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
        FROM bsas
        APPENDING CORRESPONDING FIELDS OF TABLE <fs_dyntable>
        WHERE bukrs = p_bukrs
          AND hkont IN s_hkont
          AND budat <= p_asof
          AND augdt > p_asof.
      ENDMETHOD.
    START-OF-SELECTION.
      DATA: main TYPE REF TO lcl_main.
      CREATE OBJECT main.
      CALL METHOD main->build_table.
      CALL METHOD main->get_data.
    Need help on this problem. Thanks a lot guys and take care!

    Hi guys,
    I found out the problem  and Andreas is right. Now, I am having problems when including DMBTR, WRBTR in my select statement. All the others are ok. Here is my modified code. Please suggest what I need to add/modify. Thanks a lot!
    CLASS lcl_main IMPLEMENTATION.
    METHOD build_table
      METHOD build_table.
        DATA: lv_from    TYPE bsis-gjahr,
              lv_asof    TYPE bsis-gjahr,
              lv_check   TYPE i,
              lt_data TYPE REF TO data,
              lt      TYPE lvc_t_fcat.
        FIELD-SYMBOLS: <fs_year> TYPE gjahr.
        ASSIGN lv_asof TO <fs_year>.
        lv_from = p_year.
        lv_asof = p_asof+0(4).
        v_counter = lv_asof - lv_from.
      ZUONR
        wa_ddfields-fieldname = 'ZUONR'.
        wa_ddfields-position  = '0001'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000018'.
        wa_ddfields-decimals  = '00000'.
        APPEND wa_ddfields TO it_ddfields.
      GJAHR
        wa_ddfields-fieldname = 'GJAHR'.
        wa_ddfields-position  = '0002'.
        wa_ddfields-datatype  = 'NUMC'.
        wa_ddfields-leng      =  '000004'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BELNR
        wa_ddfields-fieldname = 'BELNR'.
        wa_ddfields-position  = '0003'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BLDAT
        wa_ddfields-fieldname = 'BLDAT'.
        wa_ddfields-position  = '0004'.
        wa_ddfields-datatype  = 'DATS'.
        wa_ddfields-leng      =  '00008'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      WAERS
        wa_ddfields-fieldname = 'WAERS'.
        wa_ddfields-position  = '0005'.
        wa_ddfields-datatype  = 'CUKY'.
        wa_ddfields-leng      =  '000005'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BLART
        wa_ddfields-fieldname = 'BLART'.
        wa_ddfields-position  = '0006'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000002'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      DMBTR
        wa_ddfields-fieldname = 'DMBTR'.
        wa_ddfields-position  = '0007'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
      WRBTR
        wa_ddfields-fieldname = 'WRBTR'.
        wa_ddfields-position  = '0008'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
      HKONT
        wa_ddfields-fieldname = 'HKONT'.
        wa_ddfields-position  = '0009'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      AMOUNT
        wa_ddfields-fieldname = 'AMOUNT'.
        wa_ddfields-position  = '0010'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        DATA: lv_position TYPE i.
        lv_position = 0011.
      Additional fields for the years
        WHILE lv_check < v_counter.
          wa_ddfields-fieldname = <fs_year>.
          wa_ddfields-position  = lv_position.
          wa_ddfields-datatype  = 'NUMC'.
          wa_ddfields-leng      =  '000004'.
          wa_ddfields-decimals  = '000000'.
          APPEND wa_ddfields TO it_ddfields.
          lv_asof = lv_asof - 1.
          ADD 1 TO: lv_check, lv_position.
        ENDWHILE.
        CLEAR lv_position.
        lv_position = 1.
        LOOP AT it_ddfields INTO wa_ddfields.
          CASE wa_ddfields-fieldname.
            WHEN 'BLDAT'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-inttype   = 'D'.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'BLDAT'.
            WHEN 'WAERS'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'WAERS'.
            when 'DMBTR'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'DMBTR'.
            when 'WRBTR'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'WRBTR'.
            WHEN OTHERS.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
          ENDCASE.
          APPEND ls TO lt.
          ADD 1 TO lv_position.
        ENDLOOP.
        CLEAR lv_position.
        ASSIGN lt_data TO <fs_data>.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
          it_fieldcatalog = lt
         IMPORTING
          ep_table = <fs_data>
         EXCEPTIONS
          generate_subpool_dir_full = 1
         OTHERS = 2.
        IF sy-subrc <> 0.
        ENDIF.
        ASSIGN <fs_data>->* TO <fs_1>.
        ASSIGN <fs_1> TO <fs_2>.
        ASSIGN <fs_1> TO <fs_dyntable>.
      ENDMETHOD.

Maybe you are looking for

  • How do I use my Macbook Air's keyboard to access Apple Tv device?

    I cannot figure out how to interfrace my hdtv, apple tv and my computer.

  • Hp5520 scan no longer works after Yosemite update

    My hp5520 has been working fine for both printing and scanning wirelessly from my iMac until the recent Yosemite update.  I can still print, but can no longer scan.  What is the solution for this?  Is there a driver update needed for Yosemite?  I nee

  • Issue in confirmation links for personal data ESS application (CA)

    Hi All, We have implemented EXIT button configuration for ESS applications and the Exit button along with 'Go to Home page' link is navigating to custom created page in portal. The configuration done earlier for ESS applications like Address Update,

  • Video issues tx2500z

    I've been having some epic graphics issues with my tx2500z. I get a bunch of random colorful boxes that appear all over my screen and then my computer becomes unresponsive and needs to be shut down forcibly. Sometimes it blue screens as well. I have

  • Wrt310n trouble connecting windows2000

    Hello I just upgraded my wireless router to a WRT310 and I'm having trouble connecting to it via wireless with windows 2000. It worked perfectly before, I used all the same setups as my previous wireless to minimize issues. wireless mode is set to mi