At end of row is skipping inside loop.

MY requirement is for BAPI.but facing problem uploading excel sheet into sap.And in particular at end of row statement is not working.as a result of which data is not coming in IT_FINAL.
DATA: it_exload LIKE alsmex_tabline  OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF it_final OCCURS 0,
*     BUKRS TYPE BKPF-BUKRS,
      BLDAT(10) TYPE C,
*     BLDAT TYPE INVFO-BLDAT,
      XBLNR TYPE INVFO-XBLNR,
      BUDAT TYPE INVFO-BUDAT,
      WAERS TYPE INVFO-WAERS,
*     MWSKZ TYPE INVFO-MWSKZ,
      BUPLA TYPE INVFO-BUPLA,
      SECCO TYPE INVFO-SECCO,
      SGTXT TYPE INVFO-SGTXT,
*     KURSF TYPE INVFO-KURSF,
      GSBER TYPE INVFO-GSBER,
      ZUONR TYPE INVFO-ZUONR,
      BKTXT TYPE INVFO-BKTXT,
      EBELN TYPE RM08M-EBELN,
      WRBTR TYPE INVFO-WRBTR,
      lfbnr TYPE DRSEG-LFBNR,
      END OF it_final.
LOOP AT IT_EXLOAD.
     CASE IT_EXLOAD-COL.
       WHEN '0001'.
         IT_FINAL-BLDAT = IT_EXLOAD-VALUE.
       WHEN '0002'.
         IT_FINAL-XBLNR = IT_EXLOAD-VALUE.
       WHEN '0003'.
         IT_FINAL-BUDAT = sy-datum.
       WHEN '0004'.
         IT_FINAL-WAERS = IT_EXLOAD-VALUE.
       WHEN '0005'.
         IT_FINAL-BUPLA = IT_EXLOAD-VALUE.
       WHEN '0006'.
         IT_FINAL-SECCO = IT_EXLOAD-VALUE.
       WHEN '0007'.
         IT_FINAL-SGTXT = IT_EXLOAD-VALUE.
       WHEN '0008'.
         IT_FINAL-GSBER = IT_EXLOAD-VALUE.
       WHEN '0009'.
         IT_FINAL-ZUONR = IT_EXLOAD-VALUE.
        WHEN '0010'.
         IT_FINAL-BKTXT = IT_EXLOAD-VALUE.
       WHEN '0011'.
*        IT_FINAL-EBELN = IT_EXLOAD-VALUE.
       WHEN '0012'.
         IT_FINAL-WRBTR = IT_EXLOAD-VALUE.
       WHEN '0013'.
         IT_FINAL-LFBNR = it_exload-value.
         ENDCASE.
       AT END OF ROW.
       APPEND IT_FINAL.
       CLEAR IT_FINAL.
     ENDAT.
     ENDLOOP.
ENDFORM.

Hi Kumar,
Kindly make sure, the field 'ROW' in Internal Table IT_EXLOAD have value. Use Flag in-between AT END OF.... END AT.
DATA: l_flag TYPE I VALUE 0.
AT END OF ROW.
L_FLAG = 1.          "Set the Flag for End of Row
ENDAT.
IF L_FLAG = 1.
    APPEND IT_FINAL.
     CLEAR IT_FINAL.
      L_FLAG = 0.
ENDIF.
Regards
Rajkumar Narasimman

