2018년 10월 29일 월요일

전표simulation

FUNCTION z_ev_rfc_acc_document_check.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(I_BUKRS) TYPE  BUKRS DEFAULT '1000'
*"     VALUE(I_BLART) TYPE  BLART
*"     VALUE(I_BLDAT) TYPE  BLDAT
*"     VALUE(I_BUDAT) TYPE  BUDAT
*"     VALUE(I_BKTXT) TYPE  BKTXT
*"     VALUE(I_WAERS) TYPE  WAERS
*"  EXPORTING
*"     VALUE(E_TYPE) TYPE  BAPI_MTYPE
*"     VALUE(E_MSG) TYPE  BAPI_MSG
*"  TABLES
*"      INTAB STRUCTURE  ZITEM_02
*"      OUTTAB1 STRUCTURE  BAPIRET2
*"      OUTTAB2 STRUCTURE  ZEV_ACC_TEXT
*"----------------------------------------------------------------------

* generate test data record
  fbgenmac 'Z_EV_RFC_ACC_DOCUMENT_CHECK'.


  DATA: BEGIN OF lt_ztfi0129 OCCURS 0,
          saknr     LIKE ztfi0129-saknr,
          zexp_cat1 LIKE ztfi0129-zexp_cat1,
          cat1txt   LIKE ztfi0129t-cat1txt,
        END OF lt_ztfi0129.

  DATA lv_glaccount TYPE saknr.

* 적요코드
  FREE lt_ztfi0129.
  SELECT a~saknr          "계정코드
         a~zexp_cat1      "적요코드(FI)
         b~cat1txt        "적요코드 텍스트
    INTO CORRESPONDING FIELDS OF TABLE lt_ztfi0129
    FROM ztfi0129 AS a INNER JOIN ztfi0129t AS b
      ON a~saknr     = b~saknr
     AND a~zexp_cat1 = b~zexp_cat1
   WHERE a~loevm EQ space.
  SORT lt_ztfi0129 BY saknr zexp_cat1.


  CLEAR gs_header.
  MOVE i_bukrs TO gs_header-bukrs.
  MOVE i_blart TO gs_header-blart.
  MOVE i_bldat TO gs_header-bldat.
  MOVE i_budat TO gs_header-budat.
  MOVE i_bktxt TO gs_header-bktxt.
  MOVE i_waers TO gs_header-waers.

  FREE : gd_documentheader,
         gd_customercpd,
         gd_fica_hd,
         it_accountreceivable,
         it_accountgl,
         it_accounttax,
         it_criteria,
         it_valuefield,
         it_currencyamount,
         it_return,
         it_receivers,
         it_fica_it,
         it_accountpayable,
         it_paymentcard,
         outtab1,
         outtab2.

  PERFORM fill_header USING intab.

  CLEAR gv_itemno.
  LOOP AT intab.
    ADD 1 TO gv_itemno.
    PERFORM fill_accountgl      USING intab.
    PERFORM fill_accountar      USING intab.
    PERFORM fill_accountap      USING intab.
    PERFORM fill_accounttax     USING intab.
    PERFORM fill_currencyamount USING intab.

    CLEAR outtab2.
    MOVE intab-buzei TO outtab2-buzei.
    PERFORM get_text USING intab
                     CHANGING outtab2.
    APPEND outtab2.
  ENDLOOP.

