VL01N增强:
VL01N保存前增强:
METHOD if_ex_le_shp_delivery_proc~save_document_prepare. DATA: lt_xlikp LIKE LINE OF ct_xlikp, " lt_xlips LIKE LINE OF ct_xlips, lt_ylips LIKE LINE OF ct_ylips, x_brgew TYPE lips-brgew, x_ntgew TYPE lips-ntgew, zntgew TYPE mara-ntgew, zbrgew TYPE mara-brgew, y_brgew TYPE lips-brgew, y_ntgew TYPE lips-ntgew, l_rfmng TYPE vbfa-rfmng, lv_fail TYPE char1, ischeck TYPE char1, wmswerks TYPE zvaname, zresult TYPE string, zresult1 TYPE string. DATA: g_ztdelvl02n TYPE STANDARD TABLE OF ztdelvl02n INITIAL SIZE 0, l_ztdelvl02n LIKE LINE OF g_ztdelvl02n. * lt_xlips LIKE LINE OF it_xlips, * lt_ylips LIKE LINE OF it_ylips. DATA: iporg TYPE msxxlist-hostadr, ipdec(16) TYPE c, host(18) TYPE c. DATA: l_zchangenr TYPE ztdelcs02-zchangenr, l_matnr TYPE ztdelcs02-matnr, l_werks TYPE ztdelcs02-werks, l_tdname TYPE thead-tdname, l_langu(1) TYPE c. DATA: convert TYPE REF TO zw3c_co_hello_port_type, input_par TYPE zw3c_say_hello_request, output_pat TYPE zw3c_say_hello_response, zline TYPE lips-posnr, zlines TYPE string, oplen TYPE string, bgno TYPE string, zmsg TYPE string, l_mtart TYPE mara-mtart, l_vgbel TYPE lips-vgbel, l_vgpos TYPE lips-vgpos, l_zgf_date TYPE vbap-zgf_date. DATA:l_msg TYPE string, l_zadraction TYPE ztzpsuimg-zadraction, l_lgort TYPE ztlgort-lgort, gt_vbak TYPE STANDARD TABLE OF vbak, wa_vbak LIKE LINE OF gt_vbak, lt_clbatch TYPE TABLE OF clbatch, wa_clbatch LIKE LINE OF lt_clbatch, f_ntgew TYPE ztsd006-ntgew, f_brgew TYPE ztsd006-brgew, z_gjahr TYPE ztsd006-gjahr, zmtart TYPE mara-mtart, zvkorg TYPE vbak-vkorg, zvtweg TYPE vbak-vtweg, zspart TYPE vbak-spart, zvdatu TYPE vbak-vdatu, zmindat TYPE erdat. DATA:gt_remark TYPE TABLE OF tline, wa_remark LIKE LINE OF gt_remark, zdesc TYPE string, zdnntgew TYPE c LENGTH 255, zdnbrgew TYPE c LENGTH 255, e_ans TYPE c, n_ntgew TYPE STANDARD TABLE OF line, w_ntgew LIKE LINE OF n_ntgew, z_ntgew TYPE lips-ntgew, n_brgew TYPE STANDARD TABLE OF line, w_brgew LIKE LINE OF n_brgew, z_brgew TYPE lips-brgew, l_vrvez TYPE marc-vrvez, l_kwmeng TYPE vbap-kwmeng, l_lfimg TYPE lips-lfimg, zlfimg TYPE lips-lfimg, zqtypo TYPE ekpo-menge, zqtyvl TYPE ekpo-menge, zqtycan TYPE ekpo-menge, isdel, iswmswly, iswmssodn. TYPES: BEGIN OF ty_zlips, vbeln_so TYPE vbap-vbeln, posnr_so TYPE vbap-posnr, werks TYPE lips-werks, matnr TYPE lips-matnr, lfimg TYPE lips-lfimg, vrkme TYPE lips-vrkme, updkz TYPE lipsvb-updkz, END OF ty_zlips. DATA: gt_zlips TYPE TABLE OF ty_zlips, wa_zlips LIKE LINE OF gt_zlips. DATA: zisconfirm TYPE string, lv_text TYPE string, lx_sql_exc TYPE REF TO cx_sql_exception, cl_exec_ref TYPE REF TO cx_sy_native_sql_error. TYPES: BEGIN OF line1, isconfirm TYPE string, END OF line1. DATA: z1 TYPE cursor, gt_data_detail_del TYPE TABLE OF line1, "INITIAL SIZE 0 wa_data_detail LIKE gt_data_detail_del. DATA: l_iscon TYPE ztciq003-iscon. DATA: contable TYPE string. CONSTANTS: mycon1 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS01', mycon3 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS03', mycon4 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS04', mycon6 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS06', mycon7 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS07', mycon8 TYPE c LENGTH 16 VALUE 'SQL_SERVER_EBS08'. CHECK sy-tcode NE 'VL09'. GET PARAMETER ID 'ZISWMSSODN' FIELD iswmssodn. SET PARAMETER ID 'ZISWMSSODN' FIELD space. GET PARAMETER ID 'ZISWMSWLY' FIELD iswmswly. SET PARAMETER ID 'ZISWMSWLY' FIELD space. GET PARAMETER ID 'ZISVL02NDEL' FIELD isdel. SET PARAMETER ID 'ZISVL02NDEL' FIELD space. GET PARAMETER ID 'ZDNNTGEW' FIELD zdnntgew. SET PARAMETER ID 'ZDNNTGEW' FIELD space. GET PARAMETER ID 'ZDNBRGEW' FIELD zdnbrgew. SET PARAMETER ID 'ZDNBRGEW' FIELD space. * IMPORT iswmswly FROM MEMORY ID 'ISWMSWLY'. * IMPORT iswmssodn FROM MEMORY ID 'ISWMSSODN'. * IF sy-tcode+0(5) = 'VL01N'. READ TABLE ct_xlikp INTO lt_xlikp INDEX 1. IF sy-subrc = 0. IF ( sy-tcode = 'VL01N' OR sy-tcode = 'VL02N' OR sy-tcode = 'VL03N' OR sy-tcode = 'VL01NO' ) AND lt_xlikp-updkz <> 'D'. IF lt_xlikp-wadat_ist IS INITIAL OR lt_xlikp-wadat_ist = space. MESSAGE '实际发货日期不能为空' TYPE 'E'. ENDIF. ENDIF. IF lt_xlikp-lfart = 'Z007' AND isdel <> 'X'. IF iswmssodn <> 'X'. IF lt_xlikp-ziswly <> 'X'. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = '请维护是否转厂?' default_button = '1' IMPORTING answer = e_ans EXCEPTIONS text_not_found = 1 OTHERS = 2. IF e_ans = '1'. MESSAGE '请维护是否转厂' TYPE 'E'. ENDIF. LOOP AT ct_xlips INTO lt_xlips WHERE uecha = space AND updkz <> 'D'. CLEAR: l_vgbel,l_vgpos,l_zgf_date,l_msg. * SELECT SINGLE vgbel vgpos INTO (l_vgbel,l_vgpos) FROM lips * WHERE vbeln = lt_xlips-vbeln AND posnr = lt_xlips-posnr. IF lt_xlips-vgbel IS NOT INITIAL. SELECT SINGLE zgf_date INTO l_zgf_date FROM vbak WHERE vbeln = lt_xlips-vgbel. IF l_zgf_date IS NOT INITIAL. IF lt_xlikp-bldat IS NOT INITIAL AND lt_xlikp-bldat < l_zgf_date. l_msg = '交货单第' && lt_xlips-posnr && '行凭证日期不能早于关封日期'. MESSAGE l_msg TYPE 'E'. ENDIF. IF lt_xlikp-wadat_ist IS NOT INITIAL AND lt_xlikp-wadat_ist < l_zgf_date. l_msg = '交货单第' && lt_xlips-posnr && '行实际发货日期不能早于关封日期'. MESSAGE l_msg TYPE 'E'. ENDIF. ELSE. SELECT SINGLE zgf_date INTO l_zgf_date FROM vbap WHERE vbeln = lt_xlips-vgbel AND posnr = lt_xlips-vgpos. IF l_zgf_date IS INITIAL. l_msg = '交货单第' && lt_xlips-posnr && '行关封未准备好,不可以交货,请联系PMC处理!'. MESSAGE l_msg TYPE 'E'. ELSE. IF lt_xlikp-bldat IS NOT INITIAL AND lt_xlikp-bldat < l_zgf_date. l_msg = '交货单第' && lt_xlips-posnr && '行凭证日期不能早于关封日期'. MESSAGE l_msg TYPE 'E'. ENDIF. IF lt_xlikp-wadat_ist IS NOT INITIAL AND lt_xlikp-wadat_ist < l_zgf_date. l_msg = '交货单第' && lt_xlips-posnr && '行实际发货日期不能早于关封日期'. MESSAGE l_msg TYPE 'E'. ENDIF. ENDIF. ENDIF. ENDIF. wa_zlips-vbeln_so = lt_xlips-vgbel. wa_zlips-posnr_so = lt_xlips-vgpos. wa_zlips-werks = lt_xlips-werks. wa_zlips-matnr = lt_xlips-matnr. wa_zlips-lfimg = lt_xlips-lfimg. wa_zlips-vrkme = lt_xlips-vrkme. wa_zlips-updkz = lt_xlips-updkz. COLLECT wa_zlips INTO gt_zlips. ENDLOOP. IF lt_xlikp-erdat >= '20200302'. LOOP AT gt_zlips INTO wa_zlips WHERE updkz <> 'D'. CLEAR: zlfimg,l_vrvez,l_kwmeng,l_lfimg. SELECT SINGLE vrvez INTO l_vrvez FROM marc WHERE werks = wa_zlips-werks AND matnr = wa_zlips-matnr. SELECT SINGLE kwmeng INTO l_kwmeng FROM ztsdwly WHERE vbeln = wa_zlips-vbeln_so AND posnr = wa_zlips-posnr_so. IF l_vrvez IS NOT INITIAL. IF l_kwmeng IS NOT INITIAL. SELECT SUM( lfimg ) INTO l_lfimg FROM lips AS p INNER JOIN likp AS k ON p~vbeln = k~vbeln WHERE p~vgbel = wa_zlips-vbeln_so AND p~vgpos = wa_zlips-posnr_so AND k~ziswly <> 'X'. IF sy-tcode = 'VL01N'. zlfimg = wa_zlips-lfimg + l_lfimg. ELSE. zlfimg = l_lfimg. ENDIF. IF zlfimg > l_kwmeng. l_msg = '物料代码为' && wa_zlips-matnr && '的交货行不走物流园的总数量 ' && zlfimg && ' 不可以超过维护的数量 ' && l_kwmeng. MESSAGE l_msg TYPE 'E'. ENDIF. ELSE. l_msg = '物料代码为' && wa_zlips-matnr && '的交货行必须走物流园'. MESSAGE l_msg TYPE 'E'. ENDIF. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. IF iswmssodn = 'X' AND iswmswly IS NOT INITIAL. "sy-tcode = 'VL01N' AND LOOP AT ct_xlikp INTO lt_xlikp. IF iswmswly = 'Y'. lt_xlikp-ziswly = 'X'. ELSEIF iswmswly = 'N'. lt_xlikp-ziswly = ''. ENDIF. MODIFY ct_xlikp FROM lt_xlikp. ENDLOOP. ENDIF. IF if_tcode = 'VL01NO'. READ TABLE ct_xlikp INTO lt_xlikp INDEX 1. IF sy-subrc = 0. SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE gt_vbak WHERE vbeln = lt_xlikp-zstvbeln. READ TABLE gt_vbak INTO wa_vbak INDEX 1. IF sy-subrc = 0. IF wa_vbak-kunnr <> lt_xlikp-kunnr. l_msg = `输入交货单的送达方` && lt_xlikp-kunnr && `与销售订单的售达方` && wa_vbak-kunnr && `不一致`. MESSAGE l_msg TYPE 'E'. ENDIF. IF wa_vbak-vkorg <> lt_xlikp-vkorg. l_msg = `输入交货单的组织` && lt_xlikp-vkorg && `与销售订单的组织` && wa_vbak-vkorg && `不一致`. MESSAGE l_msg TYPE 'E'. ENDIF. READ TABLE ct_xlips INTO lt_xlips INDEX 1. IF sy-subrc = 0. IF wa_vbak-vtweg <> lt_xlips-vtweg. l_msg = `输入交货单的分销渠道` && lt_xlips-vtweg && `与销售订单的分销渠道` && wa_vbak-vtweg && `不一致`. MESSAGE l_msg TYPE 'E'. ENDIF. IF wa_vbak-spart <> lt_xlips-spart. l_msg = `输入交货单的部门` && lt_xlips-spart && `与销售订单的部门` && wa_vbak-spart && `不一致`. MESSAGE l_msg TYPE 'E'. ENDIF. ENDIF. ENDIF. ENDIF. LOOP AT ct_xlips INTO lt_xlips WHERE charg <> '' AND updkz <> 'D'. CLEAR: l_zadraction,l_lgort. SELECT SINGLE zadraction INTO l_zadraction FROM ztzpsuimg WHERE werks = lt_xlips-werks. IF l_zadraction = 'X'. SELECT SINGLE lgort INTO l_lgort FROM ztlgort WHERE werks = lt_xlips-werks AND lgort = lt_xlips-lgort. IF sy-subrc <> 0. l_msg = `交货单第` && lt_xlips-posnr && `行请从规定的库存地点进行发货!(参见ZPSUIMG配置)`. MESSAGE l_msg TYPE 'E'. ENDIF. ENDIF. ENDLOOP. ENDIF. LOOP AT ct_xlips INTO lt_xlips. IF lt_xlips-updkz <> 'D'. IF ( sy-tcode = 'VL02N' OR sy-tcode = 'VL03N' ) AND ( lt_xlips-pstyv = 'NLC' OR lt_xlips-pstyv = 'ZBAT' ). CLEAR: zqtypo,zqtyvl,zqtycan. SELECT SINGLE menge INTO zqtypo FROM ekpo WHERE ebeln = lt_xlips-vgbel AND ebelp = lt_xlips-vgpos. IF sy-subrc = 0 AND zqtypo IS NOT INITIAL. SELECT SUM( lfimg ) INTO zqtyvl FROM lips WHERE vgbel = lt_xlips-vgbel AND vgpos = lt_xlips-vgpos AND pstyv IN ('NLC','ZBAT') AND ( vbeln <> lt_xlips-vbeln OR ( vbeln = lt_xlips-vbeln AND posnr <> lt_xlips-posnr AND uecha <> lt_xlips-posnr ) ). zqtycan = zqtypo - zqtyvl. IF lt_xlips-lfimg > zqtycan. l_msg = '交货单第' && lt_xlips-posnr && '行的数量' && lt_xlips-lfimg && '已超过可交货数量' && zqtycan. MESSAGE l_msg TYPE 'E'. ENDIF. ENDIF. ENDIF. ENDIF. CLEAR l_rfmng. "净毛重要用批次上的单重来计算 CLEAR: lt_clbatch, lt_clbatch[]. IF lt_xlips-charg IS NOT INITIAL. CALL FUNCTION 'VB_BATCH_GET_DETAIL' EXPORTING matnr = lt_xlips-matnr charg = lt_xlips-charg werks = lt_xlips-werks get_classification = 'X' TABLES char_of_batch = lt_clbatch[] EXCEPTIONS no_material = 1 no_batch = 2 no_plant = 3 material_not_found = 4 plant_not_found = 5 no_authority = 6 batch_not_exist = 7 lock_on_batch = 8 OTHERS = 9. IF sy-subrc = 0. "CLEAR lt_clbatch. READ TABLE lt_clbatch INTO wa_clbatch WITH KEY atnam = 'Z_BATCH_Z101'. IF sy-subrc = 0. REPLACE ALL OCCURRENCES OF ',' IN wa_clbatch-atwtb WITH ''. CONDENSE wa_clbatch-atwtb. lt_xlips-ntgew = wa_clbatch-atwtb. ELSE. lt_xlips-ntgew = 0. ENDIF. "CLEAR lt_clbatch. READ TABLE lt_clbatch INTO wa_clbatch WITH KEY atnam = 'Z_BATCH_Z102'. IF sy-subrc = 0. REPLACE ALL OCCURRENCES OF ',' IN wa_clbatch-atwtb WITH ''. CONDENSE wa_clbatch-atwtb. lt_xlips-brgew = wa_clbatch-atwtb. ELSE. CLEAR l_mtart. SELECT SINGLE mtart INTO l_mtart FROM mara WHERE matnr = lt_xlips-matnr. IF l_mtart = 'HALB'. lt_xlips-brgew = lt_xlips-ntgew. ELSE. lt_xlips-brgew = 0. ENDIF. ENDIF. IF lt_xlips-updkz <> 'D'. IF lt_xlips-ntgew IS INITIAL OR lt_xlips-ntgew = 0. IF iswmssodn = 'X'. IF sy-langu = '1'. zmsg = '物料' && lt_xlips-matnr && '批次' && lt_xlips-charg && '没有找到批次重量, 请检查!'. ELSE. zmsg = `Materail ` && lt_xlips-matnr && ` Batch ` && lt_xlips-charg && ` no appropriate weight, pls check.`. ENDIF. MESSAGE zmsg TYPE 'E'. ELSE. IF sy-langu = '1'. zmsg = '当前交货单第' && lt_xlips-posnr && '找不到合适的净重,请联系品管部'. ELSE. zmsg = `The line ` && lt_xlips-posnr && ` not have net weight, pls check with QC team.`. ENDIF. MESSAGE zmsg TYPE 'I'. LEAVE TO SCREEN 4004. ENDIF. RETURN. ENDIF. IF lt_xlips-brgew IS INITIAL OR lt_xlips-brgew = 0. zmsg = '当前交货单第' && lt_xlips-posnr && '找不到合适的毛重,请联系品管部'. IF iswmssodn = 'X'. IF sy-langu = '1'. zmsg = '物料' && lt_xlips-matnr && '批次' && lt_xlips-charg && '没有找到批次重量, 请检查!'. ELSE. zmsg = `Materail ` && lt_xlips-matnr && ` Batch ` && lt_xlips-charg && ` no appropriate weight, pls check.`. ENDIF. MESSAGE zmsg TYPE 'E'. ELSE. IF sy-langu = '1'. zmsg = '当前交货单第' && lt_xlips-posnr && '找不到合适的毛重,请联系品管部'. ELSE. zmsg = `The line ` && lt_xlips-posnr && ` not have gross weight, pls check with QC team.`. ENDIF. MESSAGE zmsg TYPE 'I'. LEAVE TO SCREEN 4004. ENDIF. RETURN. ENDIF. ENDIF. IF lt_xlips-updkz = 'I'. MODIFY ct_xlips FROM lt_xlips. ENDIF. ENDIF. ENDIF. IF lt_xlips-updkz = 'I'. CLEAR: zmtart,zmindat,z_gjahr,f_ntgew,f_brgew,zvkorg,zvtweg,zspart,zvdatu,zntgew,zbrgew. IF lt_xlips-pikmg = 0. SELECT SINGLE mtart ntgew brgew INTO (zmtart,zntgew,zbrgew) FROM mara WHERE matnr = lt_xlips-matnr. IF zmtart = 'FERT'. SELECT SINGLE vkorg vtweg spart vdatu INTO (zvkorg,zvtweg,zspart,zvdatu) FROM vbak WHERE vbeln = lt_xlips-vgbel. SELECT SINGLE zseason INTO z_gjahr FROM ztsd021 WHERE vkorg = zvkorg AND vtweg = zvtweg AND spart = zspart AND zdatf < zvdatu AND zdatt > zvdatu. ELSE. CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL' EXPORTING date = sy-datum days = 0 months = 0 signum = '-' years = 1 IMPORTING calc_date = zmindat. SELECT MAX( gjahr ) INTO z_gjahr FROM ztsd006 WHERE matnr = lt_xlips-matnr AND werks = lt_xlips-werks AND erdat >= zmindat. ENDIF. SELECT SUM( ntgew ) SUM( brgew ) INTO (f_ntgew,f_brgew) FROM ztsd006 WHERE matnr = lt_xlips-matnr AND werks = lt_xlips-werks AND gjahr = z_gjahr. IF sy-subrc = 0 AND f_ntgew <> 0. lt_xlips-brgew = f_brgew * lt_xlips-lfimg. lt_xlips-ntgew = f_ntgew * lt_xlips-lfimg. MODIFY ct_xlips FROM lt_xlips. ELSE. lt_xlips-brgew = zbrgew * lt_xlips-lfimg. lt_xlips-ntgew = zntgew * lt_xlips-lfimg. MODIFY ct_xlips FROM lt_xlips. ENDIF. ENDIF. ENDIF. IF lt_xlips-updkz <> 'D'. SELECT SINGLE rfmng INTO l_rfmng FROM vbfa WHERE vbelv = lt_xlips-vbeln AND posnv = lt_xlips-posnr. IF l_rfmng NE lt_xlips-pikmg. lt_xlips-brgew = lt_xlips-brgew * lt_xlips-pikmg. lt_xlips-ntgew = lt_xlips-ntgew * lt_xlips-pikmg. MODIFY ct_xlips FROM lt_xlips. ENDIF. ENDIF. IF sy-tcode = 'VL02N' AND lt_xlips-updkz = 'D'. CALL FUNCTION 'TH_USER_INFO' " Get user IP,hostname EXPORTING client = sy-mandt user = sy-uname IMPORTING hostaddr = iporg terminal = host EXCEPTIONS OTHERS = 1. CALL FUNCTION 'GWY_IPADR2STRING' "Conv.IP addr EXPORTING ipadr = iporg IMPORTING string = ipdec. SELECT MAX( zchangenr ) INTO l_zchangenr FROM ztdelvl02n. l_ztdelvl02n-zchangenr = l_zchangenr + 1. l_ztdelvl02n-host = host. l_ztdelvl02n-hostip = ipdec. l_ztdelvl02n-werks = lt_xlips-werks. l_ztdelvl02n-vbeln = lt_xlips-vbeln. l_ztdelvl02n-posnr = lt_xlips-posnr. l_ztdelvl02n-matnr = lt_xlips-matnr. l_ztdelvl02n-lgort = lt_xlips-lgort. l_ztdelvl02n-charg = lt_xlips-charg. l_ztdelvl02n-lfimg = lt_xlips-lfimg. l_ztdelvl02n-vrkme = lt_xlips-vrkme. l_ztdelvl02n-pikmg = lt_xlips-pikmg. l_ztdelvl02n-ntgew = lt_xlips-ntgew. l_ztdelvl02n-brgew = lt_xlips-brgew. l_ztdelvl02n-gewei = lt_xlips-gewei. l_ztdelvl02n-aedat = sy-datum. l_ztdelvl02n-utime = sy-uzeit. l_ztdelvl02n-aenam = sy-uname. APPEND l_ztdelvl02n TO g_ztdelvl02n. CLEAR : contable. IF l_ztdelvl02n-werks = '1100'. EXEC SQL. connect to :mycon1 ENDEXEC. contable = 'dbo.ebs01_ygt'. ELSEIF l_ztdelvl02n-werks = '1110'. EXEC SQL. connect to :mycon7 ENDEXEC. contable = 'dbo.ebs07_ygt'. ELSEIF l_ztdelvl02n-werks = '1180'. EXEC SQL. connect to :mycon3 ENDEXEC. contable = 'dbo.ebs03_ygt'. ELSEIF l_ztdelvl02n-werks = '1190'. EXEC SQL. connect to :mycon4 ENDEXEC. contable = 'dbo.ebs04_ygt'. ELSEIF l_ztdelvl02n-werks = '1130'. EXEC SQL. connect to :mycon6 ENDEXEC. contable = 'dbo.ebs06_ygt'. ELSEIF l_ztdelvl02n-werks = '1140'. EXEC SQL. connect to :mycon8 ENDEXEC. contable = 'dbo.ebs08_ygt'. ENDIF. CLEAR l_iscon. SELECT SINGLE iscon INTO l_iscon FROM ztciq003 WHERE iscon = 'X' AND werks = l_ztdelvl02n-werks. TRY . CLEAR: zisconfirm. IF l_ztdelvl02n-werks = '1100'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs01_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon1 ENDEXEC. ELSEIF l_ztdelvl02n-werks = '1110'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs07_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon7 ENDEXEC. ELSEIF l_ztdelvl02n-werks = '1180'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs03_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon3 ENDEXEC. ELSEIF l_ztdelvl02n-werks = '1190'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs04_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon4 ENDEXEC. ELSEIF l_ztdelvl02n-werks = '1130'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs06_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon6 ENDEXEC. ELSEIF l_ztdelvl02n-werks = '1140'. IF l_iscon = 'X'. EXEC SQL. SELECT isconfirm from dbo.ebs08_ygt into :zisconfirm where outbillno = :l_ztdelvl02n-vbeln and itemNo = :l_ztdelvl02n-posnr ENDEXEC. ENDIF. EXEC SQL. DISCONNECT :mycon8 ENDEXEC. ENDIF. CATCH cx_sql_exception INTO lx_sql_exc. lv_text = lx_sql_exc->get_text( ). MESSAGE lv_text TYPE 'S'. ENDTRY. IF zisconfirm = '1' AND lt_xlips-uecha = space. CLEAR zmsg. zmsg = '交货单' && l_ztdelvl02n-vbeln && '第' && lt_xlips-posnr && '行已在云关通产生报关单:' && bgno && ' 不能删除'. MESSAGE zmsg TYPE 'I'. LEAVE TO SCREEN 4004. RETURN. ENDIF. IF l_iscon <> 'X'. TRY . CLEAR zline. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = lt_xlips-posnr IMPORTING output = zline. CREATE OBJECT convert. input_par-in0 = sy-mandt && '_' && lt_xlips-vbeln && '_' && zline && '_' && sy-uname. CALL METHOD convert->say_hello EXPORTING say_hello_request = input_par IMPORTING say_hello_response = output_pat. IF output_pat IS NOT INITIAL AND output_pat-out CS 'Hello'. oplen = strlen( output_pat-out ) - 10. bgno = output_pat-out+10(oplen). CONDENSE bgno NO-GAPS. IF bgno <> ''. CLEAR zmsg. zmsg = '当前交货单第' && lt_xlips-posnr && '行已在GDS产生报关单:' && bgno && ' 不能删除'. MESSAGE zmsg TYPE 'I'. LEAVE TO SCREEN 4004. RETURN. ENDIF. ENDIF. IF output_pat IS INITIAL OR output_pat-out NS 'hello'. IF zlines IS INITIAL. zlines = zline. ELSE. zlines = zlines && '、' && zline. ENDIF. ENDIF. CATCH cx_ai_system_fault. IF zlines IS INITIAL. zlines = zline. ELSE. zlines = zlines && '、' && zline. ENDIF. CONTINUE. CATCH cx_ai_application_fault. IF zlines IS INITIAL. zlines = zline. ELSE. zlines = zlines && '、' && zline. ENDIF. CONTINUE. ENDTRY. ENDIF. ENDIF. ENDLOOP. IF zlines IS NOT INITIAL AND sy-uname <> 'SHI-LIN.YANG' AND sy-uname <> 'ADA.LING' AND sy-uname <> 'WMS_SERVICE'. zmsg = '同步GDS的WebService没有启动,没有成功删除交货单行' && zlines. MESSAGE zmsg TYPE 'E'. ENDIF. LOOP AT g_ztdelvl02n INTO l_ztdelvl02n. MODIFY ztdelvl02n FROM l_ztdelvl02n. ENDLOOP. "COMMIT WORK AND WAIT. LOOP AT ct_ylips INTO lt_ylips. CLEAR l_rfmng. SELECT SINGLE brgew ntgew INTO (y_brgew,y_ntgew) FROM mara WHERE matnr = lt_ylips-matnr. SELECT SINGLE rfmng INTO l_rfmng FROM vbfa WHERE vbelv = lt_xlips-vbeln AND posnv = lt_xlips-posnr. IF l_rfmng NE lt_ylips-pikmg. lt_ylips-brgew = y_brgew * lt_ylips-pikmg. lt_ylips-ntgew = y_ntgew * lt_ylips-pikmg. MODIFY ct_ylips FROM lt_ylips. ENDIF. ENDLOOP. ENDMETHOD.
抬头屏幕增强:
SE11 Append Structure 在交货单抬头增强需要在Likp中添加新结构
增强的结构的字段,我们一般已ZZ / YY开头。
SE80创建一个Function Group函数组:YDELIVER_HEAD(Deliver Header:customer Fields)
分别创建两个Function module:
Y_GET_DATA_DELI_HEAD(get values for screen)
cs_likp-yyfull = gv_full. cs_likp-yypartial = gv_partial. cs_likp-yyveh_no = gv_veh_no. cs_likp-yylr_dkt_no = gv_lr_dkt_no. cs_likp-yylr_dkt_dt = gv_lr_dkt_dt. cs_likp-yydriver = gv_driver. cs_likp-yyinote_num = gv_inote_num . cs_likp-yyinote_dt = gv_inote_dt. cs_likp-yyinote_cntr = gv_inote_cntr. cs_likp-yytrnsp = gv_trnsp.
Y_SET_DATA_DELI_ITEM(set values for screen)
gv_full = is_likp-yyfull . gv_partial = is_likp-yypartial . gv_veh_no = is_likp-yyveh_no . gv_lr_dkt_no = is_likp-yylr_dkt_no. gv_lr_dkt_dt = is_likp-yylr_dkt_dt . gv_driver = is_likp-yydriver . gv_inote_num = is_likp-yyinote_num . gv_inote_dt = is_likp-yyinote_dt . gv_inote_cntr = is_likp-yyinote_cntr. gv_trnsp = is_likp-yytrnsp.
创建一个Subscreen屏幕9000
画出屏幕增强需要的字段
输入*,点击Get From Program按钮,获取程序中所有的变量,选中想要的即可
别忘了激活全部元素
查找相应的BADI
查找方法请参考: SAP第三代增强BADI的实现方法及查找方式
Delivery Header level:LE_SHP_TAB_CUST_HEAD
Delivery Item level:LE_SHP_TAB_CUST_ITEM
这里Additional tab,我们只需要LE_SHP_TAB_CUST_HEAD
SE18 BADI实施
在BADI对象的方法中实现我们相应的代码
IF_EX_LE_SHP_TAB_CUST_HEAD~ACTIVATE_TAB_PAGE
METHOD if_ex_le_shp_tab_cust_head~activate_tab_page. ef_caption = text-000. " screen caption ef_program = 'SAPLYDELIVER_HEAD'."FunctionPool:sapl + function group name ef_position = 4. "tab position ef_dynpro = '9000'. "screen number cs_v50agl_cust = 'X'. ENDMETHOD.
IF_EX_LE_SHP_TAB_CUST_HEAD~TRANSFER_DATA_TO_SUBSCREEN
METHOD if_ex_le_shp_tab_cust_head~transfer_data_to_subscreen. CALL FUNCTION 'Y_SET_DATA_DELI_ITEM' EXPORTING is_likp = is_likp. ENDMETHOD.
IF_EX_LE_SHP_TAB_CUST_HEAD~TRANSFER_DATA_FROM_SUBSCREEN
METHOD if_ex_le_shp_tab_cust_head~transfer_data_from_subscreen. CALL FUNCTION 'Y_GET_DATA_DELI_HEAD' IMPORTING cs_likp = cs_likp. ENDMETHOD.
激活代码,激活BADI对象
这里的FUNCTION的import/export为什么是CS_LIKP、IS_LIKP?能不能自己随便定义能?
当然不能,我们可以在Interface:IF_EX_LE_SHP_TAB_CUST_HEAD中Parameter中查找我们所需的传入、传出参数
VL02N测试
F4查找一个存在的交货单
这里就能查看我们增强的屏幕了
标签:增强,ztdelvl02n,&&,xlips,lt,ABAP,VL01N,ENDIF,TYPE From: https://www.cnblogs.com/ap-ad-java-abap/p/16991791.html