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: 

Problem with accesing table field in subroutine

Former Member
0 Kudos

Hello All,

I am calling a subroutine multiple times and everytine passing 2 different tables (with different structures) int he subroutine.

PERFORM fill_itabs TABLES t_adnat_bus_in

gt_adnat_bus_in_dummy

USING p_filename..

.

.

.

PERFORM fill_itabs TABLES t_adcust_ban_in

gt_adcust_ban_in_dummy

USING p_filename.

.

.

The following is the subroutine definition.

FORM fill_itabs TABLES p_t_table

p_t_table_dummy

USING p_filename .

.

.

p_t_table_dummy[] = p_t_table[].

SORT p_t_table_dummy BY cust_id.

.

.

ENDFORM.

I am getting a syntax error which states -

<u><b>"The specified type has no structure and therefore no component called "cust_id"."</b></u>

The problem is the structure of the table passed to subroutine is different in the

different times when it is called and so in subroutine defintion I cannot mention an explicit structure for the table.

Could anyone please suggest how to avoid this?

Regards,

Indrajit.

1 REPLY 1

Former Member
0 Kudos

Hi Indrajit,

you can add one more formal parameter to the subroutine, which will act as a flag.

while calling the subroutine, you can set the flag if cust_id field is there in the structure of the table, else dont set the flag.

And in the the subroutine, put check on the flag status before writing

p_t_table_dummy[] = p_t_table[].

SORT p_t_table_dummy BY cust_id.

Ex:

FORM fill_itabs TABLES p_t_table

p_t_table_dummy

USING p_filename

p_flag.

.

.

.

if p_flag eq 'X'.

p_t_table_dummy[] = p_t_table[].

SORT p_t_table_dummy BY cust_id.

endif.

.

.

ENDFORM.