ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 请款(MIRO)RFC

请款(MIRO)RFC

原创 Linux操作系统 作者:zhaoshuhong 时间:2011-01-25 10:18:49 0 删除 编辑

    请款的RFC创建有标准的BAPI:BAPI_INCOMINGINVOICE_CREATE。这不是我要说的重点。个人认为比较难的是将所需请款的采购订单的行项目抓取出来展示在屏幕上这一步。

    主要是两个Function的运用,MRM_ASSIGNMENT与MRM_AMOUNT_QUANTITY_PROPOSE_N。

     废话不说了,直接上RFC吧。

FUNCTION Z_MME_CALLSAP_GETPOITEMS.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(IVORGANG) LIKE  RM08M-VORGANG
*"     VALUE(IREFERENZBELEGTYP) LIKE  RM08M-REFERENZBELEGTYP
*"     VALUE(IEBELN) LIKE  RM08M-EBELN OPTIONAL
*"     VALUE(IXWARE_BNK) LIKE  RM08M-XWARE_BNK
*"     VALUE(IEBELP) LIKE  RM08M-EBELP OPTIONAL
*"     VALUE(IBLDAT) LIKE  INVFO-BLDAT OPTIONAL
*"     VALUE(IBUDAT) LIKE  INVFO-BUDAT
*"     VALUE(IBUKRS) LIKE  BKPF-BUKRS
*"     VALUE(ISUPERFIELD) LIKE  RM08M-SUPERFIELD OPTIONAL
*"     VALUE(IXZUORDLIDELIVERY) LIKE  RBKPB-XZUORDLI OPTIONAL
*"     VALUE(IXZUORDLIRETURN) LIKE  RBKPB-XZUORDLI OPTIONAL
*"     VALUE(IDELIVERYBEGIN) LIKE  RBKPB-LFDATABLI OPTIONAL
*"     VALUE(IDELIVERYEND) LIKE  RBKPB-LFDATBISLI OPTIONAL
*"     VALUE(IRETURNBEGIN) LIKE  RBKPB-LFDATABLI OPTIONAL
*"     VALUE(IRETURNEND) LIKE  RBKPB-LFDATBISLI OPTIONAL
*"  EXPORTING
*"     VALUE(RETURNMSG) LIKE  ZRETURNMSG STRUCTURE  ZRETURNMSG
*"  TABLES
*"      IDRSEG STRUCTURE  DRSEG OPTIONAL
*"----------------------------------------------------------------------
  TYPES: BEGIN OF MRM_RBVS.
          INCLUDE STRUCTURE RBVS.
  TYPES: SELKZ(1) TYPE C,
         END OF MRM_RBVS.

  TYPES: BEGIN OF MRM_RBKPV.
          INCLUDE STRUCTURE RBKP_V.
  TYPES: RBTX LIKE RBTX OCCURS 0,
         THEAD  TYPE THEAD,              " Note header
         TNOTE  TYPE TLINE    OCCURS 0,  " Note lines
         H_RBVS TYPE MRM_RBVS OCCURS 0,  " vendor split
         H_RBWS LIKE RBWS     OCCURS 0,  " extended withholding tax
*       bupla  LIKE accit-bupla,        " Business place Korea
         WWERT  LIKE ACCIT-WWERT,        "  Umrechnungsdatum f黵 Kufix
         MRM_ZLSPR TYPE MRM_ZLSPR,       "  Log. Zahlsperre
         XCPDD TYPE XCPDD,               " CPD Dialog bearbeitet
         ADRNR TYPE ADRNR,               " CPD Adresse
         PENRC TYPE PENRC,               " Cause for late Payment
                                         "(PS/USA)
         BAPI_EXTBLNR TYPE RE_BELNR,
         " External doc. no. for BAPI when
         BAPI_PROCESS TYPE C,         " changing fiscal year / flag
                                         " that doc. comes from BAPI
         END OF MRM_RBKPV.

  TYPES: BEGIN OF MMCR_DRSEG_CO.
          INCLUDE STRUCTURE COBL_MRM_D.
  TYPES: CR LIKE DRSEG_CR    OCCURS 0,
         UNPL_REFWR TYPE REFWR,
         END OF MMCR_DRSEG_CO.

  TYPES: BEGIN OF MMCR_DRSEG.
          INCLUDE STRUCTURE DRSEG.
  TYPES: CR LIKE DRSEG_CR OCCURS 0,
         CO TYPE MMCR_DRSEG_CO OCCURS 0,
         SM LIKE DRSEG_SM OCCURS 0,
         CHARACT TYPE RBCHARACT_INSTANCE OCCURS 3,
                                         "instances of characteristics
         UEBGMAT  TYPE MATNR,
         UEBRBLGP TYPE RBLGP,
         SELKZ_DB TYPE SELKZ,
         RBLGP_OLD TYPE RBLGP,           "rblgp before aggregation
         END OF MMCR_DRSEG.

  TYPES: MMCR_LIMIT  LIKE RELIMIT.
