‎2008 Jul 10 6:26 AM
Hello Experts,
I am new to BAPI creation, my requirment has two decimal inputs(as import parameters) and out output can be a simple add of these two numbers.
Decimal Input has 9 characters with 7 decimals Ex: 10.0000000. How to create a structure or data type and use the same back in my BAPI.
What is the ABAP code that, I should write to add these two inputs and export them.
Please help ASAP, I am in a critcal position.
Thanks,
Suma
‎2008 Jul 11 8:22 AM
Hello Suma,
This error is caused because you are trying to use a data type rather a data element, it better if you follow the below process
Start with creating a Structure with ZBAPI name, from SE11
give a component name with Z and component type with Z and then double click on new component type and this will ask what to generate click on dataelement and enter discription then enter a Z new name in the Domain and double click on it, click on data type and enter DEC, no char 9 and decimal 7 then save activate, clikc on back save activate and again click on back and save activate now your sturcture will be saved. Follow the proces if have new data type or else the same for your next entres.
For your Req....
take component ZINPUT1 compenent type ZINPUT with domain as ZZINPUT...
use the sam for ZINPUT2 and ZOUTPUT and then save activate. Now the structure is created.
SE37 create new BAPI, In import parameters take parameters as T_INPUT1 and T_INPUT2 with ZBAPI_SUM-ZINPUT1 and ZBAPI_SUM-ZINPUT2.Then in export if you wnat inputs also in there just give some export names and give the assoated type as what you have used in import, also add OUTPUT and RETURN with ZBAPI_SUM-ZOUTPUT and BAPIRETURN.Now write the source code as follows
FUNCTION ZBAPI_TESTDEC1.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(T_INPUT1) TYPE ZBAPI_SUM-ZINPUT OPTIONAL
*" VALUE(T_INPUT2) TYPE ZBAPI_SUM-ZINPUT1 OPTIONAL
*" EXPORTING
*" VALUE(INPUT1) TYPE ZBAPI_SUM-ZINPUT
*" VALUE(INPUT2) TYPE ZBAPI_SUM-ZINPUT1
*" VALUE(OUTPUT) TYPE ZBAPI_SUM-ZOUTPUT
*" VALUE(RETURN) TYPE BAPIRETURN
*"----
INPUT1 = T_INPUT1.
INPUT2 = T_INPUT2.
OUTPUT = T_INPUT1 + T_INPUT2.
ENDFUNCTION.
Now save it and then activate and then clikc on tables tab then functional module on main menu and then relase.
Go to T-code SWO1 create new Obj with ZBAPI name and then clikc create enter Obj name,Name,Des,Program,and Application has to be * then enter.
Click on methods,Utilites, API Methods, Add method, Select BAPI Name then contine for 3 times then click BAPI Added in the methods then on edit change relase status- object type To modeled, To impimented and To relased at 3 diff times then follow the same for Object Type component.
Now click on red and white round button which is similar to BMW symbol. This will generate the BAPI and now you see it in BAPI T-Code.
Hope this helps you ...
Reward if helpfull....
Thanks,
Srikanth
‎2008 Jul 10 7:21 AM
Hi Suma,
I guess you need to create a Function Module which takes 2 decimal inputs and sums them up and give as out put. Right.
For this you can create a Functiona Module with 2 Import Parameters.
declare the import parameters of type Domain which satisfies your requirement, for eg PMX_FACTIMP this is 9char, 2position before and 7after the decimal point.
have one export parameter in that FM, with same domain.
Inside the code you just sum it up.
Thats it. If your intention is to call it remotely, Make it a RFC Enabled Fuction module.
Regards,
Simha
‎2008 Jul 10 8:40 AM
Hello Simha,
I have created a new data element and use the same for input and output. Its working fine in SE37 without any errors.
When try to create a BOR using SWO1 and adding the method I am getting the following error:
"You tried to create a method in the BOR with a data type that is not supported. Only data elements and structures are allowed as reference types for parameters in the BOR.
"
What to do now? With out doing this does a BAPI can be accssed by other applications?
Please help...
Thanks,
Suma
‎2008 Jul 10 8:56 AM
Even a RFC Enabled FM is also accessed by other applications just like your BAPI.
For this - Processing Type = Remote - enabled module
Radio button has to be enabled in Attributes of that Function Module.
If you insist to go ahead with Custom BAPI, just create a Data Element and have the domain that suits your requirement in that Data element and use this in your BAPI.
Regards,
Simha
Edited by: Simha on Jul 10, 2008 9:57 AM
‎2008 Jul 11 8:22 AM
Hello Suma,
This error is caused because you are trying to use a data type rather a data element, it better if you follow the below process
Start with creating a Structure with ZBAPI name, from SE11
give a component name with Z and component type with Z and then double click on new component type and this will ask what to generate click on dataelement and enter discription then enter a Z new name in the Domain and double click on it, click on data type and enter DEC, no char 9 and decimal 7 then save activate, clikc on back save activate and again click on back and save activate now your sturcture will be saved. Follow the proces if have new data type or else the same for your next entres.
For your Req....
take component ZINPUT1 compenent type ZINPUT with domain as ZZINPUT...
use the sam for ZINPUT2 and ZOUTPUT and then save activate. Now the structure is created.
SE37 create new BAPI, In import parameters take parameters as T_INPUT1 and T_INPUT2 with ZBAPI_SUM-ZINPUT1 and ZBAPI_SUM-ZINPUT2.Then in export if you wnat inputs also in there just give some export names and give the assoated type as what you have used in import, also add OUTPUT and RETURN with ZBAPI_SUM-ZOUTPUT and BAPIRETURN.Now write the source code as follows
FUNCTION ZBAPI_TESTDEC1.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(T_INPUT1) TYPE ZBAPI_SUM-ZINPUT OPTIONAL
*" VALUE(T_INPUT2) TYPE ZBAPI_SUM-ZINPUT1 OPTIONAL
*" EXPORTING
*" VALUE(INPUT1) TYPE ZBAPI_SUM-ZINPUT
*" VALUE(INPUT2) TYPE ZBAPI_SUM-ZINPUT1
*" VALUE(OUTPUT) TYPE ZBAPI_SUM-ZOUTPUT
*" VALUE(RETURN) TYPE BAPIRETURN
*"----
INPUT1 = T_INPUT1.
INPUT2 = T_INPUT2.
OUTPUT = T_INPUT1 + T_INPUT2.
ENDFUNCTION.
Now save it and then activate and then clikc on tables tab then functional module on main menu and then relase.
Go to T-code SWO1 create new Obj with ZBAPI name and then clikc create enter Obj name,Name,Des,Program,and Application has to be * then enter.
Click on methods,Utilites, API Methods, Add method, Select BAPI Name then contine for 3 times then click BAPI Added in the methods then on edit change relase status- object type To modeled, To impimented and To relased at 3 diff times then follow the same for Object Type component.
Now click on red and white round button which is similar to BMW symbol. This will generate the BAPI and now you see it in BAPI T-Code.
Hope this helps you ...
Reward if helpfull....
Thanks,
Srikanth