Processing more in detail
Sometimes it is necessary to use the full functionality of Carrier Connect. For this requirement you can use the class /AEB/CL_PA_PB_CARRIER_BF. This class allows to directly address the Carrier Connect functions completely. To see more about using those functions check https://transport-freight-management.docs.developers.aeb.com/docs/getting-started-with-carrier-connect.
But don't worry, there are a still few complementary features that we provide out of the box. So you don't have to develop everything from scratch.
Task | Class |
---|---|
Determination of the org unit | Freight order: /AE1/CL_PA_PB_FRO_OU_RULE_BC |
Determination of connection parms | /AEB/CL_PA_PB_ENGN_PRM_BC |
Collecting data for a shipment | Freight order: /AE1/CL_PA_PB_FRO_SHP_COLL_BC |
Determination of the shipment reference | Freight order: /AE1/CL_PA_PB_FRO_SHP_REF_BC |
Determination of the workstation ID | /AEB/CL_PA_PB_WSTA_ID_BC |
In the following program you will see a reference implementation that combines those functions. The task is to implement the same as seen in the "the first shipment"- part, but now using the functions above. First thing is to determine an organisational unit.
REPORT zaeb_create_first_shipment.
PARAMETERS: vbeln TYPE likp-vbeln.
DATA:
likp TYPE likp,
lipss TYPE STANDARD TABLE OF lips,
vbpas TYPE STANDARD TABLE OF vbpa,
vekps TYPE STANDARD TABLE OF vekp,
org_unit_rule_bc TYPE REF TO /aeb/cl_pa_pb_dlv_ou_rule_bc,
org_unit TYPE string.
SELECT SINGLE * FROM likp INTO likp WHERE vbeln = vbeln.
SELECT * FROM lips INTO TABLE lipss WHERE vbeln = vbeln.
SELECT * FROM vbpa INTO TABLE vbpas WHERE vbeln = vbeln.
SELECT * FROM vekp INTO TABLE vekps WHERE vpobjkey = vbeln.
org_unit_rule_bc = /aeb/cl_pa_pb_dlv_ou_rule_bc=>new_for(
im_likp = likp
im_lipss = lipss ).
org_unit = org_unit_rule_bc->get_org_unit( ).
WRITE: 'OrgUnit: ' , org_unit.
WRITE /.
If you run the report the org unit should be shown. The next step is to determine the connection parameter with this org unit.
REPORT zaeb_create_first_shipment.
PARAMETERS: vbeln TYPE likp-vbeln.
DATA:
likp TYPE likp,
lipss TYPE STANDARD TABLE OF lips,
vbpas TYPE STANDARD TABLE OF vbpa,
vekps TYPE STANDARD TABLE OF vekp,
org_unit_rule_bc TYPE REF TO /aeb/cl_pa_pb_dlv_ou_rule_bc,
org_unit TYPE /aeb/01_char20,
engn_prm_bc TYPE REF TO /aeb/cl_pa_pb_engn_prm_bc,
engn_prm_mo TYPE REF TO /aeb/if_pa_pb_engn_prm_mo.
SELECT SINGLE * FROM likp INTO likp WHERE vbeln = vbeln.
SELECT * FROM lips INTO TABLE lipss WHERE vbeln = vbeln.
SELECT * FROM vbpa INTO TABLE vbpas WHERE vbeln = vbeln.
SELECT * FROM vekp INTO TABLE vekps WHERE vpobjkey = vbeln.
org_unit_rule_bc = /aeb/cl_pa_pb_dlv_ou_rule_bc=>new_for( im_likp = likp im_lipss = lipss ).
org_unit = org_unit_rule_bc->get_org_unit( ).
WRITE: 'OrgUnit: ' , org_unit.
WRITE /.
engn_prm_bc = /aeb/cl_pa_pb_engn_prm_bc=>get_instance( ).
engn_prm_mo = engn_prm_bc->get_engn_prm_do_for( org_unit ).
WRITE: 'Destination: ' , engn_prm_mo->get_destination( ).
WRITE: 'Engine client: ' , engn_prm_mo->get_engine_client( ).
If you run the report again the destination and engine client will be printed on screen. Now we need the data for the shipment.
REPORT zaeb_create_first_shipment.
PARAMETERS: vbeln TYPE likp-vbeln.
DATA:
likp TYPE likp,
lipss TYPE STANDARD TABLE OF lips,
vbpas TYPE STANDARD TABLE OF vbpa,
vekps TYPE STANDARD TABLE OF vekp,
org_unit_rule_bc TYPE REF TO /aeb/cl_pa_pb_dlv_ou_rule_bc,
org_unit TYPE /aeb/01_char20,
engn_prm_bc TYPE REF TO /aeb/cl_pa_pb_engn_prm_bc,
engn_prm_mo TYPE REF TO /aeb/if_pa_pb_engn_prm_mo,
collector_bc TYPE REF TO /aeb/cl_pa_pb_dlv_shp_coll_bc,
shipment TYPE /aeb/pa_pb_dl_shp_req_do.
SELECT SINGLE * FROM likp INTO likp WHERE vbeln = vbeln.
SELECT * FROM lips INTO TABLE lipss WHERE vbeln = vbeln.
SELECT * FROM vbpa INTO TABLE vbpas WHERE vbeln = vbeln.
SELECT * FROM vekp INTO TABLE vekps WHERE vpobjkey = vbeln.
org_unit_rule_bc = /aeb/cl_pa_pb_dlv_ou_rule_bc=>new_for( im_likp = likp im_lipss = lipss ).
org_unit = org_unit_rule_bc->get_org_unit( ).
WRITE: 'OrgUnit: ' , org_unit.
WRITE /.
engn_prm_bc = /aeb/cl_pa_pb_engn_prm_bc=>get_instance( ).
engn_prm_mo = engn_prm_bc->get_engn_prm_do_for( org_unit ).
WRITE: 'Destination: ' , engn_prm_mo->get_destination( ).
WRITE /.
WRITE: 'Engine client: ' , engn_prm_mo->get_engine_client( ).
WRITE /.
collector_bc = /aeb/cl_pa_pb_dlv_shp_coll_bc=>new_for( im_likp = likp
im_lipss = lipss
im_vbpas = vbpas
im_vekps = vekps ).
shipment = collector_bc->create_shipment( org_unit ).
write shipment-referencenumber1.
WRITE /.
Now the program has collected data of the delivery, e.g. the reference number. What you need as well for printing the label is a workstation ID. Just add the following code lines to the program.
DATA: workstation_id TYPE string.
workstation_id = /aeb/cl_pa_pb_wsta_id_bc=>new( )->get_workstation_id( ).
write: workstation_id.
write /.
Now you have everything to create your first shipment. You have to combine the data you collected with the class /AEB/CL_PA_PB_CARRIER_BF. Add the following code to your report.
DATA:
request TYPE REF TO /aeb/cl_pa_pb_cr_shp_req_do,
result_language_iso_codes TYPE /aeb/01_char2s,
result TYPE REF TO /aeb/cl_pa_pb_cr_shp_res_do,
exc TYPE REF TO /aeb/cx_01_pb_bf_inv_sc,
msg TYPE REF TO /aeb/cl_01_pb_res_msg_do,
text TYPE REF TO /aeb/cl_01_pb_til_do,
creation_parms TYPE REF TO /aeb/cl_pa_pb_cr_prm_do,
process_parms TYPE REF TO /aeb/cl_pa_pb_shp_prp_do,
output_mode TYPE REF TO /aeb/cl_pa_pb_doc_outm_do,
prepare_scope TYPE REF TO /aeb/cl_pa_pb_doc_scope_do,
process_mode TYPE /aeb/pa_pb_dl_pmode_do,
output_scope TYPE REF TO /aeb/cl_pa_pb_doc_scope_do,
carrier_bf TYPE REF TO /aeb/cl_pa_pb_carrier_bf.
CREATE OBJECT request.
request->set_client_identcode( engn_prm_mo->get_engine_client( ) ).
request->set_client_system_id( 'E23_400' ).
request->set_shipment( shipment ).
request->set_username( sy-uname ).
APPEND 'DE' TO result_language_iso_codes.
APPEND 'EN' TO result_language_iso_codes.
request->set_result_language_iso_codes( result_language_iso_codes ).
CREATE OBJECT creation_parms.
creation_parms->set_creation_mode( 'ALWAYS' ).
request->set_creation_parms( creation_parms ).
CREATE OBJECT process_parms.
process_parms->set_do_completion( 'X' ).
process_parms->set_workstation_id( workstation_id ).
CREATE OBJECT output_mode.
output_mode->set_mode( 'NONE' ).
process_parms->set_document_output_mode( output_mode ).
process_mode-mode = 'EXTENDED'.
process_parms->set_process_mode( process_mode ).
CREATE OBJECT prepare_scope.
prepare_scope->set_scope( 'ALL' ).
process_parms->set_document_prepare_scope( prepare_scope ).
CREATE OBJECT output_scope.
output_scope->set_scope( 'ALL' ).
process_parms->set_document_output_scope( output_scope ).
request->set_process_parms( process_parms ).
TRY.
carrier_bf = /aeb/cl_pa_pb_carrier_bf=>new_for( im_engn_prm = engn_prm_mo
im_org_unit = org_unit ).
result = carrier_bf->create_shipment( request ).
IF result->get_has_errors( ) = 'X'.
LOOP AT result->get_messages( ) INTO msg.
LOOP AT msg->get_message_texts( ) INTO text.
WRITE text->get_text( ).
WRITE /.
ENDLOOP.
ENDLOOP.
ELSE.
WRITE result->get_shipment_number( ).
ENDIF.
CATCH /aeb/cx_01_pb_bf_inv_sc INTO exc.
WRITE exc->/aeb/if_01_cx_message~get_msg_as_str( ).
ENDTRY.
Run the report. Now you should see the shipment number on your screen. Next step is to collect the data of the shipment.
REPORT zaeb_get_first_shipment.
PARAMETERS: vbeln TYPE likp-vbeln.
DATA:
likp TYPE likp,
lipss TYPE STANDARD TABLE OF lips,
org_unit_rule_bc TYPE REF TO /aeb/cl_pa_pb_dlv_ou_rule_bc,
org_unit TYPE /aeb/01_char20,
engn_prm_bc TYPE REF TO /aeb/cl_pa_pb_engn_prm_bc,
engn_prm_mo TYPE REF TO /aeb/if_pa_pb_engn_prm_mo,
shp_ref_bc TYPE REF TO /aeb/cl_pa_pb_dlv_shp_ref_bc,
shipment_ref TYPE /aeb/pa_pb_dl_shp_ref_do,
carrier_bf TYPE REF TO /aeb/cl_pa_pb_carrier_bf.
SELECT SINGLE * FROM likp INTO likp WHERE vbeln = vbeln.
SELECT * FROM lips INTO TABLE lipss WHERE vbeln = vbeln.
org_unit_rule_bc = /aeb/cl_pa_pb_dlv_ou_rule_bc=>new_for( im_likp = likp im_lipss = lipss ).
org_unit = org_unit_rule_bc->get_org_unit( ).
engn_prm_bc = /aeb/cl_pa_pb_engn_prm_bc=>get_instance( ).
engn_prm_mo = engn_prm_bc->get_engn_prm_do_for( org_unit ).
shp_ref_bc = /aeb/cl_pa_pb_dlv_shp_ref_bc=>new_for( likp ).
shipment_ref = shp_ref_bc->get_shp_ref_do( ).
DATA:
request TYPE REF TO /aeb/cl_pa_pb_get_shp_req_do,
result_language_iso_codes TYPE /aeb/01_char2s,
result TYPE REF TO /aeb/cl_pa_pb_get_shp_res_do,
exc TYPE REF TO /aeb/cx_01_pb_bf_inv_sc,
msg TYPE REF TO /aeb/cl_01_pb_res_msg_do,
text TYPE REF TO /aeb/cl_01_pb_til_do,
shp_refs TYPE /aeb/pa_pb_dl_shp_ref_dos,
shipment TYPE /aeb/pa_pb_dl_shp_res_do.
CREATE OBJECT request.
request->set_client_identcode( engn_prm_mo->get_engine_client( ) ).
request->set_client_system_id( 'E23_400' ).
request->set_username( sy-uname ).
APPEND 'DE' TO result_language_iso_codes.
APPEND 'EN' TO result_language_iso_codes.
request->set_result_language_iso_codes( result_language_iso_codes ).
APPEND shipment_ref TO shp_refs.
request->set_shipment_references( shp_refs ).
TRY.
carrier_bf = /aeb/cl_pa_pb_carrier_bf=>new_for( im_engn_prm = engn_prm_mo
im_org_unit = org_unit ).
result = carrier_bf->get_shipments( request ).
IF result->get_has_errors( ) = 'X'.
LOOP AT result->get_messages( ) INTO msg.
LOOP AT msg->get_message_texts( ) INTO text.
WRITE text->get_text( ).
WRITE /.
ENDLOOP.
ENDLOOP.
ELSE.
loop at result->get_shipments( ) into shipment.
write shipment-referencenumber1.
endloop.
ENDIF.
CATCH /aeb/cx_01_pb_bf_inv_sc INTO exc.
WRITE exc->/aeb/if_01_cx_message~get_msg_as_str( ).
ENDTRY.
Run the report and the delivery number should be shown on your screen.
Now that you know which functions you need to combine using /AEB/CL_PA_PB_CARRIER_BF you should be able to implement everything else what is possible via this API. In addition, there is a function module /AEB/PA_PB_GET_CAR_PROPS that enables you to get the master data information from Carrier Connect.
Note: The public class will not write log entries. You can use the class /AEB/CL_PA_PB_LOGGER_BC and use the response data from the call to write a log entry. You can use the result type to determine if you should write an error or a warning log entry e.g. IF result->has_error( ) = 'X'. logger->create_log_error( ). ELSEIF result->has_warning( ) ...
Updated 5 days ago