METHOD if_ex_workorder_update~before_update.
*---------------------->增强1 开始
* "当生产订单类型为PP01时,如果该生产订单有参考相关的销售订单,
* "那么在此生产订单存盘时,就需要判断该生产订单是否已经维护了相关的长文本数据,如果没有长文本数据,就需要查看
* "所对应的销售订单行项目上是否有长文本数据,如果有则将销售订单行项目的长文本带到该生产订单长文本中。
* "反之,如果此生产订单已经维护有相关的长文本数据,则不需要再去考虑销售订单行项目中的长文本
FIELD-SYMBOLS: <f1> TYPE cobai_t_header,
<f2> TYPE LINE OF cobai_t_header.
DATA v_program(50) TYPE c VALUE '(SAPLCOBT)CAUFV_BT[]'.
DATA: wa_header TYPE LINE OF cobai_t_header,
v_flag.
DATA: v_tdname TYPE thead-tdname,
lt_lines TYPE STANDARD TABLE OF tline,
lt_lines0 TYPE STANDARD TABLE OF tline,
lt_lines1 TYPE STANDARD TABLE OF tline,
lt_lines2 TYPE STANDARD TABLE OF tline,
lt_lines3 TYPE STANDARD TABLE OF tline,
ls_line TYPE tline,
ls_line1 TYPE tline.
CLEAR: v_tdname, lt_lines0, lt_lines1, lt_lines2, lt_lines3,
lt_lines, ls_line, ls_line1.
CASE sy-tcode.
WHEN 'CO40' OR 'CO08' OR 'CO01' OR 'CO41'.
READ TABLE it_header INTO wa_header INDEX 1.
"AUART订单类型、LTEXT长文本标识、KDAUF_AUFK参考销售订单号、KDPOS_AUFK参考销售订单行项目号
IF wa_header-auart EQ 'PP01' AND wa_header-ltext EQ space AND wa_header-kdauf_aufk IS NOT INITIAL
AND wa_header-kdpos_aufk IS NOT INITIAL.
CONCATENATE wa_header-kdauf_aufk wa_header-kdpos_aufk INTO v_tdname. "销售订单行项目长文本的Name
"读取参考的销售订单行项目长文本
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'Z002'
language = sy-langu
name = v_tdname
object = 'VBBP'
TABLES
lines = lt_lines0
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
v_tdname = wa_header-kdauf_aufk.
"读取参考的销售订单行项目长文本
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'ZV06'
language = sy-langu
name = v_tdname
object = 'VBBK'
TABLES
lines = lt_lines1
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
CONCATENATE wa_header-kdauf_aufk wa_header-kdpos_aufk INTO v_tdname. "销售订单行项目长文本的Name
"读取参考的销售订单行项目长文本
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'Z001'
language = sy-langu
name = v_tdname
object = 'VBBP'
TABLES
lines = lt_lines2
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
* CONCATENATE wa_header-kdauf_aufk wa_header-kdpos_aufk INTO v_tdname. "销售订单行项目长文本的Name
* "读取参考的销售订单行项目长文本
* CALL FUNCTION 'READ_TEXT'
* EXPORTING
* id = 'Z002'
* language = sy-langu
* name = v_tdname
* object = 'VBBP'
* TABLES
* lines = lt_lines3
* EXCEPTIONS
* id = 1
* language = 2
* name = 3
* not_found = 4
* object = 5
* reference_check = 6
* wrong_access_to_archive = 7
* OTHERS = 8.
ls_line1-tdline = '行项目备注:'.
INSERT ls_line1 INTO lt_lines0 INDEX 1.
ls_line1-tdline = '此单特殊要求:'.
INSERT ls_line1 INTO lt_lines1 INDEX 1.
ls_line1-tdline = '开模信息:'.
INSERT ls_line1 INTO lt_lines2 INDEX 1.
*
* ls_line1-tdline = '行项目备注:'.
* INSERT ls_line1 INTO lt_lines3 INDEX 1.
LOOP AT lt_lines0 INTO ls_line.
APPEND ls_line TO lt_lines.
ENDLOOP.
LOOP AT lt_lines1 INTO ls_line.
APPEND ls_line TO lt_lines.
ENDLOOP.
LOOP AT lt_lines2 INTO ls_line.
APPEND ls_line TO lt_lines.
ENDLOOP.
* LOOP AT lt_lines3 INTO ls_line.
* APPEND ls_line TO lt_lines.
* ENDLOOP.
IF lt_lines IS NOT INITIAL.
CONCATENATE sy-mandt wa_header-aufnr INTO v_tdname."生产订单行项目长文本的Name
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'KOPF'
flanguage = sy-langu
fname = v_tdname
fobject = 'AUFK'
TABLES
flines = lt_lines
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc = 0.
ASSIGN (v_program) TO <f1>.
READ TABLE <f1> ASSIGNING <f2> INDEX 1.
<f2>-ltext = '1'.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
*--------------------------->增强1结束
ENDMETHOD. "if_ex_workorder_update~before_update