Similar Messages

  • New object inside loop condition

    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
         //now would like use File object created above
    }What's the notation for that?

    YoungWinston wrote:
    TheGreatEmperor wrote:
    I would like to create new object inside loop condition and use in its body
    while(new File(localization).exists()){
    //now would like use File object created above
    }What's the notation for that?Encephalopathic gave it to you, but I'd worry about ending up with a never-ending loop. What about
    if ((myFile = new File(fileString)).exists()) { ...instead?
    Winston1) Same thing I put (except change the name "f" with "myFile")
    2) you could get a never-ending loop with your answer (depending on the body)
    3) The previous answer by Encephalopathic would NOT give a never-ending loop unless there was a never-ending listing of files with the name:
    "Foo" + fileCounter + ".txt"; where "fileCounter" is incrementing (as done in his code)

  • XSL-How to get value of a variable from inside loop-- to the outside loop?

    Pls help
    hi im currently working on this xsl file..
    This works on generating a txt file,my problem right now is
    ' how can i get the value of a variable generated from the inside forloop,
    i have to get the total,sum value of this variables after performing the loop
    ***this is the for loop
    <xsl:for-each select="OutboundPayment">
    <xsl:variable name='id' select='generate-id(OutboundPayment)'/>
    <xsl:sort select="PaymentNumber/CheckNumber" data-type="text" />
    <xsl:variable name='PValue' select='format-number(100*PaymentAmount/Value,"0000000000000")'/>
    <xsl:value-of select='$id'/>
    <xsl:text>D</xsl:text>
    <xsl:value-of select='$DDate'/>
    <xsl:value-of select='$Batch'/>
    <xsl:text>3</xsl:text>
    <xsl:value-of select='format-number(PaymentNumber/PaymentReferenceNumber,"0000000000")'/>
    <xsl:value-of select='format-number(PayeeBankAccount/BankAccountNumber,"0000000000")'/>
    <xsl:value-of select='substring(Payee/Name,1,20)'/>
    <xsl:value-of select='$PValue'/>
    <xsl:variable name='Addend' select='concat($DDate,substring($DAcct,5,5),$Batch)'/>
    <xsl:variable name="LHash">
    <xsl:call-template name="GetHash">
    <xsl:with-param name="A1" select="$PValue" />
    <xsl:with-param name="A2" select="$Addend" />
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="concat('[',$LHash,']')" />
    <!--LHash*i have to get the total amount of this one from the outside loop /---->
    <xsl:call-template name='NewLine'/>
    </xsl:for-each>
    <!--I have to put in here the total value of that LHash/---->
    <!--This is the template on how to get the value of that variable in the inside loop/---->
    <xsl:template name="GetHash">
    <xsl:param name='A1'/>
    <xsl:param name='A2'/>
    <xsl:variable name='TwoSum' select='format-number($A1+$A2,"000000000000000")'/>
    <xsl:variable name='Weight' select='317191314191112'/>
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="15"/>
    <xsl:with-param name="Sum" select="$TwoSum"/>
    <xsl:with-param name="Wgt" select="$Weight"/>
    <xsl:with-param name="Tot" select="0"/>
    </xsl:call-template>
    </xsl:template>
    <xsl:template name='WDigit'>
    <xsl:param name='Cnt'/>
    <xsl:param name='Sum'/>
    <xsl:param name='Wgt'/>
    <xsl:param name='Tot'/>
    <xsl:choose>
    <xsl:when test="$Cnt > 0">
    <xsl:variable name='Multip' select='substring($Wgt,$Cnt,1)'/>
    <xsl:variable name='Factor' select='substring($Sum,$Cnt,1)'/>
    <xsl:variable name='Prduct' select='$Multip$Factor'/>
    <!--xsl:value-of select="concat($Tot,'[',$Cnt,']')"/-->
    <!--xsl:value-of select="concat($Multip,'x',$Factor,'=',$Prduct)"/-->
    <!--xsl:call-template name='NewLine'/-->
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="$Cnt - 1"/>
    <xsl:with-param name="Sum" select="$Sum"/>
    <xsl:with-param name="Wgt" select="$Wgt"/>
    <xsl:with-param name="Tot" select="$Tot+$Prduct"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="Rem" select="$Tot mod 11"/>
    <xsl:variable name="Chk" select="11 - $Rem"/>
    <xsl:value-of select="format-number(concat($Tot,$Chk),'00000')"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:template name='GetTotal'>
    </xsl:template>
    Thanks in advance for those who are willing to help.
    -Leighya

    It would have helped if you had posted your code as CODE but as it is, I could hardly read it. My guess about what you are asking is, if you want a template to return a value, just write that value to the result stream inside the template.
    If that wasn't what you were asking, then please post your code in a readable format.

  • Passivated row is lost inside taskflow

    Hi,
         I am using jdeveloper ver 11.1.1.2.0
    On activation / passivation my newly created row is lost inside taskflow.
    My case as explained below,
    I have unchecked Enable Application Module Pooling condition.
    Within a region i have a grid layout (Entity based -child grid),my master grid layout(Entity base - master grid) is not shown to my user interface.
    Pro-grammatically i am creating and inserting row to my master grid which is not visible to user, and setting that newly created row as current row in master table.
    eg,
    Row row = vo.createRow();    
    row.setAttribute("PrimaryKey",-1);
    row.setAttribute("CompanyCode",aaaa);
    vo.insertRow(row);
    vo.setCurrentRow(row) 
    2. Having Add button in child grid, while adding a new row i was trying to pass some value from master to child,
    during this time my master table row is lost.
    I faced this scenario only when i unchecked Enable Application Module Pooling condition. It works fine when application module pooling is set true.

    Within a region i have a grid layout (Entity based -child grid),my master grid layout(Entity base - master grid) is not shown to my user interface.
    Pro-grammatically i am creating and inserting row to my master grid which is not visible to user, and setting that newly created row as current row in master table.
    eg,
    I don't understand your laptop. What do you mean by gtid layout?  Jdev 11.1.1.2.0 don't has a grid layout.
    Where do you add the new route?  Bean method or a service method in your application module?
    You are seeing the pk to -1 is this the real pk?
    Timo

  • VBA crashes on "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row"

    I have code that has the line "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row". Every once in a while the macro crashes on this line. It doesn't happen regularly or with a pattern. The entire code is below. I have several
    modules that use this line of code. Any ideas?
    Function ImportScores()
    Dim RecSet As DAO.Recordset
    Dim objXLAppln As Excel.Application
    Dim objWBook As Excel.Workbook
    Dim rowNum As Variant
    Dim i As Integer
    Dim j As Integer
    Dim StrPathFile As String, strFile As String, strPath As String
    Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
    'show dialogue box
    strBrowseMsg = "Select the EXCEL file:"
    'set directory to load files from
    strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
    'run strFilter function
    strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
    StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
    Filter:=strFilter, OpenFile:=True, _
    DialogTitle:=strBrowseMsg, _
    Flags:=ahtOFN_HIDEREADONLY)
    If StrPathFile = "" Then
    MsgBox "No file was selected.", vbOK, "No Selection"
    Exit Function
    End If
    'Set Excel application object. Critical for macro to run properly. Do not change.
    Set objXLAppln = New Excel.Application
    'Open workbook and worksheet to load data.
    With objXLAppln
    Set objWBook = .Workbooks.Open(StrPathFile)
    objXLAppln.Visible = True
    End With
    Set RecSet = CurrentDb.OpenRecordset("Performance_Scores")
    'Copy data from Excel cells to Access fields
    objXLAppln.Sheets("Performance_Attributes").Select
    rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row
    objXLAppln.Range("A10").Select
    'Add records to table from Excel
    With RecSet
    For i = 0 To rowNum - 9
    RecSet.AddNew
    RecSet.Fields("CIP_ID").value = objXLAppln.ActiveCell.Offset(i, 0).value
    RecSet.Fields("5YearScore").value = objXLAppln.ActiveCell.Offset(i, 53).value
    RecSet.Fields("10YearScore").value = objXLAppln.ActiveCell.Offset(i, 54).value
    RecSet.Fields("15YearScore").value = objXLAppln.ActiveCell.Offset(i, 55).value
    RecSet.Fields("20YearScore").value = objXLAppln.ActiveCell.Offset(i, 56).value
    RecSet.Update
    Next i
    End With
    'Close everything
    RecSet.Close
    objWBook.Close SaveChanges:=False
    objXLAppln.Quit
    Set RecSet = Nothing
    Set objWBook = Nothing
    Set objXLAppln = Nothing
    End Function

    I rewrote as below.
    But rather than doing it this way, I would create a linked table to this workbook and import the data using an Append query.
    Function ImportScores()
        Const FOOTER_ROWS_TO_SKIP As Integer = 10
        Const COL_CIP_ID As Integer = 1
        Const COL_5YEARSCORE As Integer = 54
        Dim RecSet      As DAO.Recordset
        Dim objXLAppln  As Excel.Application
        Dim objWBook    As Excel.Workbook
        Dim objXLSheet  As Excel.Worksheet
        Dim rowNum      As Variant
        Dim row         As Integer
        Dim j           As Integer
        Dim StrPathFile As String, strFile As String, strPath As String
        Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
        'show dialogue box
        strBrowseMsg = "Select the EXCEL file:"
        'set directory to load files from
        strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
        'run strFilter function
        strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
        StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
                                            Filter:=strFilter, OpenFile:=True,
                                            DialogTitle:=strBrowseMsg,
                                            Flags:=ahtOFN_HIDEREADONLY)
        'StrPathFile = "C:\Users\Tom\Documents\test.xlsx"        'testonly
        If StrPathFile = "" Then
            MsgBox "No file was selected.", vbOK, "No Selection"
            Exit Function
        End If
        'Set Excel application object. Critical for macro to run properly. Do not change.
        Set objXLAppln = New Excel.Application
        'Open workbook and worksheet to load data.
        With objXLAppln
            Set objWBook = .Workbooks.Open(StrPathFile)
            objXLAppln.Visible = True
            Set objXLSheet = objXLAppln.Sheets("Performance_Scores")
        End With
        rowNum = objXLSheet.UsedRange.Rows.Count
        'Add records to table from Excel
        Set RecSet = CurrentDb.OpenRecordset("Performance_Scores", dbOpenDynaset)
        With RecSet
            For row = 1 To rowNum - FOOTER_ROWS_TO_SKIP
                RecSet.AddNew
                RecSet.Fields("CIP_ID").Value = objXLSheet.Cells(row, COL_CIP_ID).Value
                RecSet.Fields("5YearScore").Value = objXLSheet.Cells(row, COL_5YEARSCORE).Value
                'etc.
                RecSet.Update
            Next row
        End With
        'Close everything
        RecSet.Close
        objWBook.Close SaveChanges:=False
        objXLAppln.Quit
        Set RecSet = Nothing
        Set objWBook = Nothing
        Set objXLAppln = Nothing
    End Function
    -Tom. Microsoft Access MVP

  • My computer is recognizing my airport express network at first but then slips to an exclamation mark. I have followed the steps to reset everything and it ends up keeping me on a loop of asking me to rest everything after I do so. network is recognized

    My computer is recognizing my airport express network at first but then slips to an exclamation mark. I have followed the steps to reset everything and it ends up keeping me on a loop of asking me to rest everything after I do so. network is recognized on list along with all my neighbors. Any help would be greatly apprectiated.

    System Preferences > Network
    WiFi/Airport should be at the top of the list.
    Select WiFi/Airport
    [√ ] Ask to Join new Networks
    click ( Advanced )
    In the WiFi/Airport pane, remove ALL other networks except your home Network. (This will keep your computer from "wandering off" onto a neighbor's Network.)
    You are not done until you close the windows and Save Changes.

  • Can we skip one loop pass in reports

    is there any option of skipping one loop pass and moving to next loop pass in the middle of the loop in classical reporting.

    Hello Harini,
    You can use the keyword 'CONTINUE' to skip one loop pass to the next loop pass.
    LOOP AT itab. "internal table
      IF <condition>.
        CONTINUE . "this will skip to the next loop pass leaving rest of the code
      ELSE.
        *rest of the code
      ENDIF.
    ENDLOOP.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir

  • Can I put Read inside loop?

    Hi Folks
    Can I put Read inside loop?
    Performance wise is it acceptable?
    Regards,
    Sreeram

    Hi
    there is no problem to put READ statement inside the LOOP
    its a better way to put
    to avoid SELECT in a LOOP
    see this example
    i had used that in my program
    in the performance point of view it is a good method
    LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.
        READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
        IF SY-SUBRC EQ 0.
          READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
          WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
          WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
          WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
          WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
          WA_OUTPUT-UNAME = WA_HRP1026-UNAME.
          WA_OUTPUT-STEXT = WA_HRP1000-STEXT.
          READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
          WA_OUTPUT-CANCRT = WA_REASON-CANCRT.
          CLEAR WA_REASON-CANCRT.
          READ TABLE IT_LOCATION1 WITH KEY OBJID = WA_HRP1026-OBJID INTO WA_LOCATION1..
          READ TABLE IT_LSTEXT WITH KEY OBJID = WA_LOCATION1-SOBID OTYPE = 'F' INTO WA_LSTEXT.
                 WA_OUTPUT-LSTEXT = WA_LSTEXT-LSTEXT.
                 CLEAR WA_LSTEXT-LSTEXT.
          APPEND WA_OUTPUT TO IT_OUTPUT.
          CLEAR WA_OUTPUT.
          CLEAR WA_OUTPUT-CANCRT.
        ENDIF.
      ENDLOOP.
    <b>Reward if usefull</b>

  • [Forum FAQ] How to calculate the total count of insert rows within a Foreach Loop Container in SSIS?

    Introduction
    We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
    Solution
    We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
    Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
    Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
    On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
    Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
    Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
    Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
    “@[User::FilePath]”.
    (I) Execute SQL Task Method:
    In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
    Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
    DECLARE @InsertRowCnt INT,
                   @TotalRowCnt INT
    SET @InsertRowCnt=?
    SET @TotalRowCnt=?
    SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
    SELECT TotalRowCnt=@TotalRowCnt
    On to parameter 1. 
    On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
    (II) Script Task Method:
    In the Control Flow, drag a Script Task under the Data Flow Task and join them.
    In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
    Edit the Main method as follows (C#):
    public void Main()
    // TODO: Add your code here
    int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
    int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
    TotalRowCnt = TotalRowCnt + InsertRowCnt;
    Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
    Dts.TaskResult = (int)ScriptResults.Success;
              Or (VB)
              Public Sub Main()
            ' Add your code here
            Dim InsertRowCnt As Integer =        
            Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
            Dim TotalRowCnt As Integer =
            Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
            TotalRowCnt = TotalRowCnt + InsertRowCnt
            Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
            Dts.TaskResult = ScriptResults.Success
           End Sub
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Microsoft SQL Server 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Hi ITBobbyP,
    If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
    If in this scenario, please refer to the following tips:
    The Foreach Loop container should be configured as shown below:
    Enumerator: Foreach ADO.NET Schema Rowset Enumerator
    Connection String: The OLE DB Connection String for the excel file.
    Schema: Tables.
    In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
    The connection string for Excel Connection Manager is the original one, we needn’t make any change.
    Change Table Name or View name to the variable Sheet_Name.
    If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
    http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Finding sum inside Loop

    Hi Experts,
    here i am printing report output.
    in my internal tab there are 10 fields, inthat last field is CURRENCY (amt).
    now i want to sum that field at end of first field.
    my pease of code is below:
    LOOP AT it_display INTO wa_display.
        IF wa_display-amount NE 0.
          WRITE: /05 wa_display-pspid,
                 15 wa_display-pspnr1,
                 35 wa_display-vornr,
                 45 wa_display-post1,
                 70 wa_display-verna,
                 85 wa_display-plfaz,
                 97 wa_display-plsez,
                 110 wa_display-gjahr,
                 125 wa_display-versn,
                 135 wa_display-wrttp,
                 140 wa_display-beltp,
                 145 wa_display-vorga,
                 152 wa_display-twaer,
                 160 wa_display-period,
                 180 wa_display-amount.
        ENDIF.
        AT END OF pspid.
        WRITE: /160 'TOTAL AMOUNT',wa_display-pspid COLOR 3.
          SKIP 2.
        ENDAT.
      ENDLOOP.
    how calculate the sum for last field (wa_display-amount).
    Thanks in advance,
    sudharsan.

    Hi friends thank u for ur help.
    i got it and i ve rewarded.
    and i ve one more issue on this.
    in my table suppose there are 3 fields. like below
    field1         field2        field3
    100          100.01        40
    100          100.01.01    50
    200          200.01        30
    200          200.01.01    70
    but iwant output like below
    field1         field2        field3
    100          100.01       40
    100          100.01.01   50
        Total is -
       90
    200          200.01        30
    200          200.01.01    70
    Total is -
            100
    now am getting output like below:
    field1         field2        field3
    100          100.01       40
        Total is -
       40
    100          100.01.01   50
        Total is -
        50
    200          200.01        30
    Total is -
            30
    200          200.01.01    70
    Total is -
            70
    i want sum at end of field1, but am getting every end of field2.
    but in my display loop i ve done like
    AT END OF field1 only but why am getting like this.
    any help...
    Thanks in advance,
    sudharsan.

  • Need help in logic change to avoid select statement inside loop .

    Hello all ,
    Please see the below code . Here i got the shipment number in internal table  IT_VTTK . So For this shipment number i want to get the details from Vekp table in to internal table  IT_VEKP  . There is no need for me to use For all entries . I have passed the value of it_vekp into work area wa_vekp and getting the details in to IT_vekp using loop.
    But since we should not use the select statement inside the loop , Can anybody please tell me how to achieve this functionality .
    Instead of passing into work area wa_vttk if i directly use the internal table I'm getting the following error .
    "IT_VTTK" is a table without a header line and therefore has no component called "TKNUM".
    Hence i have used select statement inside a loop . Please tell me is there any other way to avoid this ?
    types:begin of ty_likp,
            vbeln type likp-vbeln,
           end of ty_likp,
           begin of ty_vttk,
            tknum type vttk-tknum,
            end of ty_vttk.
    DATA: IT_VEKP TYPE STANDARD TABLE OF TY_VEKP,
          WA_VEKP TYPE TY_VEKP.
      data:it_likp type standard table of ty_likp,
           wa_likp type ty_likp,
           it_likp1 type standard table of ty_likp,
           it_vttk type standard table of ty_vttk,
           wa_vttk type ty_vttk.
      data:w_tknum type vttk-tknum.
    if not it_likp is initial .
        select vbeln
                from
                 vbfa
          into table it_vttk
           for all entries in it_likp where vbelv = it_likp-vbeln and vbtyp_n = '8'.
      endif .
    IF IT_VTTK[] IS NOT INiTIAL.
        loop at it_vttk into wa_vttk.
        SELECT venum
               EXIDV
               EXIDV2
               BRGEW
               NTGEW
               GEWEI
               TARAG
               GEWEI
               VHART
               INHALT
             FROM VEKP INTO TABLE IT_VEKP where VPOBJKEY = wa_vttk-tknum  and vpobj = '4'.
          endloop.
          endif.

    Hello,
    Why would you not like to use FOR ALL ENTRIES in the second select? Is it becasue of the length or type mismatch error between the fields VPOBJKEY and wa_vttk-tknum ?
    Vikranth

  • LOOP inside loop -performance  issue.

    hi ppl,
    I want to put the select query mentioned below outside the loop to resolve performance issue. The 'for all entries' does not support aggregate functions like 'sum' and 'group by'. plz have a look at my approach and suggest some changes.
    the code:
    LOOP AT T_UNITS.
    V_TABIX = SY-TABIX.
    CONCATENATE TEXT-S01 T_UNITS-UNIT INTO VL_TEXT SEPARATED BY ' '.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
    PERCENTAGE = 0
    TEXT = VL_TEXT.
    get GLPCA postings
    SELECT AWTYP AWORG RACCT REFDOCNR SUM( HSL ) FROM GLPCA "1062
    INTO TABLE T_GLPCA
    WHERE RPRCTR = T_UNITS-UNIT
    AND RACCT IN S_HKONT
    AND KOKRS = V_KOKRS
    AND RYEAR = P_GJAHR
    AND POPER <= P_MONAT
    GROUP BY AWTYP AWORG RACCT REFDOCNR.
    lopp at t_glpca.
    endloop.
    endloop.
    my approach:
    all this put outside the loop 'loop at t_units'.
    SELECT rprctr AWTYP AWORG RACCT REFDOCNR HSL FROM GLPCA  "1062
      INTO TABLE T_GLPCA
      For all entries in t_units            
       WHERE RPRCTR = T_UNITS-UNIT
       AND   RACCT  IN S_HKONT
       AND   KOKRS = V_KOKRS
       AND   RYEAR = P_GJAHR
       AND   POPER  <= P_MONAT.
    loop at t_glpca.
        v_tabix = sy-tabix.
        select sum( hsl ) from glpca into t_glpca-hsl.
        modify t_glpca index v_tabix.
      endloop.
    The select query 'select sum( hsl ) from glpca into t_glpca-hsl' is consuming lot of time.
    thanks in advance
    Archana

    hi ,
        u can use sum function while displaying also .
    u have selected some values into itab na .aftyer that use the below code.
    loop at itab.
    at end of <fielname>.
    sum.
    write:/ itab-<fieldname>.
    endat.
    like this also u can some .so u can use for all entries in select statement .
    hopw it's usefull for u .
    or use
    on change of <fielname>
    endon.
    instead of at endof.
    EXAMPLE CODE
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab.
    LOOP AT sflight_tab INTO sflight_wa.
      AT NEW connid.
        WRITE: / sflight_wa-carrid,
                 sflight_wa-connid.
        ULINE.
      ENDAT.
      WRITE: / sflight_wa-fldate,
               sflight_wa-seatsocc.
      AT END OF connid.
        SUM.
        ULINE.
        WRITE: / 'Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        SKIP.
      ENDAT.

  • Confusion in loop inside loop

    Hi Experts,
    i have some confution in below code:
    here am trying to calculate  Actual Billing and Planned Revenue. but here for each value am looping it_final table inside the main loop.
    but the prob is if i loop it_final for one value it is giving value, but if i try to loop 2 times for 2 values, it is not giving first value also.  
    i.e if i comment loop for Planned Revenue then Actual Billing is displaying, if i try for 2 values, then its giving zeros for 2 values.
    so could anyone check is there any mistake i did.
    CLEAR: it_prps, it_final, wa_final, wa_it_prps.
      LOOP AT it_prps.
        CASE month.
          WHEN '08'.
      ACTUAL BILLING
            LOOP AT it_final INTO wa_final
             WHERE posid = it_prps-posid
                AND wrttp = c_04
                AND beltp = c_02
                AND versn = c_0
                AND ( vorga = c_coin OR vorga = c_rku2 ).
              CLEAR act_billing.
              IF sy-subrc IS INITIAL.
                MOVE wa_final-wlp08 TO t_act_billing.
                act_billing = act_billing + t_act_billing.
              ENDIF.
              CLEAR: it_prps, it_final.
            ENDLOOP.
    *************PLANNED REVENUE
            LOOP AT it_final INTO wa_final
                             WHERE posid = it_prps-posid
                             AND wrttp = c_01
                             AND beltp = c_02
                             AND versn = c_0
                             AND ( vorga = c_sdor OR vorga = c_rkp5 ).
              CLEAR plan_rev.
              IF sy-subrc IS INITIAL.
                MOVE wa_final-wlp08 TO t_plan_rev.
                plan_rev = plan_rev + t_plan_rev.
              ENDIF.
              CLEAR: it_prps, it_final.
            ENDLOOP.
    ENDCASE.
    ENDLOOP.
    WRITE:/10 'Actual Billing is',act_billing.
    WRITE:/20 'Actual Cost is........', actu_cost.
    Thanks in advace,
    sudharsan.

    Hi SUDHARSAN RAO
    U r clearing the headers and tables. So u cannot use the values on the nested loops  as u have cleared the values. There wont be anything in the workare ur using in where clause.
    Please see the below comments that I kept.
    LOOP AT it_prps.
    ACTUAL BILLING
    LOOP AT it_final INTO wa_final
    WHERE posid = it_prps-posid
    AND wrttp = c_04
    AND beltp = c_02
    AND versn = c_0
    AND ( vorga = c_coin OR vorga = c_rku2 ).
    CLEAR act_billing.
    IF sy-subrc IS INITIAL.
    MOVE wa_final-wlp08 TO t_act_billing.
    act_billing = act_billing + t_act_billing.
    ENDIF.
    CLEAR: it_prps, it_final.
    Here IT_FINAL is cleared by u... should not be cleared
    ENDLOOP.
    *************PLANNED REVENUE
    LOOP AT it_final INTO wa_final
    WHERE posid = it_prps-posid
    AND wrttp = c_01
    AND beltp = c_02
    AND versn = c_0
    AND ( vorga = c_sdor OR vorga = c_rkp5 ).
    CLEAR plan_rev.
    IF sy-subrc IS INITIAL.
    MOVE wa_final-wlp08 TO t_plan_rev.
    plan_rev = plan_rev + t_plan_rev.
    ENDIF.
    Again ur clearing both tables.
    CLEAR: it_prps, it_final.
    ENDLOOP.
    ENDCASE.
    ENDLOOP.
    WRITE:/10 'Actual Billing is',act_billing.
    WRITE:/20 'Actual Cost is........', actu_cost.

  • How do I export to text file and suppress the cr-lf at end of row?

    Hello.
    I have created a report that is mean to export to a text file.  It will always be a 1 row report and it's always going to be uploaded to a vendor via their website.  They don't want the cr-lf at the end of the row.
    I can't figure out how to get crystal to not do that.  When I export to a text file (not a tab delimited text file), it seems to throw in the cr-lf at the end of the row.  I have to manually remove it before uploading it.  This task of uploading the file will go to someone else in the near future and I would like to not have to rely on them to do it.
    Am I missing it?

    Could you please elaborate what do you mean by 'cr-lf'. Just came across these SAP notes,however don't know whether they are applicable in your context.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313331333533303333%7D.do
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313333333333373332%7D.do
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233303334333033383337%7D.do
    Thanks

  • Place of newly opened tabs is not logical (not put to the end of row)

    When I have more tabs opened (for example 5) and I click a link with the middle mouse-button NOT on the last tab (for example on the 2nd one) Firefox does not put the newly opened tab to the end of the row, it is inserted right after the clicked page (newly opened tab is inserted between 2 existing tabs). Previous Firefox versions did always put the newly opened tabs to the end. How could it be set in case of 3.6.10?

    A couple of options. You can use the [https://addons.mozilla.org/en-US/firefox/addon/61766/ New Tabs at the End] add-on. A second option is to change a hidden preference.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # In the filter box type '''Related'''
    # Double-click on the preference '''browser.tabs.insertRelatedAfterCurrent''' to change its value to '''false'''

Maybe you are looking for