*Today we will learn how to use SAP ABAP TCODE OKEON SAMPLE DEMO example BAPI_CUSTOMER_CREATEFROMDATA Only for ONLINE Store!!! Customer: Create Customer
*You can paster this sample ABAP CODE in tr-code se38……
*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI. Only for ONLINE Store!!! Customer: Create Customer
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. Only for ONLINE Store!!! Customer: Create Customer
*Note: In SAP R/3 4.5A, this BAPI is replaced by BAPI
*”BAPI_CUSTOMER_CREATEFROMDATA1″, which takes full account of the
*integration of customer address data in Central Address Management
*(CAM). As this BAPI (“BAPI_CUSTOMER_CREATEFROMDATA”) is being replaced,
*it will only be supported for 2 releases after SAP R/3 4.5A.
*This method of the “Customer” business object can be used to create a
*customer in SAP R/3 on the basis of entered address data (import
*parameter PI_ADDRESS).
*The entered address data has a direct influence on the master data,
*company code data and contact person data. One contact person record is
*created for the customer to be created.
*All the master data, company code data, sales area data, and tax code
*data that is not entered is adopted from a reference customer, and from
*sales area data (sales organization, distribution channel and division
*- import parameter PI_COPYREFERENCE).
*(Exception: Currency field of the sales area data. This field can be
*transferred to the BAPI via structure PI_ADDRESS via the currency
*fields (in R/3 or in ISO format).
*If both currency fields are transferred to the BAPI, the currency field
*in R/3 format has priority.
*If both currency fields are blank when transferred to the BAPI, the
*currency field is determined using table T005, on the basis of the
*country that is specified.
*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.
*(i) Data needed for creating a customer in SAP R/3:
*Fields of import parameter PI_ADDRESS:
*Surname, language, location, and country
*Depending on the country, further data may be necessary.
*The country can be transferred to the BAPI in either R/3 format or ISO
*standard. If both fields (R/3 format and ISO standard) are selected and
*transferred to the BAPI, the country key in R/3 format has priority
*over the ISO standard format.
*Note: The ‘old’ ISO standard fields for the country (numerical and
*alphanumerical formats) are not supported and have been shut down.
*Lastly, a language key in R/3 format or ISO 639 standard must also be
*transferred to the BAPI.
*If it is transferred to the BAPI in both formats (R/3 and ISO
*standard), the country key in R/3 format has priority.
*Fields of import parameter PI_COPYREFERENCE:
*R/3 reference customer, sales area data (sales organization,
*distribution channel and division)
*Note on reference customer:
*The reference customer should be created bearing in mind that his only
*purpose is to provide data for customers that are created via the BAPI.
*In other words, 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.
*(ii) The permitted countries are those in R/3 table T005. The permitted
*regions in these countries are those in R/3 table T005S. The length and
*necessity of the postal code depend on the country in question.
*(iii) An e-mail address is only valid if it contains the character ‘@’.
*(iv) A check on duplicate records for the purpose of matchcode field
*consistency (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.
*(v) Messages are returned in parameter RETURN. The return values and
*their meanings can be found in this parameter documentation.
*(vi) The customer is updated synchronously.
*(vii) The new customer number is returned in the field CUSTOMERNO.
*Note: Field PE_CUSTOMER always contains exactly the same value as
*CUSTOMERNO. Field CUSTOMERNO stands for a method view of the function
*module, field PE_CUSTOMER for a procedural view of the function module.
*(viii) Authorization requirements for using the BAPI:
*”Create” authorization is required 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 above objects are SAP_ALL,
*V_Verkauf and V_Versand.
REPORT ZDEMO_BAPI_CUSTOMER_CREATEFROMDATA.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..
**********************************************************************
*******Defination of Work Area Structrue [Import]-[PI_ADDRESS ] . “”Address Structure for BAPIs for Business Object Customer
**********************************************************************
DATA: LS_PI_ADDRESS TYPE BAPIKNA101 . “”Address Structure for BAPIs for Business Object Customer
LS_PI_ADDRESS-FORM_OF_AD = ‘CHAR30’. “Form of address
LS_PI_ADDRESS-FIRST_NAME = ‘CHAR35’. “First Name
LS_PI_ADDRESS-NAME = ‘CHAR35’. “Name
LS_PI_ADDRESS-NAME_3 = ‘CHAR35’. “Name 3
LS_PI_ADDRESS-NAME_4 = ‘CHAR35’. “Name 4
LS_PI_ADDRESS-DATE_BIRTH = ‘20241208’. “Date of birth
LS_PI_ADDRESS-STREET = ‘CHAR35’. “Street
LS_PI_ADDRESS-POSTL_CODE = ‘CHAR10’. “Postal Code
LS_PI_ADDRESS-CITY = ‘CHAR35’. “City
LS_PI_ADDRESS-REGION = ‘CHAR3’. “Region
LS_PI_ADDRESS-COUNTRY = ‘CHAR3’. “Country/Region Key
LS_PI_ADDRESS-COUNTRNISO = ‘CHAR3’. “ISO_CLOSE_CTRY/REG
LS_PI_ADDRESS-COUNTRAISO = ‘CHAR3’. “ISO_CLOSE_CTRY/REG
LS_PI_ADDRESS-INTERNET = ‘CHAR130’. “Clrk’s internet add.
LS_PI_ADDRESS-FAX_NUMBER = ‘CHAR31’. “Fax Number
LS_PI_ADDRESS-TELEPHONE = ‘CHAR16’. “Telephone 1
LS_PI_ADDRESS-TELEPHONE2 = ‘CHAR16’. “Telephone 2
LS_PI_ADDRESS-LANGU = ‘LANG1’. “Language Key
LS_PI_ADDRESS-LANGU_ISO = ‘CHAR2’. “Language Code
LS_PI_ADDRESS-CURRENCY = ‘CUKY5’. “Currency
LS_PI_ADDRESS-CURRENCY_ISO = ‘CHAR3’. “ISO Currency Code
LS_PI_ADDRESS-COUNTRYISO = ‘CHAR2’. “ISO Code
LS_PI_ADDRESS-ONLY_CHANGE_COMADDRESS = ‘CHAR1’. ”
**********************************************************************
*******Defination of Work Area Structrue [Import]-[PI_COPYREFERENCE ] . “”Structure for BAPIs for Business Object Customer
**********************************************************************
DATA: LS_PI_COPYREFERENCE TYPE BAPIKNA102 . “”Structure for BAPIs for Business Object Customer
LS_PI_COPYREFERENCE-SALESORG = ‘CHAR4’. “Sales Organization
LS_PI_COPYREFERENCE-DISTR_CHAN = ‘CHAR2’. “Distribution Channel
LS_PI_COPYREFERENCE-DIVISION = ‘CHAR2’. “Division
LS_PI_COPYREFERENCE-REF_CUSTMR = ‘CHAR10’. “Ref. customer
DATA: LV_CUSTOMERNO TYPE BAPIKNA103-CUSTOMER .”Obligatory
DATA: LV_PE_CUSTOMER TYPE BAPIKNA103-CUSTOMER .”Obligatory
**********************************************************************
*******Defination of Work Area Structrue [Export]-[RETURN ] . “”Return Parameter
**********************************************************************
DATA: LS_RETURN TYPE BAPIRETURN . “”Return Parameter
**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_CUSTOMER_CREATEFROMDATA’
EXPORTING
PI_ADDRESS = LS_PI_ADDRESS
PI_COPYREFERENCE = LS_PI_COPYREFERENCE
IMPORTING
CUSTOMERNO = LV_CUSTOMERNO
PE_CUSTOMER = LV_PE_CUSTOMER
RETURN = LS_RETURN
EXCEPTIONS
OTHERS = 1
.
BREAK-POINT…
IF sy-subrc <> 0.
*Implement suitable error handling here
ENDIF.
FORM frm_settitle USING uv_old .
DATA lv_ret_s TYPE c LENGTH 200.
CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
string = uv_old
lang = ‘E’
IMPORTING
rstring = lv_ret_s
EXCEPTIONS
too_small = 1
OTHERS = 2.
DATA lv_astring TYPE string.
lv_astring = lv_ret_s.
DATA lv_xs TYPE xstring.
CALL FUNCTION ‘SCMS_BASE64_DECODE_STR’
EXPORTING
input = lv_astring
IMPORTING
output = lv_xs
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
DATA lt_str TYPE STANDARD TABLE OF solix.
DATA lv_i TYPE i.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lv_xs
IMPORTING
output_length = lv_i
TABLES
binary_tab = lt_str[].
CHECK NOT lt_str[] IS INITIAL.
DATA lv_long TYPE string.
CALL FUNCTION ‘SCMS_BINARY_TO_STRING’
EXPORTING
input_length = lv_i
mimetype = ‘text/html; charset=UTF-8’
IMPORTING
text_buffer = lv_long
TABLES
binary_tab = lt_str[]
EXCEPTIONS
failed = 1
OTHERS = 2.
sy-title = lv_long.
ENDFORM.
If you have problem, please fell free to contact.Thanks.
This post is come from www.hot583.com, you can share/use it with the post original link for free.
But pay attention of any risk yourself.
微信原文《The End》