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

Call SD bapi in WebAS

Former Member
0 Likes
571

Dear Alles.

I want to build a procedure which calls bapi to create customers and material in WebAS so that provide user to operate( cerate, edit, delete, etc customer and material,table: KNA1,MARA) in web environment( browser).but in 'BAPI_CUSTOMER_CREATE',it calls a transaction 'XD01',a dialog program that need to input parameters. How to implement it? how to transport the parameter to it? Thanks for your help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
508

Hi Fei Lu,

The bapi you want to invoke can't be used in a background process but in dialog.

You might try to use BAPI_CUSTOMER_CREATEFROMDATA1 instead.

As a general rule always look for bapis that include the string CREATEFROMDATA instead of just CREATE since the last ones usually are for online use only.

Hope it helps,

David R.

Pd: Don't forget to reward useful answers plis!

2 REPLIES 2
Read only

Former Member
0 Likes
509

Hi Fei Lu,

The bapi you want to invoke can't be used in a background process but in dialog.

You might try to use BAPI_CUSTOMER_CREATEFROMDATA1 instead.

As a general rule always look for bapis that include the string CREATEFROMDATA instead of just CREATE since the last ones usually are for online use only.

Hope it helps,

David R.

Pd: Don't forget to reward useful answers plis!

Read only

Former Member
0 Likes
508

Hi,

Use BAPI BAPI_CUSTOMER_CREATEFROMDATA1 to create a customer...

About the BAPI:

This method of the "Customer" business object is used to create a customer in SAP R/3 on the basis of entered personal data (import parameter PI_PERSONALDATA) or entered company data (import parameter PI_COMPANYDATA).

Only one structure (personal data or company data) can be transferred to the BAPI with entries.

One person to be created as a customer:

With the entered personal data, addresses of type 1 (company address), type 2 (address for a person/private address of a contact person), and type 3 (contact partner address) are created simultaneously in Central Address Management (CAM).

If the "Allow Consumer Maintenance" indicator is set, then a consumer is created in SAP R/3. (See also: import parameter PI_CONSUMEREN ).

(a) No consumers to be created:

The entered personal data has a direct influence on the master data, company code data and contact person data. One contact partner record is created for the customer in question.

All the master data, company code data, sales area data, tax code data, and reminder data that is not entered is adopted from a reference customer and from the sales area data (sales organization, distribution channel and division - import parameter PI_COPYREFERENCE).

If parameter PI_CREDIT_CONTROL_FLAG is set, then the credit control data of the reference customer is adopted.

Exceptions to the fields mentioned above can only exist for the fields of import structure "optional personal data" (PI_OPT_PERSONALDATA). If values exist for the fields in this structure, these values take priority over any equivalent values for the reference customer.

Note:

- Important data that is adopted from the reference customer:

Master data: Account group. This must be an account group linked to a number range that internally assigns a customer number.

Company code data: Reconciliation account in Financial Accounting

Sales data: Customer schema (for determining the calculation schema), term of payment key, shipping conditions, Incoterms part 1, 2 and supplying plant.

- Data that is not adopted from the reference customer:

Contact person data, partner function data, and bank details.

Example

Notes

(1) Data needed to create a customer in SAP R/3:

- Fields of import parameter PI_PERSONALDATA

Surname, language, location, country, currency.

Depending on the country, further data may be necesary.

The country can be transferred to the BAPI in R/3 format or ISOstandard.

If the country key is transferred to the BAPI in both formats (R/3 format and ISO standard), the country key in R/3 format has priority.

A language key in R/3 format or ISO 639 standard must also be transferred to the BAPI.

If both formats are transferred to the BAPI, the language key in R/3 format has priority.

Finally, a currency key in R/3 format or ISO standard format must be transferred to the BAPI.

If both formats are transferred, the currency key in R/3 format has priority.

Notes on names and search term field:

Surnames are always entered in the Search term A field in the customer master.

- Fields of optional import parameters PI_OPT_PERSONALDATA:

None of these fields are mandatory for customer creation.

The structure consists of the following fields:

Customer master field: Transportation zone

