INTERNAL TABLE FILL

hi,
i am posting the select part of my code and would like to ask someone to look trough it and to check why my internal table isn't filling up???
thanx so much in advance!!!
code:
  SELECT vbeln fkart fktyp vbtyp waerk vkorg vtweg knumv
         fkdat gjahr poper zterm netwr kunrg mwsbk
         zuonr kunag
  INTO CORRESPONDING FIELDS OF TABLE it_hd
  FROM vbrk
  WHERE vbeln IN so_vbeln AND
        erdat IN so_erdat.
  IF vbrk-vbtyp = 'H' OR
    vbrk-vbtyp = 'K' OR
    vbrk-vbtyp = 'N' OR
    vbrk-vbtyp = 'O' OR
    vbrk-vbtyp = 'T' OR
    vbrk-vbtyp = '6'.
    wa_hd-bsart = 'CRME'.
  ELSE.
    wa_hd-bsart = 'INVO'.
    IF sy-subrc <> 0.
      WRITE: / 'Wrong IF statement'.
    ENDIF.
  ENDIF.
Maja

here it is:
DATA: BEGIN OF wa_hd,
        vbeln TYPE vbrk-vbeln,
        gjahr TYPE vbrk-gjahr,
        poper TYPE vbrk-poper,
        fkart TYPE vbrk-fkart,
        fktyp TYPE vbrk-fktyp,
        vbtyp TYPE vbrk-vbtyp,
        kunrg TYPE vbrk-kunrg,
        fkdat TYPE vbrk-fkdat,
        zterm TYPE vbrk-zterm,
        invdue_date TYPE sy-datum,
        vkorg TYPE vbrk-vkorg,
        vtweg TYPE vbrk-vtweg,
        waerk TYPE vbrk-waerk,
        netwr TYPE vbrk-netwr,
        mwsbk TYPE vbrk-mwsbk,
        knumv TYPE vbrk-knumv,
        zuonr TYPE ordnr_v,                          
        kunag TYPE kunag,                            
        bsart TYPE bsart      ,                      
      END OF wa_hd,
       it_hd LIKE TABLE OF wa_hd.

