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

Create an address but doesnu00B4t relate with business partner? (BAS)

Hi Gurus,

I need your help. I have the following requirement:

when creating a business partner with role 'Contact person' the system must ask for another business partner to establish automatically a relationship type 'BUR001'. Also the system must create an address for the contact person with business partner's standard data address, who the system is asking for.

I have create an entry for event DSAVC (CRMH application) through BUBI transaction.

The source code of the z function module is the following:

*Show a pop-up asking for a business partner

CALL FUNCTION 'FOBU_POPUP_GET_VALUE'

EXPORTING

TABLENAME = 'BUT000'

FIELDNAME = 'PARTNER'

VALUE_CHECK = 'X'

POPUP_TITLE = 'Relación IC'

START_COLUMN = 5

START_ROW = 5

IMPORTING

FIELD_VALUE_INT = partner2

  • FIELD_VALUE_INT_C =

  • FIELD_VALUE_EXT =

  • EX_CURRENCY =

  • EX_UNIT =

EXCEPTIONS

INTERNAL_ERROR = 1

CANCELLED = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*Create the relationship

CALL FUNCTION 'BURS_RELATION_MAINTAIN'

EXPORTING

iv_aktyp = c_activ_crear

  • IV_RELNR =

iv_partner1 = partner2

iv_partner2 = partner

iv_date_to = c_el_fin_de_los_tiempos

IV_DATE_FROM = hoy

IV_RELTYP = c_relac_pers_contacto

IV_XRF = ' '

IV_DFTVAL = ' '

  • IV_RLTYP =

IV_XBDT_CLASS_INIT = ' '

IV_XSAVE = 'X'

  • IV_XUPDTASK = 'X'

IV_XSWAP_PARTNERS = 'X'

IV_XDIALOG_NODET = 'X'

IV_DISPLAY_MODE = 'P'

IV_MESSAGE_MODE = '4'

IV_XCHECK_ONLY = ' '

EXCEPTIONS

OTHERS = 1

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*Verification wether the contact person has an address

data: T_ADDRESS type table of BUS020_EXT.

CALL FUNCTION 'BUA_BUPA_ADDRESS_MEM_GET_ALL'

EXPORTING

i_partner = partner

I_ADR_KIND = 'XXDEFAULT'

I_XWA = 'X'

TABLES

T_ADDRESS = t_address

EXCEPTIONS

PARTNER_NOT_IN_MEMORY = 1

NO_ADDRESS_FOUND = 2

ADDRESS_NOT_EXIST = 3

PERSON_NOT_EXIST = 4

INTERNAL_ERROR = 5

OTHERS = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

data: lin type i.

DATA: RETURN TYPE TABLE OF BAPIRET2.

data: et_return type table of bapiret2.

data: ADDRNUMBER TYPE AD_ADDRNUM.

describe table t_address lines lin.

*If contact person hasn't an standard address,

*it must be created

if lin = 0.

*search for the standard address of the business *partner, who the system is asking for

CALL FUNCTION 'BUPA_ADDRESS_GET_NUMBERS'

EXPORTING

IV_PARTNER = partner2

  • IV_PARTNER_GUID =

  • IV_ADDRNUMBER =

  • IV_ADDRGUID =

  • IV_ADDREXTERNAL =

  • IV_VALDT_OF_STANDARD_ADDR =

IMPORTING

EV_ADDRNUMBER = ADDRNUMBER

  • EV_ADDRGUID =

  • EV_ADDREXTERNAL =

TABLES

ET_RETURN = et_return

.

data: address_selection like addr1_sel.

data: ADDRESS_VALUE like addr1_val.

address_selection-addrnumber = ADDRNUMBER.

*Reads a (fully qualified) address. All versions of this *address are read into local memory, and are *subsequently accessible without database access

CALL FUNCTION 'ADDR_GET'

EXPORTING

address_selection = address_selection

  • ADDRESS_GROUP =

  • READ_SADR_ONLY = ' '

  • READ_TEXTS = ' '

  • IV_CURRENT_COMM_DATA = ' '

IMPORTING

ADDRESS_VALUE = ADDRESS_VALUE

  • ADDRESS_ADDITIONAL_INFO =

  • RETURNCODE =

  • ADDRESS_TEXT =

  • SADR =

  • TABLES

  • ADDRESS_GROUPS =

  • ERROR_TABLE =

  • VERSIONS =

EXCEPTIONS

PARAMETER_ERROR = 1

ADDRESS_NOT_EXIST = 2

VERSION_NOT_EXIST = 3

