|
<< Click to Display Table of Contents >> Navigation: All About ABAP Technique > English > ABAP Tutorial > ABAP Workbench Tools > Enhancement > Customer Exits > Customer Exits Examples > Project ZWMWS001 > Funtions Exits > Function Group XLTO > ZXLTOF02 |
*----------------------------------------------------------------------*
***INCLUDE ZXLTOF02 .
*----------------------------------------------------------------------*
data: lv_pooln like LTAP_VB-POOLN,
lv_vltyp like LTAP_VB-VLTYP,
lv_kober like LTAP_VB-KOBER,
lv_vkapv like LTAP_VB-VKAPV,
lv_split type c,
lv_nlber like LTAP_VB-nlber,
lv_nltyp like LTAP_VB-nltyp,
lv_count(2) type n,
lv_count_max(2) type n,
lv_refnr like ltak-refnr,
lv_tapri like ltak-tapri,
lw_ltak like ltak,
li_iltak like ltak,
lv_brgew like ltap-brgew,
lv_brgew_max like T312B-GWGEW,
ch_RF(1) type c,
ch_ltak like ltak occurs 0 with header line,
ch_forklift type c,
T_LTAP_VB1 like LTAP_VB occurs 50 with header line,
T_LTAP_TMP1 like LTAP_VB occurs 50 with header line,
T_LTAP_TMP2 like LTAP_VB occurs 50 with header line,
ablad like ltap-ablad,
vb1_tabix like sy-tabix,
tmp1_tabix like sy-tabix,
lv_tapos like ltap-tapos.
data: begin of tobe_split occurs 5,
pooln like LTAP_VB-POOLN,
end of tobe_split.
DATA: BEGIN OF li_Ltak OCCURS 5.
INCLUDE STRUCTURE ltak.
INCLUDE STRUCTURE ltak1.
DATA: END OF li_Ltak.
*&---------------------------------------------------------------------*
*& Form get_memory
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SPLIT_TO
tables
T_LTAP_VB1
using
ablad.
read table t_ltap_vb1 index 1.
perform get_memory tables ch_ltak.
perform get_RF tables t_ltap_vb1.
perform get_weight tables t_ltap_vb1.
lv_count_max = 99.
read table ch_ltak index 1.
if ch_ltak-TRART = 'A'.
perform split_picking tables t_ltap_vb1.
elseif ch_ltak-TRART = 'E'.
perform split_putaway tables t_ltap_vb1.
endif.
* perform split_by_priority tables t_ltap_vb1.
ENDFORM. " get_memory
*&---------------------------------------------------------------------*
*& Form get_memory
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_memory tables ch_ltak.
*--- import ltak
clear ch_ltak. refresh ch_ltak.
import ch_ltak from memory id 'ZWM_SPLIT_TO'.
free memory id 'ZWM_SPLIT_TO'.
*---- check forklift
clear ch_forklift.
ch_forklift = 'X'.
import ch_forklift from memory id 'ZWM_ZLT0E'.
if sy-subrc ne 0.
if ABLAD(4) eq 'HAND'.
clear ch_forklift.
endif.
else.
free memory id 'ZWM_ZLT0E'.
endif.
ENDFORM. " get_memory
*&---------------------------------------------------------------------*
*& Form get_RF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_RF tables t_ltap_vb1 structure LTAP_VB.
*--- check RF queue
read table t_ltap_vb1 index 1.
clear ch_RF.
select single lgnum into t_ltap_vb1-LGNUM from t346
where lgnum = t_ltap_vb1-LGNUM. "check RF queue
if sy-subrc = 0.
ch_RF = 'X'.
endif.
ENDFORM. " get_RF
*&---------------------------------------------------------------------*
*& Form get_weight
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_weight tables t_ltap_vb1 structure LTAP_VB.
read table t_ltap_vb1 index 1.
select single gwgew into lv_brgew_max from t312b
where lgnum = t_ltap_vb1-LGNUM
and PRSPL = '000001'.
if lv_brgew_max is initial.
lv_brgew_max = 9999999.
endif.
ENDFORM. " get_weight
*&---------------------------------------------------------------------*
*& Form split_picking
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_picking tables t_ltap_vb1 structure LTAP_VB.
perform delete_pooln tables t_ltap_vb1.
perform split_Picking_Eceran tables t_ltap_vb1.
lv_pooln = 1.
if not ch_forklift is initial.
perform split_picking_forklift tables t_ltap_vb1.
else.
perform split_picking_handpallet tables t_ltap_vb1.
endif.
ENDFORM. " split_picking
*&---------------------------------------------------------------------*
*& Form split_putaway
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_putaway tables t_ltap_vb1 structure LTAP_VB.
perform delete_pooln tables t_ltap_vb1.
perform split_Putaway_Eceran tables t_ltap_vb1.
lv_pooln = 1.
perform split_full_pallet tables t_ltap_vb1.
sort t_ltap_vb1 DESCENDING by NLTYP VKAPV. "section and capacity
clear: lv_vkapv, lv_count,
lv_split, lv_nltyp.
loop at t_ltap_vb1 where pooln lt 1.
if t_ltap_vb1-pooln gt 0. continue. endif.
vb1_tabix = sy-tabix.
clear lv_split.
lv_vkapv = lv_vkapv + t_ltap_vb1-VKAPV.
if t_ltap_vb1-nltyp ne lv_nltyp.
move 'X' to lv_split.
elseif lv_vkapv ge 1.
move 'X' to lv_split.
elseif lv_vkapv lt 1.
clear t_ltap_tmp1. refresh t_ltap_tmp1.
APPEND LINES OF t_ltap_vb1 TO t_ltap_tmp1.
DELETE t_ltap_tmp1 where pooln gt 0
or nltyp ne t_ltap_vb1-nltyp.
sort t_ltap_tmp1 DESCENDING by vkapv.
lv_tapos = t_ltap_vb1-tapos.
loop at t_ltap_tmp1.
if t_ltap_tmp1-tapos eq lv_tapos. continue. endif.
lv_vkapv = lv_vkapv + t_ltap_vb1-VKAPV.
if lv_vkapv le 1.
t_ltap_tmp1-pooln = lv_pooln.
modify t_ltap_vb1 from t_ltap_tmp1 transporting pooln where tapos = t_ltap_tmp1-tapos.
else.
lv_vkapv = lv_vkapv - t_ltap_vb1-VKAPV.
endif.
endloop.
sy-tabix = vb1_tabix.
endif.
IF not lv_split is initial.
add 1 to lv_pooln.
t_ltap_vb1-pooln = lv_pooln.
clear: lv_vkapv, lv_nltyp.
move t_ltap_vb1-nltyp to lv_nltyp.
move t_ltap_vb1-vkapv to lv_vkapv.
ELSE.
t_ltap_vb1-pooln = lv_pooln.
ENDIF.
MODIFY t_ltap_vb1 index vb1_tabix transporting pooln.
endloop.
ENDFORM. " split_putaway
*&---------------------------------------------------------------------*
*& Form split_by_priority
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_by_priority tables t_ltap_vb1 structure LTAP_VB.
**-------------------------------------------------"mod sgt14112005
break imc_sigit.
if sy-tcode eq 'LT0E'.
clear lv_count.
* move-corresponding ltak to li_iltak.
select *
into table li_Ltak
from LTAK
for all entries in t_ltap_vb1
where LGNUM eq t_ltap_vb1-lgnum
and KQUIT eq space
and QUEUE eq t_ltap_vb1-queue
and BWLVS eq '850'
and TAPRI ne space.
clear lv_refnr.
sort li_Ltak by tanum tapri.
loop at li_Ltak.
select single *
into lw_ltak
from LTAK
where lgnum eq li_Ltak-lgnum
and tanum eq li_Ltak-tanum.
if sy-subrc eq 0.
clear lw_ltak-tapri.
* at new tanum.
* clear lv_count.
* endat.
if lv_refnr ne li_Ltak-refnr.
clear lv_count.
move li_Ltak-refnr to lv_refnr.
endif.
add 1 to lv_count.
move lv_count to LW_LTAK-TAPRI.
UPDATE LTAK from LW_LTAK.
endif.
endloop.
endif.
**----------------------------------------"end sgt14112005
ENDFORM. " split_by_priority
*&---------------------------------------------------------------------*
*& Form split_picking_forklift
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_picking_forklift tables t_ltap_vb1 structure ltap_vb.
perform split_full_pallet tables t_ltap_vb1.
perform split_pick_full_weight tables t_ltap_vb1.
perform split_pick_zero_weight tables t_ltap_vb1.
perform split_pick_weight tables t_ltap_vb1.
ENDFORM. " split_picking_forklift
*&---------------------------------------------------------------------*
*& Form split_picking_handpallet
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_picking_handpallet tables t_ltap_vb1 structure ltap_vb.
perform split_pick_full_weight tables t_ltap_vb1.
perform split_pick_zero_weight tables t_ltap_vb1.
perform split_pick_weight tables t_ltap_vb1.
ENDFORM. " split_picking_handpallet
*&---------------------------------------------------------------------*
*& Form split_Picking_Eceran
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM split_Picking_Eceran tables t_ltap_vb1 structure ltap_vb.
loop at t_ltap_vb1.
if t_ltap_vb1-vltyp eq 'ZYY'.
t_ltap_vb1-pooln = 1.
MODIFY t_ltap_vb1 index sy-tabix transporting pooln.
endif.
endloop.
ENDFORM. " split_Picking_Eceran
*&---------------------------------------------------------------------*
*& Form delete_pooln
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM delete_pooln TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
loop at T_LTAP_VB1.
clear t_ltap_vb1-pooln.
modify t_ltap_vb1 index sy-tabix transporting pooln.
endloop.
ENDFORM. " delete_pooln
*&---------------------------------------------------------------------*
*& Form split_full_pallet
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM split_full_pallet TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
loop at t_ltap_vb1 where pooln lt 1
and VKAPV ge 1.
add 1 to lv_pooln.
t_ltap_vb1-pooln = lv_pooln.
modify t_ltap_vb1 index sy-tabix transporting pooln.
endloop.
ENDFORM. " split_full_pallet
*&---------------------------------------------------------------------*
*& Form split_pick_weight
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM split_pick_weight TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
sort t_ltap_vb1 DESCENDING by pooln KOBER BRGEW.
clear: lv_brgew, lv_split,
lv_kober, lv_tapos,
vb1_tabix, tmp1_tabix.
loop at t_ltap_vb1 where pooln lt 1.
if t_ltap_vb1-pooln gt 0. continue. endif.
clear lv_split.
lv_brgew = lv_brgew + t_ltap_vb1-BRGEW.
vb1_tabix = sy-tabix.
if t_ltap_vb1-kober ne lv_kober.
move 'X' to lv_split.
elseif t_ltap_vb1-LGNUM ne '004' and t_ltap_vb1-brgew gt 0
and lv_brgew ge lv_brgew_max.
move 'X' to lv_split.
elseif t_ltap_vb1-LGNUM ne '004' and t_ltap_vb1-brgew gt 0
and lv_brgew lt lv_brgew_max.
clear t_ltap_tmp1. refresh t_ltap_tmp1.
APPEND LINES OF t_ltap_vb1 TO t_ltap_tmp1.
DELETE t_ltap_tmp1 where pooln gt 0
or kober ne t_ltap_vb1-kober.
sort t_ltap_tmp1 DESCENDING by BRGEW.
lv_tapos = t_ltap_vb1-tapos.
loop at t_ltap_tmp1.
if t_ltap_tmp1-tapos eq lv_tapos. continue. endif.
lv_brgew = lv_brgew + t_ltap_tmp1-brgew.
if lv_brgew <= lv_brgew_max.
t_ltap_tmp1-pooln = lv_pooln.
modify t_ltap_vb1 from t_ltap_tmp1 transporting pooln where tapos = t_ltap_tmp1-tapos.
else.
lv_brgew = lv_brgew - t_ltap_tmp1-brgew.
endif.
endloop.
sy-tabix = vb1_tabix.
endif.
IF lv_split is initial.
t_ltap_vb1-pooln = lv_pooln.
else.
add 1 to lv_pooln.
t_ltap_vb1-pooln = lv_pooln.
clear: lv_kober, lv_brgew.
move t_ltap_vb1-kober to lv_kober.
move t_ltap_vb1-brgew to lv_brgew.
ENDIF.
MODIFY t_ltap_vb1 index vb1_tabix transporting pooln.
endloop.
ENDFORM. " split_pick_weight
*&---------------------------------------------------------------------*
*& Form split_pick_full_weight
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM split_pick_full_weight TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
loop at t_ltap_vb1 where pooln lt 1
and brgew ge lv_brgew_max
and lgnum ne '004'.
add 1 to lv_pooln.
t_ltap_vb1-pooln = lv_pooln.
modify t_ltap_vb1 index sy-tabix transporting pooln.
endloop.
ENDFORM. " split_pick_full_weight
*&---------------------------------------------------------------------*
*& Form split_pick_zero_weight
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM split_pick_zero_weight TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
clear: lv_split, lv_kober.
sort t_ltap_vb1 DESCENDING by pooln KOBER BRGEW.
loop at t_ltap_vb1 where pooln lt 1
and brgew eq 0
and lgnum ne '004'.
clear lv_split.
if t_ltap_vb1-kober ne lv_kober.
move 'X' to lv_split.
endif.
if lv_split is initial.
t_ltap_vb1-pooln = lv_pooln.
else.
add 1 to lv_pooln.
t_ltap_vb1-pooln = lv_pooln.
clear: lv_kober.
move t_ltap_vb1-kober to lv_kober.
endif.
MODIFY t_ltap_vb1 index sy-tabix transporting pooln.
endloop.
ENDFORM. " split_pick_zero_weight
*&---------------------------------------------------------------------*
*& Form split_Putaway_Eceran
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*
FORM split_Putaway_Eceran TABLES T_LTAP_VB1 STRUCTURE LTAP_VB.
loop at t_ltap_vb1.
if t_ltap_vb1-nltyp eq 'ZYY'.
t_ltap_vb1-pooln = 1.
MODIFY t_ltap_vb1 index sy-tabix transporting pooln.
endif.
endloop.
ENDFORM. " split_Putaway_Eceran
*&---------------------------------------------------------------------*
*& Form split_Putaway_full_pallet
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LTAP_VB1 text
*----------------------------------------------------------------------*