2019-12-25 abap遇到耍流氓的增强 启用异步调用解决
需求是当系统更改了mm02 的长文本的时候做一个增强,找了半天,值是读到了,可长文本的条目也太多了,根本没法确定哪条是对的
这个时候怎么办,先找个隐式增强,保证mm01 和 mm02操作都会经给找个地方
SELECT SINGLE CLASSNAME
FROM RZLLITAB
INTO G_CLASSNAME "Server Group Name
WHERE APPLSERVER = G_APPLSERVER
AND GROUPTYPE = 'S'. "S:服务器组,空:登陆组
LV_MATNR = WMARA-MATNR.
CALL FUNCTION 'ZFM_SAP_SRM_011' STARTING NEW TASK LV_MATNR
DESTINATION IN GROUP G_CLASSNAME
PERFORMING FRM_SAP_CRM ON END OF TASK
EXPORTING
IV_MATNR = LV_MATNR.
FORM FRM_SAP_CRM USING NAME.
RECEIVE RESULTS FROM FUNCTION 'ZFM_SAP_SRM_011'.
ENDFORM.
DATA : GNAME LIKE SEQG3-GNAME VALUE 'MARA',
GARG LIKE SEQG3-GARG,
GUNAME LIKE SEQG3-GUNAME,
LT_ITAB TYPE ZFM_SAP_SRM_007_INS,
LS_ITAB LIKE LINE OF LT_ITAB,
IM_JSON_STR TYPE STRING,
EX_JSON_STR TYPE STRING,
LT_OUTS TYPE ZFM_SAP_SRM_007_OUTS,
LS_OUTS LIKE LINE OF LT_OUTS,
LV_KEY01 TYPE ZKEY01,
RAW_ENQ LIKE SEQG7 OCCURS 0 WITH HEADER LINE.
CONCATENATE SY-MANDT IV_MATNR INTO GARG.
BREAK GB05.
DO 10 TIMES.
CALL FUNCTION 'ENQUE_READ2'
EXPORTING
GNAME = GNAME
GARG = GARG
GUNAME = GUNAME
TABLES
ENQ = RAW_ENQ.
IF RAW_ENQ[] IS INITIAL.
EXIT.
ELSE.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDDO.
IF RAW_ENQ[] IS NOT INITIAL.
ZTYPE = 'E'.
CONCATENATE '物料号码' IV_MATNR '被锁定,请稍后处理!' INTO ZMESSAGE.
EXIT.
ENDIF.
最终结果
原理是启用异步调用后,你程序执行 我和你是并行的,但是我读取物料号是否被你原来程序锁止了,如果你锁止放开了,我这个程序拿到物料号,当然完成一个长文本读取是so easy.
你耍流氓我也来,哈哈 等你mm01 或者mm02跑完了 我再去抓你保存好的数据,然后再进行操作