业务要求migo产生批次后 再进行该凭证得批次更新 ,难度很大
前台操作时migo收获操作
···
DATA:lv_mblnr TYPE mblnr, lv_mjahr TYPE mjahr.* ls_mkpf TYPE mkpf,* lt_mseg TYPE TABLE OF mseg.DATA: g_classname TYPE rzlli_apcl, "Server Group Name g_applserver TYPE rzllitab-applserver. "RFC Serve Group
DATA : gname LIKE seqg3-gname VALUE 'MKPF', garg LIKE seqg3-garg, raw_enq LIKE seqg7 OCCURS 0 WITH HEADER LINE, guname LIKE seqg3-guname.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'rdisp/myname' ID 'VALUE' FIELD g_applserver.SELECT SINGLE classname
FROM rzllitab
INTO g_classname "Server Group Name WHERE applserver = g_applserver
AND grouptype = 'S'. "S:服务器组,空:登陆组
READ TABLE doc_head_tab INTO DATA(ls_bkpf) INDEX 1.CHECK ls_bkpf-awkey IS NOT INITIAL.CLEAR:lv_mblnr,lv_mjahr.
lv_mblnr
= ls_bkpf-awkey+0(10).
lv_mjahr
= ls_bkpf-awkey+10(4).
IF sy-tcode = 'MIGO'. CALL FUNCTION 'ZFM_MM_CREATE_BATCH_DEST' STARTING NEW TASK lv_mblnr
DESTINATION IN GROUP g_classname
PERFORMING frm_batch_upload ON END OF TASK EXPORTING iv_mblnr = lv_mblnr
iv_mjahr = lv_mjahr.ENDIF.
FORM frm_batch_upload USING lv_mblnr. RECEIVE RESULTS FROM FUNCTION 'ZFM_MM_CREATE_BATCH_DEST'.ENDFORM.
Rfc内容
FUNCTION zfm_mm_create_batch_dest.*"----------------------------------------------------------------------*"*"本地接口:*" IMPORTING*" VALUE(IV_MBLNR) TYPE MBLNR OPTIONAL*" VALUE(IV_MJAHR) TYPE MJAHR OPTIONAL*"---------------------------------------------------------------------- DATA:iv_matnr TYPE matnr, iv_werks TYPE werks_d, iv_charg TYPE charg_d, e_objek TYPE cuobn, e_obtab TYPE tabelle, e_klart TYPE klassenart, e_class TYPE klasse_d, lt_num TYPE TABLE OF bapi1003_alloc_values_num, lt_char TYPE TABLE OF bapi1003_alloc_values_char, lt_curr TYPE TABLE OF bapi1003_alloc_values_curr, it_mseg TYPE TABLE OF mseg, is_mkpf TYPE mkpf, lt_return TYPE TABLE OF bapiret2.
CLEAR:is_mkpf,it_mseg[]. DO 10 TIMES. SELECT SINGLE * INTO CORRESPONDING FIELDS OF is_mkpf FROM mkpf WHERE mblnr = iv_mblnr AND mjahr = iv_mjahr. IF sy-subrc = 0. EXIT. ELSE. WAIT UP TO 1 SECONDS. ENDIF. ENDDO.
IF is_mkpf IS INITIAL. EXIT. ENDIF.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_mseg FROM mseg WHERE mblnr = iv_mblnr AND mjahr = iv_mjahr.
* ls_catt TYPE bapibatchatt. "产地 生产厂家编码 生产产家 SELECT FROM ekpo AS a
INNER JOIN ztcqm002 AS b
ON a~werks = b~werks AND a~matnr = b~matnr AND a~idnlf = b~zid
FIELDS a~ebeln,a~ebelp,a~matnr,a~idnlf, b~zid,b~zscsmc,b~zchandi
FOR ALL ENTRIES IN @it_mseg[]
WHERE ebeln = @it_mseg-ebeln
AND ebelp = @it_mseg-ebelp
AND zdel = '' INTO TABLE @DATA(lt_ekpo). SORT lt_ekpo BY ebeln ebelp matnr. DELETE ADJACENT DUPLICATES FROM lt_ekpo COMPARING ebeln ebelp matnr.* 上市许可持有人:证书类型Z032* 第二类医疗器械经营备案凭证:证书类型Z015* 医疗器械经营许可证:证书类型Z017 SELECT FROM ztgsp_lic_mas AS a
INNER JOIN t001k AS b
ON a~bukrs = b~bukrs
INNER JOIN ztgsp_bukrs AS c ON a~bukrs = c~bukrs
FIELDS a~zzlicid,b~bwkey AS werks,a~bukrs,a~matnr,a~zzholder,a~zzlictyp,a~zzlicno
FOR ALL ENTRIES IN @it_mseg
WHERE matnr = @it_mseg-matnr
AND zzlictyp IN ('Z032','Z015','Z017') AND zzvalto > @sy-datum
AND b~bwkey = @it_mseg-werks
INTO TABLE @DATA(lt_lic_mas). SORT lt_lic_mas BY werks matnr zzlictyp. DELETE ADJACENT DUPLICATES FROM lt_lic_mas COMPARING werks matnr zzlictyp.*注册证/备案号取数逻辑: SELECT FROM ztmm_master_bas
FIELDS matnr, zzcba
FOR ALL ENTRIES IN @it_mseg
WHERE matnr = @it_mseg-matnr
INTO TABLE @DATA(lt_master_bas). SORT lt_master_bas BY matnr. LOOP AT it_mseg ASSIGNING FIELD-SYMBOL(
i_charg = iv_charg
i_werks = iv_werks
IMPORTING e_objek = e_objek
e_obtab = e_obtab
e_klart = e_klart
e_class = e_class. CALL FUNCTION 'BAPI_OBJCL_GETDETAIL' EXPORTING* OBJECTKEY = objecttable = e_obtab
classnum = e_class
classtype = e_klart
* KEYDATE = SY-DATUM* UNVALUATED_CHARS = ' '* LANGUAGE = SY-LANGU objectkey_long = e_objek
* IMPORTING* STATUS =* STANDARDCLASS = TABLES allocvaluesnum = lt_num
allocvalueschar = lt_char
allocvaluescurr = lt_curr
return = lt_return. READ TABLE lt_ekpo ASSIGNING FIELD-SYMBOL(
ebelp =
matnr =
BINARY SEARCH. IF sy-subrc = 0. IF e_class = 'Z_BATCH01'. " 生产厂家编号 IF
zzlictyp = 'Z032' BINARY SEARCH. IF sy-subrc = 0. READ TABLE lt_char ASSIGNING
matnr =
zzlictyp = 'Z015' BINARY SEARCH. IF sy-subrc = 0. READ TABLE lt_char ASSIGNING
matnr =
zzlictyp = 'Z017' BINARY SEARCH. IF sy-subrc = 0. READ TABLE lt_char ASSIGNING
classnum = e_class
classtype = e_klart
objectkey_long = e_objek
* IMPORTING* CLASSIF_STATUS = V_STATUS TABLES allocvaluesnumnew = lt_num
allocvaluescharnew = lt_char
allocvaluescurrnew = lt_curr
return = lt_return
EXCEPTIONS OTHERS = 01.
DATA:lv_check TYPE c. CLEAR:lv_check. LOOP AT lt_return ASSIGNING FIELD-SYMBOL(
IF lv_check = ''. COMMIT WORK . ENDIF. ENDLOOP.ENDFUNCTION.
···