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

problem in form-routines

Former Member
0 Likes
916

Hello ABAP gutus,

i am using 10 form-routines to get some data, in all subroutines code is same, but i am passing different internal tables to all form-routines with USING, CHANGING parameters.

for example

perform get_header1 using itab changing jtab.

perform get_header2 using itab1 changing jtab1.

FORM get_header1 USING P_ITAB

CHANGING P_JTAB.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = itab[].

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

jtab-header = lv_text.

APPEND jtab.

endloop.

endform.

FORM get_header2 USING P_ITAB

CHANGING P_JTAB.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = itab1[].

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

jtab1-header = lv_text.

APPEND jtab1.

endloop.

endform.

as above i used 10 form-routines.but i passed different internal tables.after these subrotines i am using those internal table in function modules.

now my client wants me to maintain one form-routine instead of 10 form-routines.

Is it possible that? please tell me . its urgent, Thanks in adavance.

Regards

Mahesh

Hello ABAP gutus,

i am using 10 form-routines to get some data, in all subroutines code is same, but i am passing different internal tables to all form-routines with USING, CHANGING parameters.

for example

perform get_header1 using itab changing jtab.

perform get_header2 using itab1 changing jtab1.

FORM get_header1 USING P_ITAB

CHANGING P_JTAB.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = itab[].

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

jtab-header = lv_text.

APPEND jtab.

endloop.

endform.

FORM get_header2 USING P_ITAB

CHANGING P_JTAB.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = itab1[].

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

jtab1-header = lv_text.

APPEND jtab1.

endloop.

endform.

as above i used 10 form-routines.but i passed different internal tables.after these subrotines i am using those internal table in function modules.

now my client wants me to maintain one form-routine instead of 10 form-routines.

Is it possible that? please tell me . its urgent, Thanks in adavance.

Regards

Mahesh

7 REPLIES 7
Read only

varun_maharshi
Active Participant
0 Likes
877

in the form parameters define like this

form xyz using t_table type table.

endform.

This uses the generic table type.and gets the structure of the table that you are passing at time of perform routine.

Read only

0 Likes
877

Hello Varun,

Thank you for your Quick Reply,now i am using this code

PERFORM get_header1 using itab[] changing jtab[]

PERFORM get_header1 using itab1[] changing jtab1[]

FORM get_header1 using P_TAB type any table

changing P_HEADER type any table.

data: begin of lv_tab occurs 0,

line type string,

end of lv_tab.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = p_tab.

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

lv_tab-line = lv_text.

append lv_tab.

endloop.

P_HEADER[] = lv_tab[].

ENDFORM. " get_header1

here data is coming properly to p_header[], but runtime error is coming while displaying that data.i am using GUI_DOWNLOAD to display the data.

Runtime error is ' You attempted to assign a field to a typed field symbol,

but the field does not have the required type.' please help me if you know.

Regards

Mahesh

Read only

0 Likes
877

Hi Mahesh,

Generally, in the subroutines we pass the internal tables using the following:

PERFORM get_header1 TABLES <itab1> USING <field1> CHANGING <field2>.

In the FORM, it needs to be defined like this:

FORM get_header1 TABLES itab structure <Structure Name> USING field1 CHANGING field2.

Hope this helps u.

Regards,

Himanshu

Read only

0 Likes
877

Hello Mahesh,

The syntax for a PERFORM statement is like

PERFORM form 1. ... USING p1 p2 p3 ...

2. ... CHANGING p1 p2 p3 ...

3. ... TABLES itab1 itab2 ...

and the syntax for FORM statement is

FORM form 1. ... TABLES itab1 ... itabn

2. ... USING [VALUE(p1)| p1] ... [VALUE(pn) |pn]

3. ... CHANGING [VALUE(p1(| p1] ... [VALUE(pn) |pn]

Eg: PERFORM get_supplier_list TABLES li_supplier

USING po_supp_no.

FORM get_supplier_list TABLES li_supplier STRUCTURE i_supplier

USING po_supp_no.

.....

ENDFORM. " get_supplier_list

So you have to use the TABLES when you pass the internal table using a sub routine. But the doubt i have is that why do you have to pass the internal tables to the subroutine using the PERFORM and FORM when it already is available since the internal tables you specified are global.

Thanks and Regards

Joe

Read only

0 Likes
877

Hello everyone,

thank you actually i am using FM gui_downlaod,so error is coming .

if i use cl_gui_fronted_services->gui_download, program runs correctly

Regards

Mahesh

Read only

Former Member
0 Likes
877

Mahesh,

I am not sure why you need to pass the internal tables to the subroutine. In report programs when you define an internal table in the program it becomes globally available to all forms defined in that program.

The other thing I noticed is that the code in the subroutine is identical in both your subroutines. I do not understand why you need multiple subroutines to perform the same task. How do these subroutines differ?

Can you post the entire program so that I can tell you how to go about it.

Read only

Former Member
0 Likes
877

Thank you for your Quick Reply,now i am using this code

PERFORM get_header1 using itab[] changing jtab[]

PERFORM get_header1 using itab1[] changing jtab1[]

FORM get_header1 using P_TAB type any table

changing P_HEADER type any table.

data: begin of lv_tab occurs 0,

line type string,

end of lv_tab.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = r_alvtab

CHANGING

t_table = p_tab.

CALL METHOD r_alvtab->get_columns

RECEIVING

value = r_col.

CALL METHOD r_col->get

RECEIVING

value = r_cols.

loop at r_cols into wa_col.

ref_col = wa_col-r_column.

CALL METHOD ref_col->get_medium_text

RECEIVING

value = lv_text.

lv_tab-line = lv_text.

append lv_tab.

endloop.

P_HEADER[] = lv_tab[].

ENDFORM. " get_header1

here data is coming properly to p_header[], but runtime error is coming while displaying that data.i am using GUI_DOWNLOAD to display the data.

if i use CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

program runs porfectly.

Regards

Mahesh