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

Facing problem in smartforms. ( Getting Values from Internal Table)

Former Member
0 Likes
641

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
521

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

4 REPLIES 4
Read only

Former Member
0 Likes
521

Give mytable in the Input parameters of the program lines.

Edited by: Reshma R on Feb 14, 2010 12:31 PM

Read only

0 Likes
521

it gives the following error

Field " MYTABLE" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .

Read only

Former Member
0 Likes
522

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

Read only

Former Member
0 Likes
521

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.