below code gives an option of creating Vehicles along with SO in VMS system in SAP. User has option o creating multiple Vehicle and SO with multiple or single vehicle. as of now the code has been tested with few Materials which has to be of the Material Group VEHI and configurable (consult your SAP Funct expert).
The below code still gives an Pop-up while creating the SO for the Vehicle. But this Pop-up can be cancelled by the User and it doesnt effect on the Vehicle creation process. I am still working on the pop-up screen and trying to fix it so that the program can run in the background:
**************************************************************************************
The below code still gives an Pop-up while creating the SO for the Vehicle. But this Pop-up can be cancelled by the User and it doesnt effect on the Vehicle creation process. I am still working on the pop-up screen and trying to fix it so that the program can run in the background:
**************************************************************************************
*&---------------------------------------------------------------------*
*& Report YCREATEVEH_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ycreateveh_test.
DATA: gt_vehicle TYPE STANDARD TABLE OF bapivehicle,
gt_vehicle1 TYPE STANDARD TABLE OF bapivehicle,
gw_vehicle TYPE bapivehicle,
gt_config TYPE STANDARD TABLE OF bapicucfg,
gt_config1 TYPE STANDARD TABLE OF bapicucfg,
gw_config TYPE bapicucfg,
gt_inst TYPE STANDARD TABLE OF bapicuins,
gt_inst1 TYPE STANDARD TABLE OF bapicuins,
gw_inst TYPE bapicuins,
gt_charval TYPE STANDARD TABLE OF bapicuval,
gt_charval1 TYPE STANDARD TABLE OF bapicuval,
gw_charval TYPE bapicuval,
gw_req TYPE bapirequestedtablesx,
gt_return TYPE STANDARD TABLE OF bapiret2,
gw_edidd TYPE edidd,
gt_condkey TYPE STANDARD TABLE OF bapicuvk,
gt_qual TYPE STANDARD TABLE OF bapivehiclequalifiers,
gw_qual TYPE bapivehiclequalifiers.
TYPES: tt_ret TYPE STANDARD TABLE OF bapiret2.
PARAMETERS: p_veh TYPE i,"no. o veh
p_mat TYPE mara-matnr DEFAULT 'IT8911',
p_1 RADIOBUTTON GROUP g1,
p_2 RADIOBUTTON GROUP g1.
START-OF-SELECTION.
gw_vehicle-materialnumber = p_mat."'B100'."'IT8911'."'B100'. "E1EDP19
gw_vehicle-plant = '1000'.
APPEND gw_vehicle TO gt_vehicle.
CLEAR: gw_vehicle,gw_edidd.
gw_config-config_id = '1'."E1CUCFG-CONFIG_ID
gw_config-root_id = '1'." E1CUCFG-ROOT_ID
APPEND gw_config TO gt_config.
CLEAR: gw_config,gw_config.
gw_inst-config_id = '1'.
gw_inst-inst_id = '1'."E1CUINS-INST_ID
gw_inst-obj_type = 'MARA'."E1CUINS-OBJ_TYPE
gw_inst-class_type = '300'."E1CUINS-CLASS_TYPE
APPEND gw_inst TO gt_inst.
CLEAR: gw_inst,gw_edidd.
gw_charval-charc = 'B001'."E1CUVAL-CHARC
gw_charval-value = '1'."E1CUVAL-VALUE
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B002'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B003'.
gw_charval-value = '2'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B005'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B006'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B007'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B008'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'VF_TST01'.
gw_charval-value = '0001'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_req-extensionout = 'X'.
gw_req-config_data = 'X'.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
*
** This BAPI is responsible for creation of Vehicle.
DO p_veh TIMES.
CALL FUNCTION 'BAPI_VEHICLE_CREATE'
EXPORTING
vehicleaction = 'CREA'
requestedtablex = gw_req
TABLES
vehicle = gt_vehicle
config_data = gt_config
config_instances = gt_inst
config_charsvalues = gt_charval
vehicle_qualifiers = gt_qual
* EXTENSIONIN =
created_vehicle = gt_vehicle1
created_config_data = gt_config1
created_config_instance = gt_inst1
created_config_charsval = gt_charval1
* EXTENSIONOUT =
return = gt_return
* CONFIG_CONDKEY =
created_config_condkey = gt_condkey
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
PERFORM write_log USING gt_return.
ENDDO.
IF sy-uname EQ 'TIN2841'.
* BREAK-POINT.
ENDIF.
DATA: gw_head TYPE bapivehiactiondata_head,
gw_head1 TYPE bapivehiactiondata_head,
gw_headx TYPE bapivehiactiondata_headx,
gw_id TYPE bapivehicle_id_type,
gt_item TYPE STANDARD TABLE OF bapivehiactiondata_item,
gw_item TYPE bapivehiactiondata_item,
gt_ref TYPE STANDARD TABLE OF bapiconfig_references,
gw_ref TYPE bapiconfig_references,
gt_ret TYPE STANDARD TABLE OF bapiret2,
gw_ret TYPE bapiret2,
lv_mess TYPE string,
gw_itemx TYPE bapivehiactiondata_itemx.
IF p_1 EQ 'X'." Different SO
PERFORM differnt_so.
ELSEIF p_2 EQ 'X'.
PERFORM same_so.
PERFORM write_log USING gt_ret.
ENDIF.
*&---------------------------------------------------------------------*
*& Form DIFFERNT_SO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM differnt_so .
LOOP AT gt_vehicle1 INTO gw_vehicle."for every vehicle created
gw_head-plant = gw_vehicle-plant.
gw_head-material = gw_vehicle-materialnumber.
gw_head-salesorg = '1000'.
gw_head-distr_chan = '10'.
gw_head-division = '00'.
gw_head-doc_type = 'OR'.
gw_head-sold_to = '0000002200'.
gw_head-purch_no = 'ABC1234'.
gw_head-payer = '0000002200'.
gw_head-req_dat_h = '20110515'.
gw_head-ship_to = '0000002000'.
gw_head-material_external = gw_vehicle-materialnumber_external.
gw_head-material_guid = gw_vehicle-materialnumber_guid.
gw_head-material_version = gw_vehicle-materialnumber_version.
MOVE 'X' TO: gw_headx-plant,gw_headx-material,gw_headx-salesorg,
gw_headx-distr_chan,gw_headx-division,gw_headx-doc_type,
gw_headx-material_external,gw_headx-material_guid,
gw_headx-material_version,gw_headx-sold_to,
gw_headx-purch_no,gw_headx-req_dat_h,
gw_headx-ship_to,gw_headx-ship_to.
MOVE-CORRESPONDING gw_vehicle TO gw_item.
gw_item-po_number = 'ABC1234'.
APPEND gw_item TO gt_item.
MOVE 'X' TO: gw_itemx-vehicleguid,gw_itemx-vehicleguid32,gw_itemx-vehiclenumber,
gw_itemx-po_number.
* READ TABLE gt_qual INTO gw_qual INDEX 1.
gw_ref-vehicleidentifier = gw_vehicle-vehicleguid32.
READ TABLE gt_config1 INTO gw_config INDEX 1.
gw_ref-config_id = gw_config-config_id.
gw_ref-inst_id = gw_config-root_id.
APPEND gw_ref TO gt_ref.
gw_id-vehicle_id_type = 'G'.
CALL FUNCTION 'BAPI_VEHICLE_CHANGE_MULTIPLE'
EXPORTING
vehicleaction = 'CUOR'
vehiactiondata_head = gw_head
requestedtablex = gw_req
vehiactiondata_headx = gw_headx
vehiactiondata_itemx = gw_itemx
vehicle_id_type = gw_id
* IMPORTING
* CHANGED_VEHIACTIONDATA_HEAD = gw_head1
TABLES
vehiactiondata_item = gt_item
config_references = gt_ref
config_data = gt_config1
config_instances = gt_inst1
config_charsvalues = gt_charval
* VEHICLE_QUALIFIERS =
* EXTENSIONIN =
* CHANGED_VEHIACTIONDATA_ITEM =
* CHANGED_VEHICLE =
* CHANGED_CONFIG_DATA =
* CHANGED_CONFIG_INSTANCE =
* CHANGED_CONFIG_CHARSVAL =
* EXTENSIONOUT =
return = gt_ret
config_varcondnkeys = gt_condkey
* CHANGED_CONFIG_VARCONDNKEYS =
* vehicle_data = gt_vehicle1
.
CLEAR: gt_item,gt_ref,gw_itemx,gw_head,gw_headx.
* Write Log
PERFORM write_log USING gt_ret.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
ENDFORM. " DIFFERNT_SO
*&---------------------------------------------------------------------*
*& Form SAME_SO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM same_so .
LOOP AT gt_vehicle1 INTO gw_vehicle."for every vehicle created
*READ TABLE gt_vehicle1 INTO gw_vehicle INDEX 1.
* IF sy-subrc EQ 0.
gw_head-plant = gw_vehicle-plant.
gw_head-material = gw_vehicle-materialnumber.
gw_head-salesorg = '1000'.
gw_head-distr_chan = '10'.
gw_head-division = '00'.
gw_head-doc_type = 'OR'.
gw_head-sold_to = '0000002200'.
gw_head-purch_no = 'ABC1234'.
gw_head-payer = '0000002200'.
gw_head-req_dat_h = '20110515'.
gw_head-ship_to = '0000002000'.
gw_head-material_external = gw_vehicle-materialnumber_external.
gw_head-material_guid = gw_vehicle-materialnumber_guid.
gw_head-material_version = gw_vehicle-materialnumber_version.
MOVE 'X' TO: gw_headx-plant,gw_headx-material,gw_headx-salesorg,
gw_headx-distr_chan,gw_headx-division,gw_headx-doc_type,
gw_headx-material_external,gw_headx-material_guid,
gw_headx-material_version,gw_headx-sold_to,
gw_headx-purch_no,gw_headx-req_dat_h,
gw_headx-ship_to,gw_headx-ship_to.
MOVE-CORRESPONDING gw_vehicle TO gw_item.
gw_item-po_number = 'ABC1234'.
APPEND gw_item TO gt_item.
MOVE 'X' TO: gw_itemx-vehicleguid,gw_itemx-vehicleguid32,gw_itemx-vehiclenumber,
gw_itemx-po_number.
* READ TABLE gt_qual INTO gw_qual INDEX 1.
gw_ref-vehicleidentifier = gw_vehicle-vehicleguid32.
READ TABLE gt_config1 INTO gw_config INDEX sy-tabix."loop pass
gw_ref-config_id = gw_config-config_id.
gw_ref-inst_id = gw_config-root_id.
APPEND gw_ref TO gt_ref.
ENDLOOP.
gw_id-vehicle_id_type = 'G'.
CALL FUNCTION 'BAPI_VEHICLE_CHANGE_MULTIPLE'
EXPORTING
vehicleaction = 'CUOR'
vehiactiondata_head = gw_head
requestedtablex = gw_req
vehiactiondata_headx = gw_headx
vehiactiondata_itemx = gw_itemx
vehicle_id_type = gw_id
* IMPORTING
* CHANGED_VEHIACTIONDATA_HEAD = gw_head1
TABLES
vehiactiondata_item = gt_item
config_references = gt_ref
config_data = gt_config1
config_instances = gt_inst1
config_charsvalues = gt_charval
* VEHICLE_QUALIFIERS =
* EXTENSIONIN =
* CHANGED_VEHIACTIONDATA_ITEM =
* CHANGED_VEHICLE =
* CHANGED_CONFIG_DATA =
* CHANGED_CONFIG_INSTANCE =
* CHANGED_CONFIG_CHARSVAL =
* EXTENSIONOUT =
return = gt_ret
config_varcondnkeys = gt_condkey
* CHANGED_CONFIG_VARCONDNKEYS =
vehicle_data = gt_vehicle1
.
* ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
* ENDIF.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
ENDFORM. " SAME_SO
*&---------------------------------------------------------------------*
*& Form WRITE_LOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM write_log USING pt_ret TYPE tt_ret.
LOOP AT pt_ret INTO gw_ret.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = gw_ret-id
msgnr = gw_ret-number
msgv1 = gw_ret-message_v1
msgv2 = gw_ret-message_v2
msgv3 = gw_ret-message_v3
msgv4 = gw_ret-message_v4
IMPORTING
message_text_output = lv_mess.
NEW-LINE.
WRITE lv_mess.
*WRITE: gw_ret-TYPE, gw_ret-MESSAGE_V1, gw_ret-MESSAGE_V2.
ENDLOOP.
ENDFORM. " WRITE_LOG
*& Report YCREATEVEH_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ycreateveh_test.
DATA: gt_vehicle TYPE STANDARD TABLE OF bapivehicle,
gt_vehicle1 TYPE STANDARD TABLE OF bapivehicle,
gw_vehicle TYPE bapivehicle,
gt_config TYPE STANDARD TABLE OF bapicucfg,
gt_config1 TYPE STANDARD TABLE OF bapicucfg,
gw_config TYPE bapicucfg,
gt_inst TYPE STANDARD TABLE OF bapicuins,
gt_inst1 TYPE STANDARD TABLE OF bapicuins,
gw_inst TYPE bapicuins,
gt_charval TYPE STANDARD TABLE OF bapicuval,
gt_charval1 TYPE STANDARD TABLE OF bapicuval,
gw_charval TYPE bapicuval,
gw_req TYPE bapirequestedtablesx,
gt_return TYPE STANDARD TABLE OF bapiret2,
gw_edidd TYPE edidd,
gt_condkey TYPE STANDARD TABLE OF bapicuvk,
gt_qual TYPE STANDARD TABLE OF bapivehiclequalifiers,
gw_qual TYPE bapivehiclequalifiers.
TYPES: tt_ret TYPE STANDARD TABLE OF bapiret2.
PARAMETERS: p_veh TYPE i,"no. o veh
p_mat TYPE mara-matnr DEFAULT 'IT8911',
p_1 RADIOBUTTON GROUP g1,
p_2 RADIOBUTTON GROUP g1.
START-OF-SELECTION.
gw_vehicle-materialnumber = p_mat."'B100'."'IT8911'."'B100'. "E1EDP19
gw_vehicle-plant = '1000'.
APPEND gw_vehicle TO gt_vehicle.
CLEAR: gw_vehicle,gw_edidd.
gw_config-config_id = '1'."E1CUCFG-CONFIG_ID
gw_config-root_id = '1'." E1CUCFG-ROOT_ID
APPEND gw_config TO gt_config.
CLEAR: gw_config,gw_config.
gw_inst-config_id = '1'.
gw_inst-inst_id = '1'."E1CUINS-INST_ID
gw_inst-obj_type = 'MARA'."E1CUINS-OBJ_TYPE
gw_inst-class_type = '300'."E1CUINS-CLASS_TYPE
APPEND gw_inst TO gt_inst.
CLEAR: gw_inst,gw_edidd.
gw_charval-charc = 'B001'."E1CUVAL-CHARC
gw_charval-value = '1'."E1CUVAL-VALUE
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B002'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B003'.
gw_charval-value = '2'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B005'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B006'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B007'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'B008'.
gw_charval-value = '1'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_charval-charc = 'VF_TST01'.
gw_charval-value = '0001'.
APPEND gw_charval TO gt_charval.
CLEAR gw_charval.
gw_req-extensionout = 'X'.
gw_req-config_data = 'X'.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
*
** This BAPI is responsible for creation of Vehicle.
DO p_veh TIMES.
CALL FUNCTION 'BAPI_VEHICLE_CREATE'
EXPORTING
vehicleaction = 'CREA'
requestedtablex = gw_req
TABLES
vehicle = gt_vehicle
config_data = gt_config
config_instances = gt_inst
config_charsvalues = gt_charval
vehicle_qualifiers = gt_qual
* EXTENSIONIN =
created_vehicle = gt_vehicle1
created_config_data = gt_config1
created_config_instance = gt_inst1
created_config_charsval = gt_charval1
* EXTENSIONOUT =
return = gt_return
* CONFIG_CONDKEY =
created_config_condkey = gt_condkey
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
PERFORM write_log USING gt_return.
ENDDO.
IF sy-uname EQ 'TIN2841'.
* BREAK-POINT.
ENDIF.
DATA: gw_head TYPE bapivehiactiondata_head,
gw_head1 TYPE bapivehiactiondata_head,
gw_headx TYPE bapivehiactiondata_headx,
gw_id TYPE bapivehicle_id_type,
gt_item TYPE STANDARD TABLE OF bapivehiactiondata_item,
gw_item TYPE bapivehiactiondata_item,
gt_ref TYPE STANDARD TABLE OF bapiconfig_references,
gw_ref TYPE bapiconfig_references,
gt_ret TYPE STANDARD TABLE OF bapiret2,
gw_ret TYPE bapiret2,
lv_mess TYPE string,
gw_itemx TYPE bapivehiactiondata_itemx.
IF p_1 EQ 'X'." Different SO
PERFORM differnt_so.
ELSEIF p_2 EQ 'X'.
PERFORM same_so.
PERFORM write_log USING gt_ret.
ENDIF.
*&---------------------------------------------------------------------*
*& Form DIFFERNT_SO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM differnt_so .
LOOP AT gt_vehicle1 INTO gw_vehicle."for every vehicle created
gw_head-plant = gw_vehicle-plant.
gw_head-material = gw_vehicle-materialnumber.
gw_head-salesorg = '1000'.
gw_head-distr_chan = '10'.
gw_head-division = '00'.
gw_head-doc_type = 'OR'.
gw_head-sold_to = '0000002200'.
gw_head-purch_no = 'ABC1234'.
gw_head-payer = '0000002200'.
gw_head-req_dat_h = '20110515'.
gw_head-ship_to = '0000002000'.
gw_head-material_external = gw_vehicle-materialnumber_external.
gw_head-material_guid = gw_vehicle-materialnumber_guid.
gw_head-material_version = gw_vehicle-materialnumber_version.
MOVE 'X' TO: gw_headx-plant,gw_headx-material,gw_headx-salesorg,
gw_headx-distr_chan,gw_headx-division,gw_headx-doc_type,
gw_headx-material_external,gw_headx-material_guid,
gw_headx-material_version,gw_headx-sold_to,
gw_headx-purch_no,gw_headx-req_dat_h,
gw_headx-ship_to,gw_headx-ship_to.
MOVE-CORRESPONDING gw_vehicle TO gw_item.
gw_item-po_number = 'ABC1234'.
APPEND gw_item TO gt_item.
MOVE 'X' TO: gw_itemx-vehicleguid,gw_itemx-vehicleguid32,gw_itemx-vehiclenumber,
gw_itemx-po_number.
* READ TABLE gt_qual INTO gw_qual INDEX 1.
gw_ref-vehicleidentifier = gw_vehicle-vehicleguid32.
READ TABLE gt_config1 INTO gw_config INDEX 1.
gw_ref-config_id = gw_config-config_id.
gw_ref-inst_id = gw_config-root_id.
APPEND gw_ref TO gt_ref.
gw_id-vehicle_id_type = 'G'.
CALL FUNCTION 'BAPI_VEHICLE_CHANGE_MULTIPLE'
EXPORTING
vehicleaction = 'CUOR'
vehiactiondata_head = gw_head
requestedtablex = gw_req
vehiactiondata_headx = gw_headx
vehiactiondata_itemx = gw_itemx
vehicle_id_type = gw_id
* IMPORTING
* CHANGED_VEHIACTIONDATA_HEAD = gw_head1
TABLES
vehiactiondata_item = gt_item
config_references = gt_ref
config_data = gt_config1
config_instances = gt_inst1
config_charsvalues = gt_charval
* VEHICLE_QUALIFIERS =
* EXTENSIONIN =
* CHANGED_VEHIACTIONDATA_ITEM =
* CHANGED_VEHICLE =
* CHANGED_CONFIG_DATA =
* CHANGED_CONFIG_INSTANCE =
* CHANGED_CONFIG_CHARSVAL =
* EXTENSIONOUT =
return = gt_ret
config_varcondnkeys = gt_condkey
* CHANGED_CONFIG_VARCONDNKEYS =
* vehicle_data = gt_vehicle1
.
CLEAR: gt_item,gt_ref,gw_itemx,gw_head,gw_headx.
* Write Log
PERFORM write_log USING gt_ret.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
ENDFORM. " DIFFERNT_SO
*&---------------------------------------------------------------------*
*& Form SAME_SO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM same_so .
LOOP AT gt_vehicle1 INTO gw_vehicle."for every vehicle created
*READ TABLE gt_vehicle1 INTO gw_vehicle INDEX 1.
* IF sy-subrc EQ 0.
gw_head-plant = gw_vehicle-plant.
gw_head-material = gw_vehicle-materialnumber.
gw_head-salesorg = '1000'.
gw_head-distr_chan = '10'.
gw_head-division = '00'.
gw_head-doc_type = 'OR'.
gw_head-sold_to = '0000002200'.
gw_head-purch_no = 'ABC1234'.
gw_head-payer = '0000002200'.
gw_head-req_dat_h = '20110515'.
gw_head-ship_to = '0000002000'.
gw_head-material_external = gw_vehicle-materialnumber_external.
gw_head-material_guid = gw_vehicle-materialnumber_guid.
gw_head-material_version = gw_vehicle-materialnumber_version.
MOVE 'X' TO: gw_headx-plant,gw_headx-material,gw_headx-salesorg,
gw_headx-distr_chan,gw_headx-division,gw_headx-doc_type,
gw_headx-material_external,gw_headx-material_guid,
gw_headx-material_version,gw_headx-sold_to,
gw_headx-purch_no,gw_headx-req_dat_h,
gw_headx-ship_to,gw_headx-ship_to.
MOVE-CORRESPONDING gw_vehicle TO gw_item.
gw_item-po_number = 'ABC1234'.
APPEND gw_item TO gt_item.
MOVE 'X' TO: gw_itemx-vehicleguid,gw_itemx-vehicleguid32,gw_itemx-vehiclenumber,
gw_itemx-po_number.
* READ TABLE gt_qual INTO gw_qual INDEX 1.
gw_ref-vehicleidentifier = gw_vehicle-vehicleguid32.
READ TABLE gt_config1 INTO gw_config INDEX sy-tabix."loop pass
gw_ref-config_id = gw_config-config_id.
gw_ref-inst_id = gw_config-root_id.
APPEND gw_ref TO gt_ref.
ENDLOOP.
gw_id-vehicle_id_type = 'G'.
CALL FUNCTION 'BAPI_VEHICLE_CHANGE_MULTIPLE'
EXPORTING
vehicleaction = 'CUOR'
vehiactiondata_head = gw_head
requestedtablex = gw_req
vehiactiondata_headx = gw_headx
vehiactiondata_itemx = gw_itemx
vehicle_id_type = gw_id
* IMPORTING
* CHANGED_VEHIACTIONDATA_HEAD = gw_head1
TABLES
vehiactiondata_item = gt_item
config_references = gt_ref
config_data = gt_config1
config_instances = gt_inst1
config_charsvalues = gt_charval
* VEHICLE_QUALIFIERS =
* EXTENSIONIN =
* CHANGED_VEHIACTIONDATA_ITEM =
* CHANGED_VEHICLE =
* CHANGED_CONFIG_DATA =
* CHANGED_CONFIG_INSTANCE =
* CHANGED_CONFIG_CHARSVAL =
* EXTENSIONOUT =
return = gt_ret
config_varcondnkeys = gt_condkey
* CHANGED_CONFIG_VARCONDNKEYS =
vehicle_data = gt_vehicle1
.
* ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
* ENDIF.
*IF sy-uname EQ 'TIN2841'.
*
* BREAK-POINT.
*ENDIF.
ENDFORM. " SAME_SO
*&---------------------------------------------------------------------*
*& Form WRITE_LOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM write_log USING pt_ret TYPE tt_ret.
LOOP AT pt_ret INTO gw_ret.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = gw_ret-id
msgnr = gw_ret-number
msgv1 = gw_ret-message_v1
msgv2 = gw_ret-message_v2
msgv3 = gw_ret-message_v3
msgv4 = gw_ret-message_v4
IMPORTING
message_text_output = lv_mess.
NEW-LINE.
WRITE lv_mess.
*WRITE: gw_ret-TYPE, gw_ret-MESSAGE_V1, gw_ret-MESSAGE_V2.
ENDLOOP.
ENDFORM. " WRITE_LOG
**************************************************************************************