BAdI /AEB/AES_CONS_INV_01

DATA:
    remark TYPE /aeb/if_aes_pb_consignment_do=>t_remark.

  CONCATENATE 'Invoice number: ' im_vbrk-vbeln ', invoice date: ' im_vbrk-fkdat
         INTO remark
         SEPARATED BY space.
  im_value->set_remark( remark ).
DATA:
    total_net_mass_nv TYPE REF TO /aeb/cl_01_dec_17_3_nv,
    total_net_mass    TYPE REF TO /aeb/if_aes_pb_quantity_do,
    deliveries        TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
    first_delivery    TYPE REF TO /aeb/if_aes_pb_delivery_do.

  total_net_mass_nv = im_nullable_value_factory->dec_17_3( '500.00' ).
  total_net_mass = im_cons_data_object_factory->new_aes_pb_quantity_do_v1(
                        im_unit  = 'KG'
                        im_value = total_net_mass_nv ).

  deliveries = im_value->get_deliveries( ).
  READ TABLE deliveries INTO first_delivery INDEX 1.
  first_delivery->set_total_net_mass( total_net_mass ).
DATA:
    quantity_nv      TYPE REF TO /aeb/cl_01_dec_17_3_nv,
    new_quantity     TYPE REF TO /aeb/if_aes_pb_quantity_do,
    deliveries       TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
    first_delivery   TYPE REF TO /aeb/if_aes_pb_delivery_do,
    items            TYPE /aeb/if_aes_pb_delivery_itm_do=>tt_delivery_item_do,
    first_item       TYPE REF TO /aeb/if_aes_pb_delivery_itm_do,
    quantities       TYPE /aeb/if_aes_pb_ic_quantity_do=>tt_ic_quantity_do,
    current_quantity TYPE REF TO /aeb/if_aes_pb_ic_quantity_do.

  quantity_nv = im_nullable_value_factory->dec_17_3( 1 ).
  new_quantity = im_cons_data_object_factory->new_aes_pb_quantity_do_v1( im_unit  = 'ST'
                                                                         im_value = quantity_nv ).

  deliveries = im_value->get_deliveries( ).
  READ TABLE deliveries INTO first_delivery INDEX 1.
  items = first_delivery->get_items( ).
  READ TABLE items INTO first_item INDEX 1.
  quantities = first_item->get_quantities( ).
  LOOP AT quantities INTO current_quantity.
    IF current_quantity->get_quantity_type( ) = 'ITEM'.
      current_quantity->set_quantity( new_quantity ).
    ENDIF.
  ENDLOOP.
DATA:
  deliveries          TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
  curr_delivery       TYPE REF TO /aeb/if_aes_pb_delivery_do,
  items               TYPE /aeb/if_aes_pb_delivery_itm_do=>tt_delivery_item_do,
  curr_item           TYPE REF TO /aeb/if_aes_pb_delivery_itm_do,
  add_aggregation_key TYPE REF TO /aeb/cl_01_char_100_nv.

deliveries = im_value->get_deliveries( ).

LOOP AT deliveries INTO curr_delivery.
  items = curr_delivery->get_items( ).
  LOOP AT items INTO curr_item.
    add_aggregation_key = im_nullable_value_factory->char_100( '3LLA' ).
    curr_item->set_additional_aggregation_key( add_aggregation_key ).
  ENDLOOP.
ENDLOOP.
DATA:
deliveries         TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
curr_delivery      TYPE REF TO /aeb/if_aes_pb_delivery_do,
secu_consignee     TYPE REF TO /aeb/if_aes_pb_party_do.   

deliveries = im_value->get_deliveries( ).

 LOOP AT deliveries INTO curr_delivery.
 secu_consignee = im_cons_data_object_factory->new_aes_pb_party_do( ).
        parties = curr_delivery->get_parties( ).
        LOOP AT parties INTO party.
          IF party->get_party_type( ) = 'CONSIGNEE'.
            fld_city          = party->get_city( ).
            fld_c_number      = party->get_company_number( ).
            fld_country       = party->get_country( ).
            fld_district      = party->get_district( ).
            fld_name          = party->get_name( ).
            fld_post_code     = party->get_post_code( ).
            fld_street        = party->get_street( ).
            secu_consignee->set_city( fld_city ).
            secu_consignee->set_company_number( fld_c_number ).
            secu_consignee->set_country( fld_country ).
            secu_consignee->set_district( fld_district ).
            secu_consignee->set_name( fld_name ).
            secu_consignee->set_post_code( fld_post_code ).
            secu_consignee->set_street( fld_street ).
            secu_consignee->set_party_type( 'CONSIGNEE_SECURITY' ).
            APPEND secu_consignee TO parties.
          ENDIF.
        ENDLOOP.
        curr_delivery->set_parties( parties ).
  ENDLOOP.