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

How to pass a ABAP dictionary table to sub program?

Former Member
0 Likes
686

I need update 15 ABAP dictionary tables.

I would like use PERFORM pass the table name with other value, then use FORM to UPDATE the different tables.

How do I code?

perform 6400_update_table using ztfkreg

lw_kreg

g_cnt_kreg_11.

FORM 6400_update_table X

lw_x

l-y TYPE c.

INSERT X FROM lw_x.

IF sy-subrc <> 0.

UPDATE X FROM lw_x.

ENDIF.

l_y = 'Y'.

ENDFORM.

*ztfkreg is the table name.

  • lw_kreg is the content going to update the table

I got syntax error.

Thanks,

Helen

1 ACCEPTED SOLUTION
Read only

learnsap
Active Participant
0 Likes
654

Hi Helen,

The syntax for the Insert statement if you have a table name in the variable is

X = 'MARA'.

Insert into (X) value <Source>.

Similarly update also

Update (X) <Source>.

Or Make use of field symbols for capturing the table name and values to be inserted.

Also specify the syntax error.

Regards,

Ramesh

Edited by: Ramesh Babu Srikakollu on Dec 17, 2008 9:44 AM

I need update 15 ABAP dictionary tables.

I would like use PERFORM pass the table name with other value, then use FORM to UPDATE the different tables.

How do I code?

perform 6400_update_table using ztfkreg

lw_kreg

g_cnt_kreg_11.

FORM 6400_update_table X

lw_x

l-y TYPE c.

INSERT X FROM lw_x.

IF sy-subrc <> 0.

UPDATE X FROM lw_x.

ENDIF.

l_y = 'Y'.

ENDFORM.

*ztfkreg is the table name.

  • lw_kreg is the content going to update the table

I got syntax error.

Thanks,

Helen

4 REPLIES 4
Read only

Former Member
0 Likes
654

You can use field-symbols to update certain fields of the tabe dynamically.

Thanks

Nidhi

Read only

0 Likes
654

Not sure how to use the field-symbol. How do you pass down to the subprogram?

Thanks,

Helen

Read only

learnsap
Active Participant
0 Likes
655

Hi Helen,

The syntax for the Insert statement if you have a table name in the variable is

X = 'MARA'.

Insert into (X) value <Source>.

Similarly update also

Update (X) <Source>.

Or Make use of field symbols for capturing the table name and values to be inserted.

Also specify the syntax error.

Regards,

Ramesh

Edited by: Ramesh Babu Srikakollu on Dec 17, 2008 9:44 AM

Read only

Former Member
0 Likes
654

It's great to know that I can pass the table name via variable name.

How about the <source>? How to pass the <source> structure?

For example: the the <source> => lw_kreg : each time is defferent.

Per your help, here is my new codes:

perform 6400_update_table using p_tname lw_kreg .

FORM 6400_update_table using p_tname lw_kreg.

DATA: l_count(6) TYPE n.

DELETE FROM (p_tname).

IF sy-subrc = 0.

WRITE:/ 'Empty ztfkreg successfully'.

COMMIT WORK.

ENDIF.

INSERT (p_tname) FROM lw_kreg.

IF sy-subrc <> 0.

UPDATE (p_tname) FROM lw_kreg.

g_success_lines = g_success_lines + 1.

ENDIF

ENDFORM. " 6400_update_table