Similar Messages

  • Dynamic Internal Table Filling

    Hi Friends,
    this is a test code.
    DO 4 TIMES.
      index = sy-index.
      MOVE sy-index TO wa_colno.
      CONCATENATE 'COL' wa_colno INTO wa_fldname.
      CONCATENATE 'VALUE' index INTO fieldvalue.
      CONDENSE fieldvalue NO-GAPS.
      CLEAR <fs_dyntable>.
      ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
      <fs_fldval> = fieldvalue.
      APPEND <fs_dyntable> TO <t_dyntable>.
    ENDDO.
    *the output of this code is like this *
    col1--col2--col3----col4
    -value1
    value2
    value3
    value4     
    I like to have the output like
    col1--col2--col3----col4
    value1  value2  value3   value4
    could u please help me with the modified code.
    thanks ,
    Kat.
    Edited by: kat k on Feb 5, 2009 3:52 PM
    Edited by: kat k on Feb 5, 2009 3:53 PM
    Edited by: Matt on Feb 5, 2009 4:01 PM - added  tags

    Hi,
    Do like following my solve out your problem,
    DO 4 TIMES.
    index = sy-index.
    MOVE sy-index TO wa_colno.
    CONCATENATE 'COL' wa_colno INTO wa_fldname.
    CONCATENATE 'VALUE' index INTO fieldvalue.
    CONDENSE fieldvalue NO-GAPS.
    "CLEAR <fs_dyntable>.  as MATT says no need of this line
    ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    ENDDO.
    APPEND <fs_dyntable> TO <t_dyntable>.
    try to following too,
    DO 4 TIMES.
    index = sy-index.
    MOVE sy-index TO wa_colno.
    CONCATENATE 'COL' wa_colno INTO wa_fldname.
    CONCATENATE 'VALUE' index INTO fieldvalue.
    CONDENSE fieldvalue NO-GAPS.
    CLEAR <fs_dyntable>.
    ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    INSERT <fs_dyntable> TO <t_dyntable> index 1. " i change here
    ENDDO.
    Kind Regards,
    Faisal
    Edited by: Faisal Altaf on Feb 5, 2009 8:02 PM
    Edited by: Faisal Altaf on Feb 5, 2009 8:22 PM

  • Method to fill teh internal table .

    Hi Experts ,
                    How can i develop method of class for following purpose .
    method importing  parameter as name of the  table ( dynamic :-  caller can provide name of any table )
    and exporting  parameter as the internal table fill with the data from table whos name was entered by the user .
    Thanks ,
    Rushikesh

    Like this
    CLASS lcl_filler DEFINITION.
      PUBLIC SECTION.
        METHODS: get_table IMPORTING tab_name TYPE string
                           RETURNING value(r_table) TYPE REF TO data.  "we return reference to table
    ENDCLASS.                    "lcl_filler DEFINITION
    CLASS lcl_filler IMPLEMENTATION.
      METHOD get_table.
        FIELD-SYMBOLS <tab> TYPE STANDARD TABLE.
        CREATE DATA r_table TYPE TABLE OF (tab_name).
        ASSIGN r_table->* TO <tab>.
        SELECT * FROM (tab_name) INTO TABLE <tab> UP TO 10 ROWS.
      ENDMETHOD.                    "get_table
    ENDCLASS.                    "lcl_filler IMPLEMENTATION
    START-OF-SELECTION.
      DATA: r_filler TYPE REF TO lcl_filler,
            r_table TYPE REF TO data.
      FIELD-SYMBOLS <tab> TYPE STANDARD TABLE.
      CREATE OBJECT r_filler.
      r_table = r_filler->get_table( 'SFLIGHT' ).
      ASSIGN r_table->* TO <tab>.  "here content of first table
      r_table = r_filler->get_table( 'SPFLI' ).
      ASSIGN r_table->* TO <tab>. "here content of another one
    Regards
    Marcin

  • Fill data in table( on view ) dynamically from internal table

    Hi,
    How can I populate a table on view with data from an internal table?
    Thanks,
    Ronita

    Hi,
    if you have an internal table named xyz.
    Then create a structure in se11 for this internal table.
    Then create a node with this structure with cardinality 0:n
    Navigate into method WDDOMODIFYVIEW of view MAIN_VIEW. Insert coding for:
    -     Create a new context node for the table
    Hint: Use method Create_nodeinfo_from_struct of class Cl_wd_dynamic_tool.
    -     Remove “old” dynamic table IE element from view , if one exists. If it exists, it is a child of group GROUP_1 and has the name TESTTAB.
    -     Create a new UI element for a table named TESTTAB
    -     Create an internal table, fill it with the data from the database table and bind it to the newly created dynamic context node.
    METHOD wddomodifyview .
      DATA:
      UI Elements
        group_1       TYPE REF TO cl_wd_uielement_container,
        new_tab       TYPE REF TO cl_wd_table,
      Context Nodes
        dyn_node      TYPE REF TO if_wd_context_node,
        tabname_node  TYPE REF TO if_wd_context_node,
      Node Info
        rootnode_info TYPE REF TO if_wd_context_node_info,
      Data Reference (for internal table)
        stru_tab      TYPE REF TO data,
      String (for table name)
        tablename     TYPE string.
      FIELD-SYMBOLS:
        <tab> TYPE table.
    create context node ***************************************************************
    get node info of context root node
      rootnode_info = wd_context->get_node_info( ).
    Get the name of the table to be created
      tabname_node = wd_context->get_child_node( name = 'TABLE_DATA' ).
      tabname_node->get_attribute( EXPORTING name = 'NAME' IMPORTING value = tablename ).
      translate tablename to upper case.
    create sub node named TEST1 of structure (tablename)
      cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
        parent_info = rootnode_info
        node_name = tablename
        structure_name = tablename
        is_multiple = abap_true ).
    get instance of new node
      dyn_node = wd_context->get_child_node( name = tablename ).
    remove "old" table UI element from view , if necessary ****************************
      group_1 ?= view->get_element( 'GROUP_1' ).
      group_1->remove_child( id = 'TESTTAB' ).
    create new UI element table *******************************************************
      new_tab = cl_wd_dynamic_tool=>create_table_from_node(
    ui_parent = group_1
    table_id  = 'TESTTAB'
    node      = dyn_node ).
    fill context node with data *******************************************************
    create internal table of (tabletype)
      CREATE DATA stru_tab TYPE TABLE OF (tablename).
      ASSIGN stru_tab->* TO <tab>.
    Get table content
      SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.
    Bind internal table to context node.
      dyn_node->bind_table( <tab> ).
    ENDMETHOD.
    Edited by: Sridevi D on Apr 19, 2008 10:30 AM

  • Class reference internal table

    Hello Gurus,
    i have an internal table filled with class references and i need to acces the one field of a structure of every class.
    I am now trying something like this:
    loop ref_table assigning <l_wrk_ref_but0id>.
          IF <l_wrk_ref_but0id>->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv.
          ENDIF.
    endloop.
    I need the field "type" in the structure "m_str_but0id" of every class (reference) in the table. The error that i'm getting is: "Field m_str_but0id unknown".
    Please help.
    Ioan Constantin.

    Hello Ioan
    You have to access the field dynamically as well:
    DATA:
       ld_structure  TYPE <name of structure>,
       ld_attribute    TYPE tabname,
       ld_field          TYPE fieldname.
    FIELD-SYMBOLS:
      <ls_struct>     TYPE any,
      <ld_fld>           TYPE any.
    ld_attribute = 'M_STR_BUT0ID'.
    ld_field       = 'TYPE'. 
    loop ref_table assigning <l_wrk_ref_but0id>.
         ASSIGN <l_wrk_ref>but0id>->(ld_attribute) TO <ls_struct>.
         ASSIGN COMPONENT (ld_field) OF STRUCTURE <ls_struct> TO <ld_fld>.
    "      IF <l_wrk_ref_but0id>->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv.
           IF ( <ld_fld> = /gkv/cd40_cl_const=>con_pkkv ).
          ENDIF.
    endloop.
    Even simpler might be the following approach:
    LOOP AT ref_table assigning <l_wrk_ref_but0id>
                    WHERE ( table_line->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv ).
    ENDLOOP.
    " Assumption: Itab has class reference type as line type.
    Regards
      Uwe

  • Looping internal tables

    Hi all,
    I have an internal table filled with data. I need to take up a single record at a time and compare with all the other records of the internal table. This I need to do for all the records of the internal table.
    Please tell me the best way of doing this.
    Thx..
    Paul

    HI,
    use
    LOOP AT itab1.
    READ table itab2 with key field1 = itab1-field1
                               field2 = itab1-field2.
    ENDLOOP.
    <b>OR</b>
    LOOP AT itab1.
    LOOP AT itab2.
         if itab1-field1 = itab2-field1 AND
            itab1-field2 = itab2-field2.
         endif.
    ENDLOOP.
    ENDLOOP.
    Regards,
    HRA

  • How to fill internal table with no data in debugging mode

    Hi all,
             I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
    Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
    Thanks,
    Balaji

    Hi,
    In the debugging do the following..
    Click the Table button..
    Double click on the internal table name..
    Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
    Use the APPEND button to insert records to the internal table..
    Thanks,
    Naren

  • Internal table -Select statement -2nd plant is not being filled

    Hi,
    Second field for plant WERKD is not getting filled in this table.I am using into corresponding fields of table ITAB statement.
    I need both plants and in single select statement.
    Any ideas?
    DATA: BEGIN OF T_STOF OCCURS 0,
        VBELN LIKE LIPS-VBELN,
        ERNAM LIKE LIPS-ERNAM,
        WERKS LIKE LIPS-WERKS,
        NTGEW LIKE LIPS-NTGEW,
        GEWEI LIKE LIPS-GEWEI,
        EBELN LIKE EKKO-EBELN,
        WERKD LIKE EKPO-WERKS,
        LGORT LIKE EKPO-LGORT,
        EBELP LIKE EKPO-EBELP,
        MATNR LIKE EKPO-MATNR,
        TXZ01 LIKE EKPO-TXZ01,
        AEDAT LIKE EKPO-AEDAT,
        KNUMV LIKE EKKO-KNUMV,
        END OF T_STOF.
      SELECT  LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
      EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
      INTO CORRESPONDING FIELDS OF TABLE T_STOF
      FROM LIKP
      INNER JOIN LIPS
      ON LIKPVBELN EQ LIPSVBELN
      INNER JOIN EKKO
      ON LIPSVGBEL EQ EKKOEBELN
      INNER JOIN EKPO
      ON EKKOEBELN EQ EKPOEBELN
      WHERE LIKP~VBELN IN S_VBELN
      AND LIKP~ERNAM IN S_ERNAM
      AND LIPS~WERKS IN S_WERKS
      AND EKKO~EBELN IN S_EBELN
      AND EKPO~WERKS IN S_WERKD
      AND EKPO~LGORT IN S_LGORT
      AND EKPO~MATNR IN S_MATNR
      AND EKPO~AEDAT IN S_AEDAT
      AND BSART = 'UB'.
    Or am i doing in wrong?
    Regards
    Praveen

    Hi,
    If you use INTO CORRESPONDING then the fieldname in the internal table has to match the selecting field name..
    To avoid this you can use INTO TABLE...
    SELECT LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
    EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
    <b>INTO TABLE T_STOF</b>
    Thanks,
    Naren

  • Problem in filling the final internal table

    Hi,
    I am working on a code in which i have to fill up the final internal table which will store the values coming form different internal tables.Here's the code which i am trying to do but it is not giving the execat functionality.In this code ITOUTPUT is the final itab which is storing the values of all other internal tables.
    Here's the code:-
    loop at itab1.
      select single maktx into v_item from makt where matnr = itab1-matnr.
          ITOUTPUT-banfn = ITab1-banfn.
          ITOUTPUT-badat = ITab1-badat.
          ITOUTPUT-meins = ITab1-meins.
          ITOUTPUT-menge = ITab1-menge.
          ITOUTPUT-lfdat = ITab1-lfdat.
      IF ITAB1-MEINS = 'KG'.
        V_TOTREQ = V_TOTREQ + ITAB1-MENGE.
      ELSEIF ITAB1-MEINS = 'TO'.
        V_TOTREQ = V_TOTREQ + ( ITAB1-MENGE * 1000 ).
      ELSEIF ITAB1-MEINS = 'G'.
        V_TOTREQ = V_TOTREQ + ( ITAB1-MENGE / 1000 ).
      ENDIF.
      v_tpo = 0.
      v_por = 0.
      LOOP AT ITPO WHERE BANFN = ITAB1-BANFN AND bnfpo = ITAB1-bnfpo.
        if v_por <> '0'.
          write : / '  '.
        endif.
          ITOUTPUT-ebeln = ITPO-ebeln.
          ITOUTPUT-aedat = ITPO-aedat.
          ITOUTPUT-lifnr = ITPO-lifnr.
          ITOUTPUT-menge = ITPO-menge.
          ITOUTPUT-EINDT = ITPO-EINDT.
        IF ITAB1-MEINS = 'KG'.
          V_TOTPO = V_TOTPO + ITPO-MENGE.
        ELSEIF ITPO-MEINS = 'TO'.
          V_TOTPO = V_TOTPO + ( ITPO-MENGE * 1000 ).
        ELSEIF ITPO-MEINS = 'G'.
          V_TOTPO = V_TOTPO + ( ITPO-MENGE / 1000 ).
        ENDIF.
        v_tpo = v_tpo + itpo-menge.
        v_tgr = 0.
        v_por = 1.
        v_grr = 0.
        loop at itmrn where ebeln = itpo-ebeln and ebelp = itpo-ebelp.
          if v_grr <> '0'.
            write : / '  '.
          endif.
          select single budat from mkpf into v_grdate where MBLNR = itmrn-MBLNR.
          write: 143 Itmrn-menge,v_grdate .
            itoutput-PMENGE = itmrn-menge.
          v_tgr = v_tgr + itmrn-menge.
          v_grr = 1.
        endloop.
        p_po = itpo-menge - v_tgr.
       write: 173 p_po.
      ENDLOOP.
      p_req = itab1-menge - v_tpo.
      write :  195 p_req.
    endloop.
    loop at itoutput.
      write:/ itoutput-banfn,12 itoutput-badat,24 v_item,50 itoutput-meins,53 itoutput-menge,itoutput-lfdat,
              89 ITPO-ebeln,100 ITPO-aedat,111 ITPO-lifnr,(10) itpo-menge, ITPO-eindt.
      MODIFY itoutput.
    endloop.

    Hi,
    Ok,i ha d checked my code by using your logic and giving the run time error ......
    i had debugged my code (orignal onementioned in above thread with little modification) in which  i am able to see that finaloutput (intrenal table) is getting filled properly and the  problem arises when  the cursor comes to the write statement ... it is repeating some of the values when output is displayed where as before displaying output this iternal table is having the correct data. i am using the following code :-
    append itoutput.
      ENDLOOP.
      p_req = itab1-menge - v_tpo.
      write :  195 p_req.
      append itoutput.          ,<---  added this
      clear itoutput.               <--- added this
    endloop.
    loop at itoutput.
      write:/ itoutput-banfn,12 itoutput-badat,24 v_item,50 itoutput-meins,53 itoutput-menge,itoutput-lfdat,
              89 ITPO-ebeln,100 ITPO-aedat,111 ITPO-lifnr,(10) itpo-menge, ITPO-eindt.
      MODIFY itoutput.         <------ not removed
    endloop.

  • Fill database table from internal table

    I made one table ZDISP_CHDOC_CC and want to fill that table from internal table.and i got runtime error. that duplicate entry
    and two entry are like 10 200000    likhp 10
                                        10 200000    likp   10
    DESCRIBE TABLE IT_CHDOC .
        LOOP AT IT_CHDOC.
        INSERT ZDISP_CHDOC_CC FROM  IT_CHDOC.
        endloop.
        IF SY-SUBRC = 0.
          COMMIT WORK.
        ELSE.
    and when i used following then only one entry is insreted.
    DESCRIBE TABLE IT_CHDOC .
        LOOP AT IT_CHDOC.
        INSERT ZDISP_CHDOC_CC FROM  IT_CHDOC.
        IF SY-SUBRC = 0.
          COMMIT WORK.
    endloop.
        ELSE.

    Hi,
    Replace your current code
    DESCRIBE TABLE IT_CHDOC .
    LOOP AT IT_CHDOC.
    INSERT ZDISP_CHDOC_CC FROM IT_CHDOC.
    endloop.
    IF SY-SUBRC = 0.
    COMMIT WORK.
    ELSE.
    WITH THE ONE GIVEN BELOW
    DESCRIBE TABLE IT_CHDOC .
    INSERT ZDISP_CHDOC_CC FROM TABLE IT_CHDOC ACCEPTING DUPLICATE KEYS.
    IF SY-SUBRC = 0.
    COMMIT WORK.
    ELSE.
    Regards,
    Siddarth

  • How to fill LRAW data type from an internal table?

    Hi experts,
    I have a data type LRAW.
    ZCLUSTR type INT2.
    ZLOG type LRAW.
    It is said that: LRAW: Uninterpreted byte string of any length, but has to be declared with a minimum length of 256. Fields of this type must be located at the end of transparent tables (in each table there can be only one such field) and must be preceded by a length field of type INT2. If there is an INSERT or UPDATE in ABAP programs, this length field must be filled with the length actually required. If the length field is not filled correctly, this may lead to a data loss in the LRAW field! A fields of this type cannot be used in the WHERE condition of a SELECT statement.
    So my question is how can I store data in ZLOG? I want to store the content of an internal table into ZLOG, but I don't know how to use INSERT statement correctly. What should I do with ZCLUSTR?

    Hi Chaitanya,
    Refer IMPORT EXPORT statement with addition TO DATABASE in abap help.
    Refer below link from SAP help where it is described in detail.
    http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3bf8358411d1829f0000e829fbfe/content.htm
    Regards,
    Vishal

  • Filling dynamic internal table with data from other internal table

    Hi Friends,
    My problem is that i have already built a dynamic internal table
    (class int_table->create) but now i want to fill it with data from other internal table.
    The dynamic table column name and the field value of the data filled internal table are same, but how to access that column name, since i cant hard code it anyway.
    Like if my werks field value is '8001'. I want to place it under the column 8001 of dynamic table, Can anybody help me in this regard?
    Awarding points is not a problem for even giving a slight hint.
    Best Regards

    Hi
    See this
    Dynamic internal table is internal table that we create on the fly with flexible column numbers.
    For sample code, please look at this code tutorial. Hopefully it can help you
    Check this link:
    http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
    Sample code:
    DATA: l_cnt(2) TYPE n,
    l_cnt1(3) TYPE n,
    l_nam(12),
    l_con(18) TYPE c,
    l_con1(18) TYPE c,
    lf_mat TYPE matnr.
    SORT it_bom_expl BY bom_comp bom_mat level.
    CLEAR: l_cnt1, <fs_dyn_wa>.
    Looping the component internal table
    LOOP AT it_bom_expl INTO gf_it_bom_expl.
    CLEAR: l_cnt1.
    AT NEW bom_comp.
    CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
    it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
    <fs_check>.
    <fs_check> = gf_it_bom_expl-bom_comp.
    ENDAT.
    AT NEW bom_mat.
    CLEAR l_con.
    ENDAT.
    lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
    LOOP AT it_mat_temp.
    l_nam = c_mat.
    l_cnt1 = l_cnt1 + 1.
    CONCATENATE l_nam l_cnt1 INTO l_nam.
    LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
    ENDLOOP.
    IF <fs_xy> = lf_mat.
    CLEAR lf_mat.
    l_con1 = l_con.
    ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
    IF <fs_xy> = gf_it_bom_expl-bom_mat.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    CLEAR l_con.
    MOVE gf_it_bom_expl-level TO l_con.
    CONCATENATE c_val_l l_con INTO l_con.
    CONDENSE l_con NO-GAPS.
    IF l_con1 NE space.
    CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
    CLEAR l_con1.
    l_cnt = l_cnt - 1.
    ENDIF.
    <fs_check> = l_con.
    l_cnt = l_cnt + 1.
    ENDIF.
    ENDLOOP.
    AT END OF bom_comp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    <fs_check> = l_cnt.
    INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
    ENDAT.
    ENDLOOP.
    Reward if useful
    Anji

  • Fill internal table with mutliple entries for nested structure

    Dear ABAP Experts,
    I have a question related to fill internal tables with nested structures.
    I have a structure like this:
    BEGIN OF proto,
              sicht TYPE ysicht,
              version TYPE FAGLFLEXA-RVERS,
              BEGIN OF kons,
    kon TYPE YKONSEINHEIT,
              END OF kons,
              jahr TYPE CHAR04,
    END OF proto.
    Now I need to fill this structure with values (over an internal table), but how can I achieve that I save multiple datas für element "kon" für one single entry of structure "proto"?
    An example could be:
    sicht = '01'
    version = '100'
    kon = 1001 (first entry)
    kon = 1002 (second entry)
    usw... (n entry)
    jahr = '2008'
    Thanks in advance for every helpful answer.
    Regards
    Thomas

    BEGIN OF proto,
               sicht TYPE ysicht,
               version TYPE FAGLFLEXA-RVERS,
               kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
               jahr TYPE CHAR04,
    END OF proto.
    DATA: ls_proto TYPE proto,
          lt_proto TYPE STANDARD TABLE OF proto,
          ls_kon
    ls_proto-sicht = '01'.
    ls_proto-version = '100'
    INSERT '1001' INTO TABLE ls_proto-kons.
    INSERT '1002' INTO TABLE ls_proto-kons.
    ls_proto-jahr = '2008'.
    INSERT ls_proto INTO TABLE lt_proto
    If you're going to use a more complicated inner table with several components, then you need to define a type for those components. 
    matt

  • How many times will internal table get filled?

    Dear BW / ABAP gurus:
    I am observing a routine in a transformation in 7.0 data flow.
    The internal table is created as follows in the global declaration in the Start Routine:
    TYPES:  BEGIN OF ST_PROD,
              /BIC/AZPROD TYPE /BIC/OIAZPROD,
              /BIC/AZCOST TYPE /BIC/OIAZCOST,
            END OF ST_PROD.
    DATA: IT_PROD TYPE TABLE OF ST_PROD,
          WA_PROD TYPE ST_PROD.
    The programmer is fetching data for product cost which is not available in the source. This code is written in the Start Routine:
    SELECT /BIC/AZPROD /BIC/AZCOST
      FROM /BIC/PAZPROD
      INTO CORRESPONDING FIELDS OF TABLE IT_PROD
      WHERE OBJVERS = 'A'.
    My questions:
    (1) Is it a standard practice to create the internal table in the global declaration?
    (2) Is it a standard practice to fill the internal table with data in the Start Routine? Is it possible to fill the internal table with data in the global declaration? Or is the global declaration only reserved for declaring variables and creating internal tables?
    (3) What is the use of 2nd part global?
    (4) Let's say there are 100, 000 records at the source and the DTP package size is 50,000. Then the Start Routine will get executed 2 times. So the code in the Start Routine will hit the database 2 times to fill the internal table. Is this correct?
    Note to mods: Please do not delete the thread. Move to the beginner section if you think this is basic. But please do not delete. It take a long time to type out the questions.

    hi Saurav,
    (1) Is it a standard practice to create the internal table in the global declaration?
    1. No ,internal table should be created in global part only if they are getting used in field level or end routine .Else they must be in local part and should get refreshed at the end  so that performance not get affected.
    (2) Is it a standard practice to fill the internal table with data in the Start Routine? Is it possible to fill the internal table with data in the global declaration? Or is the global declaration only reserved for declaring variables and creating internal tables?
    1.No if only you want to use the data in field level routine and start routine ,you will fill table in start routine otherwise no .
    2.first global part is for data declaration so no in first global part select cannot come .
    3.Second global part can have select but you cannot write any statement using source package or result package here as they are private object of transformation class and not recognized at this area.However simple select on any table other than these will be fine .
    (3) What is the use of 2nd part global?
    1.In second global part you can declare internal table ,structures that are not of type source package or result package but independent and can use them .
    2.If you will declare these table in first global part they will be private object and you cannot write select using them in second global part .
    3.Second global part is also declaration but outside the class so these objects are global across transformation with more flexibility .
    4.If you will declare any data here using the structure of source /result package you will get error .This is a data declaration part comes between transformation definition and implementation part .
    (4) Let's say there are 100, 000 records at the source and the DTP package size is 50,000. Then the Start Routine will get executed 2 times. So the code in the Start Routine will hit the database 2 times to fill the internal table. Is this correct?
    yes the source and result package are actually the DTP packages only so code will get executed same no of time as you have number of packages in DTP extraction .
    Hope this will be helpful .
    Regards,
    Jaya Tiwari

  • Filling Data in Dynamic internal table

    Hello,
    I have 2 internal tables TAB1 and TAB2.
    I have Created Dynamic internal table From TAB1 rows.
    Now I want to fill that Dynm. internal table from TAB2.
    But TAB2  have more Rows with diffarant  names.  I want to move particular field of TAB2 to particular field.of dynamic IT.
    kindly help.

    Hi,
    I am sending the dynamic alv report for your referenece.
    REPORT  YMS_DYNAMICALV.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>.
    data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat.
    selection-screen begin of block b1 with frame title text-001.
    parameters: p_flds(5) type c.
    selection-screen end of block b1.
    start-of-selection.
    build the dynamic internal table
      perform build_dyn_itab.
    write 5 records to the alv grid
      do 5 times.
        perform build_report.
      enddo.
    call the alv grid.
      perform call_alv.
    Build_dyn_itab
    form build_dyn_itab.
      data: new_table type ref to data,
            new_line  type ref to data,
            wa_it_fldcat type lvc_s_fcat.
    Create fields .
      do p_flds times.
        clear wa_it_fldcat.
        wa_it_fldcat-fieldname = sy-index.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-intlen = 5.
        append wa_it_fldcat to it_fldcat .
      enddo.
    Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
    endform.
         Form  build_report
    form build_report.
      data: fieldname(20) type c.
      data: fieldvalue(5) type c.
      data: index(3) type c.
      field-symbols: <fs1>.
      do p_flds times.
        index = sy-index.
    Set up fieldvalue
        concatenate 'FLD' index into
                 fieldvalue.
        condense   fieldvalue no-gaps.
      <b> assign component  index  of structure <dyn_wa> to <fs1>.
       <fs1> =  fieldvalue.</b>
      enddo.
    Append to the dynamic internal table
      append <dyn_wa> to <dyn_table>.
    endform.
    CALL_ALV
    form call_alv.
      data: wa_cat like line of alv_fldcat.
      do p_flds times.
        clear wa_cat.
        wa_cat-fieldname = sy-index.
        wa_cat-seltext_s = sy-index.
        wa_cat-outputlen = '5'.
        append wa_cat to alv_fldcat.
      enddo.
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat = alv_fldcat
           tables
                t_outtab    = <dyn_table>.
    endform.
    Thanks,
    Shankar

Maybe you are looking for