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 create function module to update z tables?

Former Member
0 Likes
2,565

Hi,

I am new to ABAP. I checked the forum but did not find relevant solutions.

I have 2 z tables - ZFLIGHT and ZCUSTOMER. I have a few entries in each table.

I want to write a report to update the entries in the table using function modules. For that I have created a function module - zflight_fm and also a function group- zflight_fg and assigned the function group to the Fm. I do not know how to proceed further, what to put as import, export parameters, tables, changing etc. Further I want exceptions to handle the successful update of the entries.

Thanks and regards,

Smruthi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,299

Hi,

just pass the tables parameter with the respective tables....

and also pass the exceptions parameters...

with the help of the table you receive in the function module use the

insert statement to insert into database Z tables

now once this insert statement is executed

check if sy-subrc = 0.

if not then raise exception <exception_name>.

Regards,

Siddarth

Hi,

I am new to ABAP. I checked the forum but did not find relevant solutions.

I have 2 z tables - ZFLIGHT and ZCUSTOMER. I have a few entries in each table.

I want to write a report to update the entries in the table using function modules. For that I have created a function module - zflight_fm and also a function group- zflight_fg and assigned the function group to the Fm. I do not know how to proceed further, what to put as import, export parameters, tables, changing etc. Further I want exceptions to handle the successful update of the entries.

Thanks and regards,

Smruthi

4 REPLIES 4
Read only

Former Member
0 Likes
1,300

Hi,

just pass the tables parameter with the respective tables....

and also pass the exceptions parameters...

with the help of the table you receive in the function module use the

insert statement to insert into database Z tables

now once this insert statement is executed

check if sy-subrc = 0.

if not then raise exception <exception_name>.

Regards,

Siddarth

Read only

former_member203501
Active Contributor
0 Likes
1,299

hi do like this ..

first we have to know that on what condition you want to update the table fields. suppose if you are inputting 2 fields ( for the condition ) and checking them inside , then write these in the import statement . if you want only update there is no export parametes..

if p_imp1 eq '1000' and p_imp2 = 'TEST'.

update ztable set field1 = p_imp1

field2 = p_imp2.

else.

raise exception.

endif.

Read only

Former Member
0 Likes
1,299

Steps:

1) Changing --->a) Zflight TYPE ZFLIGHT(DDIC Ref) OR Zflight TYPE ANY TABLE

b) ZCustomer TYPE ZFLIGHT(DDIC Ref) OR ZCustomer TYPE ANY TABLE

2) Execptions:

a) Upload_failed_Flight

b) Upload_Failed_Customer

3) Exporting ---> a) Information what rows are uploaded

Source Code:

Insert Zflight from Zflight(changing parameter).

If insert failed

RAISE Upload_failed_Flight.

endif.

Insert ZCustomer from ZCustomer(changing parameter).

If insert failed

RAISE Upload_failed_Customer.

endif.

Regards,

Gurpreet

Read only

Former Member
0 Likes
1,299

problem solved by guide