*  TYPES: MMCR_TLIMIT TYPE SORTED TABLE OF MMCR_LIMIT
*                     WITH UNIQUE KEY EBELN EBELP.
*
  DATA: BEGIN OF MM_ERRPROT OCCURS 0,
         MSGTY       LIKE SY-MSGTY,
         MSGID       LIKE SY-MSGID,
         MSGNO       LIKE SY-MSGNO,
         MSGV1       LIKE SY-MSGV1,
         MSGV2       LIKE SY-MSGV2,
         MSGV3       LIKE SY-MSGV3,
         MSGV4       LIKE SY-MSGV4,
         SOURCE      TYPE C,
         RBLGP       LIKE DRSEG-RBLGP,
         SHOWN       LIKE BOOLE-BOOLE,
        END OF MM_ERRPROT.

  DATA: LIN TYPE P,
        TEXT(30), "返回消息文本
        MM_RBKPV TYPE MRM_RBKPV,
        I_RBSELBEST LIKE RBSELBEST OCCURS 0 WITH HEADER LINE,
        I_RBSELLIFS LIKE RBSELLIFS OCCURS 0 WITH HEADER LINE,
        I_RBSELFRBR LIKE RBSELFRBR OCCURS 0 WITH HEADER LINE,
        I_RBSELWERK LIKE RBSELWERK OCCURS 0 WITH HEADER LINE,
        I_RBSELERFB LIKE RBSELERFB OCCURS 0 WITH HEADER LINE,
        MM_TLIMIT TYPE SORTED TABLE OF MMCR_LIMIT
                     WITH UNIQUE KEY EBELN EBELP,
        MM_DRSEG TYPE MMCR_DRSEG OCCURS 0 WITH HEADER LINE.

  CLEAR I_RBSELBEST.
  I_RBSELBEST-EBELN = IEBELN.
  I_RBSELBEST-EBELP = IEBELP.
  APPEND I_RBSELBEST.

  MM_RBKPV-BLDAT = IBLDAT.
  MM_RBKPV-BUDAT = IBUDAT.
  MM_RBKPV-BUKRS = IBUKRS.

*请货款
  IF IVORGANG = '1' AND IREFERENZBELEGTYP = '1' AND IXWARE_BNK = '1'.
    MM_RBKPV-XRECH = 'X'.       "标识: 记帐发票
    MM_RBKPV-XZUORDLI = 'X'.    "显示交货项目分配
    MM_RBKPV-XZUORDRT = 'X'.  "显示退货分配
    MM_RBKPV-XBNK = ''.         "计划交货成本标识
    MM_RBKPV-XWARE = 'X'.       "货物发票/服务标识符
    MM_RBKPV-TBTKZ = ''.        "标识: 后续借/贷
    MM_RBKPV-XBEST = 'X'.       "复选框: 分配
    MM_RBKPV-XRECHL = 'S'.      "交货项目的过帐逻辑(发票/贷项清单)
    MM_RBKPV-XRECHR = 'H'.      "交货项目的过帐逻辑(发票/贷项清单)
    TEXT = '没有需要请的货款'.
*请已计划费用
 ELSEIF IVORGANG = '1' AND IREFERENZBELEGTYP = '1' AND IXWARE_BNK = '2'.
    MM_RBKPV-XRECH = 'X'.
    MM_RBKPV-XZUORDLI = 'X'.
    MM_RBKPV-XZUORDRT = 'X'.
    MM_RBKPV-XBNK = 'X'.
    MM_RBKPV-XWARE = ''.
    MM_RBKPV-TBTKZ = ''.
    MM_RBKPV-XBEST = 'X'.
    MM_RBKPV-XRECHL = 'S'.
    MM_RBKPV-XRECHR = 'H'.
    TEXT = '没有需要请的已计划费用'.
*请未计划费用
 ELSEIF IVORGANG = '3' AND IREFERENZBELEGTYP = '1' AND IXWARE_BNK = '1'.
    MM_RBKPV-XRECH = 'X'.
    MM_RBKPV-XZUORDLI = 'X'.
    MM_RBKPV-XZUORDRT = 'X'.
    MM_RBKPV-XBNK = ''.
    MM_RBKPV-XWARE = 'X'.
    MM_RBKPV-TBTKZ = 'X'.
    MM_RBKPV-XBEST = 'X'.
    MM_RBKPV-XRECHL = 'S'.
    MM_RBKPV-XRECHR = 'H'.
    TEXT = '没有需要请未计划费用'.
*货款、已计划费用和未计划费用同时请款
 ELSEIF IVORGANG = '1' AND IREFERENZBELEGTYP = '1' AND IXWARE_BNK = '3'.
    MM_RBKPV-XRECH = 'X'.
    MM_RBKPV-XZUORDLI = 'X'.
    MM_RBKPV-XZUORDRT = 'X'.
    MM_RBKPV-XBNK = 'X'.
    MM_RBKPV-XWARE = 'X'.
    MM_RBKPV-TBTKZ = ''.
    MM_RBKPV-XBEST = 'X'.
    MM_RBKPV-XRECHL = 'S'.
    MM_RBKPV-XRECHR = 'H'.
    TEXT = '没有需要请的货款、已计划费用和未计划费用'.
