Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

doubts in query ..

Former Member
0 Likes
753

Hi Genius,

I have a doupts in Report..

<b> budat = 01.04.2007 to 30.04.2007</b>

<b> matnr = a001</b>

SELECT * FROM zs_mkpf_mseg

into corresponding fields of table it_opbal

WHERE werks = itmat-werks

AND matnr = itmat-matnr

AND budat LT s_budat-low.

Now iam getting the opening balance..that is the closing balance of up to

30-3-2007.

My req is..between 1st month to 30th, i have to calculate the opbal of every day wise(1-4-07 to 30-4-07) for that how i should write the query statement.

please suggest me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
724

Just add moving balance to open balance.

For example:


DATA: balance type <the data type>.
LOOP AT it_opbal ASSIGNING <fs>.
  IF sy-tabix = 1.
     <fs>-opbal = <closing balance from previous period>.
  ELSE.
     READ TABLE it_opbal INTO wa_temp INDEX sy-tabix - 1.
      <fs>-opbal = wa_temp-opbal + wa_temp-movbal.
      sy-tabix = sy-tabix + 1. "To revert the index to actual position
ENDLOOP.

Hope it'll work.

Hi Genius,

I have a doupts in Report..

<b> budat = 01.04.2007 to 30.04.2007</b>

<b> matnr = a001</b>

SELECT * FROM zs_mkpf_mseg

into corresponding fields of table it_opbal

WHERE werks = itmat-werks

AND matnr = itmat-matnr

AND budat LT s_budat-low.

Now iam getting the opening balance..that is the closing balance of up to

30-3-2007.

My req is..between 1st month to 30th, i have to calculate the opbal of every day wise(1-4-07 to 30-4-07) for that how i should write the query statement.

please suggest me.

4 REPLIES 4
Read only

Former Member
0 Likes
724

Hi,

Please Check the change in bold.

SELECT * FROM zs_mkpf_mseg

into corresponding fields of table it_opbal

WHERE werks = itmat-werks

AND matnr = itmat-matnr

AND budat <b>IN s_budat</b>.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

Former Member
0 Likes
725

Just add moving balance to open balance.

For example:


DATA: balance type <the data type>.
LOOP AT it_opbal ASSIGNING <fs>.
  IF sy-tabix = 1.
     <fs>-opbal = <closing balance from previous period>.
  ELSE.
     READ TABLE it_opbal INTO wa_temp INDEX sy-tabix - 1.
      <fs>-opbal = wa_temp-opbal + wa_temp-movbal.
      sy-tabix = sy-tabix + 1. "To revert the index to actual position
ENDLOOP.

Hope it'll work.

Read only

0 Likes
724

hi first i have to calculate the opbal of 01-04-07 to 30-04-07.(00-00-0000 to 30-03-2007).

Now the opening balance for 01-04-07 is calculated..Again I want to calculate the opening balance of between<b> 01-04-2007 to 30-04-2007.</b>. please guide me.

Read only

0 Likes
724

Hi



SELECT gjahr belnr  FROM bseg
                    into corresponding fields of table int_bseg
                    WHERE werks =  itmat-werks
                    AND budat = s_budat-low.


loop at int_BSEG.<-- loop at ur date declared internal table

read table int_bseg WITH KEY BELNR = INT_BSEG-BELNR
        GJAHR = INT_BSEG-GJAHR. <-- to read the same internal table 

IF int_bseg-belnr = 'compare value'.
        total = total + int_bseg-belnr. " here goes ur coding part for date "
.......................



try like thi s

Reward all helpfull answers

Regards

Pavan