‎2007 Dec 07 3:57 PM
have created a ztable with the fields same as my selection screen fields. i need to populate my ztable the data which i am giving in the selection screen when i execute the program.(only the values which are given in the selectionscreen)
types: begin of ty_data2,
ryear like zupi5t-ryear, "Fiscal year
rbukrs like zupi5t-rbukrs, "Company code
racct like zupi5t-racct, "Account number
rzzps_posid like zupi5t-rzzps_posid, "WBS element
end of ty_data2.
types: begin of ty_final1,
ryear like zupi5t-ryear, "Fiscal year
rbukrs like zupi5t-rbukrs, "Company code
racct like zupi5t-racct, "Account number
rzzps_posid like zupi5t-rzzps_posid, "WBS element
end of ty_final1.
data: i_data2 type standard table of ty_data2,
i_final1 type standard table of ty_final1,
wa_data2 type ty_data2,
wa_final1 type ty_final1.
parameters:
p_ryear like zupi5t-ryear obligatory. "Fiscal year
select-options:
s_rpmax for zupi5t-rpmax obligatory no-extension. "Period
s_racct for zupi5t-racct obligatory, "Account number
s_rzzps for zupi5t-rzzps_posid obligatory no intervals, "WBS Element
select ryear rbukrs racct rzzps_posid
from zupi5a
into table i_data2
where ryear = p_ryear
and POPER in s_rpmax
and rbukrs = p_rbukrs
and racct in s_racct
and rzzps_posid in s_rzzps.
loop at i_data2 into wa_data2.
wa_final1-ryear = wa_data2-ryear.
wa_final1-rbukrs = wa_data2-rbukrs.
wa_final1-racct = wa_data2-racct.
wa_final1-rzzps_posid = wa_data2-rzzps_posid.
append wa_final1 to i_final1.
clear : wa_final1-ryear,
wa_final1-rbukrs, wa_final-racct,
wa_final1-rzzps_posid.
loop at i_final1 into wa_final1.
STATICS v_cnt(5) type n.
clear zfirestate_log.
v_cnt = v_cnt + 1.
move v_cnt to zfirestate_log-cnt.
move wa_final1-ryear to zfirestate_log-ryear.
move wa_final1-rbukrs to zfirestate_log-rbukrs.
move wa_final1-rzzps_posid to zfirestate_log-rzzps_posid.
move s_rpmax-low to zfirestate_log-from_period.
move s_rpmax-high to zfirestate_log-to_period.
move s_racct-low to zfirestate_log-from_acct.
move s_racct-high to zfirestate_log-to_acct.
insert zfirestate_log.
clear wa_final1.
endoop .
i written the above code . i dont know whether to write this select query or not because i need to populate the table only with the data given in the selection scrren. problem is i am getting duplicate entries in the ztable which i dont want .please help me i need this very urgently.
‎2007 Dec 07 4:24 PM
hi Ramya
Declare a structure like the table u want to update, and use modify statement to update ur Z table.
modify Z*#^% from Itab.
Itab will have the data u wanted to update.... U can use index to place data in a specific location.
Reward points if u think usefull...
Regards
jackandjay
‎2007 Dec 07 4:35 PM
Hi,
You have mentioned a different Ztable to select data in the select statement.
To reduce the duplicate entries you can try any of the following:
1. Use the primary keys.
2. You can sort the internal table using the primary keys. Then you can delete the duplicate entries using the following command.
DELETE ADJACENT DUPLICATES FROM itab
[COMPARING { comp1 comp2 ...}|{ALL FIELDS}]... .
This will delete the duplicated entries in your internal table.
Thanks,
Samantak.
<b>Rewards points for useful answer.</b>
‎2007 Dec 10 5:12 AM