**  PERFORM fill_criteria USING intab.
**  PERFORM fill_valuefield USING intab.
**  PERFORM fill_re USING intab.
**  PERFORM fill_cpd USING intab.
**  PERFORM fill_contractitem USING intab.
**  PERFORM fill_contractheader USING intab.
**  PERFORM fill_paymentcard USING intab.
**  PERFORM fill_extension USING intab.

  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      documentheader    = gd_documentheader
      customercpd       = gd_customercpd
      contractheader    = gd_fica_hd
    TABLES
      accountgl         = it_accountgl
      accountreceivable = it_accountreceivable
      accountpayable    = it_accountpayable
      accounttax        = it_accounttax
      currencyamount    = it_currencyamount
      criteria          = it_criteria
      valuefield        = it_valuefield
      extension1        = it_ext
      return            = it_return
      paymentcard       = it_paymentcard
      contractitem      = it_fica_it
      extension2        = it_ext2
      realestate        = it_re.

  READ TABLE it_return WITH KEY type = 'E'.
  IF sy-subrc EQ 0.
    SORT it_return BY type id number row.
    DELETE ADJACENT DUPLICATES FROM it_return COMPARING type id number row.
    CLEAR : it_return, outtab1.
    APPEND LINES OF it_return TO outtab1.
  ENDIF.

  CLEAR gv_itemno.
  LOOP AT intab.
    CLEAR outtab1.
    ADD 1 TO gv_itemno.
    IF intab-koart EQ 'S'.
      CLEAR lv_glaccount.
      conversion_exit_alpha_input : intab-hkont lv_glaccount.
      READ TABLE lt_ztfi0129 WITH KEY saknr = lv_glaccount.
      IF sy-subrc EQ 0.
        CLEAR lt_ztfi0129.
        READ TABLE lt_ztfi0129 WITH KEY saknr     = lv_glaccount
                                        zexp_cat1 = intab-zzexpcd
                                        BINARY SEARCH.
        IF sy-subrc NE 0.
          outtab1-type      = 'E'.
          outtab1-id        = 'ZFI'.
          outtab1-number    = '000'.
          outtab1-row       = gv_itemno.
          outtab1-message   = '적요코드에러'.
          APPEND outtab1.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.

  e_type = 'S'.
  e_msg  = 'Success'.

ENDFUNCTION.


*----------------------------------------------------------------------*
***INCLUDE LZDEV04F01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form BPKF_BLART
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM bkpf_blart .

  CLEAR : r_blart , r_blart[].

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'UN'. " 법인카드
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B1'. " 조활비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B2'. " 회의비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B3'. " 노사운영비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B4'. " 접대비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B5'. " 시내교통비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B6'. " 출장비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'B9'. " 교육훈련비
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'BN'." e-vourcher 전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'DR'. " 고객 송장

  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'KR'. " 공급업체 송장
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'SA'. " G/L계정 전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'SB'. " e-vourcher 전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'DA'. " 고객전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'DZ'. " 고객입금
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'EI'. " 수출입 부대비용
  APPEND r_blart.

* 2018/09/07 - 'HR' 급여상여 전표는 삭제
**  R_BLART-SIGN =  'I'.
**  R_BLART-OPTION =  'EQ'.
**  R_BLART-LOW      =  'HR'. " 급여상여
**
**  APPEND R_BLART.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'KA'. " 공급업체 전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'KZ'. " 공급업체 지급
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'TR'. " TR  자금전표
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'HR'. "
  APPEND r_blart.

  r_blart-sign =  'I'.
  r_blart-option =  'EQ'.
  r_blart-low      =  'RE'. "
  APPEND r_blart.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form BKPF_SETTING
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_I_BELNR  text
*      -->P_I_GJAHR  text
*      -->P_I_BLART  text
*      -->P_I_BLDAT  text
*      -->P_I_BUDAT  text
*      -->P_I_USNAM  text
*      -->P_I_CPUDT  text
*&---------------------------------------------------------------------*
FORM bkpf_setting  USING    pv_i_belnr
                                                   pv_i_gjahr
                                                   pv_i_bldat
                                                   pv_i_budat
                                                   pv_i_usnam
                                                   pv_cpudt_f
                                                   pv_cpudt_t
                                                   pv_cputm_f
                                                   pv_cputm_t.


*---전표번호
  CLEAR : r_belnr , r_belnr[].

  IF pv_i_belnr IS INITIAL.
  ELSE.
    r_belnr-sign =  'I'.
    r_belnr-option =  'EQ'.
    r_belnr-low      =  pv_i_belnr.

    APPEND r_belnr.
  ENDIF.

*---회계년도
  CLEAR : r_gjahr , r_gjahr[].

  IF pv_i_gjahr IS INITIAL.
  ELSE.
    r_gjahr-sign =  'I'.
    r_gjahr-option =  'EQ'.
    r_gjahr-low      =  pv_i_gjahr.

    APPEND r_gjahr.
  ENDIF.

*---증빙일
  CLEAR : r_bldat , r_bldat[].

  IF pv_i_bldat IS INITIAL.
  ELSE.
    r_bldat-sign =  'I'.
    r_bldat-option =  'EQ'.
    r_bldat-low      =  pv_i_bldat.

    APPEND r_bldat.
  ENDIF.