INTERNAL_ERROR = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Address number, address handle, address group, address *data

data: address_number like adrc-addrnumber.

data: address_handle like szad_field-handle.

*Address group in table TSAD7

data: address_group like addr_ref-addr_group value 'BP '.

data: begin of address_data.

include structure addr1_data.

data: end of address_data.

  • Use details

data: begin of usage.

include structure addr_ref.

data: end of usage.

*Error table

data: begin of errors occurs 0.

include structure addr_error.

data: end of errors.

*return codes

data: rc_insert like szad_field-returncode.

data: rc_number_get like inri-returncode.

data: rc_memory_save like sy-subrc.

data: lv_check_address like szad_field-flag.

*Move data address to my new data address for contact *person. Fill address record and determine temporary *address identifier

move-corresponding ADDRESS_VALUE to address_data.

address_handle = '1'.

  • Deactivate address check if required

lv_check_address = 'X'.

  • Insert new address in local memory

call function 'ADDR_INSERT'

exporting address_data = address_data

address_group = address_group

address_handle = address_handle

check_address = lv_check_address

importing address_data = address_data

returncode = rc_insert

tables error_table = errors

exceptions address_exist = 1

parameter_error = 2

internal_error = 3.

case sy-subrc.

when 0.

if rc_insert = 'E'.

*Check error

endif.

when others.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endcase.

  • Declare final use to address management

*Look DB table TSADRV

usage-appl_table = 'BUT000'.

usage-appl_field = 'PARTNER'.

concatenate '100' partner into usage-appl_key.

usage-addr_group = address_group.

*Assigns an address number, i.e. converts a temporary *address number (address handle) into a permanent *address number which is saved in the database key.

call function 'ADDR_NUMBER_GET'

exporting address_handle = address_handle

address_reference = usage

importing address_number = address_number

returncode_numberrange = rc_number_get

exceptions address_handle_not_exist = 1

internal_error = 2

parameter_error = 3.

case sy-subrc.

when 0.

when others.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endcase.

*Saves the local memory contents in the database. All *address data changes made since the first call of any *function module in the function group are then *permanent. Numbers must have been assigned to all *addresses before storing.

call function 'ADDR_MEMORY_SAVE'

EXPORTING

EXECUTE_IN_UPDATE_TASK = 'X'

exceptions address_number_missing = 1

person_number_missing = 2

internal_error = 3

database_error = 4

reference_missing = 5.

case sy-subrc.

when 0.

when others.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endcase.

This code works partially fine. I mean that the contact person is created and the relationship with the business partner, who the system is asking for, is also created. Also, a new address is created. You can see it in DB table ADRC, however this address is not assigned to contact person. That means that no entry is created in DB table BUT020. Thus, when I display the contact person in BP, no address is displayed.

Why happens this??????????????????????

I thought that when I declare the usage details as:

usage-appl_table = 'BUT000'.

usage-appl_field = 'PARTNER'.

concatenate '100' partner into usage-appl_key.

usage-addr_group = address_group.

In table TSADRV (Where-used list addresses: Object types, DDIC information),

there is an entry with key BUT000 PARTNER with following fields:

BUT000 --> Application table logical name

PARTNER --> Applic. table address logical field name

BUS1006 --> Object Type

BUT020 --> Data Dictionary applic. table name

ADDRNUMBER --> Data Dictionary applic. table field name

BP --> Address or Person Group(Business Address Services)

I thougt the system did the relationship through TSADRV entry above and the usage I have defined using

usage-appl_key equal client plus partner number. As in TSADRV for key BUT000 PARTNER, Data Dictionary applic. table name is BUT020, I supposed an entry would be created in BUT020 to relate business partner with address, but it seems not working in this way.

Perhaps I must customize something else, but what?

Please, I would be grateful with any recommendation.

Thanks in Advance.

Rosa

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Oct 19, 2006 at 01:59 PM

    Hi Rosa,

    Maybe you can build too the but020 data, try with function modules:

    BUP_MEMORY_BUT020_CALLBACK

    BUP_MEMORY_BUT020_FILL

    BUP_MEMORY_BUT020_GET

    Regards.

    Manuel

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Manuel,

      BUP MEMORY_BUT020_GET doesn't return anything. I have used BUP MEMORY_BUT020_FILL but as I don´t fill the field ADDRESS_GUID, the function module doesn´t work fine. My doubt: how to obtain an ADDREES_GUID since I have the ADDRNUMBER?????

      Any idea?

      Best Regards,

      Rosa

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.