‎2009 Jul 19 7:03 PM
I have a internal table which has the following field
1) posting data
2) amount
3) account no
4) account indicator ( S for debit , H for credit)
Now I have to implement 3 logic on this internal table
first ->I have to loop on this internal table and... on change of posting date i have to add all the amount for this posting date (this amount can be both credit and debit.Debit will be with -sign and credit will be + sign).
Second -> after adding I need to check the no of record which is processed for the same posting date
if it is less than 900..
third - > I will check the amount , if the amount (ie credit + debit ) is not equal to zero, I will a balancing entry in account no 3311001 and amount will the total amount calculated with a opposite sign...so that the total becomes 0, and add this entry to internal table.
if the no of records is more than 900...then first I need to process the first 900 (by repaeting step third) record and the rest of the record for the same posting date will be processed (according to step third)
I am very confused about how to implment all 3 logic..I can use AT new posting data...sum ...endat.
but sum only calculates the numeric value of a row..I want total value of the column...and then checking for 900 records...please help..any suggestion would be helpful.
‎2009 Jul 20 12:40 AM
Hi ,
below should work .
loop at itab .
x = x + 1.
amount_tot = itab-amount + amount_tot
if x > 900 .
if amount_tot <> 0.
create docu with itab-postingdate .
clear x.
endif.
clear amount_tot.
endif.
at end posting_dt .
if amount_tot <> 0.
create document with itab-postingdate .
endif.
clear amount_tot.
clear x .
endat .
endloop.
Regards
vinay
Edited by: vinay kolla on Jul 20, 2009 1:40 AM
Edited by: vinay kolla on Jul 20, 2009 1:44 AM
‎2009 Jul 20 7:04 AM
Hi,
Check this. I am giving you a skeleton of the logic that you asked for. Work on this.
LOOP AT t_itab.
IF t_itab-acct_ind = 'S'.
s_amount = s_amount + t_itab-amount.
ELSEIF t_itab-acct_ind = 'H'.
h_amount = h_amount + t_itab-amount.
ENDIF.
tot_amount = s_amount + h_amount.
count = count + 1.
IF count EQ 900.
temp_amount = tot_amount.
" Do your logic
ENDIF.
AT END OF post_date.
IF count LE 900.
"Make an entry and add a -ve sign
ELSEIF count GT 900.
tot_amount = tot_amount-temp_amount.
"Do your logic
ENDIF.
CLEAR: s_amount,
h_amount,
count.
ENDAT.
ENDLOOP.
‎2009 Jul 20 7:27 AM
Hi,
Thanx for ur help...but you are forgetting I dont have to sum all the amount to get the net amount..rather on change of posting date..I have to check first whether the totol number of record till the new posting date is less than 900 or not
if it is less than 900 then I have to do the sum and check if the balance is zero and then add a balancing entry.
if it is more than 900, then I have to take the first 900...add and check whether balance is 0 and add a balancing entry to make the total 0 and post it and then process the remaining data in the same way.