2009 Apr 24 11:12 AM
Hi Experts,
I am really stuck up at this juncture and need your help.
I tried to search in the forum but of no use.
The scenario is as follows.
I have developed various bar code labels for different brands of a textile company which are to be scanned during Delivery Order.
I created a Module Pool Program where in the user would enter the Shipping point, sale order number and its item (if required) , from here on the sale order item details were fetched and a provision for reading bar codes was provided wherein upon scanning the Barcode, the batch , its storage location and the batch Quantity were fetched into my screen somewhat similar to the batch split of vl01n.
I used the BAPI BAPI_OUTB_DELIVERY_CREATE_SLS initially to create a delivery number . Here i did not have any provision to provide my batch split data and hence i had to use BAPI_OUTB_DELIVERY_CHANGE to fetch my batch split line items along with main item and batch split items after the delivery number is created.
Now the problem is i keep getting error messages some times telling that the target Qty has been exceeded , message class VL and message Number 363.
I even have noticed one pecularity here where in the scenario is as follows.
If the total sale order quantity is 120.
When i delivered only 42 M, the system did not throw any error since 42 * 2 = 84 which is less than the target Qty of 120 which means anything below 60 ( 120 / 2) is acceptable.The delivery order was created with batch split exactly as i had desired
When i try to deliver the total 120 M, the system tells target Quantity exceeded.
I have checked with both automatic batch split On and Off in SPRO settings.
Please help.
Regards,
Ravi Kiran
2009 Apr 24 11:15 AM
Hi Ravi Kiran,
Can you check the Unit of measure that you are using when passing to the BAPI?
Regards,
Ravi Kanth Talagana
2009 Apr 24 11:54 AM
Hey Ravi,
The UOM is always 'M'.it will always be Metres.
Anyways i will paste the code below.
data: hdr type bapiobdlvhdrchg,
hdrc type bapiobdlvhdrctrlchg,
item_data type table of bapiobdlvitemchg with header line,
item_c type table of bapiobdlvitemctrlchg with header line,
return1 type table of bapiret2 with header line.
hdr-deliv_numb = delivery. " This is the Delivery Number.
hdrc-deliv_numb = delivery.
it_delv_det is the table having the main line items.
it_ztrf is the table having the batch split line items.
loop at it_delv_det.
item_c-deliv_numb = delivery.
item_c-deliv_item = it_delv_det-posnr.
item_c-chg_delqty = 'X'.
append item_c.
clear item_c.
item_data-deliv_numb = delivery.
item_data-material = it_delv_det-matnr.
item_data-deliv_item = it_delv_det-posnr.
item_data-hieraritem = it_delv_det-posnr.
item_data-fact_unit_nom = '1'.
item_data-fact_unit_denom = '1'.
item_data-sales_unit = it_delv_det-vrkme.
append item_data.
clear item_data.
loop at it_ztrf where uecha eq it_delv_det-posnr.
item_data-deliv_numb = delivery.
item_data-deliv_item = it_ztrf-posnr1.
item_data-material = it_ztrf-matnr.
item_data-batch = it_ztrf-rbatch.
item_data-hieraritem = it_ztrf-uecha.
item_data-usehieritm = '1'.
item_data-dlv_qty = it_ztrf-menge.
item_data-dlv_qty_imunit = it_ztrf-menge."it_ztrf-meins.
item_data-fact_unit_nom = '1'.
item_data-fact_unit_denom = '1'.
item_data-sales_unit = it_delv_det-vrkme.
item_data-base_uom = 'M'.
append item_data.
clear : item_data,
it_ztrf.
endloop.
endloop.
call function 'BAPI_OUTB_DELIVERY_CHANGE'
exporting
header_data = hdr
header_control = hdrc
delivery = delivery
tables
item_data = item_data
item_control = item_c
return = return1.
Is there anything which i am missing.
The strange thing is some times delivery order is created and some times it gives me message 363 of id VL.
Regards,
Ravi Kiran
2010 Sep 28 12:35 PM
Resolved it Myself.
The problem was due to standard Functional Settings
2013 Oct 31 11:32 AM
2012 Oct 11 11:21 AM
Give this a try.
REPORT z_delivery_batch_split.
DATA:header_data LIKE bapiibdlvhdrchg,
header_control LIKE bapiibdlvhdrctrlchg,
delivery LIKE bapiibdlvhdrchg-deliv_numb,
ls_return LIKE bapiret2,
item_data TYPE TABLE OF bapiibdlvitemchg,
item_control TYPE TABLE OF bapiibdlvitemctrlchg,
ls_item_data LIKE bapiibdlvitemchg,
ls_item_control LIKE bapiibdlvitemctrlchg,
return TYPE TABLE OF bapiret2 WITH NON-UNIQUE KEY type.
header_data-deliv_numb = '1800005005'.
header_control-deliv_numb = '1800005005'.
delivery = '1800005005'.
ls_item_data-deliv_numb = '1800005005'.
ls_item_data-deliv_item = '900001'.
ls_item_data-material = '000000000020067722'.
PERFORM create_batch CHANGING ls_item_data-batch.
ls_item_data-hieraritem = '000010'.
ls_item_data-usehieritm = '1'.
ls_item_data-dlv_qty = 80.
ls_item_data-dlv_qty_imunit = 80.
ls_item_data-fact_unit_nom = '1'.
ls_item_data-fact_unit_denom = '1'.
ls_item_data-sales_unit = 'EA'.
ls_item_data-base_uom = 'EA'.
APPEND ls_item_data TO item_data.
ls_item_data-deliv_numb = '1800005005'.
ls_item_data-deliv_item = '900002'.
ls_item_data-material = '000000000020067722'.
PERFORM create_batch CHANGING ls_item_data-batch.
ls_item_data-hieraritem = '000010'.
ls_item_data-usehieritm = '1'.
ls_item_data-dlv_qty = 60.
ls_item_data-dlv_qty_imunit = 60.
ls_item_data-fact_unit_nom = '1'.
ls_item_data-fact_unit_denom = '1'.
ls_item_data-sales_unit = 'EA'.
ls_item_data-base_uom = 'EA'.
APPEND ls_item_data TO item_data.
ls_item_control-deliv_numb = '1800005005'.
ls_item_control-deliv_item = '900001'.
ls_item_control-chg_delqty = 'X'.
APPEND ls_item_control TO item_control.
ls_item_control-deliv_numb = '1800005005'.
ls_item_control-deliv_item = '900002'.
ls_item_control-chg_delqty = 'X'.
APPEND ls_item_control TO item_control.
break cgavin.
CALL FUNCTION 'BAPI_INB_DELIVERY_CHANGE'
EXPORTING
header_data = header_data
header_control = header_control
delivery = delivery
* TECHN_CONTROL = TECHN_CONTROL
TABLES
* HEADER_PARTNER = HEADER_PARTNER
* HEADER_PARTNER_ADDR = HEADER_PARTNER_ADDR
* HEADER_DEADLINES = HEADER_DEADLINES
item_data = item_data
item_control = item_control
* ITEM_SERIAL_NO = ITEM_SERIAL_NO
* EXTENSION1 = EXTENSION1
* EXTENSION2 = EXTENSION2
return = return
* TOKENREFERENCE = TOKENREFERENCE
* HANDLING_UNIT_HEADER = HANDLING_UNIT_HEADER
* HANDLING_UNIT_ITEM = HANDLING_UNIT_ITEM
* PARTIAL_GR_OBJECTS = PARTIAL_GR_OBJECTS
.
READ TABLE return
INTO ls_return
WITH TABLE KEY type = 'E'.
IF sy-subrc = 0.
MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number WITH ls_return-message_v1 ls_return-message_v2
ls_return-message_v3 ls_return-message_v4.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
break cgavin.
*&---------------------------------------------------------------------*
*& Form CREATE_BATCH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LS_ITEM_DATA_BATCH text
*----------------------------------------------------------------------*
FORM create_batch CHANGING p_ls_item_data_batch.
DATA: ls_bncom TYPE bncom.
ls_bncom-matnr = ls_item_data-material.
ls_bncom-werks = 'C333'.
ls_bncom-lgort = '3000'.
SELECT SINGLE mtart
FROM mara
INTO ls_bncom-mtart
WHERE matnr = ls_bncom-matnr.
CALL FUNCTION 'VB_NEXT_BATCH_NUMBER'
EXPORTING
matnr = ls_bncom-matnr
werks = ls_bncom-werks
check_batch = 'X'
check_material = ''
message_when_auto = ' '
x_bncom = ls_bncom
lock_batch = ' '
IMPORTING
new_charg = p_ls_item_data_batch
EXCEPTIONS
no_material = 1
no_plant = 2
material_not_found = 3
plant_not_found = 4
no_batch_handling = 5
batch_exist = 6
no_number = 7
illegal_batch_number = 8
interval_not_found = 9
object_not_found = 10
interval_overflow = 11
error_automatic_batch_number = 12
cancelled = 13
automatic_batch_num_not_active = 14
OTHERS = 15.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDFORM. " CREATE_BATCH