*退货订单请款
 ELSEIF IVORGANG = '2' AND IREFERENZBELEGTYP = '1' AND IXWARE_BNK = '1'.
    MM_RBKPV-XRECH = ''.
    MM_RBKPV-XZUORDLI = 'X'.
    MM_RBKPV-XZUORDRT = 'X'.
    MM_RBKPV-XBNK = ''.
    MM_RBKPV-XWARE = 'X'.
    MM_RBKPV-TBTKZ = ''.
    MM_RBKPV-XBEST = 'X'.
    MM_RBKPV-XRECHL = 'H'.
    MM_RBKPV-XRECHR = 'H'.
    TEXT = '没有需要请的退货货款'.
*批次请款
 ELSEIF IVORGANG = '1' AND IREFERENZBELEGTYP = '5' AND IXWARE_BNK = '3'.
    TEXT = '此供应商没有需要请的货款及费用'.
    IF IXZUORDLIDELIVERY = 'X' AND IXZUORDLIRETURN = 'X'. "交货和退货
      MM_RBKPV-LFDATABLI = IDELIVERYBEGIN.
      MM_RBKPV-LFDATBISLI = IDELIVERYEND.
      MM_RBKPV-LFDATABRT = IRETURNBEGIN.
      MM_RBKPV-LFDATBISRT = IRETURNEND.
      MM_RBKPV-XZUORDLI = 'X'.
      MM_RBKPV-XZUORDRT = 'X'.
      MM_RBKPV-XBNK = 'X'.
      MM_RBKPV-XWARE = 'X'.
      MM_RBKPV-TBTKZ = ''.
      MM_RBKPV-XBEST = ''.
      MM_RBKPV-SELIF = ISUPERFIELD.
      MM_RBKPV-XRECHL = 'S'.
      MM_RBKPV-XRECHR = 'H'.
    ELSEIF IXZUORDLIDELIVERY = 'X' AND IXZUORDLIRETURN = ''. "交货
      MM_RBKPV-LFDATABLI = IDELIVERYBEGIN.
      MM_RBKPV-LFDATBISLI = IDELIVERYEND.
      MM_RBKPV-LFDATABRT = IRETURNBEGIN.
      MM_RBKPV-LFDATBISRT = IRETURNEND.
      MM_RBKPV-XZUORDLI = ''.
      MM_RBKPV-XZUORDRT = 'X'.
      MM_RBKPV-XBNK = 'X'.
      MM_RBKPV-XWARE = 'X'.
      MM_RBKPV-TBTKZ = ''.
      MM_RBKPV-XBEST = ''.
      MM_RBKPV-SELIF = ISUPERFIELD.
      MM_RBKPV-XRECHL = 'S'.
      MM_RBKPV-XRECHR = 'H'.
    ELSEIF IXZUORDLIDELIVERY = '' AND IXZUORDLIRETURN = 'X'. "退货
    ENDIF.
  ENDIF.

  CALL FUNCTION 'MRM_ASSIGNMENT'
    EXPORTING
      I_DISPLAY          = 'X'
*   TI_DRSEG_OLD       =
* IMPORTING
*   E_CANCEL           =
    TABLES
      T_DRSEG            = MM_DRSEG
      T_RBSELBEST        = I_RBSELBEST
      T_RBSELLIFS        = I_RBSELLIFS
      T_RBSELFRBR        = I_RBSELFRBR
      T_RBSELWERK        = I_RBSELWERK
      T_RBSELERFB        = I_RBSELERFB
      T_ERRPROT          = MM_ERRPROT
*   T_EBELNTAB         =
*   T_RBSELTRAN        =
    CHANGING
      C_RBKPV            = MM_RBKPV
      T_LIMIT            = MM_TLIMIT
      .
 LOOP AT MM_DRSEG WHERE KOART = ''.
   MOVE MM_RBKPV-TBTKZ TO MM_DRSEG-TBTKZ.
   CALL FUNCTION 'MRM_AMOUNT_QUANTITY_PROPOSE_N'
     EXPORTING
       I_RBKPV = MM_RBKPV
     CHANGING
       C_DRSEG = MM_DRSEG.
   MODIFY MM_DRSEG.
 ENDLOOP.
 LOOP AT MM_DRSEG.
    MOVE-CORRESPONDING MM_DRSEG TO IDRSEG.
    APPEND IDRSEG.
    CLEAR MM_DRSEG.
  ENDLOOP.

  DESCRIBE TABLE MM_DRSEG LINES LIN.
  IF LIN = 0.
    RETURNMSG-MTYPE = 'W'.
    RETURNMSG-MTEXT = TEXT.
  ENDIF.

ENDFUNCTION.

不知各位老大有没有标准的、省力的办法。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9859323/viewspace-684596/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-09-27

  • 博文量
    31
  • 访问量
    85306