*---전기일
  CLEAR : r_budat , r_budat[].

  IF pv_i_budat IS INITIAL.
  ELSE.
    r_budat-sign =  'I'.
    r_budat-option =  'EQ'.
    r_budat-low      =  pv_i_budat.

    APPEND r_budat.
  ENDIF.

*---사용자이름
  CLEAR : r_usnam , r_usnam[].

  IF pv_i_usnam IS INITIAL.
  ELSE.
    r_usnam-sign =  'I'.
    r_usnam-option =  'EQ'.
    r_usnam-low      =  pv_i_usnam.

    APPEND r_usnam.
  ENDIF.

*---최초입력일
  CLEAR : r_cpudt , r_cpudt[].
  IF pv_cpudt_f IS NOT INITIAL AND pv_cpudt_t IS NOT INITIAL.
    r_cpudt-sign   = 'I'.
    r_cpudt-option = 'BT'.
    r_cpudt-low    = pv_cpudt_f.
    r_cpudt-high   = pv_cpudt_t.
    APPEND r_cpudt.
  ENDIF.

*---최초입력시간
  CLEAR : r_cputm , r_cputm[].
  IF pv_cputm_f IS NOT INITIAL AND pv_cputm_t IS NOT INITIAL.
    r_cputm-sign   = 'I'.
    r_cputm-option = 'BT'.
    r_cputm-low    = pv_cputm_f.
    r_cputm-high   = pv_cputm_t.
    APPEND r_cputm.
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  DYNPRO_PROC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0198   text
*      -->P_0199   text
*      -->P_0200   text
*----------------------------------------------------------------------*
*FORM DYNPRO_PROC  USING    value(p_0198)
*                           value(p_0199)
*                           value(p_0200).
FORM dynpro_proc  USING dynbegin name value.
  CLEAR bdcdata.
  IF dynbegin  =  'X'.
    MOVE: name          TO bdcdata-program,      " BDC 모듈 풀
          value         TO bdcdata-dynpro,       " BDC 화면번호
          'X'           TO bdcdata-dynbegin.     " BDC 화면시작
  ELSE.
    MOVE: name          TO bdcdata-fnam,         " 필드이름
          value         TO bdcdata-fval.         " BDC 필드값
  ENDIF.
  APPEND bdcdata.

ENDFORM.                    " DYNPRO_PROC
*&---------------------------------------------------------------------*
*& Form FILL_HEADER
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM fill_header  USING ps_intab LIKE zitem_02.

  CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
      own_logical_system = gd_documentheader-obj_sys.

* OBJ_TYPE has to be replaced by customers object key (Y* or Z*)
  gd_documentheader-obj_type   = 'BKPFF'.
  gd_documentheader-obj_key    = '$'.
  gd_documentheader-username   = sy-uname.
  gd_documentheader-header_txt = 'Mass LineItem'.
* gd_documentheader-obj_key_r  =
* GD_DOCUMENTHEADER-reason_rev =
  gd_documentheader-comp_code  = gs_header-bukrs.
* GD_DOCUMENTHEADER-AC_DOC_NO  =
  gd_documentheader-fisc_year  = gs_header-budat+0(4).
  gd_documentheader-doc_date   = gs_header-bldat.
  gd_documentheader-pstng_date = gs_header-budat.
* GD_DOCUMENTHEADER-TRANS_DATE =
* GD_DOCUMENTHEADER-VALUE_DATE =
* GD_DOCUMENTHEADER-FIS_PERIOD =
  gd_documentheader-doc_type   = gs_header-blart.
* GD_DOCUMENTHEADER-REF_DOC_NO =
* GD_DOCUMENTHEADER-COMPO_ACC  =
  gd_documentheader-bus_act    = 'RFBU'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_ACCOUNTGL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM fill_accountgl  USING ps_intab LIKE zitem_02.

  CHECK ps_intab-koart EQ 'S'.

  CLEAR it_accountgl.
  it_accountgl-itemno_acc     = gv_itemno.

  conversion_exit_alpha_input : ps_intab-hkont it_accountgl-gl_account.
