EXIT_SAPMF02D_001 用户在保存前退出检查
业务需求:客户付款条件更改并联动更改其销售付款条件(TCODE:XD03-VA03)
*&---------------------------------------------------------------------* *& 包括 ZXF04U01 *&---------------------------------------------------------------------* IF i_knb1-bukrs = '6666' . DATA:bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE. "用来存储屏幕字段参数值,传递录屏参数 DATA:messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE. "记录执行BDC过程中产生的消息 DATA:result_mesg TYPE TABLE OF string WITH HEADER LINE. "结果信息 DATA:zterm_i TYPE dzterm. "付款条件代码 DATA:lfstkc TYPE c. "付款条件代码 DATA:BEGIN OF vbelns OCCURS 0, "销售和分销凭证号VBELN_VA vbeln TYPE vbeln_va, END OF vbelns. DATA:i_inact LIKE jest-inact. DATA:i_objnr LIKE jest-objnr. DEFINE bdc_dynpro. clear bdcdata. bdcdata-program = &1. bdcdata-dynpro = &2. bdcdata-dynbegin = 'X'. append bdcdata. END-OF-DEFINITION. DEFINE bdc_field. clear bdcdata. bdcdata-fnam = &1. bdcdata-fval = &2. append bdcdata. END-OF-DEFINITION. SELECT SINGLE zterm INTO zterm_i FROM knb1 WHERE kunnr = i_knvv-kunnr AND bukrs = i_knb1-bukrs. "查询原本的付款条件 IF i_knb1-zterm <> zterm_i. SELECT vbeln INTO CORRESPONDING FIELDS OF TABLE vbelns FROM vbak WHERE kunnr = i_knb1-kunnr. LOOP AT vbelns. CLEAR:i_inact,i_objnr,lfstkc. SELECT SINGLE lfstk INTO lfstkc FROM vbuk WHERE vbeln = vbelns-vbeln. IF lfstkc = 'C'. CONTINUE. ENDIF. *销售订单审批状态 SELECT SINGLE jest~inact onrvb~objnr INTO (i_inact,i_objnr) FROM vbak INNER JOIN onrvb ON onrvb~vbeln = vbak~vbeln INNER JOIN jest ON jest~objnr = onrvb~objnr WHERE vbak~vbeln = vbelns-vbeln AND jest~stat = 'E0001' . IF sy-subrc = 0. IF i_inact = 'X'."如果订单已审批,刷新为未审核 UPDATE jest SET inact = '' WHERE stat = 'E0001' AND objnr = i_objnr. UPDATE jest SET inact = 'X' WHERE stat = 'E0002' AND objnr = i_objnr. ENDIF. ENDIF. CLEAR: bdcdata,bdcdata[] . bdc_dynpro 'SAPMV45A' '0102'. bdc_field 'BDC_CURSOR' 'VBAK-VBELN'. bdc_field 'BDC_OKCODE' '/00'. bdc_field 'VBAK-VBELN' vbelns-vbeln. bdc_dynpro 'SAPMV45A' '4001'. bdc_field 'BDC_OKCODE' '=SICH'. bdc_field 'BDC_SUBSCR' 'SAPMV45A 4021SUBSCREEN_HEADER'. bdc_field 'VBKD-ZTERM' i_knb1-zterm. bdc_field 'BDC_SUBSCR' 'SAPMV45A 8310HEAD_USER'. bdc_field 'BDC_SUBSCR' 'SAPLV45W 0400SUBSCREEN_VERTRAG'. bdc_field 'BDC_SUBSCR' 'SAPMV45A 4900SUBSCREEN_TC'. bdc_field 'BDC_SUBSCR' 'SAPMV45A 4050SUBSCREEN_BUTTONS'. CALL TRANSACTION 'VA02' USING bdcdata MODE 'N' UPDATE 'S' MESSAGES INTO messtab. READ TABLE messtab WITH KEY msgtyp = 'E'. IF sy-subrc = 0. LOOP AT messtab WHERE msgtyp = 'E'. CALL FUNCTION 'MESSAGE_TEXT_BUILD' "消息编号及变量使用函数转换为消息内容输出 EXPORTING msgid = messtab-msgid msgnr = messtab-msgnr msgv1 = messtab-msgv1 msgv2 = messtab-msgv2 msgv3 = messtab-msgv3 msgv4 = messtab-msgv4 IMPORTING message_text_output = result_mesg. ENDLOOP. MESSAGE result_mesg TYPE 'E'. ELSE. * message '' Type 'S'. ENDIF. IF i_inact = 'X'. "刷新为审核 UPDATE jest SET inact = 'X' WHERE stat = 'E0001' AND objnr = i_objnr. UPDATE jest SET inact = '' WHERE stat = 'E0002' AND objnr = i_objnr. ENDIF. ENDLOOP. ENDIF. ENDIF.