Skip to Content
author's profile photo Former Member
Former Member

how to create a BAPI

how to create a BAPI

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2006 at 01:06 PM

    Hello Rajesh:

    I don't think that question belongs to this forum. Anyway, to create a BAPI in a nutshell you need access to an ABAP Workbench editor, ABAP knowledge and Developer privileges:

    1) BAPIs in General are created in two parts, first a Function Group and then the Function Modules.

    Both user defined Group/Modules names must start with Z or Y.

    2) Using the Object navigator (SE80) we must click on "EDIT OBJECT" ->"FUNCTION GROUP". Some dataFields

    must be maintained:

    • FunctionGroupName

    • Short Description

    • Development Class / Package

    3) With the previously created FunctionGroup, a new FunctionModule can be added. In Object Navigator

    mark the option "EDIT OBJECT" ->"FUNCTION MODULE" and click CREATE (F5) The following steps must be

    performed:

    • Set the FunctionGroupName (as defined above).

    • Short Text as description

    • Maintain technical data:

    After the creation of the FunctionModule, we must define the Interface (parameters for

    external use) and the processing logic (the code itself).

    4) Possible values for parameters are:

    • Import parameters.- Input for the RFC.

    • Export parameters.- What the RFC will return

    • Tables.- Internal tables that can be transferred to/from the RFC

    • Exceptions.- Definitions for possible errors inside the RFC

    When defining this parameters, the data and dataTypes must be available globally, that is, in the

    ABAP Dictionary, also, NO GENERIC DATA TYPES MAY BE USED FOR A VARIABLE IN THE INTERFACE, such as int,

    char, etc.

    5) An example for import/export parameters definition is as follows

    • Import:

    ParameterName.- PORTAL_LOGON_NAME

    Type.- LIKE

    Associated type.- Z_LOGON_ID (previously defined in the Dictionary)

    Optional .- OK

    PassValue.- OK

    • Export

    ParameterName.- CLIENT_DATA

    Type Spec.- LIKE

    Associated type.- Z_CLIENTS_1 (a table in the Dictionary, meaning that a structure

    will the result of this RFC)

    PassValue.- OK

    • Exceptions

    Exception.- ERROR_CLIENT_DOES_NOT_EXIST

    6) Now he actual processing logic must be set, as ABAP source code. In this case, we get a name for User

    logon (e.g. "Reporter") and fetch it's user ID in a mapping table. Afterwards, with this id, go to

    clients table and get the client details.

    TYPES: BEGIN OF client_eq_type,

    client_logon TYPE int4,

    client_number TYPE int4,

    END OF client_eq_type .

    DATA: client_eq TYPE client_eq_type,

    temp_client_id TYPE int4.

    • First find out the logon username and get the equivalence. The client_id is stored in a

    • temporary structure

    SELECT SINGLE client_number

    FROM zclients_code_eq

    INTO CORRESPONDING FIELDS OF client_eq

    WHERE client_logon = portal_logon .

    IF sy-subrc <> 0.

    RAISE error_client_does_not_exist .

    ENDIF .

    temp_client_id = client_eq-client_number.

    SELECT SINGLE *

    FROM zalex_clients_1

    INTO CORRESPONDING FIELDS OF client_data

    WHERE client_id = temp_client_id.

    IF sy-subrc <> 0 .

    RAISE error_client_does_not_exist .

    ENDIF .

    ENDFUNCTION.

    7) Test the function and activate.

    8) Now this is very important. Go to attributes in the SE80 function Module and <b>enable the Remote Call for this function, in order

    to set it as RFC. PROCESSING TYPE -> REMOTE ENABLED MODULE</b>

    I hope that helps

    Alejandro

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 29, 2007 at 03:10 AM

    follow this is link.......

    this is the perfect material for bapi...

    otherwise give ur email..id i will send it to ur mail id...

    http://www.erpgenie.com/abap/bapi/index.htm

    http://www.erpgenie.com/abap/bapi/example.htm

    regards

    anilreddy

    reward points if helpful

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.