* IT_ACCOUNTGL-STAT_CON       =
* IT_ACCOUNTGL-REF_KEY_1      =
* IT_ACCOUNTGL-REF_KEY_2      =
* IT_ACCOUNTGL-REF_KEY_3      =
*  it_accountgl-tax_code       = ps_intab-mwskz.
* IT_ACCOUNTGL-ACCT_KEY       =
* IT_ACCOUNTGL-TAXJURCODE     =
* IT_ACCOUNTGL-CSHDIS_IND     =
  it_accountgl-alloc_nmbr     = ps_intab-zuonr.
  it_accountgl-item_text      = ps_intab-sgtxt.
  it_accountgl-bus_area       = '9000'.
  IF ps_intab-bschl = '70'.
    CLEAR it_accountgl-bus_area.
  ENDIF.

  conversion_exit_alpha_input : ps_intab-kostl it_accountgl-costcenter.
  conversion_exit_alpha_input : ps_intab-aufnr it_accountgl-orderid.
* it_accountgl-ext_object_id  =
* it_accountgl-bus_scenario   =
* IT_ACCOUNTGL-MATERIAL       =
* IT_ACCOUNTGL-QUANTITY       =
* IT_ACCOUNTGL-BASE_UOM       =
* IT_ACCOUNTGL-BASE_UOM_ISO   =
* IT_ACCOUNTGL-PLANT          =
* it_accountgl-profit_ctr     =
* IT_ACCOUNTGL-PART_PRCTR     =
* IT_ACCOUNTGL-WBS_ELEMENT    =
* IT_ACCOUNTGL-NETWORK        =
* IT_ACCOUNTGL-CMMT_ITEM      =
* IT_ACCOUNTGL-FUNDS_CTR      =
* IT_ACCOUNTGL-FUND           =
* IT_ACCOUNTGL-SALES_ORD      =
* IT_ACCOUNTGL-S_ORD_ITEM     =
* IT_ACCOUNTGL-P_EL_PRCTR     =
* IT_ACCOUNTGL-BILL_TYPE      =
* IT_ACCOUNTGL-DISTR_CHAN     =
* IT_ACCOUNTGL-SOLD_TO        =
* IT_ACCOUNTGL-DIVISION       =
* IT_ACCOUNTGL-SALESORG       =
* IT_ACCOUNTGL-SALES_OFF      =
* IT_ACCOUNTGL-SALES_GRP      =
* IT_ACCOUNTGL-INV_QTY        =
* IT_ACCOUNTGL-SALES_UNIT     =
* IT_ACCOUNTGL-SALES_UNIT_ISO =
* IT_ACCOUNTGL-INV_QTY_SU     =
* IT_ACCOUNTGL-NET_WEIGHT     =
* IT_ACCOUNTGL-GROSS_WT       =
* IT_ACCOUNTGL-UNIT_OF_WT     =
* IT_ACCOUNTGL-UNIT_OF_WT_ISO =
* IT_ACCOUNTGL-VOLUME         =
* IT_ACCOUNTGL-VOLUMEUNIT     =
* IT_ACCOUNTGL-VOLUMEUNIT_ISO =
* it_accountgl-fm_area        =
* it_accountgl-log_proc       =
* it_accountgl-ac_doc_no      =
  it_accountgl-acct_type      = ps_intab-koart.
  it_accountgl-doc_type       = gs_header-blart.
  it_accountgl-comp_code      = gs_header-bukrs.
