How to create EXCEPTION in function module
hi experts,
how to create exeptions in function module i want step by step.
regards,
chaitu
hi,
Raising Exceptions
There are two ABAP statements for raising exceptions. They can only be used in function modules:
RAISE except.
und
MESSAGE.....RAISING except.
The effect of these statements depends on whether the calling program handles the exception or not. The calling program handles an exception If the name of the except exception or OTHERS is specified after the EXCEPTION option of the CALL FUNCTION statement.
If the calling program does not handle the exception
· The RAISEstatement terminates the program and switches to debugging mode.
· The MESSAGE..... RAISING statement displays the specified message. Processing is continued in relation to the message type.
If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE..... RAISING statement does not display a message. Instead, it fills the system fields sy-msgid, sy-msgty, sy-msgno , and SY-MSGV1 to SY-MSGV4.
Source Code of READ_SPFLI_INTO_TABLE
The entire source code of READ_SPFLI_INTO_TABLE looks like this:
FUNCTION read_spfli_into_table.
""Local Interface:
*" IMPORTING
*" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '
*" EXPORTING
*" VALUE(ITAB) TYPE SPFLI_TAB
*" EXCEPTIONS
*" NOT_FOUND
SELECT * FROM spfli INTO TABLE itab WHERE carrid = id.
IF sy-subrc NE 0.
MESSAGE e007(at) RAISING not_found.
ENDIF.
ENDFUNCTION.
The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table spfli_tab. If it cannot find any entries, the exception NOT_FOUND is triggered with MESSAGE ... RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
Calling READ_SPFLI_INTO_TABLE
The following program calls the function module READ_SPFLI_INTO_TABLE:
REPORT demo_mod_tech_fb_read_spfli.
PARAMETERS carrier TYPE s_carr_id.
DATA: jtab TYPE spfli_tab,
wa LIKE LINE OF jtab.
CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
EXPORTING
id = carrier
IMPORTING
itab = jtab
EXCEPTIONS
not_found = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
WHEN 2.
MESSAGE e702(at).
ENDCASE.
LOOP AT jtab INTO wa.
WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
ENDLOOP.
The actual parameters carrier and jtab have the same data types as their corresponding interface parameters in the function module. The exception NOT_FOUND is handled in the program. It displays the same message that the function module would have displayed had it handled the error.
Hope this is helps,Do reward.
Similar Messages
-
How to create a custom function module with the records in SAP R/3?
Hi All,
How to create a custom function module with the records in SAP R/3? Using RFC Adapter I have to fetch the custom function module records.
Regards
SaraHi
goto se37...here u need to create a function group... then u need to create a function module. inside assign import/export parameters. assign tables/exceptions. activate the same. now write ur code within the function module
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Look at the below SAP HELP links, These links will show you the way to create a Function Module
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm -
How to create a callback function module
Hi all,
I am working in a requirement where we need to call a function module at a 'after change' event. So how to create a callback function module and register it with the crmvevent ?_
I created a sample function module and try to create entries in table crmv_event_cust, but i got an error message saying that the function module name I provided is not in table CRMC_FUNC_ASSIGN. When I try to create entry there, I got a message that function module is not in CRMC_OBJ_FUNC and that table is a standard table with no maintanance options !!
looks like i am going in wrong way ... can any one please help ??Looking at my system all you need to do is create the entry for the callback function in maint view: CRMV_FUNC_ASSIGN.
Your entry should be as simple as Z-function name Object Function - <same as others in the segment you are assigning>
IE for the partner it would be CRM_PARTNER as object function, for general order processing CRM_ORDER
Take care,
Stephen -
How to create a new function module?
I was doing the tutorial to create a SAP data widget and the tutorial was using BAPI_FLIGHT_GETLIST to display the data. However, in my system, theres no data in the table SFLIGHT2 and i couldnt populate any data in it.
So i am trying to create my own function module. Can anyone tell me how should i go about doing it?Hi Low Soon ,
please check the below links for creating a new function module.
SAP Help :
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/frameset.htm
Step by Sterp approach to create a Functional Module:
http://www.****************/Tutorials/ABAP/FunctionModule/page1.htm
Thanks
Jaideep Srinivasan -
How to create the INBOUND Function Module for INBOUND IDOCs
Hi Friends,
Can any Suggest me How to proceed to Create an INBOUND Function Module for Processing the INBOUND IDOCS
which are recieved from XI Server ?
I am working in SAP-ISU
Here i will recieve the INBOUND IDOCs for the Meter Reading Orders.
We have a Standard INBOUND FUNCTION MODULE
IDOC_INPUT_ISU_MR_UPLOAD
which Uploads the Meter Reading Results.
I copied the Same function Module into ZIDOC_INPUT_
and working on it.
Can any one suggest me, whether i am going in correct way or not.
In IDOC_INPUT_ISU_MR_UPLOAD Inbound fun module,
BAPI_MTRREADDOC_UPLOAD is used to Update or Insert the Meter Reading Results,
My requirment is to Insert and Update the Meter Reading Orders which are Inbounded from XI.
Can I Use the Same BAPI
BAPI_MTRREADDOC_UPLOAD
to Update the below fields,
EABL-SERNR
EABL-ZWNUMMER
EABLG-ABLESGR
EABL-V_ZWSTAND
EABL-N_ZWSTAND
EABL-ABLHINW
EABL-ZSKIPC
EABL-ADAT
EABL-ATIMTATS
EABL-ADATTATS
EABL-ATIM
EABL-ZMESSAGE
EABL-ABLESER(Meter reader number)
Kindly Suggest me,
Thanks in Advance,
GaneshHello Ganesh
I think you are going completely astray with you z-function module for IDoc processing.
If you look at TABLES parameter METERREADINGRESULTS (type BAPIEABLU ) of BAPI_MTRREADDOC_UPLOAD you will find many of the requested fields already:
EABL-SERNR => BAPIEABLU-SERIALNO
EABL-ZWNUMMER =>REGISTER
EABLG-ABLESGR
EABL-V_ZWSTAND
EABL-N_ZWSTAND
EABL-ABLHINW
EABL-ZSKIPC
EABL-ADAT
EABL-ATIMTATS => ACTUALMRTIME
EABL-ADATTATS => ACTUALMRDATE
EABL-ATIM
EABL-ZMESSAGE
EABL-ABLESER(Meter reader number)
Field EABL-ZMESSAGE appears to be custom field (at least I cannot find it on ECC 6.0). If this field was added using include CI_EABL then you probably can get these values into the BAPI using the EXTENSIONIN parameter.
Check routine CHECK_UPLOADRECORDS in the BAPI which allows two extension structures:
- BAPI_TE_EABL
- BAPI_TE_EOSB
Not surprisingly BAPI_TE_EABL contains the include CI_EABL.
Regards
Uwe -
How to create a Z Function Module
Hi,
I am trying to create a Z function module in BI 7.0 that i can use in Transformations.
SE37> Name of FM.Create..>
It is prompting me to enter Function Group.
What is Function Group and How can i create a new function group (Detail Steps please)
and steps involved in creating a Function Module in BI 7.0
Thanks in AdvanceHi,
Function Group is just like a folder under which we can store n no. of function modules for organizational purpose. If u want any global declarations we will declare at function Group Level.
It is mandatory to save a function module under one function group. Select Goto menu item, select Function Group, then select, create function group in SE37. Just give the technical name and description and save.
Hope this helps u..
Regards
Ramakrishna Kamurthy -
How to create webservice from function module
Hello,
I'm trying to create webservice from function module from. I choose Utilities/More Utilities/Create Webservice/..From function Module. What data should I enter in section "Enter Package/Request" ?
When I check "Local object" checkbox I get a message "Test objects cannot be created in foreign namespaces"
Is there any doc about this procedure (web service creation) with description of all sections ?
thanks for any reply,
Lukasz FerencHi,
Which SAP product of wich release of which SP are you using ?
The procedure is documented in help.sap.com and in blogs and SDN forum messages.
It means that the use of the SEARCH button should give plenty of answers...
>When I check "Local object" checkbox I get a message "Test objects cannot be created in foreign >namespaces"
As usual, begin your choosen name with an "Z".
Regards,
Olivier -
How to create IDOC from Function module or RFC
Hi all,
I have tested one inbound IDOC for Time Upload to CAT2 using basic type "CATS_INSERT01" in WE19 through function module BAPI_IDOC_INPUT1 .It works well.
Now i need to create this IDOC once the sale order gets created thru BAPI.
For creation of Sale order i wrote one RFC in which i will call the Standard Sale Order Bapi.My question is once the Sale order gets created in that RFC How do i trigger the IDOC for CATS upload.Hi,
Which SAP product of wich release of which SP are you using ?
The procedure is documented in help.sap.com and in blogs and SDN forum messages.
It means that the use of the SEARCH button should give plenty of answers...
>When I check "Local object" checkbox I get a message "Test objects cannot be created in foreign >namespaces"
As usual, begin your choosen name with an "Z".
Regards,
Olivier -
HOW TO RAISE EXCEPTION IN FUNCTION MODULE !
I have created a function module....where i want to raise some error message when some wrong data will be inputed
what is the syntax ? Please tell me the syntax .hi you can do like this:
in exception tab of FM write exceptions you want to raise.
e.g. incorrect_input.
now in code write
if input not correct (write your validation condition here)
raise incorrect_input.
endif.
reward if useful. -
How to create s cutomised function module
Hi all,
i want to create acutomised fm , i want to create a zfm , same as like one standard fm .
how to copy the original one, i wnat to change one include based on customer requirement.
Regards,
pandu.Hi,
Go to se37 give your standard function module name.
select function module from menu -->click on other functions
then select copy (ctrl+F5).
Then it will show the standard function module and target function module and function group.
Give your target function module name and give your function group name.
now you have your customized fuction module similar to standard function module.
now you can add your own logic or includes in this function module.
regards,
swami. -
How to create a Z Function module for the standard FM VIEW_KURGV?
Hi all,
There is a requirement to the change the functionality of the standard FM VIEW_KURGV. This FM is being used in a Z report. Hence, I have a copied this FM to a Z FM ZVIEW_KURGV after having created the Z Function Group ZV05E. However, there are a number of standard routines which are present in the standard FM VIEW_KURGV which need to be also created in the Z FM ZVIEW_KURGV. Please advise how to proceed.
Thanks and regards,
AnishurInstead of copyg the std fm to z, do the following,
1. Go to se37 open FM VIEW_KURGV in display mode.
2. Click on the spiral icon on the top.
3. Then in menu go edit->enhancment options -> show implicit enhancement
4. """""""""""""""""""""" kind of lines will appear in the cde, just rt click on the line at the place u want to insert the code and select
enhancement implementation create.
5. Give apropriate name for thi , it will inset a n place to write your code.
This is an std sap methodology and is supported in upgradde also. -
Creating Includes for Function Modules
Hi Experts,
Can you please let me know how to create includes for function modules.
I came across this in a standard include program, which was generated by a function library. The includes inside this program where linked to the function modules (when I double clicked on them).
Please let me know how to create it.
Thanks in advance !
Regards,
Anand Patil.Hi,
have a look at the code for better understanding
Declaration of Workareas *
DATA: lwa_e1bp2017_gm_item_create TYPE e1bp2017_gm_item_create,
lwa_data TYPE edidd, " Work area for IDOC
lwa_control TYPE edidc. " Work Area for control rec
Read the control data information of idoc.
loop at idoc_contrl INTO lwa_control Where mestyp = lc_mbgmcr.
Extract the data from the segments.
LOOP AT idoc_data INTO lwa_data
WHERE docnum = lwa_control-docnum and
segnam = lc_item_create.
*->> Set the tabix of the internal table
lv_index = sy-tabix.
Move the Material Document Item Segment data
MOVE lwa_data-sdata TO lwa_e1bp2017_gm_item_create.
Modify the material document item data internal table
PERFORM sub_modify_idocdata changing lwa_e1bp2017_gm_item_create.
*->> set the changed values to the IDOC SDATA
MOVE lwa_e1bp2017_gm_item_create TO lwa_data-sdata.
*->> Modify the table
MODIFY idoc_data FROM lwa_data index lv_index.
Clear the Work areas
CLEAR : lwa_data,
lwa_e1bp2017_gm_item_create.
ENDLOOP. "LOOP AT t_idoc_data
Call the BAPI function module to create the
appropriate Material Document
CALL FUNCTION 'BAPI_IDOC_INPUT1'
EXPORTING
input_method = input_method
mass_processing = mass_processing
IMPORTING
workflow_result = workflow_result
application_variable = application_variable
in_update_task = in_update_task
call_transaction_done = call_transaction_done
TABLES
idoc_contrl = idoc_contrl
idoc_data = idoc_data
idoc_status = idoc_status
return_variables = return_variables
serialization_info = serialization_info
EXCEPTIONS
wrong_function_called = 1
OTHERS = 2.
IF sy-subrc = 1.
RAISE wrong_function_called.
ENDIF.
endloop.
ENDFUNCTION.
here when we write the statment
PERFORM sub_modify_idocdata changing lwa_e1bp2017_gm_item_create and double click on sub_modify_idocdata .
it will create a include with the name "LZDTSINT052F_GPOMS_GMF01 ".
now we can write the FORM ..END FORM In this inculde.like this.
***INCLUDE LZDTSINT052F_GPOMS_GMF01 .
*& Form sub_modify_idocdata
Modify the material document item data internal table
FORM sub_modify_idocdata
CHANGING pwa_e1bp2017_gm_item_create TYPE e1bp2017_gm_item_create.
contant declaration
CONSTANTS: lc_261(3) TYPE c VALUE '261'.
DATA : lv_aplzl LIKE resb-aplzl,
lv_aufpl LIKE resb-aufpl,
lv_subrc LIKE sy-subrc,
lv_charg LIKE resb-charg,
lv_uom LIKE pwa_e1bp2017_gm_item_create-entry_uom.
CLEAR: pwa_e1bp2017_gm_item_create-reserv_no,
pwa_e1bp2017_gm_item_create-res_item.
*->> Get SAP storage bin & Storage type from the Z table
SELECT lgtyp lgpla
INTO (pwa_e1bp2017_gm_item_create-stge_type,
pwa_e1bp2017_gm_item_create-stge_bin)
UP TO 1 ROWS
FROM zdtsint050_sttyp
WHERE zstorage_typ = pwa_e1bp2017_gm_item_create-stge_type
AND zstorage_bin = pwa_e1bp2017_gm_item_create-stge_bin.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR: pwa_e1bp2017_gm_item_create-stge_type,
pwa_e1bp2017_gm_item_create-stge_bin.
ENDIF.
PERFORM get_oper CHANGING pwa_e1bp2017_gm_item_create.
Get the Reservation number and Reservation item number
basing on the idoc data.
SELECT rspos werks lgort
INTO (pwa_e1bp2017_gm_item_create-res_item,
pwa_e1bp2017_gm_item_create-plant,
pwa_e1bp2017_gm_item_create-stge_loc)
FROM resb
UP TO 1 ROWS
WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no
AND matnr = pwa_e1bp2017_gm_item_create-material
AND charg = pwa_e1bp2017_gm_item_create-batch
AND aufnr = pwa_e1bp2017_gm_item_create-orderid
AND vornr = pwa_e1bp2017_gm_item_create-activity
AND bwart = lc_261.
ENDSELECT.
IF sy-subrc <> 0.
Start of insertion for R31K993797
CLEAR lv_charg.
SELECT rspos werks lgort
INTO (pwa_e1bp2017_gm_item_create-res_item,
pwa_e1bp2017_gm_item_create-plant,
pwa_e1bp2017_gm_item_create-stge_loc)
FROM resb
UP TO 1 ROWS
WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no
AND matnr = pwa_e1bp2017_gm_item_create-material
AND charg = lv_charg
AND aufnr = pwa_e1bp2017_gm_item_create-orderid
AND vornr = pwa_e1bp2017_gm_item_create-activity
AND ( splkz = 'X' or
splkz = space )
AND bwart = lc_261.
ENDSELECT.
IF sy-subrc <> 0.
End of insertion for R31K993797
SELECT SINGLE werks lgort
INTO (pwa_e1bp2017_gm_item_create-plant,
pwa_e1bp2017_gm_item_create-stge_loc)
FROM resb
WHERE rsnum = pwa_e1bp2017_gm_item_create-reserv_no.
CLEAR : pwa_e1bp2017_gm_item_create-reserv_no,
pwa_e1bp2017_gm_item_create-res_item.
ENDIF.
ENDIF.
get SAP UOM
SELECT SINGLE zsap_uom
INTO lv_uom
FROM zca_uom_conv
WHERE zext_uom = pwa_e1bp2017_gm_item_create-entry_uom.
IF sy-subrc = 0.
pwa_e1bp2017_gm_item_create-entry_uom = lv_uom.
ENDIF.
ENDFORM. " sub_modify_idocdata
*& Form get_oper
Get the operation
<--P_PWA_E1BP2017_GM_ITEM_CREATE_RE Segment
FORM get_oper CHANGING p_pwa_e1bp2017_gm_item_create TYPE
e1bp2017_gm_item_create.
DATA : l_aufpl LIKE afko-aufpl,
l_aplzl LIKE afvc-aplzl.
REFRESH : i_op.
UNPACK p_pwa_e1bp2017_gm_item_create-orderid TO
p_pwa_e1bp2017_gm_item_create-orderid.
Get the reservation and routing number for the order
SELECT SINGLE
rsnum
aufpl
FROM afko
INTO (p_pwa_e1bp2017_gm_item_create-reserv_no,
l_aufpl)
WHERE aufnr = p_pwa_e1bp2017_gm_item_create-orderid.
IF sy-subrc = 0.
CALL FUNCTION 'CONVERSION_EXIT_NUMCV_INPUT'
EXPORTING
input = p_pwa_e1bp2017_gm_item_create-activity
IMPORTING
output = p_pwa_e1bp2017_gm_item_create-activity.
ENDIF.
ENDFORM. " get_oper
Regards,
nagaraj -
How to use SWC_CREATE_OBJECT in Function Module
Hi All,
I need to create a one function module to fill the work flow container field. this work flow builder had only one task, that task is triggering through QM Action box. I need to maintain this function module in AM Action box, FM when saving field.
Please help me how to create a new function module in QM Acion box. When run the QM02 with usage decesion option is triggered Associated task is triggering, now how i will pass the notification number to work flow container.
Please help meI think you can
SWC_CREATE_OBJECT 'QMObject' Object Key
Or you can pass the QM number to the Workflow and use GENERICINSTANTIATE Method of Business Object SYSTEM to instantiate the QM Business Object.
Thanks
Arghadip -
Hi,
How to use exception in Function module ?
How Can I use the exception my program while calling the Function Module ?
Can anyone explain with example ?
Thanks
NKHI,
if something happens in ur FM and u want it to be tracked in ur calling program, then u can use exception...............
If u r having(say) 3 exceptions in ur FM....
and in ur calling program its like below.
EXCEPTIONS
exception1 = 1
exception2 = 2
exception3 = 3
then if the first exception is raised in ur FM,then sy-subrc value ll be 1( exception1 = 1 )....llly if the second exception is raised in ur FM,then sy-subrc value ll be 2( exception2 = 2 ).........
now u can use this sy-subrc values like below....
If sy-subrc = '1'.
message 'First exception is raised' type 'I'.
else.
message '2nd or 3rd exception is raised' type 'I'.
endif.
Cheers,
jose. -
How to raise the exception in function module
Dear abaper's.
I am creating a Function module .In that in' EXCEPTION' Tab i am giving
3 exception .1.NO_DATA_FOUND 2.NO_PRINTER_FOUND 3.SMARTFORM_INTERFACE_NOT_FOUND.
In my coding if this condtion matches i want to raise this exception.how can i do this in my coding .can any one suggest me..
advance thanks,
Warm regards,
VeeraHi,
if that condition is not satisfied,and u didn't handle that exception while calling function module then in the runtime error u will get the text as the description of the exception in function module definition.
rgds,
bharat.
Maybe you are looking for
-
1. I have used Thunderbird for 5 years or so, using at least 3 mail addresses at a time. I stow useful mails in folders and subfolders for reference. I regularly use Mozbackup. 2. Recently I found that one of the main folders was missing, a search of
-
Windows 2003 server loses security tab for folders created in OS X
We have a centralised storage system that is running on a Windows 2003 cluster. This server has folders for each department so they can store colaborative work. They can create their own folders and files within their departments folder. When files a
-
I purchased a new computer and also Adobe acrobat XI Pro. It has not worked properly. I uninstalled it and tried to reinstall it, but the computer will not accept the Serial number. What can I do?
-
Apple movie trailers not working
Hi! I have a problem watching any movie trailers on www.apple.com/trailers page. If I try to open HD trailer it i get a message that URL is not valid. If I try to open normal trailer (not HD) I get quicktime logo with question mark and nothing happen
-
Hi! Does anyone knows if there is an API, standard function or whatever that helps me get customer's available credit. I know there is a report "Customer Credit Snapshot" that gives credit limit, credit available, credit exceeded... I tried to find i