07-12-2007 3:40 AM
Hi Experts,
I would like to create a ABAP function that can take in value and update the value into the custom database table. How do i do it? Is there any step by step procedure material?
At the end of the day, i would like create a web service of the function and allow the developer using Interactive form to pass the value into the web service and update the database table. How do i accomplish that?
Your feedback is very much appreciated. Thanks
Regards,
Rayden
07-12-2007 2:51 PM
Hi Rayden,
First it would be a good idea to create a function group at SE80, only select fuction group in the combo and define a name to it.
Then, go to SE37 and create your function.
The function, if I understood correctly, needs to receive data and input (or modify?) entries in a Z table. For this, you need to define how this data will be received and if there will be more than one entry at a time (if will receive a table or a workarea or even a sequence of entries for every field), and create the relative Importing data.
If you receive a table, just use the following code, consider E_RESULT a Exporting parameter for confirmation of the action:
INSERT (or MODIFY) dbtab FROM TABLE ITAB.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
E_RESULT = 'OK'.
ELSE.
ROLLBACK WORK.
E_RESULT = 'ER'.
ENDIF.
If you receive from a workarea consider this code:
INSERT (or MODIFY) dbtab FROM E_DATA.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
E_RESULT = 'OK'.
ELSE.
ROLLBACK WORK.
E_RESULT = 'ER'.
ENDIF.
If you receive the data from every field, you will need to create a workarea at your function and set the data you receive in the respective fields then you do the last code (above one).
Regards,
-h
07-12-2007 4:08 AM
07-12-2007 8:53 AM
Hi Bala,
Thanks for your valuable feedback. Well, do you have any code sample to supply for the above situation? Or do you have any simple material which take in a parameter and do a insert statement of data into database table and return a "Success" message as a output parameter?
Thank you very much.
Rgds
Rayden
07-12-2007 2:51 PM
Hi Rayden,
First it would be a good idea to create a function group at SE80, only select fuction group in the combo and define a name to it.
Then, go to SE37 and create your function.
The function, if I understood correctly, needs to receive data and input (or modify?) entries in a Z table. For this, you need to define how this data will be received and if there will be more than one entry at a time (if will receive a table or a workarea or even a sequence of entries for every field), and create the relative Importing data.
If you receive a table, just use the following code, consider E_RESULT a Exporting parameter for confirmation of the action:
INSERT (or MODIFY) dbtab FROM TABLE ITAB.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
E_RESULT = 'OK'.
ELSE.
ROLLBACK WORK.
E_RESULT = 'ER'.
ENDIF.
If you receive from a workarea consider this code:
INSERT (or MODIFY) dbtab FROM E_DATA.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
E_RESULT = 'OK'.
ELSE.
ROLLBACK WORK.
E_RESULT = 'ER'.
ENDIF.
If you receive the data from every field, you will need to create a workarea at your function and set the data you receive in the respective fields then you do the last code (above one).
Regards,
-h