on 2023 Oct 17 11:39 AM
Hi Gurus,
I'm working on a developing program to copy a Material Routing. There is the Material XPTO_A and with 3 Versions. Like this:
And the material XPTO_B. In material XPTO_A there is a production version 30 and the same production version there isn't in material XPTO_B, as you can see.
I need to create the production version 30 of Material XPTO_A to Material XPTO_B.
I have created a program to select the material(XPTO_A) that has changed in the determined period. The program finds the changes there were in this material(XPTO_A) in the period.
Coping this production version(XPTO_A 30 => XPTO_B 30) I'm following this steps:
1) Selecting Production Versions of Material
METHOD select_mkal.
DATA:
lr_matnr TYPE ty_matnr_r.
IF i_aend IS NOT INITIAL.
lr_matnr = VALUE #(
FOR ls_aend IN
i_aend ( sign = 'I'
option = 'CP'
low = |{ ls_aend-matnr(11) }*| ) ).
SORT lr_matnr BY low.
DELETE ADJACENT DUPLICATES FROM lr_matnr COMPARING low.
SELECT *
FROM mkal
INTO TABLE @r_mkal
WHERE matnr IN @lr_matnr
AND werks EQ '0508'.
SORT r_mkal BY matnr.
ENDIF.
ENDMETHOD.
2. Start Material Display for BOM Explosions and
METHOD bom_expl_mat.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
aufsw = 'X'
capid = 'PP01'
datuv = sy-datum
emeng = 1
mdnot = 'X'
mdmps = 'X'
mehrs = 'X'
mtnrv = i_ltmat-matnr
stlal = i_ltmat-stlal
stlan = i_ltmat-stlan
werks = i_ltmat-werks
IMPORTING
topmat = e_topmt
TABLES
stb = e_stb
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
APPEND LINES OF e_stb TO c_stpox.
ENDMETHOD.
DELETE lt_stb WHERE loekz IS NOT INITIAL.
3) Reading data of a routing
METHOD routing_read_to_maint.
DATA:
lt_task TYPE pdsmaint_tsk_t,
lt_seqnc TYPE pdsmaint_seq_t,
lt_opert TYPE pdsmaint_opr_tab,
lt_cmpas TYPE zttpp_capp_com.
CALL FUNCTION 'CARO_ROUTING_READ'
EXPORTING
date_from = sy-datum
date_to = '99991231'
plnty = 'N'
plnnr = i_mkal-plnnr
plnal = i_mkal-alnal
matnr = i_matnr
werks = i_mkal-werks
TABLES
tsk_tab = lt_task
* seq_tab = lt_seqnc
opr_tab = lt_opert
com_tab = lt_cmpas
EXCEPTIONS
not_found = 1
ref_not_exp = 2
not_valid = 3
OTHERS = 4.
TRY.
DATA(ls_marc) = i_marc[
matnr = i_mkal-matnr
werks = i_mkal-werks
].
DATA(ls_plko) = i_plko[
plnty = i_mkal-plnty
plnnr = i_mkal-plnnr
plnal = i_mkal-alnal
].
DATA(ls_mara) = i_mara[
matnr = i_mkal-matnr
].
CATCH cx_sy_itab_line_not_found INTO DATA(lo_subrc).
ENDTRY.
"Mapping returned data from FM CARO_ROUTING_READ to run the FM
"ROUTING_MAINTAIN
r_maint-mater = me->match_mater_to_maint( i_mkal ).
* r_routg-task = me->match_task_to_maint( lt_task ).
me->match_opert_to_maint(
EXPORTING
i_opert = lt_opert
i_mara = ls_mara
i_mkal = i_mkal
IMPORTING
e_opert = r_maint-opert
e_opertx = r_maint-opertx
).
me->match_cmpas_to_maint(
EXPORTING
i_mkal = i_mkal
i_mast = i_mast
i_cmpas = lt_cmpas
i_opert = lt_opert
i_stb = i_stb
i_matnr = i_matnr
IMPORTING
e_cmpas = r_maint-cmpas
e_cmpasx = r_maint-cmpasx
).
me->match_task_to_maint(
EXPORTING
i_task = lt_task
i_mkal = i_mkal
i_mara = ls_mara
i_plko = ls_plko
IMPORTING
e_task = r_maint-task
e_taskx = r_maint-taskx
).
ENDMETHOD.
4) Changing a work/inspection plan
METHOD routing_maintain.
DATA:
ls_task TYPE cps_task_list_maint_tsk,
ls_taskx TYPE cps_task_list_maint_tsk_x,
lt_return TYPE bapiret2_t,
lt_mater TYPE cpt_task_list_maint_mtk,
lt_materx TYPE cpt_task_list_maint_mtk_x,
* seqnc TYPE c,
lt_opert TYPE cpt_task_list_maint_opr,
lt_opertx TYPE cpt_task_list_maint_opr_x,
lt_cmpas TYPE cpt_task_list_maint_com,
lt_cmpasx TYPE cpt_task_list_maint_com_x,
lc_changeno TYPE aennr.
ls_task = i_routm-task.
ls_taskx = i_routm-taskx.
lt_mater = i_routm-mater.
lt_materx = i_routm-materx.
lt_opert = i_routm-opert.
lt_opertx = i_routm-opertx.
lt_cmpas = i_routm-cmpas.
lt_cmpasx = i_routm-cmpasx.
CALL FUNCTION 'ROUTING_MAINTAIN'
EXPORTING
change_no = lc_changeno
key_date = sy-datum
task_list_group = i_mkal-plnnr "组
group_counter = i_mkal-alnal "组计数器
material = i_mkal-matnr "物料编号
plant = i_mkal-werks "工厂
task = ls_task
task_x = ls_taskx
application = 'PP01'
bom_usage = i_mkal-stlan
TABLES
material_task_allocations = lt_mater
material_task_allocations_x = lt_materx
* SEQUENCES = SEQUENCES
* SEQUENCES_X = SEQUENCES_X
operations = lt_opert
operations_x = lt_opertx
component_allocations = lt_cmpas
component_allocations_x = lt_cmpasx
return = lt_return.
ASSIGN me->t_outtab[
matnr = i_mkal-matnr
werks = i_mkal-werks
verid = i_mkal-verid
] TO FIELD-SYMBOL(<outtab>).
IF line_exists( lt_return[ type = 'E' ] ) OR
line_exists( lt_return[ type = 'A' ] ).
LOOP AT lt_return INTO DATA(ls_return) WHERE type EQ 'E' OR
type EQ 'A'.
me->log_msg_add(
EXPORTING
i_lghdl = c_lghdl
i_msgty = ls_return-type
i_msgno = ls_return-number
i_matnr = i_mkal-matnr
i_werks = i_mkal-werks
i_verid = i_mkal-verid
i_msgv1 = ls_return-message_v1
i_msgv2 = ls_return-message_v2
i_msgv3 = ls_return-message_v3
i_msgv4 = ls_return-message_v4
).
ENDLOOP.
IF <outtab> IS ASSIGNED.
<outtab>-msg = TEXT-e05.
ENDIF.
ROLLBACK WORK.
ELSE.
IF <outtab> IS ASSIGNED.
<outtab>-msg = TEXT-s01.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
EXPORTING
wait = 'X'.
ENDIF.
ENDMETHOD.
In the FM ROUTING_MAINTAIN return a list of errors:
continue...
continue...
I don't know why it occurs:
- CZCL 006 - Material-routing assignment already exists
Could you help me...
Request clarification before answering.
User | Count |
---|---|
86 | |
13 | |
9 | |
5 | |
4 | |
4 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.