* it_accountgl-func_area      =
* it_accountgl-plant          =
* it_accountgl-fis_period     =
* it_accountgl-fisc_year      =
* it_accountgl-pstng_date     =
* it_accountgl-value_date     =
* it_accountgl-customer       =
* it_accountgl-vendor_no      =
* it_accountgl-costobject     =
* it_accountgl-acttype        =
* it_accountgl-order_itno     =
* it_accountgl-routing_no     =
* it_accountgl-activity       =
* it_accountgl-cond_type      =
* it_accountgl-cond_count     =
* it_accountgl-cond_st_no     =
* it_accountgl-co_busproc     =
* it_accountgl-asset_no       =
* it_accountgl-sub_number     =
* it_accountgl-de_cre_ind     =
* it_accountgl-p_el_prctr     =
* it_accountgl-xmfrw          =
* it_accountgl-po_pr_qnt      =
* it_accountgl-po_pr_uom      =
* it_accountgl-po_pr_uom_iso  =
* it_accountgl-entry_qnt      =
* it_accountgl-entry_uom      =
* it_accountgl-entry_uom_iso  =
* it_accountgl-item_cat       =
* it_accountgl-matl_type      =
* it_accountgl-mvt_ind        =
* it_accountgl-reval_ind      =
* it_accountgl-orig_group     =
* it_accountgl-orig_mat       =
* it_accountgl-serial_no      =
* it_accountgl-part_acct      =
* it_accountgl-tr_part_ba     =
* it_accountgl-trade_id       =
* it_accountgl-val_area       =
* it_accountgl-val_type       =
* it_accountgl-asval_date     =
* it_accountgl-po_number      =
* it_accountgl-po_item        =
  APPEND it_accountgl.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_ACCOUNTAR
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM fill_accountar  USING ps_intab LIKE zitem_02.

  CHECK ps_intab-koart EQ 'D'.

  CLEAR it_accountreceivable.

  it_accountreceivable-itemno_acc = gv_itemno.

  conversion_exit_alpha_input : ps_intab-lifnr1
                                it_accountreceivable-customer.
* IT_ACCOUNTRECEIVABLE-REF_KEY_1  =
* IT_ACCOUNTRECEIVABLE-REF_KEY_2  =
* IT_ACCOUNTRECEIVABLE-REF_KEY_3  =
  it_accountreceivable-pmnttrms   = ps_intab-zterm.
* IT_ACCOUNTRECEIVABLE-BLINE_DATE =
* IT_ACCOUNTRECEIVABLE-DSCT_DAYS1 =
* IT_ACCOUNTRECEIVABLE-DSCT_DAYS2 =
* IT_ACCOUNTRECEIVABLE-NETTERMS   =
* IT_ACCOUNTRECEIVABLE-DSCT_PCT1  =
* IT_ACCOUNTRECEIVABLE-DSCT_PCT2  =
  it_accountreceivable-pymt_meth  = ps_intab-zlsch.
* IT_ACCOUNTRECEIVABLE-DUNN_KEY   =
* IT_ACCOUNTRECEIVABLE-DUNN_BLOCK =
* IT_ACCOUNTRECEIVABLE-PMNT_BLOCK =
* IT_ACCOUNTRECEIVABLE-VAT_REG_NO =
  it_accountreceivable-alloc_nmbr = ps_intab-zuonr.
  it_accountreceivable-item_text  = ps_intab-sgtxt.
* IT_ACCOUNTRECEIVABLE-PARTNER_BK =
  conversion_exit_alpha_input : ps_intab-hkont
                                it_accountreceivable-gl_account.
  it_accountreceivable-comp_code  = gs_header-bukrs.
  it_accountreceivable-bus_area   = '9000'.
  IF ps_intab-bschl = '70'.
    CLEAR it_accountreceivable-bus_area.
  ENDIF.
* it_accountreceivable-pmtmthsupl
* it_accountreceivable-paymt_ref
* it_accountreceivable-scbank_ind
 it_accountreceivable-businessplace = ps_intab-bupla.
* it_accountreceivable-sectioncode
* it_accountreceivable-branch
* it_accountreceivable-pymt_cur
* it_accountreceivable-pymt_cur_iso
* it_accountreceivable-pymt_amt
* it_accountreceivable-c_ctr_area
* it_accountreceivable-bank_id
* it_accountreceivable-supcountry
* it_accountreceivable-supcountry_iso
*  it_accountreceivable-tax_code = ps_intab-mwskz.
* it_accountreceivable-taxjurcode
* it_accountreceivable-tax_date
* it_accountreceivable-sp_gl_ind
* it_accountreceivable-partner_guid
  APPEND it_accountreceivable.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form FILL_ACCOUNTAP
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM fill_accountap  USING ps_intab LIKE zitem_02.

  CHECK ps_intab-koart EQ 'K'.

  CLEAR it_accountpayable.

  it_accountpayable-itemno_acc = gv_itemno.

  conversion_exit_alpha_input : ps_intab-lifnr1
                                it_accountpayable-vendor_no.

  conversion_exit_alpha_input : ps_intab-hkont
                                it_accountpayable-gl_account.
