You are on page 1of 3

Here is an example ABAP code for creating business partner (BP) master data:

```

REPORT Z_CREATE_BP_MASTER.

DATA: lv_name1 TYPE BAPIADDR1-NAME1,

lv_city1 TYPE BAPIADDR1-CITY1,

lv_post_code1 TYPE BAPIADDR1-POST_CODE1,

lv_country TYPE BAPIADDR1-COUNTRY,

lv_partner_guid TYPE BAPI_BUS_PARTNER-GUID,

lv_partner_number TYPE BAPI_BUS_PARTNER-BPARTNER,

lv_return_code LIKE BAPIRET2-TYPE.

* Set up BP address data

lv_name1 = 'John Doe'.

lv_city1 = 'New York'.

lv_post_code1 = '10001'.

lv_country = 'US'.

* Call function module to create BP

CALL FUNCTION 'BAPI_BUSPARTNER_CREATE'

EXPORTING

businesspartnercategory = '2' " BP category: Person

partnerlanguage = 'EN'

iscompanyind = 'X'

organization = 'John Doe'

countrykey = lv_country

IMPORTING

partnerguid = lv_partner_guid

partnernumber = lv_partner_number

return = lv_return_code
TABLES

addressdata = lt_address_data.

* Check for errors

IF lv_return_code NE 'S'.

MESSAGE 'BP creation failed' TYPE 'E'.

ELSE.

MESSAGE 'BP created successfully' TYPE 'I'.

ENDIF.

```

Note that this is just a simple example and you may need to modify the code to suit your specific
business requirements. You will also need to define the LT_ADDRESS_DATA table, which contains
the address information for the BP, before calling the function module.

Here is an example ABAP code for displaying Business Partner (BP) master data in a report:

```

REPORT Z_DISPLAY_BP_MASTER.

* Define internal table for storing BP data

TYPES: BEGIN OF ty_bp_data,

bp_number TYPE bapi_bus_partner-bpartner,

bp_name TYPE bapiaddr1-name1,

bp_city TYPE bapiaddr1-city1,

bp_post_code TYPE bapiaddr1-post_code1,

bp_country TYPE bapiaddr1-country,

END OF ty_bp_data.

DATA: lt_bp_data TYPE STANDARD TABLE OF ty_bp_data,

lv_return_code LIKE bapiret2-type.


* Call function module to retrieve BP data

CALL FUNCTION 'BAPI_BUSPARTNER_GETLIST'

EXPORTING

maxrows = 100 " Maximum number of rows to retrieve

TABLES

businesspartnerlist = lt_bp_data

RETURNING

RETURN = lv_return_code.

* Display BP data in a report

IF lt_bp_data IS NOT INITIAL.

WRITE: / 'BP Number', 'BP Name', 'City', 'Post Code', 'Country'.

LOOP AT lt_bp_data INTO DATA(ls_bp_data).

WRITE: / ls_bp_data-bp_number, ls_bp_data-bp_name, ls_bp_data-bp_city,

ls_bp_data-bp_post_code, ls_bp_data-bp_country.

ENDLOOP.

ELSE.

WRITE: / 'No BP data found'.

ENDIF.

```

Note that this is just a simple example and you may need to modify the code to suit your specific
business requirements. The BAPI_BUSPARTNER_GETLIST function module retrieves a list of BP data
and populates it into the LT_BP_DATA table. You can then loop through the table and display the BP
data in a report.

You might also like