on 10-09-2007 7:53 AM
hi,
i want to know the code for following problem,
my code gives o/p of respective closing balance of the posting dates like on 1/2/2007 closing bal for a respective g/l acc. was 1300 , on 2/2/2007 was 1500
and on 6/2/2007 was 1400, but on 3/2/2007 , 4/2/2007 and 5/2/2007 there were no transactions at all and<b> these dates do not exist in the table(database).</b>
but in my o/p of code ihave to show all these dates with the closing bal of 2/2/2007ie 1500 as between 2/2/2007 and 6/2/2007 there were no transactions.
the report is to be run monthly ie from 1/2/2007 upto 28/2/2007 if between 5/2/2007 and 28/2/2007 there is no transactions my report should show all the dates of the month and the bal of each dates should be 1400 as there was last transaction on
6/2/2007.
urgent pls help me out. if possible send me the code.
thanks
pankaj
Hi pankaj,
First fill the internal table with the dates given on the selection screen.
After getting all the dates use the internal table while fetching data from relevant
table with the addition <b>for all entries</b> .
Use the below code.
SELECT-OPTIONS: s_date FOR sy-datum.
DATA: BEGIN OF itab OCCURS 0,
date type sy-datum,
END OF itab.
loop at s_date.
IF s_date-option = 'BT' and
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL AND
NOT s_date-high IS INITIAL.
WHILE s_date-low LE s_date-high.
itab-date = s_date-low.
collect itab.
s_date-low = s_date-low + 1.
ENDWHILE.
ENDIF.
ENDIF.
IF s_date-option = 'EQ' and
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL.
LOOP AT s_date.
itab-date = s_date-low.
collect itab.
ENDLOOP.
ENDIF.
ENDIF.
endloop.
if not itab[] is initial.
sort itab by date.
endif.
loop at itab.
write:/5 itab-date.
endloop.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi abapers,
table im using is bsis.
after executing my code o/p is coming like this.
date closing balance
01.10.2007 500
02.10.2007 400
05.10.2007 900
but i have to bring in following format.
01.10.2007 500
02.10.2007 400
<b>03.10.2007 400</b>
<b>04.10.2007 400</b>
05.10.2007 900
<b>06.10.2007 900</b>
<b>07.10.2007 900</b>
<b>08.10.2007 900</b>
<b>09.10.2007 900</b>
<b>10.10.2007 900</b> upto sy-datum.
pls note dates in block letters are not present in table itself.
dont cosider the date before 01.10.2007.,
posting starts from this date onwards and to be calculated upto sy-datum.
the report will be executed monthly ie then sy-datum will be 31.10.2007
and on that also closing bal will be 900 since there is no fresh transactions
after 05.10.2007 ( suppose).
pls help me
well wishes
pankaj
hi maam
can u send me some more details, table im using is basis i am selecting hkont(g/l acc) budat and dmbtr and keeping it in an internal table say itab1.
now how i will use it in for all entries clause,
in itab all dates given from screen is coming and in itab1 only selected dates from bsis is coming.
pls help
pankaj
Hi Pankaj,
first you select <b>budat and hkont</b> from the table <b>bsis</b> into the internal table <b>it_actual</b>.
At present i have filled <b>it_actual</b> with the dates and amounts provided by you.
<b>Use the below code.</b>
SELECT-OPTIONS: s_date FOR sy-datum.
DATA:BEGIN OF it_actual OCCURS 0,
date LIKE sy-datum,
bal TYPE i,
END OF it_actual.
DATA: it_final LIKE it_actual OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF itab OCCURS 0,
date TYPE sy-datum,
END OF itab.
DATA: v_bal TYPE i.
it_actual-date = '20071001'.
it_actual-bal = 500.
APPEND it_actual.
it_actual-date = '20071002'.
it_actual-bal = 400.
APPEND it_actual.
it_actual-date = '20071005'.
it_actual-bal = 900.
APPEND it_actual.
IF NOT it_actual[] IS INITIAL.
SORT it_actual BY date.
ENDIF.
*<b>To fill the internal table with the dates given on *the selection screen use the below logic.</b>
LOOP AT s_date.
IF s_date-option = 'BT' AND
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL AND
NOT s_date-high IS INITIAL.
WHILE s_date-low LE s_date-high.
itab-date = s_date-low.
COLLECT itab.
s_date-low = s_date-low + 1.
ENDWHILE.
ENDIF.
ENDIF.
IF s_date-option = 'EQ' AND
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL.
LOOP AT s_date.
itab-date = s_date-low.
COLLECT itab.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT itab[] IS INITIAL.
SORT itab BY date.
ENDIF.
*main process starts from here
LOOP AT itab.
READ TABLE it_actual WITH KEY date = itab-date BINARY SEARCH.
IF sy-subrc = 0.
v_bal = it_actual-bal.
ENDIF.
it_final-date = itab-date.
it_final-bal = v_bal.
APPEND it_final.
CLEAR it_final.
ENDLOOP.
LOOP AT it_final.
WRITE:/5 it_final-date,
20 it_final-bal.
ENDLOOP.
hi maam,
at first thanks to u for ur code it is working well,
it is taking all the dates but there is a slight problem
when i am giving g/l acc(hkont field ) in the selection screen(ser-screen consists of
hkont and date as select-options).
01.10.2007 to 10.10.2007 all the dates are coming,,,, but for hkont-13001,01.10.2007- 06.10.2007 is coming and for g/l 13002, 07.10.2007-10.10.2007 is coming i want all dates should come for both the g/ls
well wishes to u
pankaj
Hi Pankaj,
Check the below code
SELECT-OPTIONS: s_date FOR sy-datum.
DATA:BEGIN OF it_actual OCCURS 0,
accno type i,
date LIKE sy-datum,
bal TYPE i,
END OF it_actual.
data: it_accno LIKE it_actual OCCURS 0 WITH HEADER LINE.
DATA: it_final LIKE it_actual OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF itab OCCURS 0,
date TYPE sy-datum,
END OF itab.
DATA: v_bal TYPE i.
it_actual-accno = 1.
it_actual-date = '20071001'.
it_actual-bal = 500.
APPEND it_actual.
it_actual-accno = 1.
it_actual-date = '20071002'.
it_actual-bal = 400.
APPEND it_actual.
it_actual-accno = 1.
it_actual-date = '20071005'.
it_actual-bal = 900.
APPEND it_actual.
it_actual-accno = 2.
it_actual-date = '20071003'.
it_actual-bal = 1500.
APPEND it_actual.
it_actual-accno = 2.
it_actual-date = '20071006'.
it_actual-bal = 2400.
APPEND it_actual.
it_actual-accno = 3.
it_actual-date = '20071009'.
it_actual-bal = 3900.
APPEND it_actual.
IF NOT it_actual[] IS INITIAL.
SORT it_actual BY accno date.
it_accno[] = it_actual[].
delete adjacent duplicates from it_accno comparing accno.
ENDIF.
*To fill the internal table with the dates given on *the selection screen use the below logic.
LOOP AT s_date.
IF s_date-option = 'BT' AND
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL AND
NOT s_date-high IS INITIAL.
WHILE s_date-low LE s_date-high.
itab-date = s_date-low.
COLLECT itab.
s_date-low = s_date-low + 1.
ENDWHILE.
ENDIF.
ENDIF.
IF s_date-option = 'EQ' AND
s_date-sign = 'I'.
IF NOT s_date-low IS INITIAL.
LOOP AT s_date.
itab-date = s_date-low.
COLLECT itab.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT itab[] IS INITIAL.
SORT itab BY date.
ENDIF.
*main process starts from here
loop at it_accno.
clear : it_final, v_bal.
loop at itab.
READ TABLE it_actual WITH KEY accno = it_accno-accno date = itab-date BINARY SEARCH.
IF sy-subrc = 0.
v_bal = it_actual-bal.
ENDIF.
it_final-accno = it_accno-accno.
it_final-date = itab-date.
it_final-bal = v_bal.
APPEND it_final.
CLEAR it_final.
endloop.
endloop.
LOOP AT it_final.
WRITE:/5 it_final-accno,
20 it_final-date,
40 it_final-bal.
ENDLOOP.
hi maam,
i haven't tried yet ur last code given by u..
but before that i have a query.
as i told u on 01.10.2007 bal was 500 (say) on 03.10.2007 it was 700 and after that since there were no transactions upto 31.10.2007 so upto 31.10.2007 bal will com 700. now when i m executing my reprt from 01.10. 2007 to 10.10.2007dta is coming like this
01.10.2007 500
02.10.2007 500
03.10.2007 700
04.10.2007 700
05.10.2007 700
06.10.2007 700
07.10.2007 700
08.10.2007 700
09.10.2007 700
10.10.2007 700 it is ok.
but when i m giving range from 02.10.2007 to 10.10.2007
it is coming like this
<b>02.10.2007 00</b> bal becomes 0 and not showing 500
03.10.2007 700
04.10.2007 700
05.10.2007 700
06.10.2007 700
07.10.2007 700
08.10.2007 700
09.10.2007 700
10.10.2007 700
maam can u pls send me ur mail-id so that i can interact with u.
pls help me out......if this is sort out
my problem will be solved
well wishes to u.
pankaj
first declare a varialble of type d.
eg: dat type d.
then assaign the lowest date of your selection date to thid varaible
eg: here data will be 2/2/2007.
if dat LE (max dat of the selection date)
read ur internal table with DAT.
if sy-subrc ne 0
then the date is not present in the itab.
then u can create a new row with that date .
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.