Opening and Closing values on two separate rows for an indvidual A/c?

Hi / Salam To all SAP Members,
I am creating a COGS report in which i need to show opening and closing values for a stock account in two separate rows. The tool i am using is report painter.
What i need to know is how can the system identify between opening and closing values for that account? Which characteristic/s do i need to include in the rows? The table i am using is FAGLFLEXT.
Please provide help.
Regards,
Mohammed Ali Khan.

Resolved Issue.

Similar Messages

  • Opening and closing balance between 2 dates

    hi.
    i am facing a problem while fetching the opening and closing balance for a particular G/L account.
    In my  program  i am entering G/L account for a date range i.e, between two dates and i want opening and closing balance for these 2 date ranges.
    So, please tell me is there any function module to fetch opening and closing balance between two dates.
    Regards,
    ROHINI.K.

    Hi Rohini,
                 Check this FM :   BAPI_GL_GETGLACCPERIODBALANCES.
    If we use this functional module, we will get opening and closing balance of corresponding G/L Acc.
    (e.g)
    CALL FUNCTION 'BAPI_GL_GETGLACCPERIODBALANCES'
        EXPORTING
          companycode                   =  '1000'
          glacct                              = '0000548101'
          fiscalyear                         = '2007'    
         currencytype                      = '10'
       IMPORTING
    BALANCE_CARRIED_FORWARD       =  gs_bal-balance
         RETURN                                        =  v_return
        TABLES
          account_balances                            = gt_bal.

  • Inventory opening and closing stock with value report

    Hi All,
    Is it possible to get details of both opening and closing stock with value of each items of last financial year (2009-10) in inventory report?
    Mizan

    Hi..
    you can  try this query
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    set @FromDate =
        (Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
    set @ToDate =
        (Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
    select * from
        SELECT T0.itemcode,
        min(T0.Dscription) as 'Item Description',
        min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
        (isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate ),0)-
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate),0)
        ) as [Opening Stock],
        isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate
            and O1.docdate<=@ToDate and O1.inqty>0
            and O1.transtype in (20,18)),0
        ) as [Purchase Quantity],
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate
            and O1.outqty>0 and O1.transtype in (21,19)),0
        ) as [Purchase Return Quantity],
       isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
            and O1.transtype in (13,15)),0
        ) as [sale Quatity],
        (isnull
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate<=@ToDate),0
            isnull((
                Select sum(isnull(outqty,0))
                from OINM O1
                where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
                and O1.docdate<=@ToDate),0)
        ) as [Closing Stock]
        FROM OINM T0
        INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
        INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode
        INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod
        INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
        INNER JOIN OLCT C1 ON W1.Location=C1.Code
        Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
    ) a
    where (a.[Opening Stock]
            +a.[Purchase Quantity]
            + a.[Purchase Return Quantity]
            +a.[sale Quatity]+a.[Closing Stock]
           ) !=0
    Regards,
    Bhavank

  • Opening and closing balance values at storage location level

    Dear all,
    I want to know opening and closing balance values and receipts and issue values at storage location level for certain period.
    I tried with MB5B, it is not giving value at storage location level, it is giving quantities at storage location level and values at plant level. But requirement is: please see below example:
    All values are in USD          
    Storage location:      1001     1002
    Opening Balance:      2000     3000
    Receipts:                           1000      2000
    Issues:                            2000     3000
    Closing Balance:      1000     2000
    Please help in this regard (I want value of the stock only, not qty)
    Regads,
    Veerappa
    Edited by: Chinna Veerappa on Jul 27, 2010 5:27 PM
    Edited by: Chinna Veerappa on Jul 27, 2010 5:28 PM

    vlauation is at plant level (MBEW table) the storage location level does not carry values (table MARD).
    You may have to develope your own ZMB5B  program and calculate yourself what is not stored in SAP.

  • Report showing GL Accountwise Open, Reciept,Issue,and  Closed Value

    Hi.,
           i want to do a report that shows GL Accountwise Open, Reciept,Issue,and  Closed Value based on Posting Date. Is there any standard report available.Please guide me how to do this.Please tell me the list tables to be accessed .
    Regards.,
    S.Sivakumar

    Transaction FBL4N

  • Opening and Closing balance of a material

    How to check the opening and closing balance of a material in a given period?
    GL account /Plant/material number is known
    Can we see along with the PO/reservations made  in this period?
    Is there any report or Tcode?

    In mbew and mbewh table u will get the value and stock of material at plant level  for each period( if plant is valuation level ) . GL account u will get from valuation class attched to material master.
    Else use fi tcodefbl3n .
    if u want closing balance for period 6 then you  goto fbl3n and run the report for the GL ACC of stock till period 5. In that go to menu and in that special fields add bseg-matnr and bseg-plant and then sort the report on material/plant level. this will opening balance for period 6.
    then run same report till period 6 and this will give closing balance for period 6.
    this two report give opening and closing balace for period 6.

  • How to calculate opening and closing balance for period

    Hi all,
    i have to find out opening and closing balance.
    the table structure of temporary table is
    select * from hwcn_xn_fa_report_temp1 where asset_id=10029400
    PERIOD_COUNTER CST_OP_BAL CST_ADDITION CST_TRANSFER CST_DISPOSAL COST_CLOSING_BALANCE
    24108 0 0 0
    24109 12000
    24110 0 0 0
    24111 0 0 0
    in this table cst_op_balnce and cost_closing_balace is null
    i have display cost_op_bal and cost_closing_balnce
    cost_closing_balance=cst_op_bal+cst_addition+cst_transfer+cst_disposal
    for period 2408 op_balnce=0 closing_bal=0
    for period 2409 op_balnce=0 closing_balce=1200
    for period 2410 op_bal=1200 closing_bal=1200
    closing balance of dec will be opening bal of jan
    thanks and regards
    Edited by: user10664276 on Apr 19, 2009 11:08 PM
    Edited by: user10664276 on Apr 19, 2009 11:13 PM

    Hi,
    user11118871 wrote:
    Can you explain what that is? Thank you if you have one example.
    ROWS BETWEEN  UNBOUNDED PRECEDING AND 1 PRECEDING
    When you use the analytic SUM (c) function, then, on each row, it returns the values of column (or expression) c from several rows in the result set added together.
    Which rows? That depends.
    If the analytic clause (the part in parentheses after OVER) does not include ORDER BY, then it is all rows.
    If the analytic clause has an ORDER BY clause, but no windowing clause (that is, ROWS BETWEEN ... or RANGE BETWEEN ...), then the rows included in the sum are all rows up to and including the row where the function is being called (as sorted by the analytic ORDER BY).
    If the analytic cluase has both ORDER BY and a windowing clause "ROWS BETWEEN x PRECEDING AND y PRECEDING", then the rows included in the sum are the rows from x to y rows before the one where the function is called.
    Do some experiments with different values of x and y.
    First, create a table like the one in the problem above, but simplified a little.
    CREATE TABLE     test_sum
    (      period     NUMBER
    ,      new_amt     NUMBER
    INSERT INTO test_sum (period, new_amt) VALUES (24108,     1);
    INSERT INTO test_sum (period, new_amt) VALUES (24109,     4);
    INSERT INTO test_sum (period, new_amt) VALUES (24110,     2);
    INSERT INTO test_sum (period, new_amt) VALUES (24111,     8);
    INSERT INTO test_sum (period, new_amt) VALUES (25001,     32);
    INSERT INTO test_sum (period, new_amt) VALUES (25002,     16);
    COMMIT;The original problem above used names that were meaningful for its application, and columns that have nothing to do with the SUM function. Let's simplify the former and lose the latter.
    That problem involved the SUM of three columns added together. Since we just want to understand how the windowing clause works, let's simplify that to one column.
    With these simplifications, my original query is:
    SELECT       period
    ,       new_amt     
    ,       SUM (new_amt) OVER ( ORDER BY          period
                                         ROWS BETWEEN  UNBOUNDED PRECEDING
                                 AND          1            PRECEDING
                        ) AS opening_balance
    ,       SUM (new_amt) OVER ( ORDER BY          period
                        ) AS closing_balance
    FROM       test_sum
    ORDER BY  period;Given the data above, it produces these results:
    .   PERIOD    NEW_AMT OPENING_BALANCE CLOSING_BALANCE
         24108          1                               1
         24109          4               1               5
         24110          2               5               7
         24111          8               7              15
         25001         32              15              47
         25002         16              47              63So, for example, on the row where period=24110,
    opening_balance=5, which is the total of new_amt from all rows up to but not including that row: 5=1+4, and
    closing_balance=7, which is the total of new_amt from all rows up to and including that row: 7=1+4+2.
    To really understand how the windowing clause works, do some experiments. Change the definition of opening_balance to include " BETWEEN x PRECEDING AND y PRECEDING". You'll find that:
    (a) "UNBOUNDED PRECEDING" means the same as "n PRECEDING", where n is greater than the number of rows in your result set.
    (b) "CURRENT ROW" means the same as "0 PRECEDING"
    (c) x must be greater than or equal to y
    (d) neither x nor y can be negative (but you can use "FOLLOWING" instead of "PRECEDING" to get the same effect).
    For more, see the introduction to "Analytic Functions" in the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions001.htm#sthref972]
    When you're finished, don't forget to
    DROP TABLE     test_sum;

  • Better approach for checking column values between two different rows

    My requirement is to find best Approach to find difference between column values of two different rows.Below I've mentioned two different
    approaches I'm thinking of,but I'd like to know is there any other better approach.
    version details
    SQL> SELECT *
      2  FROM V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionTable creation script
    CREATE TABLE R_DUMMY
       (CA_ID VARCHAR2(16) NOT NULL ENABLE,
         CA_VER_NUM NUMBER(4,2) NOT NULL ENABLE,
         BRWR_SHORT_NAME VARCHAR2(25 CHAR),
         sic_code     number,
         FAC_ID VARCHAR2(10) NOT NULL ENABLE
    / insert script
    insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
    values ('CA2001/11/0002', 2.00, 'Nandu',1234, 'FA000008');
    insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
    values ('CA2001/11/0002', 3.00, 'SHIJU',456, 'FA000008');Desired O/P :
    ca_id               fac_id          column_name          previous name          after_modification
    CA2001/11/0002          FA000008     BRWR_SHORT_NAME          Nandu               SHIJU
    CA2001/11/0002          FA000008     sic_code          1234               456My approach
    select      ca_id,fac_id,column_name,
         decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
         decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
    from
         select
                   case
                        when ld_brwr != lg_brwr then
                        'BRWR_SHORT_NAME'
                        when ld_brwr != lg_brwr then
                        'sic_code'
                   end
              ) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
         from     (
              select ca_id,fac_id,lag_brwr,ld_brwr,ld_sic,lag_sic
              from
                        Select      lead(brwr_short_name,1) over(partition by ca_id,fac_id) ld_brwr,
                             lag(brwr_short_name,1) over(partition by ca_id,fac_id) lg_brwr,
                             lead(sic_code,1) over(partition by ca_id,fac_id) ld_sic,
                             lag(sic_code,1) over(partition by ca_id,fac_id) lg_sic,
                             ca_id,fac_id
                        from r_dummy
              where (ld_brwr != lg_brwr or ld_sic != lg_sic)
    )2nd Approach :
    =============
    select      ca_id,fac_id,column_name,
         decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
         decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
    from
         select
                   case
                        when ld_brwr != lg_brwr then
                        'BRWR_SHORT_NAME'
                        when ld_brwr != lg_brwr then
                        'sic_code'
                   end
              ) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
         from     (
              select ca_id,fac_id,brwr_short_name,sic_code
              from
                        Select      ca_id,fac_id,brwr_short_name lg_brwr,sic_code lg_sic
                        from     r_dummy
                        where     ca_ver_num = '2.00'
                   )o,(
                        Select      ca_id,fac_id,brwr_short_name ld_brwr,sic_code ld_sic
                        from     r_dummy
                        where     ca_ver_num = '3.00'
                              )n
              where      0.ca_id = n.ca_id
                   and 0.fac_id = n.fac_id
                   and (ld_brwr != lg_brwr or ld_sic != lg_sic)
    )Hi Experts,
         I've provided sample data where I'm checking for just two columns viz brwr_short_name ,sic_code,but in real time
    I've to check for 8 more columns so please suggest me with a better approach.
    I appreciate your precious suggestions.

    Hi,
    Thanks for posting the CREATE TABLE and INSERT statements; that really helps!
    Here's one wa. Like your 2nd approach, this uses a self-join:
    WITH     got_r_num     AS
         SELECT  ca_id
         ,     ROW_NUMBER () OVER ( PARTITION BY  ca_id
                                   ,                    fac_id
                             ORDER BY        ca_ver_num
                                 )    AS r_num
         ,     brwr_short_name
         ,     TO_CHAR (sic_code)     AS sic_code
         ,     fac_id
    --     ,     ...     -- Other columns (using TO_CHAR if needed)
         FROM     r_dummy
    ,     unpivoted_data     AS
         SELECT     *
         FROM     got_r_num
         UNPIVOT     INCLUDE NULLS
              (    txt
              FOR  column_name IN ( brwr_short_name          AS 'BRWR_SHORT_NAME'
                            , sic_code               AS 'SIC_CODE'
    --                        , ...     -- Other columns
    SELECT       p.ca_id
    ,       p.fac_id
    ,       p.column_name
    ,       p.txt          AS previous_name
    ,       a.txt          AS after_modification
    FROM       unpivoted_data   p
    JOIN       unpivoted_data   a  ON  p.ca_id     = a.ca_id
                           AND p.fac_id     = a.fac_id
                         AND p.column_name     = a.column_name
                         AND p.r_num      = a.r_num - 1
                         AND p.txt || 'X' != a.txt || 'X'
    ORDER BY  a.r_num
    ;To include other columns, add them in the 2 places where I put the comment "Other columns".
    Ca_ver_num can have any values, not just 2.00 and 3.00.
    This will show cases where a value in one of the columns changed to NULL, or where NULL changed to a value.
    There ought to be a way to do this without a separate sub-query like got_r_num. According to the SQL Language manual, you can put expressions in the UPIVOT ... IN list, but when I tried
    ...     UNPIVOT     INCLUDE NULLS
              (    txt
              FOR  column_name IN ( brwr_short_name          AS 'BRWR_SHORT_NAME'
                                 , TO_CHAR (sic_code)     AS 'SIC_CODE'
              )I got the error "ORA_00917: missing comma" right after TO_CHAR. Perhaps someone else can show how to eliminate one of the sub-queries.

  • MB5B Report table for Open and Closing stock on date wise

    Hi Frds,
    I am trying get values of Open and Closing stock on date wise form the Table MARD and MBEW -Material Valuation but it does not match with MB5B reports,
    Could anyone suggest correct table to fetch the values Open and Closing stock on date wise for MB5B reports.
    Thanks
    Mohan M

    Hi,
    Please check the below links...
    Query for Opening And  Closing Stock
    Inventory Opening and Closing Stock
    open stock and closing stock
    Kuber

  • Open and closed invoices

    hi experts,
    I have to capture the parked, open and closed invoices in a report in reference to vendor...
    I got the parked invoice condition from the table BSTAT either v or w.
    But i am not getting the idea how to capture the open and closed invoices...
    Some one suggested me to use the ITEMSET structure but i donno how to capture those values can anyone suggest me how to do it...?
    SIRI

    Hi,
    you can use the same query...Also check the new code after the select..
    SELECT BUKRS BELNR GJAHR <b>BSTAT</b>
    FROM BKPF
    INTO TABLE T_BKPF
    WHERE BUKRS = P_BUKRS
    AND BSTAT IN ( ' ' , 'A' ) " ' ' - Normal document, A - Parked doc
    AND BLART = P_BLART
    AND CPUDT IN SO_CPUDT " Selection screen input.
    IF NOT T_BKPF[] IS INITIAL.
    SELECT BUKRS BELNR GJAHR BUZEI EBELN AUGBL AUGBT
    INTO TABLE T_BSEG
    FOR ALL ENTRIES IN T_BKPF
    WHERE BUKRS = T_BKPF-BUKRS
    AND BELNR = T_BKPF-BELNR
    AND GJAHR = T_BKPF-GJAHR
    AND EBELN IN SO_EBELN " selection-screen input
    ENDIF.
    LOOP AT T_BKPF.
    Parked
      IF T_BKPF-BSTAT = 'A'.
        WRITE: / T_BKPF-BELNR , ' - Parked'.
    process the next record.
        CONTINUE.
      ENDIF.
    Check for Open / Closed.
      LOOP AT T_BSEG WHERE BELNR = T_BKPF-BELNR
                                   AND      BUKRS = T_BKPF-BUKRS
                                   AND      GJAHR = T_BKPF-GJAHR
                                   AND      AUGBL <> ' '.
        EXIT.
      ENDLOOP.
    If the return code is 0 then the document is cleared..
      IF sy-subrc = 0.
        WRITE: / T_BKPF-BELNR , ' - Closed'.
    Else the document is not cleared.
      ELSE.
        WRITE: / T_BKPF-BELNR , ' - Open'.
      ENDIF.
    ENDLOOP.
    Thanks,
    Naren

  • 7344 servo motion switching between open and closed loop operation

    I have a custom end-of-line test system presently using a 4-axis 7344 servo controller to perform various functional tests on small, brushed DC motors. The system is programmed in C/C++ and uses flex motion functions to control the motor during testing. Motors are coupled to external encoder feedback and third party PWM drives running in closed-loop torque mode from an analog command signal. The system uses all four motion axis channels on the 7344 board to independently and asynchronously test up to four production motors at a time.
    In closed-loop mode, the system runs without issue, satisfying the battery of testing protocols executed by this system. I now have a request to add additional test functionality to the system. This testing must be run in open loop mode. Specifically, I need to use my +/- 10v analog output command to my torque drive to send different DAC output levels to the connected motor.drive while monitoring response.
    I do not believe the flex motion library or 7344 controller includes functions to easily switch between open and closed loop mode without sending a new drive configuration. I am also under the impression that I cannot reconfigure one (or more) servo controller axis channels without disabling the entire drive. As my system runs each axis channel in an asynchronous manner, any requirement to shutdown all drives each time I change modes is an unworkable solution.
    I am open to all ideas that will allow asynchronous operation of my 4 motor testing stations. If the only solution is to add a second 7344 controller and mechanical relays to switch the drive and motor wiring between two separately configured servo channels, so be it. I just want to explore any available avenue before I place a price tag on this new system requirement.
    Bob

    Jochen,
    Thank you for the quick response. The 7344 board does an excellent job running my manufacturing motor assemblies through a custom end-of-line tester in closed loop mode. A portion of the performance history and test result couples the motor through a mechanical load and external shaft. The shaft is in contact with a linear encoder that closes my servo loop.
    My new manufacturing requirement is to also sample/document how the small DC motor behaves in open loop operation. Your solution is exactly what I need to perform the additional functional tests on the product I am manufacturing. I see no reason why this cannot work. I was originally concerned that I would need to reinitialize the 7344 board after changing axis configuration. Initialization is a global event and impacts all four channels on the 7344 board.
    Using flex_config_axis() to change axis configuration on a single channel without disturbing other potentially running axis channels will solve my concern. It will be several weeks before I can return to the manufacturing facility where the 7344-based testing machine is located. I will update this thread once I verify a successful result.
    Bob

  • COPA reporting with open and closed projects

    Dear All,
    I am designing a COPA solution for an infrastructure providing company using project systems and posting to/settling out of projects on a monthly basis. Projects run for long periods and continually incurr costs and earn revenue untill they are closed. The requirement is to report by common characteristics (say customer group) and separately for open and closed projects. My issue is how to separate the line items of projects where status changed to closed (having posted with the status REL previously), from the open ones, without entering the projects individually in the selections screen.
    Any ideas will be greatly appreciated.
    Thanks,
    Maddy

    Dear Satya,
    http://help.sap.com/saphelp_erp2005/helpdata/en/75/ee0bbd55c811d189900000e8322d00/content.htm
    An item of a purchase requisition is only regarded as Closed if the requested order quantity has been included in a purchase order.
    You can also set an item to Closed manually. <b>This item will then not be taken into account by the materials planning and control system.</b>
    You can set the Closed indicator manually at the following points (it can later be cancelled if necessary):
    When changing a purchase requisition, on the item detail screen
    When creating a purchase order referencing a requisition, on the item detail screen of the PO
    You can still create purchase orders by referencing a requisition if this indicator has been set in the requisition concerned.
    The indicator can also be set in the case of automatic PO generation from purchase requisitions. On the initial screen of the requisition, you can specify that the requisition is to count as closed as soon as an associated purchase order has been generated, even if the complete quantity requested has not been ordered, for example (Set reqs. to "closed" indicator).
    Analyses of Purchase Requisitions:
    http://help.sap.com/saphelp_erp2005/helpdata/en/75/ee1fa755c811d189900000e8322d00/frameset.htm (visit section under Reporting in Purchasing)
    Hope this will help.
    Regards,
    Naveen.

  • Open and closed cursor

    I have some doubts/questions .
    What is the difference between open and closed cursor?
    Are library cache locks same as parse locks?
    What is the difference between latch and mutex?
    I would be grateful if experts could answer these questions.
    Regards

    Almost correct. The terminology is however nor correct.
    Simplistically:
    The SQL engine receives a SQL. It attempts a soft parse first. This means looking for an existing cursor in the Shared Pool with the same SQL. This existing cursor can be in use by other sessions. It does not matter - if that cursor is in used (opend by other sessions), or not. It may not be in use at all and simply sitting there in the cache. If such a cursor is found, it is used for that session's SQL - and that session gets a cursor handle (reference/pointer) to that existing cursor.
    If the SQL engine does not find an existing cursor to use, it needs to create a brand new cursor in the Shared Pool. This is a hard parse. Again, the session receives a cursor handle for that new cursor created.
    And that is it.
    You now need to decide how to use that cursor handle. The cursor itself is a program. You have a handle to execute that cursor program. Via its bind interface you can input data to this cursor program. Then execute it and receive (fetch) output of that cursor program.
    So the ideal is to re-use the cursor handle again and again.
    Basic example: the following is not optimal as the same cursor is opened and closed, opened and closed, for each read from the file. A lot of soft parsing results.
    while not-eof( filehandle )   // read data from a file
      read file data into var1, var2
      open cursor for 'insert into testtab values( :1, :2)'   // create a cursor
      bind cursor :1 = var, :2 = var2  // bind values to cursor (for insert)
      exec cursor // do SQL insert
      close cursor 
    end whileThis is a lot better. A single cursor is used and executed again and again:
    open cursor for 'insert into testtab values( :1, :2)'   // create a cursor
    while not-eof( filehandle )   // read data from a file
      read file data into var1, var2
      bind cursor :1 = var, :2 = var2  // bind values to cursor (for insert)
      exec cursor // do SQL insert
    end while
    close cursor  In this case a single soft/hard parse - and the client uses that cursor handle to execute that cursor (insert data) program again and again.

  • GL a/c opening and closing balances

    Hi All,
    Below is my selection screen:
    select-options : s_bukrs for bkpf-bukrs obligatory.
    parameter      :  p_gjahr like bkpf-gjahr obligatory.
    select-options : s_budat for bkpf-budat,
                           s_monat for bkpf-monat,
                           s_hkont for bseg-hkont.
    I am displaying the data from tables BKPF, BSEG, KNA1-NAME1, LFA1-NAME1, SKAT-TXT50. I have to fetch Opening and Closing balances for GL a/c's. I am fetching data from table GLT0-HSLVT(opening balance). But unable to get the data for closing balance based on the period given on the selection screen. In my report I am looping on table it_bseg to populate the final internal table. How to get the closing balances's total based on the input.
    Please help me.
    Thanks,
    Haritha

    Hello Haritha,
                        Try this code by building a function module. This would cover both opening and closing balance.
    FUNCTION ZGL_OPENING_CLOSING_BAL_KEYDAT.
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(COMP) TYPE  BKPF-BUKRS
    *"     REFERENCE(DATE) TYPE  BKPF-BUDAT
    *"     REFERENCE(ACCT) TYPE  BSEG-HKONT
    *"  EXPORTING
    *"     REFERENCE(BALANCE) TYPE  BSEG-DMBTR
    DATA : COMPANYCODEID  LIKE  BAPI0002_2-COMP_CODE     ,
    POSTING_DATE   LIKE  BAPI0002_4-POSTING_DATE  ,
    FISCAL_YEAR    LIKE  BAPI0002_4-FISCAL_YEAR   ,
    FISCAL_PERIOD  LIKE  BAPI0002_4-FISCAL_PERIOD .
    DATA : ACCOUNT_BALANCES  TYPE TABLE OF BAPI3006_4 WITH HEADER LINE.
    DATA : BAL TYPE BSEG-DMBTR.
    DATA : IV_DATE  TYPE  D   ,
    EV_MONTH_BEGIN_DATE  TYPE  D,
    EV_MONTH_END_DATE  TYPE  D .
    DATA : COMPANYCODE  LIKE  BAPI3006_0-COMP_CODE,
    GLACCT  LIKE  BAPI3006_0-GL_ACCOUNT ,
    FISCALYEAR  LIKE  BAPI3006_4-FISC_YEAR,
    CURRENCYTYPE  LIKE  BAPI3006_5-CURR_TYPE VALUE 10.
    DATA : IT_BKPF TYPE TABLE OF BKPF WITH HEADER LINE.
    DATA : BEGIN OF IT_BSEG OCCURS 0,
    BELNR TYPE BSEG-BELNR,
    GJAHR TYPE BSEG-GJAHR,
    SHKZG TYPE BSEG-SHKZG  ,
    DMBTR TYPE BSEG-DMBTR,
    END OF IT_BSEG.
    COMPANYCODEID = COMP.
    POSTING_DATE = DATE.
    IV_DATE  = DATE.
    CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
    EXPORTING
    IV_DATE             = IV_DATE
    IMPORTING
    EV_MONTH_BEGIN_DATE = EV_MONTH_BEGIN_DATE
    EV_MONTH_END_DATE   = EV_MONTH_END_DATE.
    CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
    EXPORTING
    COMPANYCODEID = COMPANYCODEID
    POSTING_DATE  = POSTING_DATE
    IMPORTING
    FISCAL_YEAR   = FISCAL_YEAR
    FISCAL_PERIOD = FISCAL_PERIOD.
    IF EV_MONTH_END_DATE NE DATE.
    IF FISCAL_PERIOD = 1.
    FISCAL_PERIOD = 12              .
    FISCAL_YEAR = FISCAL_YEAR - 1  .
    ELSE.
    FISCAL_PERIOD =  FISCAL_PERIOD - 1.
    ENDIF.
    ENDIF.
    COMPANYCODE  =  COMP.
    GLACCT  = ACCT.
    FISCALYEAR  = FISCAL_YEAR.
    CALL FUNCTION 'BAPI_GL_ACC_GETPERIODBALANCES'
    EXPORTING
    COMPANYCODE      = COMPANYCODE
    GLACCT           = GLACCT
    FISCALYEAR       = FISCALYEAR
    CURRENCYTYPE     = CURRENCYTYPE
    TABLES
    ACCOUNT_BALANCES = ACCOUNT_BALANCES.
    READ TABLE ACCOUNT_BALANCES  WITH KEY FISC_YEAR = FISCALYEAR FIS_PERIOD = FISCAL_PERIOD.
    IF SY-SUBRC = 0.
    BALANCE =  ACCOUNT_BALANCES-BALANCE.
    ENDIF.
    IF EV_MONTH_END_DATE NE DATE.
    SELECT * FROM BKPF INTO TABLE IT_BKPF WHERE BUKRS = COMP AND BUDAT >= EV_MONTH_BEGIN_DATE
    AND BUDAT <= DATE.
    IF IT_BKPF[] IS NOT INITIAL.
    SELECT BELNR GJAHR SHKZG DMBTR
    FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
    FOR ALL ENTRIES IN IT_BKPF
    WHERE BELNR = IT_BKPF-BELNR AND GJAHR = IT_BKPF-GJAHR AND HKONT = ACCT AND BUKRS = COMP.
    ENDIF.
    LOOP AT IT_BSEG.
    IF IT_BSEG-SHKZG = 'H'.
    BAL = BAL - IT_BSEG-DMBTR.
    ELSEIF IT_BSEG-SHKZG = 'S'.
    BAL = BAL + IT_BSEG-DMBTR.
    ENDIF.
    ENDLOOP.
    BALANCE = BALANCE + BAL.
    ENDIF.
    ENDFUNCTION.
    Raghav

  • Customer Statement with opening and closing balances

    Dear Forum,
    The users want to generate the Customer Statement with opening and closing balances like the traditional one. The statement now generated gives the list of all open items as on date, but the users want the statement with opening balances as on the date of the begining of the range specified and the closing balance at the end of the period for which the statement is generated. Is there a way to generate the same from the system.
    Thanks for the help.
    Regards,

    Hi,
    SPRO> Financial Accounting (New) > Accounts Receivable and Accounts Payable > Customer Accounts > Line Items > Correspondence > Make and Check Settings for Correspondence
    You can use the program RFKORD10 with correspondance type SAP06 for your company code
    This program prints account statements and open items lists for customers and vendors in letter form. For account statements, all postings between two key dates, as well as the opening and closing balance, are listed.
    Regards,
    Gaurav

Maybe you are looking for

  • Firefox 4.0 keeps locking up and is slow to load pages

    I just installed 4.0 this morning. Ever since, Hotmail is extremely slow to load, it keeps locking up or not responding. I thought this was supposed to be faster and more streamlined? Now, when I try to go back and install 3.6.13 it is no longer avai

  • Dacf; imageControl; doesn't save

    JDEV 3.2/JDK 1.3 I set up a table in the database, with a nice LONG RAW column. I hooked in an entity object, a view object and a rowsetinfo. Cool. Set up a frame with a imagecontrol mapped to the rowsetinfo attribute (LONGVARBINARY). Executed it...

  • Content Server not working after 5.0.2 upgrade

    We upgraded the plumtree to 5.0.2. After upgrade, content server portlets not working properly. When I publish my portlet, Interface says it is published, HTML file generated at the published location, but log says com.plumtree.search.UnknownTypeExce

  • Bug Check error on an Exchange server running on top of server 2012

    The computer has rebooted from a bugcheck.  The bugcheck was: 0x00000133 (0x0000000000000000, 0x0000000000000504, 0x0000000000000503, 0x0000000000000000). A dump was saved in: C:\Windows\MEMORY.DMP. Report Id: 041514-30186-01.

  • Export Process from BPM Stuido 10g

    The process can be exported from Studio manually. Does anyone know how to write the code (PBL or Java) to export the process? Or the API of connecting BPM Studio. Sincerely