Read first row of the internal table

Dear All,
Please let me know how to read the first row of the internal table?
I used following read statement but it is not working
READ TABLE t_cdhdr INDEX 1.

Hi,
i think you are not reading an internal table
according to your code i think you are reading a type
which may be declared as types...
types are declared just for reference
eg
types: begin of t_cdhdr .
include strucuture  cdhdr .
types: end of t_cdhdr .
types: t_it_cdhdr type standard table of t_cdhdr.
data: git_t_cdhdr  type t_it_cdhdr.
data: gwa_t_cdhdr type t_cdhdr.
now have to fill the iternal table
and
read table git_t_cdhdr into gwa_t_cdhdr index 1.
reward points if helpful
thanks & regards,
venkatesh

Similar Messages

  • Getting the index to the first row of an Internal table

    Hi,
            Assume that i have inserted five rows(fiiling contents for some fields) in an ITAB using Append statement.. Now if i want to fill the content for the remaining field from the first row , then how will i get it back to first row, If i still use Append it starts inserting from the 6th row, Instead of 6th row i want it from first row... Plss Help!!!!!!
    Thanks In Advance,
    Sanu

    lets say itab contains fields as f1,f2,f3,f4.
    one method is :
    LOOP AT itab into is.
      if sy-tabix = 1.
        is-f2 = 'asdasd'.
        is-f3 = 'gggg'.
        is-f4 = 'kjhjk'.
        modify itab from is.
        exit. " to come out of loop.
      endif.   
    ENDLOOP.
    another method is:
    clear is.
    read table itab into is INDEX 1.
    IF sy-subrc = 0.
      is-f2 = 'asdasd'.
        is-f3 = 'gggg'.
        is-f4 = 'kjhjk'.
      MODIFY itab from is INDEX 1. 
    ENDIF.

  • ExportCollectionAction causes current rows values to be copied in the first row of the table

    Greetings experts,
    I use JDev 11.1.2.3
    I'm facing a really strange behavior of the exportCollectionActionListener. I have a table, and for each row of this table, a link, which calls a popUp. This popUp shows the history of this selected record changes (means it displays the data from another table/VO, which keeps the history of the first one) in a table. I have a button which calls the exportCollection for this second table. When i press it, an excel file is generated and downloaded, and that's all fine untill now. If there wasn't any record in this table, and o go back to the first one, pressing the submit button doesn't track any changes. But if there where any records in that history table (always talking about the history of the current row) , get back to the first one and press Submit, than the very first row of the firs table, gets all it's values set as the last row of the second table, as it is copied from one to the other. I have to press Rollback to get it back into normal ( note that the popUp has it's CancelListener invoke a Rollback operation from a backing bean).
    Why is this happening?
    Thanks in advance

    Hi Frank,
    Well, that's it. No code is involved in this process, that's why i'm asking here. The only code invoked in here is that of the CancelListener of the popUp, and i've inserted it because of this problem, but it didn't resolve anything.
    As per other code, i have another button which invokes code to generate and download a Jasper Report, in Pdf format. This has nothing to do with the exportCollection. Different buttons, different beans containing obviously different code. Further more, this behavior doesn't happen when i download the pdf (press the other button)
    As per the popUp, there is just a link in each row of the main table, which has a showPopUpBehavior, which calls this popUp, containing the second table.
    Note: if i download the pdf or do not do any operation with the popUp (i.e. just close it after it is opened) that behavior doesn't occur.
    This is the source of the popUp, i've just removed the columns as it would take too much space in here:
    <af:popup childCreation="deferred" id="p2"
                                              contentDelivery="lazyUncached"
                                              popupCanceledListener="#{popUp.adminPanelCancelListener}">
                                        <af:dialog id="d3" type="none">
                                            <f:facet name="buttonBar">
                                                <af:panelGroupLayout id="pgl7" halign="end" styleClass="AFStretchWidth"
                                                                     layout="horizontal">
                                                    <af:commandLink text="Download Excel" id="cl18">
                                                        <af:exportCollectionActionListener type="excelHTML" exportedId="t3"
                                                                                           filename="User history.xls"
                                                                                           title="User history"/>
                                                    </af:commandLink>
                                                    <af:commandLink text="Download Pdf" id="cl3">
                                                        <af:fileDownloadActionListener method="#{reportBean.downloadUserHistory}"/>
                                                    </af:commandLink>
                                                </af:panelGroupLayout>
                                            </f:facet>
                                            <af:table value="#{bindings.UsersHistory1.collectionModel}" var="row"
                                                      rows="#{bindings.UsersHistory1.rangeSize}"
                                                      emptyText="#{bindings.UsersHistory1.viewable ? 'No data to display.' : 'Access Denied.'}"
                                                      fetchSize="#{bindings.UsersHistory1.rangeSize}" rowBandingInterval="0"
                                                      selectedRowKeys="#{bindings.UsersHistory1.collectionModel.selectedRow}"
                                                      selectionListener="#{bindings.UsersHistory1.collectionModel.makeCurrent}"
                                                      rowSelection="single" id="t3" width="800px"
                                                      columnStretching="column:c10" styleClass="AFStretchWidth">
                                            </af:table>
                                        </af:dialog>
                                    </af:popup>

  • Insert a string at particular location in the internal table

    1. I have an internal table t_text of type bcsy_text , this internal table contains a few lines of HTML code
    2. I have a variable w_text of type string , this variable contains some text
    3. now the internal table t_text contains text:
    <!"<font size = "3.5" ><b>Comments:</b></font><br><br>***********<br><br><font size = "3.5" ><b>Thank You</b></font>">
    4. The text in the w_text comes from a text area on my module pool screen
    5. There is a push button SAVE on the same module pool screen
    6. now when I enter text in the text area and press the SAVE button then i want the text in the variable w_text to be inserted into the internal table at the location where i have marked *********** in my HTML code.
    How do i achieve this?
    <!-- **--> is not part of my HTML code.. i have written it because the HTML formatting appears on the screen if i dont comment it
    Edited by: DoshiAnkit on Sep 8, 2010 3:43 PM

    Ankit,
    You have to first determine which row of the internal table needs to be updated. Once you know which row, read that row into a variable using the READ statement and INDEX option.
    Once you have the row in a variable (WA_ROW) , you have to determine the position where you want to insert the w_text contents.
    Suppose that position is 123. Then, you can concatenate the first part of the row, w_text contents, and second part of the row into another variable (WA_NEW_ROW).
    CONCATENATE wa_row(123)
    w_text
    wa_row+123
    INTO wa_new_row
    SEPARATED BY SPACE.
    Finally, modify internal table contents with WA_NEW_ROW using the INDEX option.

  • How to process a block for each row in an internal table....

    Hi experts....
    In po approval workflow the scenario is like this.... for each po there may be more than one approver. approvers list i am maintaining in the ztable. list of approvers(no of approvers) is decided by the po value. I have collected these approvers into internal table. now i have to process a block ( approving or rejecting the po... )in the workflow for each row in the internal table.
    how can i do this. based on the decision of the 1st approver  approves the po then it should go to next approver in the internal table...otherwise end the workflow.....
    Please help me......

    i have created an internal table in the workflow container in which i am getting the list of approvers....
    how can i loop the internal table in the workflow...?
    how can i know the index of the loop in the workflow.....(will sy-index work here....? so that i can use loop until step in the main workflow to call the subworkflow..so that if sy-index is greater than no of entires in the itab then i can come out of the loop)

  • Merging of multiple rows in an internal table as a single record

    Hi All,
    I have an internal table which has the following columns:
    text, date, time, user.
    it stores notes in the internal table.
    The problem is...when I save a note with multiple lines and spaces it saves each line of the note as a row in the internal table.
    Thus i get more no. of rows in the internal table compare to the no. of rows!
    I need to store each notes as single row in the internal table.
    Please advise how to approach this?
    Helpful answers will be rewarded.
    Thanks & Regards,
    Anshumita.

    You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    you can check the example in the link
    regards,
    abhishek

  • Declaring the internal table in ABAP objects

    Hi every1,
    Please any one let me know how to declare an internal table in class (ABAP objects). Bcos i am new to this classes.
    help me out.
    Regards,
    Madhavi

    Hi,
    Check this example..
    TYPES: BEGIN OF TYPE_DATA,
                   MATNR TYPE MATNR,
                   WERKS TYPE WERKS_D,
                 END OF TYPE_DATA.
    DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.
    DATA: WA_DATA TYPE TYPE_DATA.
    Adding rows to the internal table.
    WA_DATA-MATNR = 'AA'.
    APPEND WA_DATA TO T_DATA.
    Processing the interna table
    LOOP AT T_DATA INTO WA_DATA.
    ENDLOOP.
    Thanks,
    Naren

  • Create an internal table with the rows of another internal table.

    Hi I want to know if posible to create an internal table structure with the  rows of another internal table?
    ex.
    If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
    Now I want that the structure of my internal table be: first, second, third

    Hi,
    If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
    Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
    Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
    Data: begin of second_table occurs 0,
    first type <first_table type>,
    second type <first_table type>,
    third type <first_table type>,
    end of second_table.
    Regards
    Prasenjit

  • Pie Chart Only Displays the Data of the First Row of the Table

    Hi Experts,
    I have a problem that the pie chart will not change when click on a second row or other rows on the table. It only displays the data of the first row of the table. How can I set up to make it reflect on any rows when I click the table? Please help, and I would very appreciate that.
    Thanks,
    -Don

    Thanks a lot for your response. I have realized that the pie chart behaves that way, so I just use the filter to see the specific data that I want. Also, you can drag the row and drop it right at the first row to see the data in the pie chart.

  • How can i read the field name in the internal table

    Hi friends
    i want to read the internal table filed name.
    my requirement is like this:
    data: begin of t_header occurs 0,
           extno(12),
           priotiy(5),
           ecnumber(10).
          end of t_header.
    loop at t_header.
    if the field name is priority i want to write some other
    logic here.....
    endloop.
    Please tell me how can i do this.

    data: wf_fld_cat type slis_t_fieldcat_alv .
    data: wf_repid like sy-repid .
    data: int_tab_name type slis_tabname .
    move: sy-repid to wf_repid  ,
            'INT_OUTPUT' to int_tab_name .
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       exporting
         i_program_name              = wf_repid
         i_internal_tabname          = int_tab_name
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
        i_inclname                   = wf_repid
        i_bypassing_buffer           = 'X'
      I_BUFFER_ACTIVE              =
        changing
          ct_fieldcat                  = wf_fld_cat[]
       exceptions
         inconsistent_interface       = 1
         program_error                = 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.
    wf_fld_cat[] will hold the itab definition.
    Regards
    Raja

  • Regarding the internal table data by using read table it_mard into wa_mard

    hi,
    i am reading the internal table it_mard with key matnr .
    my code is like this.
    *loop at it_final into wa_final.*
    *wa_second-matnr  = wa_final-matnr.*
      wa_second-bwart = wa_final-bwart.
    wa_second-bwtar = wa_final-bwtar.
    *read table it_mard into wa_mard with key matnr = wa_final-matnr*
                                                                              *binary search.*
    *if sy-subrc = 0.*
    *wa_second-labst = wa_mard-labst.*
    *endif.*
    *append wa_second to it_second.*
    clear :wa_final.
    *endloop.*
    final internal table haveing duplicate values because this table it_final having movement types
    so that i am not using delete statement .
    is there any logic for handling the duplicate values inside the loop statement
    by using read table statement.
    could u plz explain clearly  \[removed by moderator\]
    Edited by: Jan Stallkamp on Jul 11, 2008 2:11 PM

    this is my code could u plz explain  regarding duplicate material number .
    LOOP AT IT_MSEG INTO WA_MSEG.
        WA_FINAL-MBLNR = WA_MSEG-MBLNR.
        WA_FINAL-MATNR = WA_MSEG-MATNR.
        WA_FINAL-BWART = WA_MSEG-BWART.
        WA_FINAL-BWTAR = WA_MSEG-BWTAR.
        WA_FINAL-MENGE = WA_MSEG-MENGE.
        WA_FINAL-SOBKZ = WA_MSEG-SOBKZ.
        COLLECT WA_FINAL INTO IT_FINAL.
        CLEAR WA_FINAL.
      ENDLOOP.
      LOOP AT IT_FINAL INTO WA_FINAL.
        READ TABLE IT_MARD INTO WA_MARD WITH KEY MATNR = WA_FINAL-MATNR
                                                                                    BINARY SEARCH.
    this is reading the duplicate records i need to control duplicate records here .
    the   labst       value is repeating the number of times because of the meterial number duplication
    how can i restrict plz explain
        IF SY-SUBRC = 0.
          WA_FINAL-LABST = WA_MARD-LABST.
        ENDIF.
        READ TABLE IT_MKPF INTO WA_MKPF WITH KEY MBLNR = WA_FINAL-MBLNR
                                                                                    BINARY SEARCH.
        IF SY-SUBRC = 0.
          WA_FINAL-BUDAT = WA_MKPF-BUDAT.
        ENDIF.
        MODIFY IT_FINAL FROM WA_FINAL.
        CLEAR WA_FINAL.
      ENDLOOP.
      LOOP AT IT_FINAL INTO WA_FINAL.
        WA_SECOND-BWTAR = WA_FINAL-BWTAR.
        IF WA_FINAL-BWART = '101' OR WA_FINAL-BWART = '501' OR WA_FINAL-BWART = '561'.
          WA_SECOND-MENGE11 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '201'.
          WA_SECOND-MENGE12 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '541' AND WA_FINAL-SOBKZ = 'O' .
          WA_SECOND-MENGE13 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '601'.
          WA_SECOND-MENGE14 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '543'.
          WA_SECOND-MENGE15 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '702'.
          WA_SECOND-MENGE16 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '313'.
          WA_SECOND-MENGE17 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '315'.
          WA_SECOND-MENGE18 = WA_FINAL-MENGE.
        ENDIF.
        IF WA_FINAL-BWART = '122' OR WA_FINAL-BWART = '161'.
          WA_SECOND-MENGE19 = WA_FINAL-MENGE.
        ENDIF.
        COLLECT WA_SECOND INTO IT_SECOND.
        CLEAR WA_SECOND.
      ENDLOOP.

  • Reading from select-options field into the internal table

    Hi,
      I have to read the low and high ranges from the select-options fields into a field in the internal table in order to update the same field in line item table. since the user may change the screen fields, i need to pass the values directly from the screen and store it in a variable in the internal table. Is there a way to pass both ranges, low and high to one variable which holds the entire range?
    Thanks,
    Sruthy

    Hi,
    In the Selection screen you can directly read the field(Select-option)value using read statement as follows:
    READ TABLE <SELECT-OPTIONS field name> [using index] INTO <work area>.
    After reading you can directly access all the values as follows and can store them in the variables:
    var1 = <work area>-LOW
    var2 = <work area>-HIGH
    var3 = <work area>-SIGN
    var4 = <work area>-OPTION
    as per your requirement.
    I think this will help you.
    <b>Kindly reward if helpful.</b>
    Regards,
    Shakuntala.

  • How to Read the internal table for the data download from the spool

    HI all,
    I have one issue regarding the spool ,we are getting the correct output as per requirement of  user but when we send the same to the user in pdf format they did notget the same.
    they are telling that the due date is missing from the pdf.
    Please advice me how to track the internal  table for the spool data converted intopdf in a readable format.
    the FM used for the above task is : 
    call function 'CONVERT_OTFSPOOLJOB_2_PDF'
    Please reply if any one worked on the same.
    Thanks in advance.
    Gaurav,

    Hi Wang,
    Please let me know how you solved your question.
    Points will be rewarded.
    Thanks,
    Arun.

  • With in the internal table can I READ the same internal table for a record?

    With in the internal table can I READ the same internal table?
    For Suppose
    LOOP AT itab.
    can I do as below
    READ TABLE itab with key bukrs = itab-bukrs
                       belnr = itab-belnr.
    *and I have to compare
    IF itab-shkzg = itab-shkzg_ia.
    ENDIF.
    ENDLOOP.

    Hi,
    Yes..But use work area to differentiate..
    EX.
    DATA: WA LIKE ITAB.
    DATA: WA_READ LIKE ITAB.
    LOOP AT itab <b>INTO WA</b>.
    can I do as below
    READ TABLE itab <b>INTO WA_READ</b>
               with key bukrs = itab-bukrs
    belnr = itab-belnr.
    *and I have to compare
    IF <b>WA</b>-shkzg = <b>WA_READ</b>-shkzg_ia.
    ENDIF.
    ENDLOOP.
    Please reward for helpful answers.
    Thanks,
    Naren

  • SWAP COLUMNS AND ROW IN AN INTERNAL TABLE to display in ALV

    Hi ,
    I want to swap all the rows in an internal table with the column of the internal table to display it horizontally in ALV grid.
    e.g
    1     2   3  (field names)
    A    P   X
    B    Q   Y
    C    R    Z
    should look like :
    D       A   B     C
    E      P   Q    R
    F       X    Y    Z
    Where D , E, F in first column is already apended in new table.
    Or else is there a way to rotate the ALV grid so that it can display rows as columns & columns as rows.
    regards

    hi,
    i have an internal table which is like
    f1  f2 f3  f4 (column header)
    A  1  2   3
    B  4  5   6
    C  7  8   9
    the values in o/p table should be
    A B C  ( column header)
    1  4 7 
    2  5 8
    3  6 9
    Please help!!

Maybe you are looking for