Append Field symbols

Hi all,
how can we move internal tables data to field symbol table.
i am new to field symbol, can any one guide me in detail.. i have searched in forums but i am unable understand..
i have defined fields symbols like this.
FIELD-SYMBOLS: <F_TAB>   TYPE STANDARD TABLE,
               <F_LINE>  TYPE ANY,
               <F_FIELD> TYPE ANY.
and i have data in ITAB1, ITAB2 & ITAB3.
this tables data i need to move to final internal table i.e. <F_TAB>, whose structure is created dynamically..
in this way i have created the dynamical internal table structure
LOOP AT IT_WDAYS INTO WA_WDAYS.
      PERFORM MONTH_TEXT USING WA_WDAYS-PERIODAT CHANGING V_FNAME.
*   Element Description
      LO_ELEMENT ?= CL_ABAP_ELEMDESCR=>DESCRIBE_BY_NAME( 'CHAR5' ).
      MOVE V_FNAME TO LA_COMP-NAME.
*   Field type
      LA_COMP-TYPE = CL_ABAP_ELEMDESCR=>GET_P(
                        P_LENGTH   = LO_ELEMENT->LENGTH
                        P_DECIMALS = LO_ELEMENT->DECIMALS ).
*   Filling the component table
      APPEND LA_COMP TO LT_TOT_COMP.
      CLEAR: LA_COMP.
    ENDLOOP.
* 3. Create a New Type
    LO_NEW_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( LT_TOT_COMP ).
* 4. New Table type
    LO_NEW_TAB = CL_ABAP_TABLEDESCR=>CREATE(
                    P_LINE_TYPE  = LO_NEW_TYPE
                    P_TABLE_KIND = CL_ABAP_TABLEDESCR=>TABLEKIND_STD
                    P_UNIQUE     = ABAP_FALSE ).
* 5. data to handle the new table type
    CREATE DATA LO_DATA TYPE HANDLE LO_NEW_TAB.
* 6. New internal table in the fieldsymbols
    ASSIGN LO_DATA->* TO <F_TAB>.
i dont want to create thru fieldcatalog method...
just i want know how to pass 2 internal tables data into one final field symbol table..
thanks
Edited by: Matt on Mar 23, 2009 10:52 AM - added  tags

Hi,
Check this code:
*& Report  Z_RTTS_TABLE
REPORT  z_rtts_table.
TYPE-POOLS: abap.
DATA: gs_comp TYPE abap_componentdescr,
      gt_comp TYPE abap_component_tab.
"example table
DATA: BEGIN OF it OCCURS 3,   "<- your ITAB1
        pernr TYPE persno,
        kostl TYPE kostl,
        endda TYPE endda,
      END OF it.
"data references
DATA: r_type_struct TYPE REF TO cl_abap_structdescr,
      r_type_table  TYPE REF TO cl_abap_tabledescr,
      r_data_tab    TYPE REF TO data,
      r_data_str    TYPE REF TO data.
* 1. ------------- filling example table IT  -> i.e your ITAB1
it-pernr = '12345678'.
it-kostl = '0112345678'.
it-endda = sy-datum.
APPEND it.
it-pernr = '45678909'.
it-kostl = '3452345678'.
it-endda = sy-datum - 1.
APPEND it.
* 2. ------------ components structure type
gs_comp-name = 'PERNR'.
gs_comp-type ?= cl_abap_elemdescr=>describe_by_name( 'PERSNO' ).
APPEND gs_comp TO gt_comp.
gs_comp-name = 'KOSTL'.
gs_comp-type ?= cl_abap_elemdescr=>describe_by_name( 'KOSTL' ).
APPEND gs_comp TO gt_comp.
gs_comp-name = 'BEGDA'.
gs_comp-type ?= cl_abap_elemdescr=>describe_by_name( 'BEGDA' ).
APPEND gs_comp TO gt_comp.
* 3. ------------- create structure type
TRY.
    r_type_struct = cl_abap_structdescr=>create(
                              p_components = gt_comp ).
  CATCH cx_sy_struct_creation .
ENDTRY.
* 4. ------------- create table type
TRY.
    r_type_table = cl_abap_tabledescr=>create( r_type_struct ).
  CATCH cx_sy_table_creation .
ENDTRY.
" 5. -------------- create table based on RTTS types
CREATE DATA: r_data_tab TYPE HANDLE r_type_table,
             r_data_str TYPE HANDLE r_type_struct.
FIELD-SYMBOLS: <fs_table> TYPE INDEX TABLE,    "-> here table must by type INDEX TABLE in order to append to it
                           <fs_wa>    TYPE ANY.
ASSIGN: r_data_tab->* TO <fs_table>,
        r_data_str->* TO <fs_wa>.         "work area for dynamic table (based on your dynamic structure)     
" 6. ---------------- move internal table data (IT) to dynamic table
LOOP AT it.
  MOVE-CORRESPONDING it TO <fs_wa>.
  APPEND <fs_wa> TO <fs_table>.
ENDLOOP.
Do the same with ITAB2 and ITAB3.
Regards
Marcin