* it_accountpayable-ref_key_1
* it_accountpayable-ref_key_2
* it_accountpayable-ref_key_3
  it_accountpayable-comp_code = gs_header-bukrs.
  it_accountpayable-bus_area = '9000'.
  IF ps_intab-bschl = '70'.
    CLEAR it_accountpayable-bus_area.
  ENDIF.

  it_accountpayable-pmnttrms   = ps_intab-zterm.
*  it_accountpayable-bline_date = ps_intab-zfbdt.
* it_accountpayable-dsct_days1
* it_accountpayable-dsct_days2
* it_accountpayable-netterms
* it_accountpayable-dsct_pct1
* it_accountpayable-dsct_pct2
  it_accountpayable-pymt_meth = ps_intab-zlsch.
* it_accountpayable-pmtmthsupl
* it_accountpayable-pmnt_block
* it_accountpayable-scbank_ind
* it_accountpayable-supcountry
* it_accountpayable-supcountry_iso
* it_accountpayable-bllsrv_ind
  it_accountpayable-alloc_nmbr = ps_intab-zuonr.
  it_accountpayable-item_text  = ps_intab-sgtxt.
* it_accountpayable-po_sub_no
* it_accountpayable-po_checkdg
* it_accountpayable-po_ref_no
*  it_accountpayable-tax_code      = ps_intab-mwskz.
  it_accountpayable-businessplace = ps_intab-bupla.
* it_accountpayable-sectioncode
* it_accountpayable-instr1
* it_accountpayable-instr2
* it_accountpayable-instr3
* it_accountpayable-instr4
* it_accountpayable-branch
* it_accountpayable-pymt_cur
* it_accountpayable-pymt_amt
* it_accountpayable-pymt_cur_iso
* it_accountpayable-sp_gl_ind
  APPEND it_accountpayable.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_ACCOUNTTAX
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_INTAB  text
*&---------------------------------------------------------------------*
FORM fill_accounttax  USING ps_intab LIKE zitem_02.

**  CHECK ps_intab-fwbas IS NOT INITIAL.
**
**  it_accounttax-itemno_acc = gv_itemno.
**  it_accounttax-gl_account = '0000119300'.
**  it_accounttax-tax_code   = ps_intab-mwskz.
**
**  APPEND it_accounttax.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_CURRENCYAMOUNT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_INTAB  text
*&---------------------------------------------------------------------*
FORM fill_currencyamount  USING ps_intab LIKE zitem_02.

  CLEAR : it_currencyamount.

  it_currencyamount-itemno_acc   = gv_itemno.
  it_currencyamount-currency     = gs_header-waers.
  it_currencyamount-curr_type    = '00'.

  currency_amount_idoc_to_sap : gs_header-waers
                                ps_intab-wrbtr
                                it_currencyamount-amt_doccur.
  it_currencyamount-amt_doccur = it_currencyamount-amt_doccur * 100.

  IF ps_intab-shkzg EQ 'H'.
    it_currencyamount-amt_doccur = it_currencyamount-amt_doccur * -1.
  ENDIF.

  IF ps_intab-fwbas IS NOT INITIAL.
    currency_amount_idoc_to_sap : gs_header-waers
                                  ps_intab-fwbas
                                  it_currencyamount-tax_amt.
    it_currencyamount-tax_amt = it_currencyamount-tax_amt * 100.

    IF ps_intab-shkzg EQ 'H'.
      it_currencyamount-tax_amt = it_currencyamount-tax_amt * -1.
    ENDIF.

    it_currencyamount-amt_doccur
    = it_currencyamount-amt_doccur - it_currencyamount-tax_amt.
    CLEAR it_currencyamount-tax_amt.
  ENDIF.

  APPEND it_currencyamount.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_CRITERIA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_INTAB  text
