Add new data

Add an extension on item level for a declaration procedure

DATA:
    dlv_dos      TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
    dlv_do       TYPE REF TO /aeb/if_aes_pb_delivery_do,
    itm_dos      TYPE /aeb/if_aes_pb_delivery_itm_do=>tt_delivery_item_do,
    itm_do       TYPE REF TO /aeb/if_aes_pb_delivery_itm_do,
    itm_ext_do   TYPE REF TO /aeb/if_aes_pb_ditm_extd_do,
    itm_exp_se   TYPE REF TO /aeb/if_aes_pb_ditm_eu_do,
    pref_data    TYPE REF TO /aeb/if_aes_pb_pref_data_eu_do,
    prod_doc_dos TYPE /aeb/if_aes_pb_prod_doc_eu_do=>tt_prod_doc_eu_do,
    prod_doc_do  TYPE REF TO /aeb/if_aes_pb_prod_doc_eu_do.

  dlv_dos = im_value->get_deliveries( ).
  LOOP AT dlv_dos INTO dlv_do.
    itm_dos = dlv_do->get_items( ).
    LOOP AT itm_dos INTO itm_do.
*     Instantiate the extension of type Export SE
      itm_ext_do = im_cons_data_object_factory->new_aes_pb_ditm_extd_do( ).
      itm_do->set_extension( itm_ext_do ).
      itm_exp_se = im_cons_data_object_factory->new_aes_pb_ditm_eu_do( ).
      itm_ext_do->set_export_se( itm_exp_se ).

*     Fill the nature of transaction code
      itm_exp_se->set_transaction_nature_code( im_nullable_value_factory->char_2( '22' ) ).

*     Fill the preferential data
      pref_data = im_cons_data_object_factory->new_aes_pb_pref_data_eu_do( ).
      itm_exp_se->set_preferential_data( pref_data ).
      pref_data->set_preference_type( im_nullable_value_factory->char_3( '333' ) ).

*     Add a document
      prod_doc_do = im_cons_data_object_factory->new_aes_pb_prod_doc_eu_do( ).
      CLEAR prod_doc_dos.
      APPEND prod_doc_do TO prod_doc_dos.
      itm_exp_se->set_produced_documents( prod_doc_dos ).
      
      prod_doc_do->set_amount( im_cons_data_object_factory->new_aes_pb_aom_do_v1( 
        im_currency_iso = 'EUR'
        im_value        = im_nullable_value_factory->dec_17_2( '5000.00' ) ) ).
      prod_doc_do->set_complementary_info( im_nullable_value_factory->char_26( 'This is a info' ) ).
      prod_doc_do->set_document_part( im_nullable_value_factory->char_5( '10002' ) ).
      prod_doc_do->set_information_date( im_cons_data_object_factory->new_01_pb_date_and_zone_do( 
        im_date_in_timezone = '20190522120000'
        im_timezone         = 'UTC' ) ).
      prod_doc_do->set_quantity( im_cons_data_object_factory->new_01_quantity_do(
        im_unit  = 'ST'
        im_value = '1' ) ).
      prod_doc_do->set_reference( im_nullable_value_factory->char_35( '35000' ) ).
      prod_doc_do->set_status_code( im_nullable_value_factory->char_2( '22' ) ).
      prod_doc_do->set_type_code( im_nullable_value_factory->char_9( 'Y901' ) ).
    ENDLOOP.
  ENDLOOP.

Add equipment with container information

DATA:
    dlv_dos          TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
    dlv_do           TYPE REF TO /aeb/if_aes_pb_delivery_do,
    equipment_dos    TYPE /aeb/if_aes_pb_trsprt_equip_do=>tt_transport_equip_do,
    equipment_do     TYPE REF TO /aeb/if_aes_pb_trsprt_equip_do,
    container_number TYPE /aeb/if_aes_pb_trsprt_equip_do=>t_identification.

  dlv_dos = im_value->get_deliveries( ).
  LOOP AT dlv_dos INTO dlv_do.
    equipment_dos = dlv_do->get_transport_equipments( ).

    container_number = im_vttk-signi.
    equipment_do = im_cons_data_object_factory->new_aes_pb_trsprt_equip_do( im_equipment_type = 'CONTAINER'
                                                                            im_identification = container_number ).
    APPEND equipment_do TO equipment_dos.

    dlv_do->set_transport_equipments( equipment_dos ).
  ENDLOOP.

Add an additional reference for the port booking number

DATA:
    dlv_dos                  TYPE /aeb/if_aes_pb_delivery_do=>tt_delivery_do,
    dlv_do                   TYPE REF TO /aeb/if_aes_pb_delivery_do,
    additional_reference_dos TYPE /aeb/if_aes_pb_add_ref_do=>tt_add_reference_do,
    additional_reference_do  TYPE REF TO /aeb/if_aes_pb_add_ref_do,
    port_booking_number      TYPE /aeb/if_aes_pb_add_ref_do=>t_reference.

  dlv_dos = im_value->get_deliveries( ).
  LOOP AT dlv_dos INTO dlv_do.
    additional_reference_dos = dlv_do->get_additional_references( ).

    port_booking_number = im_vttk-tndr_trkid.
    additional_reference_do = im_cons_data_object_factory->new_aes_pb_add_ref_do( im_reference_type = 'PORT_BOOKING_NUMBER'
                                                                                    im_reference = port_booking_number ).
                                                                                    
		APPEND additional_reference_do TO additional_reference_dos.
    dlv_do->set_additional_references( additional_reference_dos ).
  ENDLOOP.