Skip to Content
0
Jul 02, 2018 at 12:57 PM

How can a document address be created by BOL?

200 Views Last edit Aug 13, 2018 at 02:30 PM 10 rev

Hello experts,

I have a simple problem, but do not find a solution for it.

The task is to create a document address on a one order document like a service order.

This is my code:

  " create partner entity
  DATA(lo_partner) = lo_header_entity->create_related_entity( 
                                        'BTPartnerAll' ) .

  lo_partner->set_property(: iv_attr_name = 'PARTNER_FCT'
                             iv_value     = '00000001' ),
                             iv_attr_name = 'PARTNER_NO'
                             iv_value     = '<some business partner>' ).

 " reset values on partner entity for setting document address
  lo_partner->set_property(: iv_attr_name = 'ADDR_NR'
                             iv_value     = ' ' ),
                             iv_attr_name = 'ADDR_NP'
                             iv_value     = ' ' ),
                             iv_attr_name = 'STD_BP_ADDRESS'
                             iv_value     = ' ' ),
                             iv_attr_name = 'ADDR_ORIGIN'
                             iv_value     = 'B' ). " this is necessary to allow the change for new business partner (COM_PARTNER_FIELDSELECTION_OW)

  " create partner address entity
  DATA(lo_doc_addr) = lo_partner->create_related_entity( 
                                    'BTPartnerAddress' ).

  " maintain address fields  
  lo_doc_addr->set_property(:
             iv_attr_name = 'ADDR_NO'    iv_value = ' ' ),
             iv_attr_name = 'PERS_NO'    iv_value = ' ' ),
             iv_attr_name = 'CITY'       iv_value = ls_addr-city ),
             iv_attr_name = 'STREET'     iv_value = ls_addr-street ),
             iv_attr_name = 'COUNTRY'    iv_value = ls_addr-countr ),
             iv_attr_name = 'POSTL_COD1' iv_value = ls_addr-postl_cod1 ),
             iv_attr_name = 'HOUSE_NO'   iv_value = ls_addr-house_no   ),
             iv_attr_name = 'HOUSE_NO2'  iv_value = ls_addr-house_no2  ).

lo_bol_core->modify( ).

This code will lead to retrieving the business partner address first (if the bp exists) and then the address values are maintained on that existing address. Then I have a document address which is merged/mixed containing the old and the new address data.

What is the right way to create a document address with BOL?

Any idea would be highly appreciated.

Thanks and regards,
Andre