Company-code-relevant fields: Reconciliation account and term of payment

Sales data fields: Shipping condition, supplying plant, partial delivery at item level and credit control area

- Fields of import parameter PI_COPYREFERENCE:

R/3 reference customer, sales area data (sales organization, distribution channel, division)

Note on reference customer:

The reference customer should be created bearing in mind that its sole purpose is to provide data for customers that are created via the BAPI.

That is, the reference customer is not an operative customer in the business sense. As a result, the customer should be created with a separate account group with internal number assignment. In addition, the reference customer must exist in the organizational data that is transferred to the BAPI.

If company-code-independent data is transferred to the BAPI, the reference customer must be created for a company code.

(2) The permitted countries are those in R/3 table T005. The permitted regions in these countries are those in R/3 table T005S. The correct length and necessity of a postal code depends on the country in question.

(3) An e-mail address is only valid if it contains the character '@'.

Note: The e-mail address in the reference customer's correspondence data is not adopted, as only e-mail addreses of companies or personal addresses are relevant for future operative business. The e-mail address of the reference customer is only adopted if CAM is not active.

(b) A consumer is to be created:

The entered personal data has a direct influence on the master data and

contact person data. One contact person record is created for the customer in question.

All the master data that is not entered is adopted from the reference customer of the consumer.

Exceptions to the master data fields can only exist for the first two customer master fields of the import structure "optional personal data" (PI_OPT_PERSONALDATA). If values exist for the fields in this structure, these values take priority over any equivalent values for the reference customer.

Notes

The necessary data for creating a consumer in SAP R/3 is, except for the reference customer, the same as the data described above needed for the person customer.

(ii) A company customer is to be created:

With the entered personal address data, only one type 1 address (company address) is created. Otherwise, the same mechanisms for a person customer (not a consumer) apply to a company customer.

For all three cases: person customer, consumer or company customer, the following applies:

(1) For the fields for form of address and form of address key: Only the form of address in the personal data structure is used to update this field. The form of address key in the personal data structure is irrelevant for updating the data. This field is only used for the "Customer" business object, and therefore possibly used in F4 help for the form of address field.

(2) A check on duplicate records for the purpose of matchcode fields (see MCOD1-3 and table TFMC) is carried out on the basis of an entry in R/3 table T100C (transaction OBA5 work area F2, for MsgNr 145 entry I). If the three matchcode fields are the same, an error message is issued.

(3) Messages are returned in parameter RETURN. The return values and their meanings can be found in this parameter documentation.

(4) The customer is updated synchronously, but no Commit is executed.

(5) The new customer is returned in field CUSTOMERNO (key field of "Customer" business object (KNA1)).

(6) All address data come from the central function module of the CAM (see ADDR_CHECK ).

(7) Authorization requirements for using this BAPI: "Create" authorization must exist for the following objects: F_KNA1_APP (customer: user authorization), F_KNA1_BUK (customer: authorization for company codes, for the selected company code) and V_KNA1_VKO (customer: authorization for sales organization, for the selected sales organization). Authorization profiles that cover the following objects are SAP_ALL, V_Verkauf and V_Versand.

*********************


*********************
Data declarations
*********************
Data: PERSONALDATA type BAPIKNA101_1,
      COPYREFERENCE type BAPIKNA102.
**********************
Start of selection
CALL FUNCTION 'BAPI_CUSTOMER_CREATEFROMDATA1'
  EXPORTING
*    PI_CREDIT_CONTROL_FLAG = CREDITCONTROLFLAG
    PI_COPYREFERENCE = COPYREFERENCE
*    PI_CONSUMEREN = CONSUMEREN
*    PI_OPT_COMPANYDATA = OPTIONALCOMPANYDATA
    PI_PERSONALDATA = PERSONALDATA
*    PI_OPT_PERSONALDATA = OPTIONALPERSONALDATA
*    PI_COMPANYDATA = COMPANYDATA
  IMPORTING
*    CUSTOMERNO = OBJECT-KEY-CUSTOMERNO
    RETURN = RETURN
  EXCEPTIONS
    OTHERS = 01.

Hope it helps....

Lokesh