Similar Messages

  • Appending -FIELD Symbols

    Hi,
    I am confused with append statement when using field symbols.
    When I use append <WA1> to t_FINAL. it throws an error saying T_FINAL is not an internal table "OCCURS N" is missing..
    I cannot use occurs statement because I am doing OO ABAP.ANy ideas?
    FIELD-SYMBOLS <wa> LIKE LINE OF bookmk.
    FIELD-SYMBOLS <wa1> LIKE LINE OF bookmk.
    LOOP AT T_ITAB ASSIGNING <wa>.
      SEARCH <wa>-url FOR '&XYZZZ'.
      IF sy-subrc IS  INITIAL.
        ASSIGN  t_FINAL TO <wa1>.
        MOVE-CORRESPONDING <wa> TO <wa1>.
      ****???????append <WA1> to t_FINAL.
      ENDIF.
    ENDLOOP.

    Hi there..
    FIELD-SYMBOLS <wa> LIKE LINE OF bookmk.
    FIELD-SYMBOLS <wa1> LIKE LINE OF bookmk.
    datA: it_final type standard table of bookmk."<<<use this table decl

  • 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 use different field symbols to append data in a loop

    Hi experts!
    I have to loop over a itab and I want to save different  into one table.
    See my code below:
    DATA: l_hours        TYPE i,
          grfk_ok_code    TYPE sy-ucomm,
          grfk_values     TYPE TABLE OF GPRVAL WITH HEADER LINE,
          grfk_coltxt     TYPE TABLE OF GPRTXT WITH HEADER LINE,
          wa_ztab         TYPE zqm_chq_prueflos,
          l_index      TYPE n,
          l_field      TYPE string,
          l_line_check TYPE string
    FIELD-SYMBOLS:
          <fs_0102>   TYPE ANY,
          <fs_0304>   TYPE ANY,
          <fs_0506>   TYPE ANY,
          <fs_grenze> TYPE ANY
    REFRESH: grfk_values.
    CLEAR:   l_hours.
      LOOP AT ztab INTO wa_ztab.
      AT NEW qase_serialnr.
        CLEAR: l_line_check.
        IF wa_ztab-qase_serialnr CS '-01'
        OR wa_ztab-qase_serialnr CS '-02'.
            grfk_values-rowtxt = 'gelötet'.
            l_line_check = '0102'.
        ELSEIF wa_ztab-qase_serialnr CS '-03'
        OR     wa_ztab-qase_serialnr CS '-04'.
            grfk_values-rowtxt = 'geglüht'.
            l_line_check = '0304'.
        ELSEIF wa_ztab-qase_serialnr CS '-05'
        OR     wa_ztab-qase_serialnr CS '-06'.
            grfk_values-rowtxt = 'unbehandelt'.
            l_line_check = '0506'.
        ELSE.
          grfk_values-rowtxt = 'serialnr_wrong'.
        ENDIF.
      ENDAT.
    ***---------------------------------------------------->
      AT NEW qapp_usern1.
    *   X-axis: values are:0,50,100,...,400
        grfk_coltxt-coltxt = wa_ztab-qapp_usern1.
        SHIFT grfk_coltxt-coltxt LEFT DELETING LEADING '0'.
        APPEND grfk_coltxt.
        UNASSIGN <fs_grenze>.
        CLEAR: l_index, l_field.
        l_index = sy-tabix.
        CONCATENATE 'grfk_values-val' l_index INTO l_field.
        ASSIGN (l_field) TO <fs_grenze>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        <fs_grenze> = 10.
        APPEND grfk_values.
      ENDAT.
      IF l_line_check = '0102'.
          UNASSIGN <fs_0102>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0102>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0102> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0304'.
          UNASSIGN <fs_0304>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0304>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0304> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0506'.
          UNASSIGN <fs_0506>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0506>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0506> = wa_ztab-cf_dgp.
      ENDIF.
    ENDLOOP.
    My goal should be to fill the graphic with 4 Lines:
    1 is boarderline.
    2-3 are the lines with the looped values in "ztab"
    Do I have to use references to write the values in  into different rows of internal table "grfk_values"????
    With this code I want to fill the itab which I need for the GFW_PRES_SHOW function.
    The table I have to commit has the following structure:
    -rowtxt
    -val1
    -val2
    -val31
    EDIT:
    My current output are 2 lines the first has value 0 for each point and the second shows the correct values... The boarder which always should have value 10 is completly not shown.

    hopen this will help
    report zrich_0001 .
    data: begin of itab1 occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          fld3(10) type c,
          end of itab1.
    data: begin of itab2 occurs 0,
        flda(10) type c,
        fldb(10) type c,
        fldc(10) type c,
        end of itab2.
    field-symbols: <fs_table> type table,
                   <fs_wa>,
                   <fs>.
    data: mod_field(10) type c.
    itab1-fld1 = '1'. itab1-fld2 = '2'. itab1-fld3 = '3'. append itab1.
    itab1-fld1 = '4'. itab1-fld2 = '5'. itab1-fld3 = '6'. append itab1.
    itab2-flda = 'A'. itab2-fldb = 'B'. itab2-fldc = 'C'. append itab2.
    itab2-flda = 'D'. itab2-fldb = 'E'. itab2-fldc = 'F'. append itab2.
    assign itab1[] to <fs_table>.
    assign itab1 to <fs_wa>.
    mod_field = 'FLD2'.
    perform modify_table.
    perform write_table.
    assign itab2[] to <fs_table>.
    assign itab2 to <fs_wa>.
    mod_field = 'FLDC'.
    perform modify_table.
    perform write_table.
          FORM modify_table                                             *
    form modify_table.
      loop at <fs_table> into <fs_wa>.
        assign component mod_field of structure <fs_wa> to <fs>.
        <fs> = 'Modified'.
        modify <fs_table> from <fs_wa>.
      endloop.
    endform.
          FORM write_table                                             *
    form write_table.
      loop at <fs_table> into <fs_wa>.
        do.
          assign component sy-index of structure <fs_wa> to <fs>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <fs>.
          else.
            write: <fs>.
          endif.
        enddo.
      endloop.
    endform.
    regards
    navjot
    reward points if helpfull

  • How to append records to a field symbols?

    Hi all,
    is there a way to append records from an internal table fto a field symbol of type table.

    Hi Daphne,
    Changing internal table to which field symbol is pointing will automatically change data accessed by field-symbol as it is only pointer to internal table..
    Regards,
    Mohaiyuddin..

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

  • Appending internal table which is referenced by field-symbol

    Hi,
    I have a selection screen field called SP$00005 which is not known until runtime as the field is selected in Adhoc Query (SAP Query) by the user.
    In the customer exit I am attempting to write code to default in a range to this field - it is a date field and I want to enter the range 01.04.2007 - 30.04.2007.
    As select-options require the appending of the screen field table SP$00005 I need a way of adding an entry to this table.
    Please see my latest attempt below which appends the correct value to the field symbol <startdate> but this entry does not appear in the internal table SP$00005 when stepping through at runtime.
    Can anyone suggest a possible solution?
    Thanks,
    Alan
      data: ref_field(8) type c.
      field-symbols: <startdate> type table. "table = STANDARD by default
      types: begin of sp$00005, "type definition required for syntax check
                  sign(1),
                  option(2),
                  low type d,
                  high type d,
                end of sp$00005.
      data: lt_ref type ref to data.
      ranges: selection for sy-datum.
      ref_field = 'SP$00005'.
      create data lt_ref type table of (ref_field).
      assign lt_ref->* to <startdate>.
    assign (ref_field) to <startdate>. "- raises type error
      move 'I' to selection-sign.
      move 'BT' to selection-option.
      move '20070401' to selection-low.
      move '20070430' to selection-high.
      append selection to <startdate>.

    Hi,
    I tried the following which appends <startdate> with the new entry but the underlying referenced table SP$00005 is still not updated.
    Any ideas?
    Thanks,
    Alan
      field-symbols: <startdate> type any table,
                     <l_line> type any,
                     <l_field> type any.
      data: ref_field(8) type c.
      types: begin of sp$00005, "type definition required for syntax check
               sign(1),
               option(2),
               low type d,
               high type d,
             end of sp$00005.
      data: lt_ref type ref to data.
      ranges: selection for sy-datum.
      data: new_line type ref to data.
      ref_field = 'SP$00005'.
      create data lt_ref type table of (ref_field).
      assign lt_ref->* to <startdate>.
      create data new_line like line of <startdate>.
      assign new_line->* to <l_line>.
      if <l_line> is assigned.
    move values using assing stt.
      endif .
      move 'I' to selection-sign.
      move 'BT' to selection-option.
      move '20070401' to selection-low.
      move '20070430' to selection-high.
      assign selection to <l_line>.
      insert <l_line> into table <startdate>.

  • Append a new line while using Field Symbols

    Hi,
    Below is a snippet of my code
    DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].
    FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].
    zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).
    <ls_data_package>-/bic/zd_user = <ls_data_package>-/bic/zbib_sysn(off).
    <ls_data_package>-/bic/zwrk = <ls_data_package>-/bic/zbib_sysn+off1.
    I want to insert a new line to the data package, with all the fields same while adding the above two,
    except for,
    <ls_data_package>-/bic/zd_user = zbib_sysn_temp
    <ls_data_package>-/bic/zitm = 2.
    Note: by default the field /bic/zitm = 1. So while adding for the 1st time it is set to 1 by default. I want to add a second (new line) to the datapackage which has all fields same except for the /bic/zd_user and the /bic/zitm = 2.
    Please help me with this code,
    CD

    Souvrav, thanks for the reply.
    I am not an ABAP'er, I have managed to write code so far. Can you please help me with how this can be done in this code:
      DATA: off, off1, off2, off3, off4, off5, off6 TYPE i.
      DATA: zbib_sysn_temp TYPE string.
      DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].
      FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].
      SORT DATA_PACKAGE BY /bic/zbib_id.
      LOOP AT DATA_PACKAGE ASSIGNING <ls_data_package>.
        IF <ls_data_package>-/bic/zbib_sysn IS NOT INITIAL.
          TRANSLATE <ls_data_package>-/bic/zbib_sysn TO UPPER CASE.
          FIND '/' IN <ls_data_package>-/bic/zbib_sysn MATCH OFFSET off2.
            zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).
    IF sy-subrc EQ 0.
                <ls_data_package>-/bic/zd_user =
                <ls_data_package>-/bic/zbib_sysn(off).
    Now at this point of code i want to copy this existing record from ls_data_package to create a new record where /bic/zd_user = zbib_sysn_temp and /bic/zitm = 2.
    Pleas help...

  • Modify DB by single field using Field Symbol

    Hi,
      please help me ,actually i have not use the field symbol in any object. i have one requirement ,i have to modify the DB by field STATUS using Field symbol ,
    I am sending u my code so please help me how can i modify DB using field symbol..
              gw_msg3_status1   = k_status1 .
              LOOP AT gi_msg3 INTO gs_msg3.
                gs_msg3-status  = gw_msg3_status1 .
                gs_msg3-issue   = lw_issuno.
           MODIFY gi_msg3 FROM gs_msg3 TRANSPORTING status.
                MODIFY gi_msg3 INDEX sy-tabix FROM gs_msg3 TRANSPORTING issue status.
              ENDLOOP.
    Thanks & Regards,
    Meenakshi

    perform dboperation_table using 'SET' 'BIRTHDT' '=' <fs>.
        perform dboperation_table using 'WHERE' 'PARTNER' '='  <fs>
        perform dboperation_update using 'BUT000'.
    form dboperation_table
    using p_type
          p_var1
          p_var2
          p_var3.
      data: t_l type cmst_str_data.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          clear t_l.
          if p_var3 is not initial.
            t_l = p_var3.
            condense t_l.
            concatenate '''' t_l '''' into t_l.
          endif.
          concatenate p_var1 p_var2 t_l into t_l
          separated by space.
          case p_type.
            when 'SET'.   append t_l to g_s_t.
            when 'WHERE'. append t_l to g_w_t.
          endcase.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_table
    form dboperation_update
    using  p_tabname type zdboperation-tabname.
      data: tabname type bus_table.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          tabname-tabname = p_tabname.
          call function 'ZDBOPERATION_UPDATE'
            in update task
            exporting
              tabname     = tabname
            tables
              where_table = g_w_t
              set_table   = g_s_t.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_update
    Hope it will help you.
    Regards,
    Madan.

  • Field symbols and READ TABLE with system code 4

    Hi,
    I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
    Loop at x_data assign <fs>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
    READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
                                               a2 = <c2>.
    If sy-subrc = 0.
    endif.
    I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
    How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
    Please advise. Thanks
    RT

    Hai Rob
    Go  through the following Code
    Field-Symbols are place holders for existing fields.
    A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
    Field-Symbols are like Pointers in Programming language ‘ C ‘.
    Syntax check is not effective.
    Syntax :
    Data : v1(4) value ‘abcd’.
    Field-symbols <fs>.
    Assign v1 to <fs>.
    Write:/ <fs>.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
    DO 4 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
    APPEND LINE TO ITAB.
    ENDDO.
    READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
    <FS>-COL2 = 100.
    READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
    DELETE ITAB INDEX 3.
    IF <FS> IS ASSIGNED.
    WRITE '<FS> is assigned!'.
    ENDIF.
    LOOP AT ITAB ASSIGNING <FS>.
    WRITE: / <FS>-COL1, <FS>-COL2.
    ENDLOOP.
    The output is:
    1 1
    2 100
    4 16
    Thanks & regards
    Sreenivasulu P

  • Field symbol has not yet been assigned. ???

    Dear Experts ,
    W hen i tried to execute my program this error appears :
    Short text
        Field symbol has not yet been assigned.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPLSLVC" had to be terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        You attempted to access an unassigned field symbol
        (data segment 32821).
        This error may occur if
        - You address a typed field symbol before it has been set with
          ASSIGN
        - You address a field symbol that pointed to the line of an
          internal table that was deleted
        - You address a field symbol that was previously reset using
          UNASSIGN or that pointed to a local field that no
          longer exists
        - You address a global function interface, although the
          respective function module is not active - that is, is
          not in the list of active calls. The list of active calls
          can be taken from this short dump.
    and Here is my CODE :
    *& Report  ZPO
    Report  ZPO1.
    type-pools slis.
      PARAMETERS : PO_Doc like EKBE-EBELN DEFAULT '4800000007'.
      PARAMETERS : Plant TYPE WERKS DEFAULT '1000'.
      PARAMETERS : PO_ORG TYPE EKORG DEFAULT ''.
      data TtlS type mara-wesch .
      data TtlH type mara-wesch .
      data Ttl type mara-wesch .
      data ZEKBE type TABLE OF EKBE.
      data ZEKBER type EKBE.
      data ZEKPO type TABLE OF EKPO.
      data ZEKPOR type EKPO.
      data ZEKKOR TYPE EKKO.
      data ZNAME1F type LFA1-LIFNR.
      data ZWGBEZF TYPE T023T-WGBEZ.
      data i type n.
      data counter type n.
    types : begin of SBAGDS,
      Serial Type n, "Purchase Order
      EBELN like EKKO-EBELN, "Purchase Order
      MATNR like EKPO-MATNR, "Material
      TXZ01 like EKPO-TXZ01, "Short Text
      MATKL like EKPO-MATKL, "Material Group
      WGBEZ like T023T-WGBEZ, "Material Group Desc"
      SUBMI like EKKO-SUBMI, "GPM
      CHARG like EKBE-CHARG, "Batch
      LIFNR like EKKO-LIFNR, "Vendor
      NAME1 like LFA1-NAME1, "Vendor Name
      RECV like mara-wesch, "Received Quantity
      REVR like mara-wesch, "Reversed Quantity
      DELV like mara-wesch, "Delivered Quantity
    end of SBAGDS .
    DATA : BAGDS TYPE SBAGDS OCCURS 0 WITH HEADER LINE.
    data Struc like BAGDS.
    data: gr_table like BAGDS OCCURS 0 WITH HEADER LINE.
    data: gt_fieldcat type slis_t_fieldcat_alv, gt_outtab type SBAGDS occurs 0 with header line.
    INITIALIZATION.
    i = 0.
    counter = 0 .
    perform field_cat_init using gt_fieldcat[].
    FORM field_cat_init using rt_fieldcat type slis_t_fieldcat_alv.
    data: ls_fieldcat type slis_fieldcat_alv,
             pos type i value 1.
    clear LS_FIELDCAT.
    *Column 1
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'Serial'.
    ls_fieldcat-SELTEXT_L      = 'Serial'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 2
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'EBELN'.
    ls_fieldcat-SELTEXT_L      = 'Purchase Order'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 3
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'MATNR'.
    ls_fieldcat-SELTEXT_L      = 'Material'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 4
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'TXZ01'.
    ls_fieldcat-SELTEXT_L      = 'Short Text'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 5
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'MATKL'.
    ls_fieldcat-SELTEXT_L      = 'Material Group'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 6
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'WGBEZ'.
    ls_fieldcat-SELTEXT_L      = 'Material Group Desc'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 7
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'SUBMI'.
    ls_fieldcat-SELTEXT_L      = 'GPM'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 8
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'CHARG'.
    ls_fieldcat-SELTEXT_L      = 'Batch'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 9
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'LIFNR'.
    ls_fieldcat-SELTEXT_L      = 'Vendor'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 10
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'NAME1'.
    ls_fieldcat-SELTEXT_L      = 'Vendor Name'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 11
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'RECV'.
    ls_fieldcat-SELTEXT_L      = 'Received Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 12
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'REVR'.
    ls_fieldcat-SELTEXT_L      = 'Reversed Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    *Column 13
    ls_fieldcat-col_pos           = pos.
    ls_fieldcat-fieldname        = 'DELV'.
    ls_fieldcat-SELTEXT_L      = 'Delivered Quantity'.
    ls_fieldcat-DDICTXT          = 'L'.
    append ls_fieldcat to rt_fieldcat.
    clear ls_fieldcat.
    pos = pos + 1.
    endform.
    START-OF-SELECTION.
           select SINGLE * from EKKO into ZEKKOR where EBELN = PO_DOC.
           select SINGLE * from EKPO into ZEKPOR where EBELN = PO_DOC.
           select SINGLE NAME1 from LFA1 into ZNAME1F where LIFNR = ZEKKOR-LIFNR.
    *         ' Buliding Structure
              Struc-EBELN = ZEKPOR-EBELN.
              Struc-SUBMI = ZEKKOR-SUBMI.
              Struc-LIFNR = ZEKKOR-LIFNR.
              Struc-Name1 = ZNAME1F.
           select * from EKPO into TABLE ZEKPO where EBELN = PO_Doc and WERKS = plant.
           LOOP at ZEKPO into ZEKPOR.
               select SINGLE WGBEZ from T023T into ZWGBEZF  WHERE MATKL = ZEKPOR-MATKL .
               counter = counter + 1.
    *         ' Buliding Structure
              Struc-Serial = counter.
              Struc-MATNR = ZEKPOR-MATNR.
              Struc-TXZ01 = ZEKPOR-TXZ01.
              Struc-MATKL = ZEKPOR-MATKL.
              Struc-WGBEZ = ZWGBEZF.
    *          Calcualting Debit transactions from PO History
               select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and  EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'S'.
               LOOP AT ZEKBE INTO ZEKBER.
                   TtlS = TtlS + ZEKBER-MENGE.
               ENDLOOP.
    *          ' Buliding Structure
               Struc-CHARG = ZEKBER-CHARG.
               Struc-RECV = TtlS.
               Ttl = TtlS.
               clear TtlS.
    *         Calcualting Credit transactions from PO History
             select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and  EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'H'.
               LOOP AT ZEKBE INTO ZEKBER.
                   TtlH = TtlH + ZEKBER-MENGE.
               ENDLOOP.
    *          ' Buliding Structure
               Struc-REVR = TtlH.
    *          Calculating Total Delivered
               Ttl = Ttl - TtlH.
               clear TtlH.
    *          ' Buliding Structure
               Struc-DELV = Ttl.
               clear Ttl.
    *      Writtng ITAB
           APPEND Struc to BAGDS.
           ENDLOOP.
    *      Reading ITAB
    *       WRITE : / , 'ITAB Begin : '    .
    *       loop at  BAGDS into Struc.
    *         counter = counter + 1.
    *         write : /,'Serial : ',counter.
    *         write : / ,'PO : ',Struc-EBELN.
    *         write : / ,'Vendor : ',Struc-LIFNR.
    *         write : / ,'Vendor Name : ',Struc-NAME1.
    *         write : / ,'Material : ',Struc-MATNR.
    *         write : /,'Short Text: ',Struc-TXZ01.
    *         write : / ,'Model : ',Struc-MATKL.
    *         write : / ,'Model Desc : ',Struc-WGBEZ.
    *         write : /,'GPM : ',Struc-SUBMI.
    *         write : /,'Lot : ',Struc-CHARG.
    *         write : /,'Received : ',Struc-RECV.
    *         write : /,'Reversed : ',Struc-REVR.
    *         write : /,'Delivered : ',Struc-DELV,/,/,/.
    *       ENDLOOP.
    * Call ALV Grid Viewer
    *BREAK-POINT.
    gr_Table[] = BAGDS[].
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
                 I_STRUCTURE_NAME   = 'SBAGDS'
                 IT_FIELDCAT          = gt_fieldcat[]
            TABLES
                 T_OUTTAB                  = gr_Table.
    Please Advise
    Edited by: Sap Sap on Jul 27, 2009 12:18 PM
    Edited by: Sap Sap on Jul 27, 2009 12:22 PM
    Edited by: Sap Sap on Jul 27, 2009 12:22 PM

    Hi,
    The problem seems to be in your ALV grid display.
    The reason must be your field catalog.
    Just check your fieldcatalog.
    The value in the fieldname field of the fieldcatalog should be same as the fieldname in your internal table and should be in capital letters.
    Probably you must have mistyped some field.
    Kinldy check.
    Regards,
    Ankur Parab

  • ALV report with internal in field symbol

    Hi Shifu ABAP,
    I have ALV report.
    My problem is when I tried to do sum using the sum icon. I got a message 'desired operation cannot be performed for column 'Dignostic delay'. Is it because I used field symbol, then when I clicked on the column it didn't recorgnise the field.
    FYI.
    1)The internal table for my ALV report is stored in field symbol.
    2)I dont have a problem to display the report.
    3)I had to set 'do_sum' at ALV field category, still doesn't work
    My source code to define ALV category.
    loop at i_qpcd into wa_qpcd.
    CLEAR ls_fieldcat2.
    ls_fieldcat2-col_pos = pos2.
    ls_fieldcat2-fieldname = wa_qpcd-code.
    ls_fieldcat2-reptext_ddic = wa_qpcd-desc.
    ls_fieldcat2-just = 'C'.
    ls_fieldcat2-do_sum = 'X'.
    APPEND ls_fieldcat2 TO gt_fieldcat2.
    endloop.
    My source code call the ALV FM
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
         i_callback_program         = 'ZMPMR001_Q1OOT'
         i_callback_pf_status_set = 'PF_STATUS_SET'
         is_layout                        = ls_layout
         it_fieldcat                       = gt_fieldcat2[]
         is_print                          = ls_print
    TABLES
         t_outtab                         = <l_table>
    EXCEPTIONS
         program_error                 = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Thanks a lot in advance for your attention.

    my situation is like this, declare the internal tble
    1) data : begin of itab occurs 0,          
                code like qpcd-code,
                desc like QPCT-KURZTEXT,
              end of itab.
    2) populate the itab like this
    code           desc
    01              desc 1
    02              desc 2
    03              desc 3
    3) take the selected record converted it into new dynamic internal table using field symbol declare as table, now the component of this new table are 01, 02 and 03.
    4) populate the new table with some data, so technically my new table structure will be like this
    01         02         03
    1           0          1
    0           0          3
    2           2          2
    5) display the new table in ALV report, in ALV I tried to sum-up each of column.
    6) Question : HOW can I convert the componet 01, 02 and 03 as an integer/numeric field.
    Regards
    Nislina

  • Field-Symbols: How to retrieve data into an internal table from FS

    Hello All,
    I am working on field symbols.I have declared the field symbols as shown.
    FIELD-SYMBOLS: <gt_pos_data>  TYPE table,
                               <wa_pos_data> like <gt_pos_data>.
    Data: Begin of itab occurs 0,
               field1(5) type c,
               field2(10)_type c,
             end of itab.
    The FS  <gt_pos_data> has 100 fields but I need to move only two fields from this FS to my internal table itab.I am doing the following.
    loop at <gt_pos_data> assigning <wa_pos_data>.
    itab-field1 = <wa_pos_data>-field1.
    itab-field2 = <wa_pos_data>-field2.
    append itab.
    clear itab.
    endloop.
    But it is giving me an error saying "<wa_pos_data> is a table without header line and therefore has no componet FIELD1".How to achieve this requirement?
    Thanks in advance
    Sandeep

    <wa_pos_data> should be defined LIKE LINE OF <gt_pos_data>, but it will still have no structure, so you need to assign a field symbol to the component as well.
    FIELD-SYMBOLS: <gt_pos_data> TYPE table,
                               <wa_pos_data> like LINE OF <gt_pos_data>,
                               <field> type any.
    Data: Begin of itab occurs 0,
    field1(5) type c,
    field2(10)_type c,
    end of itab.
    loop at <gt_pos_data> assigning <wa_pos_data>.
    assign componet 'FIELD1' of structure <wa_pos_data> to <field>.
    if sy-subrc  = 0.
    itab-field1 = <field>.
    endif.
    assign componet 'FIELD2' of structure <wa_pos_data> to <field>.
    if sy-subrc  = 0.
    itab-field2 = <field>.
    endif.
    append itab.
    clear itab.
    endloop.
    Regards,
    Rich Heilman

  • 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

  • Getting a runtime error in block alv that field symbol has been assigned

    hi to all experts ,
    im getting a runtime error that field symbol has not been assigned in functionmodule reuse_alv_block_list_display
    i tried a lot to rectify the error ,im unable to do it thats i have posted here
    *& Report  ZHAI_ALV_BLOCK_LIST
    REPORT  ZHAI_ALV_BLOCK_LIST.
    type-pools:slis.
    tables:mara.
    DATA:BEGIN OF  IT_MARA OCCURS 0,
            MATNR LIKE MARA-MATNR,
            MBRSH LIKE MARA-MBRSH,
            MATKL LIKE MARA-MATKL,
            END OF IT_MARA.
    data: begin of IT_DESC OCCURS 0,
             MATNR like MAKT-MATNR,
             MAKTX like MAKT-MAKTX,
         end of IT_DESC.
    data: begin of IT_MARD occurs 0,
            MATNR like mard-matnr,
            WERKS  like  mard-werks,
            LGORT  like  mard-lgort,
            LABST like mard-labst,
          end of IT_MARD.
    data: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV ,
          WA_FCAT LIKE LINE OF IT_FCAT,
          IT_FCAT1 type  slis_t_fieldcat_alv,
          WA_FCAT1 LIKE LINE OF IT_FCAT1,
          IT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV,
          WA_FCAT2 LIKE LINE OF IT_FCAT2,
          wa_layout type  SLIS_LAYOUT_ALV,
          it_event type SLIS_T_EVENT,
          wa_event like line of it_event,
         wa_layout like line of it_layout,
          V_REPID LIKE SY-REPID.
    select-options:so_matnr for mara-matnr.
    start-of-selection.
    perform f_select_data.
    DEFINE ADD_CATALOGUE1.
    WA_FCAT-COL_POS = &1.
    WA_FCAT-fieldname = &2.
    WA_fcat-tabname = &3.
    wa_fcat-emphasize = &4.
    wa_fcat-ref_tabname = &5.
    APPEND WA_FCAT TO IT_FCAT.
    END-OF-DEFINITION.
    DEFINE ADD_CATALOGUE2.
    WA_FCAT1-COL_POS = &1.
    WA_FCAT1-fieldname = &2.
    WA_fcat1-tabname = &3.
    wa_fcat1-emphasize = &4.
    wa_fcat1-ref_tabname = &5.
    APPEND WA_FCAT1 TO IT_FCAT1.
    END-OF-DEFINITION.
    DEFINE ADD_CATALOGUE3.
    WA_FCAT2-COL_POS = &1.
    WA_FCAT2-fieldname = &2.
    WA_fcat2-tabname = &3.
    wa_fcat2-emphasize = &4.
    wa_fcat2-ref_tabname = &5.
    APPEND WA_FCAT2 TO IT_FCAT2.
    END-OF-DEFINITION.
    perform f_build_fcat.
    *perform f_build_fcat1.
    perform f_build_fcat2.
    PERFORM F_BUILD_LAYOUT.
    PERFORM F_BUILD_EVENTS.
    PERFORM F_BLOC_DISPLAY.
    *&      Form  f_select_data
    FORM f_select_data .
    select matnr
           mbrsh
           matkl
         from mara into  table it_mara where matnr
    in so_matnr.
    if it_mara[] is not initial.
    select matnr
           maktx
           from makt
           into   table it_desc
           for all entries in it_mara
           where matnr eq it_mara-matnr.
    endif.
    if it_desc[] is not initial.
    select matnr
           werks
           lgort
           labst
           from mard
           into  table it_mard
           for all entries in it_desc
           where matnr eq it_desc-matnr.
    endif.
    ENDFORM.                    " f_select_data
    *&      Form  f_build_fcat
    FORM f_build_fcat .
    ADD_CATALOGUE2:
    '1' 'MATNR' 'IT_MARA' 'C500' 'MARA',
    '2' 'MBRSH' 'IT_MARA' 'C600' 'MARA',
    '3' 'MATKL' 'IT_MARA' 'C300' 'MARA'.
    ENDFORM.                    " f_build_fcat
    **&      Form  f_build_fcat1
    FORM f_build_fcat1 .
    ADD_CATALOGUE1:
    '1' 'MATNR' 'IT_DESC' 'C500' 'MAKT',
    '2' 'MAKTX' 'IT_DESC' 'C600' 'MAKT'.
    ENDFORM.                    " f_build_fcat1
    *&      Form  f_build_fcat2
    FORM f_build_fcat2.
    ADD_CATALOGUE3:
    '1' 'MATNR' 'IT_MARD' 'C500' 'MARD',
    '2' 'WERKS' 'IT_MARD' 'C600' 'MARD',
    '3' 'LGORT' 'IT_MARD' 'C200' 'MARD',
    '4' 'LABST' 'IT_MARD' 'C300' 'MARD'.
    ENDFORM.                    " f_build_fcat2
    *&      Form  F_BLOC_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM F_BLOC_DISPLAY .
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        I_CALLBACK_PROGRAM             = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = wa_layout
        IT_FIELDCAT                      = it_fcat
        I_TABNAME                        = 'IT_MARA'
        IT_EVENTS                        = it_event
      IT_SORT                          =
      I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = IT_MARA
    EXCEPTIONS
      PROGRAM_ERROR                    = 1
      MAXIMUM_OF_APPENDS_REACHED       = 2
      OTHERS                           = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = wa_layout
        IT_FIELDCAT                      = it_fcat1
        I_TABNAME                        = 'IT_DESC'
        IT_EVENTS                        = IT_EVENT
      IT_SORT                          =
      I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = IT_DESC
    EXCEPTIONS
      PROGRAM_ERROR                    = 1
      MAXIMUM_OF_APPENDS_REACHED       = 2
      OTHERS                           = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = wa_LAYOUT
        IT_FIELDCAT                      = IT_FCAT2
        I_TABNAME                        = 'IT_MARD'
        IT_EVENTS                        = IT_EVENT
      IT_SORT                          =
      I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = IT_MARD
    EXCEPTIONS
      PROGRAM_ERROR                    = 1
      MAXIMUM_OF_APPENDS_REACHED       = 2
      OTHERS                           = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " F_BLOC_DISPLAY
    *&      Form  F_BUILD_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM F_BUILD_LAYOUT .
    wa_layout-edit = 'X'.
    wa_layout-window_titlebar = 'MOHAMMED ABDUL HAI'.
    wa_layout-zebra = 'X'.
    ENDFORM.                    " F_BUILD_LAYOUT
    *&      Form  F_BUILD_EVENTS
          text
    -->  p1        text
    <--  p2        text
    FORM F_BUILD_EVENTS .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = IT_EVENT
    EXCEPTIONS
       LIST_TYPE_WRONG       = 1
       OTHERS                = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SORT IT_EVENT BY NAME.
    READ TABLE it_event INTO wa_event WITH KEY NAME = 'TOP_OF_PAGE' bINARY
    SEArch.
    if sy-subrc eq 0.
    wa_event-form = 'F_TOP_OF_PAGE'.
    ENDIF.
    MODIFY IT_EVENT FROM WA_EVENT INDEX SY-TABIX TRANSPORTING FORM.
    READ TABLE IT_EVENT INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND' BINARY SEARCH.
    WA_EVENT-FORM = 'F_USER_COMMAND'.
    MODIFY IT_EVENT FROM wa_event INDEX SY-TABIX TRANSPORTING FORM.
    ENDFORM.                    " F_BUILD_EVENTS

    Hi,
    When does this runtime error occur? When displaying output (calling FM) or.....
    I copied your coding and made a few minor changes and It's working fine for my now:
    REPORT ZHAI_ALV_BLOCK_LIST.
    TYPE-POOLS:slis.
    TABLES:mara.
    DATA:BEGIN OF it_mara OCCURS 0,
    matnr LIKE mara-matnr,
    mbrsh LIKE mara-mbrsh,
    matkl LIKE mara-matkl,
    END OF it_mara.
    DATA: BEGIN OF it_desc OCCURS 0,
    matnr LIKE makt-matnr,
    maktx LIKE makt-maktx,
    END OF it_desc.
    DATA: BEGIN OF it_mard OCCURS 0,
    matnr LIKE mard-matnr,
    werks LIKE mard-werks,
    lgort LIKE mard-lgort,
    labst LIKE mard-labst,
    END OF it_mard.
    DATA: it_fcat TYPE slis_t_fieldcat_alv ,
          wa_fcat LIKE LINE OF it_fcat,
          it_fcat1 TYPE slis_t_fieldcat_alv,
          wa_fcat1 LIKE LINE OF it_fcat1,
          it_fcat2 TYPE slis_t_fieldcat_alv,
          wa_fcat2 LIKE LINE OF it_fcat2,
          wa_layout TYPE slis_layout_alv,
          it_event TYPE slis_t_event,
          wa_event LIKE LINE OF it_event,
    *      wa_layout like line of it_layout,
    v_repid LIKE sy-repid.
    SELECT-OPTIONS:so_matnr FOR mara-matnr.
    START-OF-SELECTION.
      PERFORM f_select_data.
      DEFINE add_catalogue1.
        wa_fcat-col_pos = &1.
        wa_fcat-fieldname = &2.
        wa_fcat-tabname = &3.
        wa_fcat-emphasize = &4.
        wa_fcat-ref_tabname = &5.
        append wa_fcat to it_fcat.
      END-OF-DEFINITION.
      DEFINE add_catalogue2.
        wa_fcat1-col_pos = &1.
        wa_fcat1-fieldname = &2.
        wa_fcat1-tabname = &3.
        wa_fcat1-emphasize = &4.
        wa_fcat1-ref_tabname = &5.
        append wa_fcat1 to it_fcat1.
      END-OF-DEFINITION.
      DEFINE add_catalogue3.
        wa_fcat2-col_pos = &1.
        wa_fcat2-fieldname = &2.
        wa_fcat2-tabname = &3.
        wa_fcat2-emphasize = &4.
        wa_fcat2-ref_tabname = &5.
        append wa_fcat2 to it_fcat2.
      END-OF-DEFINITION.
      PERFORM f_build_fcat.
      PERFORM f_build_fcat1.
      PERFORM f_build_fcat2.
      PERFORM f_build_layout.
      PERFORM f_build_events.
      PERFORM f_bloc_display.
    *& Form f_select_data
    FORM f_select_data .
      SELECT matnr
      mbrsh
      matkl
      FROM mara INTO TABLE it_mara WHERE matnr
      IN so_matnr.
      IF it_mara[] IS NOT INITIAL.
        SELECT matnr
        maktx
        FROM makt
        INTO TABLE it_desc
        FOR ALL ENTRIES IN it_mara
        WHERE matnr EQ it_mara-matnr.
      ENDIF.
      IF it_desc[] IS NOT INITIAL.
        SELECT matnr
        werks
        lgort
        labst
        FROM mard
        INTO TABLE it_mard
        FOR ALL ENTRIES IN it_desc
        WHERE matnr EQ it_desc-matnr.
      ENDIF.
    ENDFORM. " f_select_data
    *& Form f_build_fcat
    FORM f_build_fcat .
      add_catalogue2:
      '1' 'MATNR' 'IT_MARA' 'C500' 'MARA',
      '2' 'MBRSH' 'IT_MARA' 'C600' 'MARA',
      '3' 'MATKL' 'IT_MARA' 'C300' 'MARA'.
    ENDFORM. " f_build_fcat
    **& Form f_build_fcat1
    FORM f_build_fcat1 .
      add_catalogue1:
      '1' 'MATNR' 'IT_DESC' 'C500' 'MAKT',
      '2' 'MAKTX' 'IT_DESC' 'C600' 'MAKT'.
    ENDFORM. " f_build_fcat1
    *& Form f_build_fcat2
    FORM f_build_fcat2.
      add_catalogue3:
      '1' 'MATNR' 'IT_MARD' 'C500' 'MARD',
      '2' 'WERKS' 'IT_MARD' 'C600' 'MARD',
      '3' 'LGORT' 'IT_MARD' 'C200' 'MARD',
      '4' 'LABST' 'IT_MARD' 'C300' 'MARD'.
    ENDFORM. " f_build_fcat2
    *& Form F_BLOC_DISPLAY
    * text
    FORM f_bloc_display .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
      is_layout = wa_layout
      it_fieldcat = it_fcat1
      i_tabname = 'IT_MARA'
      it_events = it_event
    *IT_SORT =
    *I_TEXT =
      TABLES
      t_outtab = it_mara
      EXCEPTIONS
      program_error = 1
      maximum_of_appends_reached = 2
      OTHERS = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
      is_layout = wa_layout
      it_fieldcat = it_fcat1
      i_tabname = 'IT_DESC'
      it_events = it_event
    *IT_SORT =
    *I_TEXT =
      TABLES
      t_outtab = it_desc
      EXCEPTIONS
      program_error = 1
      maximum_of_appends_reached = 2
      OTHERS = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
      is_layout = wa_layout
      it_fieldcat = it_fcat2
      i_tabname = 'IT_MARD'
      it_events = it_event
    *IT_SORT =
    *I_TEXT = ' '
      TABLES
      t_outtab = it_mard
      EXCEPTIONS
      program_error = 1
      maximum_of_appends_reached = 2
      OTHERS = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM. " F_BLOC_DISPLAY
    *& Form F_BUILD_LAYOUT
    FORM f_build_layout .
      wa_layout-edit = 'X'.
      wa_layout-window_titlebar = 'MOHAMMED ABDUL HAI'.
      wa_layout-zebra = 'X'.
    ENDFORM. " F_BUILD_LAYOUT
    *& Form F_BUILD_EVENTS
    FORM f_build_events .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      SORT it_event BY name.
    READ TABLE it_event INTO wa_event WITH KEY name = 'TOP_OF_PAGE' BINARY
    SEARCH.
      IF sy-subrc EQ 0.
        wa_event-form = 'F_TOP_OF_PAGE'.
      ENDIF.
      MODIFY it_event FROM wa_event INDEX sy-tabix TRANSPORTING form.
    READ TABLE it_event INTO wa_event WITH KEY name = 'USER_COMMAND' BINARY
    SEARCH.
      wa_event-form = 'F_USER_COMMAND'.
      MODIFY it_event FROM wa_event INDEX sy-tabix TRANSPORTING form.
    ENDFORM. " F_BUILD_EVENTS

Maybe you are looking for