Application Development 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: 

Assign internal table name passed through routines

Former Member
0 Kudos

Dear experts,

How can i pass the name of P_TAB in from fieldcat_init ?.

i call the method of an object(ob) of class .

If i call debugger on p_tab in form fieldcat_init ,i can see the data.

But how to assign it

wa_fieldcat-tabname = P_TAB.

I tried this but gives me dump.




CALL METHOD OB->printalv( exporting alv_data = t_excel ).

method printalv.
perform printing tables alv_data.
endmethod.

form printing tables p_tab like t_excel.

#  PERFORM fieldcat_init tables p_tab USING gt_fieldcat .
  PERFORM eventtab_build USING gt_events[].
  PERFORM comment_build  USING gt_list_top_of_page[].
  PERFORM disp_rep tables p_tab.

endform.


FORM fieldcat_init tables p_tab USING  p_gt_fieldcat .

  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname    = 'MATNR'.
  wa_fieldcat-tabname      =  P_TAB.
  wa_fieldcat-seltext_m    = text-001  .
  wa_fieldcat-outputlen = 18.
  wa_fieldcat-emphasize    = 'C410'.
  APPEND wa_fieldcat TO it_fieldcat.
ENDFORM.

Line with # needs clarification.

Edited by: aditya sharma on Jul 22, 2010 9:49 AM

4 REPLIES 4

bbalci
Contributor
0 Kudos

Hi Aditya,

You described your "p_tab" in TABLES section

describe your form like that :

FORM fieldcat_init USING p_tab p_gt_fieldcat .

ENDFORM.

and give the name of your table to this subroutine

not the table itself :

PERFORM fieldcat_init USING 'ITAB' p_gt_fieldcat.

wrong : PERFORM fieldcat_init USING ITAB p_gt_fieldcat.

I hope it helps.

Former Member
0 Kudos

No that wont

Former Member
0 Kudos

Hi,

Look at the way you append fieldcat:


  APPEND wa_fieldcat TO it_fieldcat.

please try to append right subroutine parameter

Former Member
0 Kudos

I did by decalring thing as follows

alv_tab like (type of p_tab)

append lines of p_tab to alv_tab.

then talking only for ALV_TAB.