*&---------------------------------------------------------------------*
FORM fill_criteria  USING ps_intab LIKE zitem_02.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_VALUEFIELD
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_INTAB  text
*&---------------------------------------------------------------------*
FORM fill_valuefield  USING ps_intab LIKE zitem_02.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_TEXT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*      -->P_INTAB  text
*      <--P_OUTTAB2  text
*&---------------------------------------------------------------------*
FORM get_text  USING    ps_intab LIKE zitem_02
               CHANGING ps_outtab2 LIKE zev_acc_text.

  DATA : lv_gsber TYPE gsber.
  DATA : lv_lifnr TYPE lifnr.
  DATA : lv_anln1 TYPE anln1.


  CLEAR lv_gsber.
  MOVE '9000' TO lv_gsber.

  IF ps_intab-bschl = '70'.
    CLEAR lv_gsber.
  ELSE.
    SELECT SINGLE gtext    "사업영역명
      FROM tgsbt
      INTO ps_outtab2-gsber_text
     WHERE spras EQ '3'
       AND gsber EQ lv_gsber.
  ENDIF.

  SELECT SINGLE text1    "세금코드명
    FROM t007s
    INTO ps_outtab2-mwskz_text
   WHERE spras EQ '3'
     AND kalsm EQ 'TAXKR'
     AND mwskz EQ ps_intab-mwskz.

  SELECT SINGLE text1    "지급조건명
    FROM t052u
    INTO ps_outtab2-zterm_text
   WHERE spras EQ '3'
     AND zterm EQ ps_intab-zterm.

  SELECT SINGLE text2    "지급방법명
    FROM t042zt
    INTO ps_outtab2-zlsch_text
   WHERE spras EQ '3'
     AND land1 EQ 'KR'
     AND zlsch EQ ps_intab-zlsch.

  conversion_exit_alpha_input : ps_intab-kostl ps_intab-kostl.
  SELECT SINGLE ltext    "코스트센터명
    FROM cskt
    INTO ps_outtab2-kostl_text
   WHERE spras EQ '3'
     AND kokrs EQ '1000'
     AND kostl EQ ps_intab-kostl.

  conversion_exit_alpha_input : ps_intab-aufnr ps_intab-aufnr.
  SELECT SINGLE ktext    "오더명
    FROM coas
    INTO ps_outtab2-aufnr_text
   WHERE aufnr = ps_intab-aufnr.

  conversion_exit_alpha_input : ps_intab-hkont ps_intab-hkont.
  SELECT SINGLE txt50    "조정계정명
    FROM skat
    INTO ps_outtab2-saknr_text
   WHERE spras EQ '3'
     AND ktopl EQ '1000'
     AND saknr EQ ps_intab-hkont.

  SELECT SINGLE txt50    "계정코드명
    FROM skat
    INTO ps_outtab2-hkont_text
   WHERE spras EQ '3'
     AND ktopl EQ '1000'
     AND saknr EQ ps_intab-hkont.

  MOVE ps_intab-lifnr1 TO lv_lifnr.
  conversion_exit_alpha_input : lv_lifnr lv_lifnr.
  SELECT SINGLE name1   "구매처코드명
    FROM lfa1
    INTO ps_outtab2-lifnr_text
   WHERE lifnr EQ lv_lifnr.

  MOVE ps_intab-anln1 TO lv_anln1.
  conversion_exit_alpha_input : lv_anln1 lv_anln1.
  SELECT SINGLE txt50    "자산번호명
    FROM anla
    INTO ps_outtab2-anln1_text
    WHERE anln1 EQ ps_intab-anln1.

  SELECT SINGLE name    "사업장명
    FROM j_1bbranch
    INTO ps_outtab2-bupla_text
   WHERE branch EQ ps_intab-bupla.

  SELECT SINGLE cat1txt  "적요코드 텍스트
    INTO ps_outtab2-zzexpcd_text
    FROM ztfi0129t
   WHERE spras     EQ '3'
     AND saknr     EQ ps_intab-hkont
     AND zexp_cat1 EQ ps_intab-zzexpcd.

  SELECT SINGLE ename
    INTO ps_outtab2-zzcarno_text
    FROM ztfi0100
   WHERE bukrs EQ gs_header-bukrs
     AND carno EQ ps_intab-zzcarno.

ENDFORM.


LZDEV04TOP

FUNCTION-POOL zdev04.                       "MESSAGE-ID ..

INCLUDE fbgenmac.

* INCLUDE LZDEV04D...                        " Local class definition

