‎2010 Feb 14 6:43 AM
Dear gurus
I have written a code in smartform using flowlogic -> program lines.
below is the following code.
data: begin of mytable occurs 0,
ktart type pa2006-ktart,
anzhl type pa2006-anzhl,
kverb type pa2006-kverb,
balance type pa2006-kverb,
ktext type t556b-ktext,
designation type c length 40,
end of mytable.year = wa_employee-key-begda+0(4).
call function 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
exporting
i_gjahr = year
i_periv = 'C1'
importing
e_first_day = fday
e_last_day = lday.select *
from pa2006 into corresponding fields of table mytable
where pernr eq wa_employee-key-personnel_number
and begda between fday and lday."date-low AND date-high.
loop at mytable.
select ktext
from t556b into mytable-ktext
where ktart eq mytable-ktart
and sprsl eq 'EN'
and mozko eq 90.
endselect.
mytable-balance = mytable-anzhl - mytable-kverb.
mytable-designation = desig.
modify mytable.
endloop.Problem im facing is that i want to fetch balances of leaves
1) Annual
2) Casual
3) Medical
having ktart 91 , 92 , 93 respectively.
I want to display these leaves in text field . when i write &mytable-balance& it gives error. saying mytable is not defined.
please guide me
regards
Saad Nisar.
‎2010 Feb 14 8:12 AM
Hi,
I think you are declared mytable in program Line. Text feild not called in program line data declaration type.
First u declared mytable in Global defination.
Types:-
Types: begin of Wa_table,
ktart type pa2006-ktart,
anzhl type pa2006-anzhl,
kverb type pa2006-kverb,
balance type pa2006-kverb,
ktext type t556b-ktext,
designation type c length 40,
end of Wa_table,
TA_table TYPE TABLE OF Wa_tablel.
Global Data:-
mytable type TA_table
Pass the mytable (Input parameters & Output parameters) both in Program line.
Thanks & Regards
Rahul Ghosh
‎2010 Feb 14 7:01 AM
Give mytable in the Input parameters of the program lines.
Edited by: Reshma R on Feb 14, 2010 12:31 PM
‎2010 Feb 14 7:36 AM
it gives the following error
Field " MYTABLE" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .
‎2010 Feb 14 8:12 AM
Hi,
I think you are declared mytable in program Line. Text feild not called in program line data declaration type.
First u declared mytable in Global defination.
Types:-
Types: begin of Wa_table,
ktart type pa2006-ktart,
anzhl type pa2006-anzhl,
kverb type pa2006-kverb,
balance type pa2006-kverb,
ktext type t556b-ktext,
designation type c length 40,
end of Wa_table,
TA_table TYPE TABLE OF Wa_tablel.
Global Data:-
mytable type TA_table
Pass the mytable (Input parameters & Output parameters) both in Program line.
Thanks & Regards
Rahul Ghosh
‎2010 Feb 14 3:42 PM
Hi Saad Nisar,
am glad that you have got your query answered.
Just a little note on your code for a good programming practice.
for these lines of your code below.
select *
from pa2006 into corresponding fields of table mytable
where pernr eq wa_employee-key-personnel_number
and begda between fday and lday."date-low AND date-high.
loop at mytable.
select ktext
from t556b into mytable-ktext
where ktart eq mytable-ktart
and sprsl eq 'EN'
and mozko eq 90.
endselect.
mytable-balance = mytable-anzhl - mytable-kverb.
mytable-designation = desig.
modify mytable.
endloop.1.Avoid using Select *
2. DO NOT USE select inside loop.
Instead do a select into an internal table outside the loop , then use read table inside the loop.
Regards,
SuryaD.