*---Z_EV_RFC_Docheader   : 전표헤더 Interface
RANGES : r_belnr FOR bkpf-belnr.          "전표번호
RANGES : r_gjahr FOR bkpf-gjahr.          "회계년도
RANGES : r_blart FOR bkpf-blart.          "전표유형
RANGES : r_bldat FOR bkpf-bldat.          "전표증빙일
RANGES : r_budat FOR bkpf-budat.         "전표전기일
RANGES : r_usnam FOR bkpf-usnam.        "사용자 아이디
RANGES : r_cpudt FOR bkpf-cpudt.         "최초생성일
RANGES : r_cputm FOR bkpf-cputm.         "최초생성시간

RANGES : r_hkont FOR bseg-hkont.         "

*---Z_EV_RFC_PARKDOC   : 임시전표 생성/삭제  Interface
  DATA: BEGIN OF bdcdata OCCURS 0.
          INCLUDE STRUCTURE bdcdata.
  DATA: END OF bdcdata.
  DATA: bdcmode(1) TYPE c VALUE 'N'.

  DATA: messtab        LIKE  bdcmsgcoll OCCURS 0  WITH HEADER LINE.



  DATA:
    gd_documentheader    LIKE bapiache09,
    gd_customercpd       LIKE bapiacpa09,
    gd_fica_hd           LIKE bapiaccahd,
    it_accountreceivable LIKE TABLE OF bapiacar09 WITH HEADER LINE,
    it_accountgl         LIKE TABLE OF bapiacgl09 WITH HEADER LINE,
    it_accounttax        LIKE TABLE OF bapiactx09 WITH HEADER LINE,
    it_criteria          LIKE TABLE OF bapiackec9 WITH HEADER LINE,
    it_valuefield        LIKE TABLE OF bapiackev9 WITH HEADER LINE,
    it_currencyamount    LIKE TABLE OF bapiaccr09 WITH HEADER LINE,
    it_return            LIKE TABLE OF bapiret2   WITH HEADER LINE,
    it_receivers         LIKE TABLE OF bdi_logsys WITH HEADER LINE,
    it_fica_it           LIKE TABLE OF bapiaccait WITH HEADER LINE,
    it_accountpayable    LIKE TABLE OF bapiacap09 WITH HEADER LINE,
    it_paymentcard       LIKE TABLE OF bapiacpc09 WITH HEADER LINE,
    it_ext               LIKE TABLE OF bapiacextc WITH HEADER LINE,
    it_re                LIKE TABLE OF bapiacre09 WITH HEADER LINE,
    it_ext2              LIKE TABLE OF bapiparex  WITH HEADER LINE.

DATA : BEGIN OF gs_header,
         bukrs TYPE bukrs,
         blart TYPE blart,
         bldat TYPE bldat,
         budat TYPE budat,
         bktxt TYPE bktxt,
         waers TYPE waers,
       END OF gs_header.

 DATA gv_itemno TYPE posnr_acc.

 DEFINE add_range_eq.
  IF &2 NE space.
    CLEAR &1.
    &1-sign = 'I'.
    &1-option = 'EQ'.
    &1-low = &2.
    APPEND &1.
  ENDIF.
END-OF-DEFINITION.

DEFINE conversion_exit_alpha_input.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = &1
    IMPORTING
      output = &2.

END-OF-DEFINITION.

DEFINE conversion_exit_alpha_output.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OURPUT'
    EXPORTING
      input  = &1
    IMPORTING
      output = &2.

END-OF-DEFINITION.

DEFINE add_range_full.
  CLEAR &1.
  &1-sign = &2.
  &1-option = &3.
  &1-low = &4.
  &1-high = &5.
  APPEND &1.
END-OF-DEFINITION.

DEFINE currency_amount_idoc_to_sap.

  CALL FUNCTION 'CURRENCY_AMOUNT_IDOC_TO_SAP'
    EXPORTING
      currency          = &1
      idoc_amount       = &2
    IMPORTING
      sap_amount        = &3.

END-OF-DEFINITION.

DEFINE currency_amount_sap_to_idoc.

  CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_IDOC'
    EXPORTING
      currency          = &1
      idoc_amount       = &2
    IMPORTING
      sap_amount        = &3.

END-OF-DEFINITION.

댓글 없음:

댓글 쓰기