项目记录: 金税接口[转载]

[引用]:翱翔云天

* Program ID/Name: ZSDE1001              Date written: 20080516
* Author's name:   xh                    Last update:
* Program title:   スースモソレSapマツエォホトオオ
* Project Name:    JSZY
* Version: 1.0
*----------------------------------------------------------------------*
* Description: (Incl. Related Function Area and System)
*----------------------------------------------------------------------*
* Change History
*----------------------------------------------------------------------*
*     Date   |   Programmer   |   Corr. #   |   Description
* 20080516   |       xh       |             |    New create
*            |                |             |
*            |                |             |
************************************************************************
report    ZSDI002_01 no standard page heading
  message-id z001.

************************************************************************
*        TABLES
************************************************************************
tables:vbrk,
       vbrp,
       kna1,
       makt,
       knbk,
       konv,
       t006a,
       vbkd,
       stxl,
       vbak,
       VBAP,
       adrc,knvv,t001,vbfa,
       BSEG ,zfi031,mara,stxh.

************************************************************************
*        INCLUDES
***********************************************************************
include z_alv_define.

************************************************************************
*        PARAMETERS
************************************************************************
data:g_lin like sy-tabix,
     p_lin like sy-tabix,
     g_num like sy-tabix,
     g_bs(1),
     g_flag(1),
     g_tabix like sy-tabix,
     c_tmp(255),
     g_text(60),
     g_dmbtr(16) type p decimals 2,
     g_pr(13),
     G_shuilv TYPE P decimals 4,
     g_vbeln like vbrk-vbeln,
     g_subrc like sy-subrc,
     g_zzfsn like zfi031-zzfsn,
     g_mod   like sy-tabix,
     G_SUM LIKE LIPS-NETWR,
     g_netwr like lips-netwr,
     g_kzwi5 like vbrp-kzwi5,
     P_FILE like RLGRAP-FILENAME,
     g_file TYPE STRING,
     g_name like THEAD-TDNAME,
     g_path like RLGRAP-FILENAME,
     G_FKART LIKE VBRK-FKART,
     G_INTYP(1),
     g_answer.

*constants:
constants:C_SEP(2) VALUE '~~',
          C_SPLT(1) VALUE ' ',
          C_SPLT2(1) VALUE ' '.

************************************************************************
*        INTERNAL TABLES
************************************************************************
data: begin of it_konv occurs 0,
      kschl like konv-kschl,
      kwert like konv-kwert,
      kbetr like konv-kbetr,
      end of it_konv.

data:begin of it_vbrk occurs 0 ,
       vbeln  like vbrk-vbeln,                              "オ・センコナ10
       FKART  LIKE VBRK-FKART,
       KUNRG  like vbrk-KUNRG,   "ハロエ・ス
       name1  like kna1-name1,   "100
       stceg like  kna1-stceg,   "15
       STRAS  like kna1-STRAS,
       ORT01  like kna1-ORT01,
       telf1  like kna1-telf1,
       bankn  like knbk-bankn,
       banka  like bnka-banka,
       bankl  like knbk-bankl,
       bkref  like knbk-bkref,
       koinh  like knbk-koinh,
       zzflag like vbrk-zzflag,
       knumv  like vbrk-knumv,
       flag   like vbrk-zzflag,
       vkorg  like vbrk-vkorg,
       spart  like vbrk-spart,
       vtweg  like vbrk-vtweg,
       SFAKN  like vbrk-sfakn,
       FKDAT  LIKE VBRK-FKDAT,
       FKDAR  LIKE VBRK-FKDAT,
       FKARR  LIKE VBRK-FKART,
       INTYP(1),                "キ「ニアタ獎ヘ
       netwr  like vbrk-netwr,
       tax    like vbrk-netwr,
       mwsbk  like vbrk-mwsbk,
       BSTKD  LIKE VBKD-BSTKD,
       zuonr  like vbrk-zuonr,
       ZZBNO  LIKE VBRK-ZZBNO,
       ZZVER  LIKE VBRK-ZZVER,
       check(08),
       payer(08),
**************
****B   タカニア
****H   コ・ア
**************
       end of it_vbrk.

data:begin of i_vbrk occurs 0 ,
       vbeln  like vbrk-vbeln,                              "オ・センコナ10
       FKART  LIKE VBRK-FKART,
       KUNRG  like vbrk-KUNRG,   "ハロエ・ス
       name1  like kna1-name1,   "100
       stceg like  kna1-stceg,   "15
       STRAS  like kna1-STRAS,
       ORT01  like kna1-ORT01,
       telf1  like kna1-telf1,
       bankn  like knbk-bankn,
       koinh  like knbk-koinh,
       zzflag like vbrk-zzflag,
       knumv  like vbrk-knumv,
       flag   like vbrk-zzflag,
       zzfsn  like zfi031-zzfsn,
       check(08),  "クエコヒネヒ
       payer(08),  "ハユソ鏸ヒ
     end of i_vbrk.

data :begin of out_vbrk occurs 0,
        vbeln(10),
        c1(02),
        num(04),
        c2(02),
        name1(100), "ケコサ・ホサテ﨤ニ
        c3(02),
        stceg(15),  "ケコキスヒーコナ
        c4(02),
        text1(80),  "ケコキスオリヨキオ扈ー
        c5(02),
        text2(80),  "ケコキスメミユハコナ
        c6(02),
        text3(160), "アクラ「?ホサハ
        c7(02),
        check(08),  "クエコヒネヒ
        C8(02),
        payer(08),  "ハユソ鏸ヒ
       end of out_vbrk.

DATA :BEGIN OF IT_VBRP OCCURS 0,
        WERKS LIKE VBRP-WERKS,
        matnr like vbrp-matnr,
        maktx like makt-maktx,
        vrkme LIKE vbap-vrkme ,"シニチソオ・ホサ*
        mseh3 LIKE t006a-mseht,"シニチソオ・ホサテ靆ソ
        fkimg type p decimals 6," like vbrp-fkimg, "ハチソ
        netpr type p decimals 6, "オ・シロ
        NETWR LIKE vbrp-netwr, "ス・
        tax(4) type p decimals 2 ,"ヒーツハ
        MWSBP like vbrp-MWSBP, "ヒーカ・
        kzwi1 like vbrp-kzwi1, "
        kzwi5 like vbrp-kzwi5, "ユロソロス・
        zks   like vbrp-MWSBP,
        zkl(09) type p decimals 3,
        groes like mara-groes,
        vbeln like vbrp-vbeln,
        posnr like vbrp-posnr,
        UEPOS like vbrp-UEPOS,
        VGBEL LIKE VBRP-VGBEL,
        VGPOS LIKE VBRP-VGPOS,
        pr    like vbrp-netwr,  "ー・ーキム
        bstkd like VBKD-BSTKD,
    END OF IT_vbrp.

data:begin of out_vbrp occurs 0,
         maktx(60),   "サ・﨤ニ
         c1(02),
         vrkme(16),   "シニチソオ・ホサ
         c2(02),
         gui(30),     "ケ貂・
         c3(02),
         fkimg(16),   "ハチソ
         c4(02),
         netwr(14),   "イサコャヒース・
         c5(02),
         tax(6),      "ヒーツハ
         c6(02),
         text1(04),   "ノフニキヒートソ
         c7(02),
         text2(16),   "ユロソロス・
         c8(02),
         mwsbp(14),   "ヒーカ・
         c9(02),
         text3(14),   "ユロソロヒーカ・
         c10(02),
         text4(06),   "ユロソロツハ
         c11(02),
         netpr(14),   "オ・シロ
         c12(02),
         pr(01),      "オ・シロキスハス
         end of out_vbrp.

data:begin of i_text occurs 0,
          text(80),
         end of i_text.

data:begin of i_stceg occurs 0,
          stceg like  kna1-stceg,
          KUNRG like  vbrk-KUNRG,
          zzbno like  vbrk-zzbno,
          intyp(1),
          end of i_stceg.

data:begin of t_text occurs 0,
          text(2000),
          end of t_text.

data:begin of i_vbeln occurs 0,
          vbeln(20),
          end of i_vbeln.

data:begin of i_zfi031  occurs 0.
        include structure zfi031.
data:end of i_zfi031.

DATA : begin of LT_LINE  occurs 0.
        include structure TLINE.
DATA:END OF LT_LINE.

data:begin of i_FKART occurs 0,
          intyp(1),
          end of i_FKART.

data:begin of i_typ occurs 0,
          fkart like vbrk-fkart,
          end of i_typ.

data:begin of t_vbeln occurs 0,
          vbeln like vbrk-vbeln,
          BSTKD like vbkd-bstkd,
          end of t_vbeln.

data:er_fieldcatd type slis_t_fieldcat_alv,
     er_layoutd   type slis_layout_alv,
     er_list_top_of_paged type slis_t_listheader,
     er_eventsd   type slis_t_event.

RANGES:R_FKARTS FOR VBRK-FKART,
       R_FKARTC FOR VBRK-FKART,
       R_FKARTR FOR VBRK-FKART,
       R_KVGR1  FOR TVV1-KVGR1,
       R_FKART  FOR VBRK-FKART.
* Selection screen
* Selection screen
selection-screen begin of block vbrk with frame title text-001.
select-options: s_vkorg FOR vbrk-vkorg no-display,
               s_bukrs for vbrk-bukrs default '8000' NO-EXTENSION NO INTERVALS .

select-options:s_werks  for vbrp-werks ,
               s_VBELN  FOR VBRp-VBELN,
               s_KUNrg FOR vbrk-KUNrg,
               s_FKDAT FOR vbrK-FKDAT default sy-datum,
               s_FKART FOR vbrK-FKART no-display,
               s_ERNAM for vbrk-ERNAM default sy-uname.
select-options s_posnr  FOR VBRp-posnr no-display.
select-options s_matnr for vbrp-matnr  no-display.
select-options s_matkl  FOR VBRp-matkl no-display.
selection-screen end of block VBRK.

*selection-screen : begin of block b2 with frame title text-002.
*selection-screen begin of line.
*selection-screen position 1.
*selection-screen comment 1(20)   text-003.
*selection-screen position 25.
*parameters: p_v radiobutton group rad1 default 'X'.
*selection-screen end of line.
*selection-screen begin of line.
*selection-screen position 1.
*selection-screen comment 1(20)   text-004.
*selection-screen position 25.
*parameters: p_n radiobutton group rad1 .
*selection-screen end of line.
*selection-screen : end of block b2.

selection-screen : begin of block b3 with frame title text-014.
selection-screen begin of line.
selection-screen position 1.
selection-screen comment 1(20)   text-005.
selection-screen position 25.
parameters: p_ck_1 radiobutton group rad2 default 'X'.
selection-screen end of line.
selection-screen begin of line.
selection-screen position 1.
selection-screen comment 1(20)   text-006.
selection-screen position 25.
parameters: p_ck_2 radiobutton group rad2.
selection-screen end of line.
*selection-screen begin of line.
*selection-screen position 1.
*selection-screen comment 1(20)   text-007.
*selection-screen position 25.
*parameters: p_ck_3 radiobutton group rad2.
*selection-screen end of line.
selection-screen : end of block b3.

initialization.
  e_repid = sy-repid.
  perform fieldcat_init  using er_fieldcat[].
  perform eventtab_build using er_events[].
  perform comment_build  using er_list_top_of_page[].

AT SELECTION-SCREEN.
*  PERFORM FRM_SC.

*&-------------------------------------------------------------------*
*& Start-of-selection
*&-------------------------------------------------------------------*
start-of-selection.
*== step two ==
  perform fmr_get_data.
  describe table it_vbrk lines g_lin.
  if g_lin < 1.
    message s006.
  else.
    perform frm_fill_out.
  endif.
*---------------------------------------------------------------------*
*       FORM fieldcat_init                                            *
*---------------------------------------------------------------------*
form fieldcat_init using u_er_fieldcat type slis_t_fieldcat_alv.

  data: ls_fieldcat type slis_fieldcat_alv,
         nn type i.
  clear:nn.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'KUNRG'.
  ls_fieldcat-tabname ='IT_VBRK'.
  ls_fieldcat-seltext_l = 'クカソ﨧ス'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'NAME1'.
  ls_fieldcat-tabname ='IT_VBRK'.
  ls_fieldcat-seltext_l = 'ケコキステ﨤ニ'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 35.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'FKART'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'キ「ニアタ獎ヘ'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'VBELN'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'オ・センコナ'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'FKDAT'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'ネユニレ'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 10.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'NETWR'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'ス・.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 16.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'TAX'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'ヒー'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 16.
  append ls_fieldcat to u_er_fieldcat.

  nn = nn + 1.
  clear ls_fieldcat.
  ls_fieldcat-col_pos  = nn.
  ls_fieldcat-fieldname  = 'BSTKD'.
  ls_fieldcat-tabname ='IT-VBRK'.
  ls_fieldcat-seltext_l = 'イノケコオ・'.
  ls_fieldcat-key         = 'X'.
  ls_fieldcat-outputlen = 16.
  append ls_fieldcat to u_er_fieldcat.

endform.                               " FIELDCAT_INIT

*---------------------------------------------------------------------*
*       FORM eventtab_build                                           *
*---------------------------------------------------------------------*
form eventtab_build using u_er_events type slis_t_event.

  data: ls_event type slis_alv_event.

  call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = u_er_events.
  read table u_er_events with key name = slis_ev_top_of_page
                           into ls_event.
  if sy-subrc = 0.
    move er_formname_top_of_page to ls_event-form.
    append ls_event to u_er_events.
  endif.
  read table u_er_events with key name = slis_ev_user_command
                           into ls_event.
  if sy-subrc = 0.
    move e_user_command to ls_event-form.
    append ls_event to u_er_events.
  endif.
  read table u_er_events with key name =  slis_ev_pf_status_set
                           into ls_event.
  if sy-subrc = 0.
    move e_status to ls_event-form.
    append ls_event to u_er_events.
  endif.

endform.                               " EVENTTAB_BUILD
*
form comment_build using u_er_list_top_of_page type
slis_t_listheader.

  data: ls_line type slis_listheader.

* Listen・erschrift: Typ H
  clear ls_line.
  ls_line-typ  = 'H'.
  ls_line-info = text-s07.
  append ls_line to u_er_list_top_of_page.
* Kopfinfo: Typ S
  clear ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = text-s08.
  append ls_line to u_er_list_top_of_page.

endform.                               " COMMENT_BUILD

*
form sp_group_build using u_er_sp_group type slis_t_sp_group_alv.

  data: ls_sp_group type slis_sp_group_alv.
  clear  ls_sp_group.
  ls_sp_group-sp_group = 'A'.
  ls_sp_group-text     = text-s06.
  append ls_sp_group to u_er_sp_group.

endform.                               " SP_GROUP_BUILD

*
form layout_build using u_er_layout type slis_layout_alv.

  u_er_layout-box_fieldname       = 'FLAG'.  " Checkbox
  u_er_layout-get_selinfos        = 'X'.
*  U_ER_LAYOUT-F2CODE              =  'FEHL' .
* u_er_layout-confirmation_prompt = 'X'.     "Sicherheitsabfrage
* u_er_layout-key_hotspot         = 'X'.    "Schl・sel alsHotspot
* u_er_layout-info_fieldname      = 'COL'.    "Zeilenfarbe
* u_er_layout-get_selinfos      = 'X'.
*  u_er_layout-colwidth_optimize = 'X'.
  u_er_layout-detail_popup      = 'X'.
*  u_er_layout-no_keyfix         = 'X'.
*  u_er_layout-numc_sum         = 'X'.
* u_er_layout-box_fieldname     = 'FLAG'.
  u_er_layout-zebra             = 'X'.
endform.                               " LAYOUT_BUILD

*---------------------------------------------------------------------*
*       FORM top_of_page                                              *
*---------------------------------------------------------------------*
form top_of_page.
*
  call function 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      i_logo             = 'ENJOYSAP_LOGO'
      it_list_commentary = er_list_top_of_page.

endform.                    "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*&      Form  fmr_get_data
*&---------------------------------------------------------------------*
FORM fmr_get_data .
  PERFORM FRM_INIT.
  refresh : it_vbrk . clear : it_vbrk.
  select vbrk~zzflag vbrk~vbeln vbrk~fkart vbrk~vsbed vbrk~vkorg
      vbrk~vtweg  vbrk~spart vbrk~fkdat vbrk~netwr vbrk~KUNRG
      vbrk~sfakn   VBRK~KNUMV VBRK~BUKRS vbrk~mwsbk VBRK~BSTNK_VF AS BSTKD VBRK~zuonr
from vbrk
into CORRESPONDING fields of  table it_vbrk
  where vbrk~vkorg in s_vkorg
  and   vbrk~KUNRG in s_KUNRG
  and   vbrk~VBELN in s_VBELN
  and  vbrk~FKDAT  in s_FKDAT
* and  vbrk~FKART in s_FKART
 and  vbrk~FKART in R_FKART
* and   vbrk~RFBSK in s_RFBSK
  and   vbrk~ERNAM in s_ERNAM
  and   vbrk~zzflag ne 'X'  "マツエォスーア・カ
  and   vbrk~fksto ne 'X'   "ニセヨ、ネ。マ﨣・カ
* AND  VBRK~RFBSK = 'C'
* and  VBRK~taxk1 = '1'
* and VBRK~land1 = 'CN'
 and VBRK~netwr ne 0
 and  vbrk~bukrs in s_bukrs.

  loop at it_vbrk.
    g_tabix = sy-tabix.
    AUTHORITY-CHECK OBJECT 'V_VBRK_FKA'
             ID 'FKART' FIELD IT_VBRK-FKART
             ID 'ACTVT' FIELD '03'.
    IF SY-SUBRC <> 0.
      delete it_vbrk index g_tabix.
      continue.
    ENDIF.
    AUTHORITY-CHECK OBJECT 'V_VBRK_VKO'
             ID 'VKORG' FIELD IT_VBRK-VKORG
             ID 'ACTVT' FIELD '03'.

    IF SY-SUBRC <> 0.
      delete it_vbrk index g_tabix.
      continue.
    ENDIF.

    select single * from knvv where kunnr = it_vbrk-KUNRG
                                and VKORG = it_vbrk-vkorg
                                and VTWEG = it_vbrk-vtweg
                                and spart = it_vbrk-spart
                                and kvgr1 in r_kvgr1.
*    if sy-subrc = 0.
**********************
    select single * from kna1 where kunnr = it_vbrk-KUNRG.
    if sy-subrc = 0.
      it_vbrk-name1 = kna1-name1.
      it_vbrk-stceg = kna1-stceg.
      it_vbrk-STRAS = kna1-STRAS.
      it_vbrk-ORT01 = kna1-ORT01.
      it_vbrk-telf1 = kna1-telf1.
    endif.
    select single * from kna1 where kunnr = 'ZZZZ'.
    IF SY-SUBRC = 0.
      IT_VBRK-CHECK = KNA1-NAME1.
      IT_VBRK-PAYER = KNA1-NAME2.
    ENDIF.
    clear knbk.
    select single * from knbk where kunnr = it_vbrk-KUNRG.
    if sy-subrc = 0.
      it_vbrk-bankn = knbk-bankn.
      it_vbrk-koinh = knbk-koinh.
      it_vbrk-bankl = knbk-bankl.
      it_vbrk-bkref = knbk-bkref.
      select single banka into it_vbrk-banka from bnka where BANKS = knbk-BANKS
                                                         and BANKL = knbk-BANKL.
    endif.
    it_vbrk-tax = it_vbrk-mwsbk.
    CLEAR:IT_VBRK-SFAKN.
    SELECT SINGLE * FROM VBFA WHERE VBELN   = IT_VBRK-VBELN
                                AND VBTYP_N = 'O'
                                AND VBTYP_V = 'M'.
    IF SY-SUBRC = 0.
        IT_VBRK-SFAKN = VBFA-VBELV.
    ENDIF.
*    if not r_fkarts[] is initial.
*      clear vbrk.
*      SELECT SINGLE * FROM VBRK WHERE SFAKN = IT_VBRK-VBELN.
*      IF SY-SUBRC = 0 AND VBRK-FKDAT+0(6) = IT_VBRK-FKDAT+0(6).
*        delete it_vbrk index g_tabix.
*        continue.
*      ENDIF.
*    endif.

*    if not r_fkartc[] is initial.
*      clear vbrk.
*      IF it_vbrk-sfakn ne space.
*        select single * from vbrk where vbeln  = it_vbrk-SFAKN
*                                    and zzflag = 'X'.
*        IF SY-SUBRC NE  0.
*          delete it_vbrk index g_tabix.
*          continue.
*        ENDIF.
*      endif.
*    endif.

*    if not r_fkartr[] is initial.
*      clear vbrk.
*      IF IT_VBRK-FKART = 'ZSE' OR IT_VBRK-FKART = 'ZSE2'.
*        select single * from vbrk where vbeln  = it_vbrk-SFAKN
*                                    and zzflag = 'X'.
*        IF SY-SUBRC NE  0.
*          delete it_vbrk index g_tabix.
*        ENDIF.
*      ELSEIF IT_VBRK-FKART = 'ZRE'.
*        SELECT SINGLE * FROM VBRK WHERE SFAKN = IT_VBRK-VBELN.
*        IF SY-SUBRC = 0 AND VBRK-FKDAT+0(6) = IT_VBRK-FKDAT+0(6).
*          delete it_vbrk index g_tabix.
*        ENDIF.
*      ENDIF.
*    endif.
    it_vbrk-intyp = 'B'.
    if it_vbrk-fkart = 'ZG1' or it_vbrk-fkart = 'ZG3' or it_vbrk-fkart = 'ZRE'
      or it_vbrk-fkart = 'ZRE2'.
      select single * from vbrk where vbeln = it_vbrk-SFAKN.
      IT_VBRK-INTYP = 'H'.
      IT_VBRK-ZZBNO = vbrk-zzbno.
      IT_VBRK-ZZVER = VBRK-ZZVER.
    endif.

    modify it_vbrk index g_tabix.
  endloop.

  refresh:it_vbrp.  clear:it_vbrp,g_lin.
  describe table it_vbrk lines g_lin.
  if g_lin > 0.
    select * into corresponding fields of table it_vbrp
             from vbrp for all entries in it_vbrk
             where vbeln = it_vbrk-vbeln
               and werks in s_werks.
  endif.

  CLEAR G_TABIX.
  loop at it_vbrp.
    g_tabix = sy-tabix.
    AUTHORITY-CHECK OBJECT 'Z_ABAP'
             ID 'WERKS' FIELD IT_VBRP-WERKS
             ID 'ACTVT' FIELD '03'.
    IF SY-SUBRC <> 0.
      delete it_vbrP index g_tabix.
      continue.
    ENDIF.

    clear: g_sum,makt,mara,t006a,mara.
    select single * from  makt where matnr = it_vbrp-matnr
                         and SPRAS = '1'.
    if sy-subrc = 0.
      it_vbrp-maktx = makt-maktx.
    else.
      select single * from  makt where matnr = it_vbrp-matnr
                            and SPRAS = 'E'.

      it_vbrp-maktx = makt-maktx.
    endif .

    select single * from mara where matnr = it_vbrp-matnr.
    if sy-subrc = 0.
      it_vbrp-groes = mara-WRKST.
    endif.

    select single * from t006a where MSEHI = it_vbrp-vrkme
                              and   SPRAS = '1'.
    if sy-subrc = 0 .
      it_vbrp-mseh3 = t006a-mseht.
    endif.

    REFRESH: it_konv . CLEAR : it_konv.

    read table it_vbrk with key vbeln = it_vbrp-vbeln.
    SELECT kschl  kwert  kbetr
    INTO CORRESPONDING FIELDS OF TABLE it_konv
    FROM konv
     WHERE knumv = it_vbrk-knumv
      AND   kposn = it_vbrp-posnr.

    READ TABLE it_konv WITH KEY  kschl = 'MWSI'.
    IF sy-subrc = 0.
      it_vbrp-tax = it_konv-kbetr / 1000 .
    ENDIF .

    READ TABLE it_konv WITH KEY  kschl = 'MWST'.
    IF sy-subrc = 0.
      it_vbrp-tax = it_konv-kbetr / 1000 .
    ENDIF .

    if it_vbrp-fkimg ne 0.
      it_vbrp-netpr = it_vbrp-netwr / it_vbrp-fkimg.
    endif.
    t_vbeln-vbeln = it_vbrp-vbeln. collect t_vbeln.

    SELECT SINGLE * FROM VBKD WHERE VBELN = IT_VBRP-VGBEL.
    IF SY-SUBRC = 0.
      IT_VBRP-BSTKD = VBKD-BSTKD.
    ENDIF.
    modify it_vbrp index g_tabix.
  endloop.
  loop at it_vbrk.
    g_tabix = sy-tabix.
    read table t_vbeln with key vbeln = it_vbrk-vbeln.
    if sy-subrc ne 0.
      delete it_vbrk index g_tabix.
    else.
    endif.
    READ TABLE IT_VBRP WITH KEY VBELN = IT_VBRK-VBELN.
    IF SY-SUBRC = 0.
      IT_VBRK-BSTKD = IT_VBRP-BSTKD.
      MODIFY IT_VBRK INDEX G_TABIX.
    ENDIF.
  endloop.
ENDFORM.                    " fmr_get_data
*&---------------------------------------------------------------------*
*&      Form  frm_fill_out
*&---------------------------------------------------------------------*
FORM frm_fill_out .
  perform layout_build using er_layout.

  call function 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = e_repid
      i_callback_pf_status_set = e_status
      i_callback_user_command  = e_user_command
      is_layout                = er_layout
      it_fieldcat              = er_fieldcat[]
      it_events                = er_events[]
    TABLES
      t_outtab                 = it_vbrk.
ENDFORM.                    " frm_fill_out
*---------------------------------------------------------------------*
*       FORM user_command                                             *
*---------------------------------------------------------------------*
form user_command using p_ucomm like sy-ucomm
                        p_selfield type slis_selfield.
  case p_ucomm.
    when 'DOWN'. "オ・ク「ニアマツエォ
      p_selfield-refresh = 'X'.
      PERFORM FRM_EXCU.
    when 'CDOW'. "サ聆ワソェニア(コマイ「テクソェニア)
      p_selfield-refresh = 'X'.
      perform frm_save.
    when 'CDF2'. ""サ聆ワソェニア(コマイ「テクソェニア)ZF2+ZF2
      p_selfield-refresh = 'X'.
      perform frm_save_zf2.
    when '&IC1'.
      read table it_vbrk index p_selfield-tabindex.
      check sy-subrc = 0.
      SET PARAMETER ID: 'VF' FIELD IT_VBRK-VBELN.
      CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
    when others.
  endcase.
endform.                    "user_command
*---------------------------------------------------------------------*
*       FORM standard_er01                                            *
*---------------------------------------------------------------------*
form standard_er01 using  extab type slis_t_extab.

  data:  wa_tab type slis_extab.
  delete extab where fcode = '&RNT_PREV'.
  delete extab where fcode = '&LFO'.
  delete extab where fcode = '&NFO'.
  move '&IC1' to wa_tab-fcode.
  append wa_tab to extab.
  set pf-status 'ALVLIST1' excluding extab.

endform.                    "STANDARD_ER01
*&---------------------------------------------------------------------*
*&      Form  FRM_EXCU
*&---------------------------------------------------------------------*
FORM FRM_EXCU .
  CLEAR:G_LIN,g_flag, i_fkart[].
  read table it_vbrk with key flag = 'X'.
  IF SY-SUBRC = 0.
    LOOP AT IT_VBRK WHERE FLAG  = 'X'
                      AND ( INTYP = 'B' OR INTYP = 'H' ).
      EXIT.
    ENDLOOP.
    IF SY-SUBRC = 0.
      PERFORM FRM_N.
    ENDIF.

*    LOOP AT IT_VBRK WHERE FLAG  = 'X'
*                      AND INTYP = 'R'.
*        EXIT.
*    ENDLOOP.
*    IF SY-SUBRC = 0.
*    PERFORM FRM_R.
*    ENDIF.

  ELSE.
    message s007.
  ENDIF.

ENDFORM.                    " FRM_EXCU
*&---------------------------------------------------------------------*
*&      Form  frm_down_h
*&---------------------------------------------------------------------*
FORM frm_down_h .
  refresh:out_vbrk. clear:out_vbrk,g_lin,g_flag.

  loop at it_vbrp where vbeln = it_vbrk-vbeln
                   and netwr ne 0.
    if it_vbrp-netwr ne 0.
      g_lin = g_lin + 1.
    endif.
  endloop.
  out_vbrk-vbeln = it_vbrk-vbeln.
  out_vbrk-c1 = c_sep.
  if g_bs = '1'.
    out_vbrk-num = g_num.
    clear g_bs.
    clear out_vbrk-text3.
    sort t_vbeln by vbeln descending.
    describe table t_vbeln lines p_lin.
    loop at t_vbeln.
      if sy-tabix = '1'.
        concatenate t_vbeln-vbeln  out_vbrk-text3 into out_vbrk-text3.
      else.
        concatenate t_vbeln-vbeln ',' out_vbrk-text3 into out_vbrk-text3.
      endif.
    endloop.
    concatenate 'チョコナ:' out_vbrk-text3 into out_vbrk-text3.
    loop at t_vbeln.
      if sy-tabix = '1'.
        concatenate t_vbeln-bstkd  out_vbrk-text3 into out_vbrk-text3.
      else.
        concatenate t_vbeln-bstkd ',' out_vbrk-text3 into out_vbrk-text3.
      endif.
    endloop.
    concatenate 'コマヘャコナ:' out_vbrk-text3 into out_vbrk-text3.
  else.
    out_vbrk-num = g_lin.
    concatenate 'チョコナ:' it_vbrp-vgbel into out_vbrk-text3.
    concatenate 'コマヘャコナ:' it_vbrp-bstkd out_vbrk-text3 into out_vbrk-text3.
  endif.
  condense out_vbrk-num.
  out_vbrk-c2 = c_sep.
  out_vbrk-name1 = it_vbrk-name1.
  out_vbrk-c3 = c_sep.
  out_vbrk-stceg = it_vbrk-stceg.
  out_vbrk-c4 = c_sep.
  SPLIT it_vbrk-STRAS AT c_splt  INTO:it_vbrk-STRAS  g_text.
  if sy-subrc ne 0.
    SPLIT it_vbrk-STRAS AT c_splt2  INTO:it_vbrk-STRAS  g_text.
  endif.
  SPLIT it_vbrk-ORT01 AT c_splt  INTO:it_vbrk-ORT01  g_text.
  if sy-subrc ne 0.
    SPLIT it_vbrk-ORT01 AT c_splt2  INTO:it_vbrk-ORT01  g_text.
  endif.

* concatenate it_vbrk-STRAS it_vbrk-ORT01 it_vbrk-telf1 into   out_vbrk-text1.
  concatenate it_vbrk-STRAS  it_vbrk-telf1 into   out_vbrk-text1.
  out_vbrk-c5 = c_sep.

  SPLIT it_vbrk-banka AT c_splt  INTO:it_vbrk-banka  g_text.
  if sy-subrc ne 0.
    SPLIT it_vbrk-banka AT c_splt2  INTO:it_vbrk-banka  g_text.
  endif.

  concatenate it_vbrk-banka it_vbrk-bankn it_vbrk-bkref into out_vbrk-text2.
* out_vbrk-text2 = it_vbrk-banka.
  out_vbrk-c6 = c_sep.
********************?

  if it_vbrk-intyp = 'H'.
    g_flag = '1'.
*    IF IT_VBRK-FKART = 'ZS' OR IT_VBRK-FKART = 'ZS2'.
*   concatenate  into .
    out_vbrk-text3 = 'ソェセ゚コ・ヨヤオヒーラィモテキ「ニアヘィヨェオ・コナ'.
*    ENDIF.
  endif.
  out_vbrk-c7 = c_sep.
  OUT_VBRK-CHECK = IT_VBRK-CHECK.
  out_vbrk-c8 = c_sep.
  OUT_VBRK-PAYER = IT_VBRK-PAYER.
  append out_vbrk.
*  CLEAR OUT_VBRK.
ENDFORM.                    " frm_down_h
*&---------------------------------------------------------------------*
*&      Form  frm_down_i
*&---------------------------------------------------------------------*
FORM frm_down_i .
  refresh:out_vbrp,t_text. clear:out_vbrp,G_FLAG,t_text.
  loop at it_vbrp where vbeln = it_vbrk-vbeln
                   and netwr ne 0
                    and fkimg ne 0.
    CLEAR G_shuilv.
    out_vbrp-maktx = it_vbrp-maktx.
    out_vbrp-c1 = c_sep.
*   out_vbrp-vrkme = it_vbrp-vrkme.mseh3
    out_vbrp-vrkme = it_vbrp-mseh3.
    out_vbrp-c2 = c_sep.
    out_vbrp-gui = IT_VBRP-GROES.
    out_vbrp-c3 = c_sep.
    out_vbrp-fkimg = it_vbrp-fkimg.
    condense out_vbrp-fkimg.
    out_vbrp-c4 = c_sep.
    G_shuilv = IT_VBRP-TAX + 1.
*    if it_vbrk-fkart = 'ZRE'.
*      IT_VBRP-NETWR = IT_VBRP-NETWR + IT_VBRP-KZWI5.
*      out_vbrp-netwr = it_vbrp-netwr.
*      it_vbrp-netpr  = it_vbrp-netwr / it_vbrp-fkimg.
*    ENDIF.
    out_vbrp-netwr = it_vbrp-netwr.
    condense out_vbrp-netwr.
    out_vbrp-c5 = c_sep.
    out_vbrp-tax = it_vbrp-tax.
    condense out_vbrp-tax.
    out_vbrp-c6 = c_sep.
    out_vbrp-text1 = '1209'.
    out_vbrp-c7 = c_sep.
*    if g_sum ne 0 and g_kzwi5 ne 0.
*    it_vbrp-zkl = g_kzwi5 / g_sum.
*    out_vbrp-text4 = it_vbrp-zkl.
*    condense out_vbrp-text4.
*    endif.

*  it_vbrp-kzwi5 = it_vbrp-netwr * it_vbrp-zkl.
*    it_vbrp-kzwi5 = 0 - it_vbrp-kzwi5.
*    IF G_BS = '1'.
*      IT_VBRP-KZWI5 = IT_VBRP-KZWI5 + G_KZWI5 * IT_VBRP-NETWR / G_SUM.
*    ENDIF.
*    if it_vbrk-fkart ne 'ZRE'.
*      out_vbrp-text2 = it_vbrp-kzwi5.
*      condense out_vbrp-text2.
*      out_vbrp-text3 = it_vbrp-kzwi5 * it_vbrp-tax.
*      condense out_vbrp-text3.
*    ENDIF.
*    clear it_vbrp-mwsbp.
*    it_vbrp-mwsbp = it_vbrp-netwr." - IT_VBRP-KZWI5.
*    it_vbrp-mwsbp = it_vbrp-mwsbp * it_vbrp-tax.
    out_vbrp-mwsbp = it_vbrp-mwsbp.
    condense out_vbrp-mwsbp.
    out_vbrp-c9 = c_sep.
    out_vbrp-c10 = c_sep.
    out_vbrp-c11 = c_sep.
    out_vbrp-c8 = c_sep.

*    out_vbrp-netpr = it_vbrp-netpr.
*    condense out_vbrp-netpr.
    out_vbrp-c12 = c_sep.
    out_vbrp-pr  = '0'.
    if it_vbrk-intyp = 'H' ." it_vbrk-fkart ne 'ZRE'.
      condense out_vbrp-fkimg.
      concatenate '-' out_vbrp-fkimg into out_vbrp-fkimg.
      condense out_vbrp-netwr.
      concatenate '-' out_vbrp-netwr into out_vbrp-netwr.
      condense out_vbrp-mwsbp.
      concatenate '-' out_vbrp-mwsbp into out_vbrp-mwsbp.
*      IF IT_VBRK-FKART NE 'ZRE'.
*        concatenate '-' out_vbrp-text2 into out_vbrp-text2.
*        concatenate '-' out_vbrp-text3 into out_vbrp-text3.
*      ENDIF.
    ENDIF.
    append out_vbrp.

    concatenate out_vbrp-maktx out_vbrp-c1  out_vbrp-vrkme out_vbrp-c2
                 out_vbrp-gui   out_vbrp-c3  out_vbrp-fkimg out_vbrp-c4
                 out_vbrp-netwr out_vbrp-c5  out_vbrp-tax   out_vbrp-c6
                 out_vbrp-text1 out_vbrp-c7  out_vbrp-text2 out_vbrp-c8 out_vbrp-mwsbp
                 out_vbrp-c9  out_vbrp-text3 out_vbrp-c10
                 out_vbrp-c11 out_vbrp-netpr out_vbrp-c12
                 out_vbrp-pr into t_text-text.
    append t_text.
    clear:out_vbrp,t_text.
  endloop.

ENDFORM.                    " frm_down_i
*&---------------------------------------------------------------------*
*&      Form  frm_save
*&---------------------------------------------------------------------*
FORM frm_save .
  refresh:i_stceg. clear:i_stceg,g_lin,g_num,g_bs,G_KZWI5,
         G_FKART,G_INTYP,i_typ,i_typ[],t_vbeln[],t_vbeln.
  loop at it_vbrk where flag = 'X'.
    i_typ-fkart = it_vbrk-fkart. collect i_typ. clear i_typ.
    g_lin = g_lin + 1.
    IF it_vbrk-fkart IN R_FKART.
      i_stceg-stceg = it_vbrk-stceg.
      i_stceg-KUNRG = it_vbrk-KUNRG.
      i_stceg-intyp = it_vbrk-intyp.
      collect i_stceg. clear i_stceg.
      loop at it_vbrp where vbeln = it_vbrk-vbeln
                     and netwr ne 0.
        g_num = g_num + 1.
*      if it_vbrp-pr ne 0.
*        g_num = g_num + 1.
*      endif.
        t_vbeln-vbeln = it_vbrp-vgbel.
        t_vbeln-bstkd = it_vbrp-bstkd.
        collect t_vbeln. clear t_vbeln.
      endloop.
    ENDIF.
  endloop.
  if g_lin < 2.
    message e000 with 'イサトワコマイ「マツヤリ!'.
  endif.
************
  clear g_lin.
  describe table i_stceg lines g_lin.
  if g_lin = 1.
    perform frm_nc.
  else.
    message s000 with 'イサトワコマイ「マツヤリ!'.
  endif.
ENDFORM.                    " frm_save
*&---------------------------------------------------------------------*
*&      Form  FRM_N
*&---------------------------------------------------------------------*
FORM FRM_N .
  refresh:i_text. clear:i_text.
  concatenate 'SJJK0101' c_sep 'マ摠ロオ・センエォネ・ into i_text-text.
  append i_text.
  concatenate 'C:\マ摠ロキ「ニアエォネ・トシ\' sy-datum '.txt' into g_path.
  CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      filename                = g_path
      codepage                = '8400'
      filetype                = 'ASC'
      item                    = 'Export Invoice'
      mode                    = 'A'
    IMPORTING
      ACT_FILENAME            = P_FILE
    TABLES
      DATA_TAB                = i_text
    EXCEPTIONS
      INVALID_FILESIZE        = 1
      INVALID_TABLE_WIDTH     = 2
      INVALID_TYPE            = 3
      NO_BATCH                = 4
      UNKNOWN_ERROR           = 5
      GUI_REFUSE_FILETRANSFER = 6
      CUSTOMER_ERROR          = 7
      OTHERS                  = 8.

  G_FILE = P_FILE.
  IF g_file IS INITIAL. EXIT. ENDIF.
  clear:g_tabix.
  loop at it_vbrk where flag = 'X' AND
   ( INTYP = 'B' OR INTYP = 'H' ).

    refresh:i_text,t_text. clear:i_text,t_text.
    g_tabix = g_tabix + 1.
    clear:g_text.
    CALL FUNCTION 'Z_GET_CHINESE_CHAR'
      EXPORTING
        NUM  = g_tabix
      IMPORTING
        CHAR = g_text.
    concatenate '//' 'オ・セン'  g_text ':' into i_text-text.
    append i_text.

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        codepage = '8400'
*TRUNC_TRAILING_BLANKS_EOL = ' '
*        filetype                = 'ASC'
        APPEND   = 'X'
      TABLES
        data_tab = i_text.

    perform frm_down_h.

    SPLIT OUT_VBRK-NAME1 AT c_splt  INTO:out_vbrk-name1  g_text.
    if sy-subrc ne 0.
      SPLIT OUT_VBRK-NAME1 AT c_splt2  INTO:out_vbrk-name1  g_text.
    endif.

    concatenate out_vbrk-vbeln out_vbrk-c1 out_vbrk-num   out_vbrk-c2
                out_vbrk-name1 out_vbrk-c3 out_vbrk-stceg out_vbrk-c4
                out_vbrk-text1 out_vbrk-c5 out_vbrk-text2 out_vbrk-c6
                out_vbrk-text3 out_vbrk-c7 out_vbrk-check out_vbrk-c8
                out_vbrk-payer into t_text-text.
    append t_text.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        CODEPAGE = '8400'
*TRUNC_TRAILING_BLANKS_EOL = ' '
        APPEND   = 'X'
*        filetype                = 'ASC'
      TABLES
        data_tab = t_text.

    perform frm_down_i.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        codepage = '8400'
*TRUNC_TRAILING_BLANKS_EOL = ' '
        APPEND   = 'X'
*       filetype                = 'ASC'
      TABLES
        data_tab = t_text.

    if sy-subrc  = 0.
      perform frm_updates.
      delete it_vbrk.
    endif.
  endloop.

ENDFORM.                    " FRM_N
*&---------------------------------------------------------------------*
*&      Form  FRM_R
*&---------------------------------------------------------------------*
FORM FRM_R .
  refresh:i_text. clear:i_text,g_file.
  concatenate 'SJJK0102' c_sep 'ラママ摠ロオ・センエォネ・ into i_text-text.
  append i_text.
  concatenate 'C:\マ摠ロキ「ニアエォネ・トシ\' sy-datum '.txt' into g_path.

  CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      filename     = g_path
      filetype     = 'ASC'
      item         = 'Export Invoice'
      mode         = 'A'
    IMPORTING
      ACT_FILENAME = g_file
    TABLES
      DATA_TAB     = i_text.

  clear:g_tabix.
  loop at it_vbrk where flag = 'X'
                    AND INTYP = 'R'.
    refresh:i_text. clear:i_text.
    g_tabix = g_tabix + 1.
    clear:g_text.
    CALL FUNCTION 'Z_GET_CHINESE_CHAR'
      EXPORTING
        NUM  = g_tabix
      IMPORTING
        CHAR = g_text.
    concatenate '//' g_text ':' into i_text-text.
    append i_text.

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        filetype = 'ASC'
        APPEND   = 'X'
      TABLES
        data_tab = i_text.

    refresh:i_vbeln.clear:i_vbeln.
    select single SFAKN into i_vbeln-vbeln from vbrk where vbeln = it_vbrk-vbeln.
*    i_vbeln-vbeln = it_vbrk-vbeln.
    append i_vbeln.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        filetype = 'ASC'
        APPEND   = 'X'
      TABLES
        data_tab = i_vbeln.

    if sy-subrc  = 0.
      perform frm_updates.
      delete it_vbrk.
    endif.
  endloop.

ENDFORM.                    " FRM_R
*&---------------------------------------------------------------------*
*&      Form  FRM_SC
*&---------------------------------------------------------------------*
FORM FRM_SC .
  IF S_BUKRS-LOW IS INITIAL.
    message e001.
  ENDIF.
  IF  NOT S_BUKRS-LOW IS INITIAL.
    SELECT SINGLE * FROM T001 WHERE BUKRS = S_BUKRS-LOW.
    IF SY-SUBRC NE 0.
      message e002.
    ENDIF.
  ENDIF.
  IF S_KUNRG[] IS INITIAL AND S_VBELN[] IS INITIAL AND S_FKDAT[] IS INITIAL.
    MESSAGE E003.
  ENDIF.

ENDFORM.                    " FRM_SC
*&---------------------------------------------------------------------*
*&      Form  frm_nc
*&---------------------------------------------------------------------*
FORM frm_nc .
  refresh:i_text,i_zfi031.clear:i_text,i_zfi031,g_file.
  concatenate 'SJJK0101' c_sep 'マ摠ロオ・センエォネ・ into i_text-text.
  append i_text.
  concatenate 'C:\マ摠ロキ「ニアエォネ・トシ\' sy-datum '.txt' into g_path.
  CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      filename     = g_path
      CODEPAGE     = '8400'
      filetype     = 'ASC'
      item         = 'Export Invoice'
      mode         = 'A'
    IMPORTING
      ACT_FILENAME = P_file
    TABLES
      DATA_TAB     = i_text.

  G_FILE = P_FILE.
  IF g_file IS INITIAL. EXIT. ENDIF.

  clear:g_tabix,g_vbeln.
  loop at it_vbrk where flag = 'X'.
    refresh:i_text. clear:i_text.
    g_tabix = g_tabix + 1.
    clear:g_text.
    if g_tabix = 1.
      g_vbeln = it_vbrk-vbeln.
      CALL FUNCTION 'Z_GET_CHINESE_CHAR'
        EXPORTING
          NUM  = g_tabix
        IMPORTING
          CHAR = g_text.
      concatenate '//' 'オ・セン' g_text ':' into i_text-text.
      append i_text.

      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = g_file
          CODEPAGE = '8400'
*          TRUNC_TRAILING_BLANKS_EOL = ' '
*         filetype = 'ASC'
          APPEND   = 'X'
        TABLES
          data_tab = i_text.

      g_bs = '1'.
      perform frm_down_h.

      clear t_text[].
      concatenate out_vbrk-vbeln out_vbrk-c1 out_vbrk-num   out_vbrk-c2
                 out_vbrk-name1 out_vbrk-c3 out_vbrk-stceg out_vbrk-c4
                 out_vbrk-text1 out_vbrk-c5 out_vbrk-text2 out_vbrk-c6
                 out_vbrk-text3 out_vbrk-c7 out_vbrk-check out_vbrk-c8
                 out_vbrk-payer into t_text-text.
      append t_text.

      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = g_file
          CODEPAGE = '8400'
*          TRUNC_TRAILING_BLANKS_EOL = ' '
*          filetype                = 'ASC'
          APPEND   = 'X'
        TABLES
          data_tab = t_text.
    endif.

    perform frm_down_i.

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        CODEPAGE = '8400'
*TRUNC_TRAILING_BLANKS_EOL = ' '
        APPEND   = 'X'
*        filetype                = 'ASC'
      TABLES
        data_tab = t_text.

    if sy-subrc  = 0.
      perform frm_upm.
      delete it_vbrk.
    endif.

  endloop.

  loop at i_zfi031.
    move-corresponding i_zfi031 to zfi031.
    modify zfi031 .
    clear zfi031.
  endloop.

ENDFORM.                    " frm_nc
*&---------------------------------------------------------------------*
*&      Form  frm_updates
*&---------------------------------------------------------------------*
FORM frm_updates .
  ZFI031-vbeln  = it_vbrk-vbeln.
  zfi031-vbeln1 = it_vbrk-vbeln.
  zfi031-intyp  = it_vbrk-intyp.
  ZFI031-UNAME = sy-uname.
  ZFI031-datum = sy-datum.
  modify zfi031.

ENDFORM.                    " frm_updates
*&---------------------------------------------------------------------*
*&      Form  frm_upm
*&---------------------------------------------------------------------*
FORM frm_upm .
  loop at it_vbrk where flag = 'X'.
    i_ZFI031-vbeln1 = g_vbeln.
*    if it_vbrk-vbeln = g_vbeln.
*      I_ZFI031-POSNR = '01'.
*    ELSE.
*      I_ZFI031-POSNR = '02'.
*    endif.
    i_zfi031-vbeln = it_vbrk-vbeln.
    i_zfi031-intyp = it_vbrk-intyp.
    i_ZFI031-UNAME = sy-uname.
    i_ZFI031-datum = sy-datum.
    append i_zfi031.
*    delete it_vbrk.
  endloop.
ENDFORM.                    " frm_upm
*&---------------------------------------------------------------------*
*&      Form  frm_save_zf2
*&---------------------------------------------------------------------*
FORM frm_save_zf2 .
  refresh:i_stceg. clear:i_stceg,g_lin,g_num,g_bs,G_KZWI5,
   G_FKART,G_INTYP,i_typ,i_typ[],g_SUM,i_zfi031[].
  data:l_tabix like sy-tabix.
  loop at it_vbrk where flag = 'X' and FKART = 'ZF2'.
    g_lin = g_lin + 1.
    i_typ-fkart = it_vbrk-fkart. collect i_typ. clear i_typ.
    i_stceg-stceg = it_vbrk-stceg.
    i_stceg-KUNRG = it_vbrk-KUNRG.
    i_stceg-intyp = it_vbrk-intyp.
    collect i_stceg. clear i_stceg.
    loop at it_vbrp where vbeln = it_vbrk-vbeln.
      if it_vbrp-netwr ne '0.00'.
        G_SUM   = G_SUM + IT_VBRP-NETWR.
        l_tabix = l_tabix + 1.
      ENDIF.
    endloop.
  endloop.

  if g_lin = 0.
    message e000 with 'ヌ・。ヤセンコマイ「マツヤリ!'.
  elseif g_lin = 1.
    message e000 with 'イサトワム。ヤサフセンコマイ「マツヤリ!'.
  endif.

  if g_sum >= '100000.00'.
    message e000 with 'イサトワコマイ「マツヤリ!(ス鋗レ10ヘ・'.
  ENDIF.

  describe table i_stceg lines g_lin.
  if g_lin >= 2.
    message e000 with 'イサトワコマイ「マツヤリ!'.
  endif.

  clear g_lin.
  describe table i_typ lines g_lin.
  if g_lin NE 1.
    message e000 with 'イサトワコマイ「マツヤリ!(ヨサトワZF2+ZF2)'.
  endif.

  refresh:i_text,i_zfi031.clear:i_text,i_zfi031,g_file,g_path.
  concatenate 'C:\マ摠ロキ「ニアエォネ・トシ\' sy-datum '.txt' into g_path.
  concatenate 'SJJK0101' c_sep 'マ摠ロオ・センエォネ・ into i_text-text.
  append i_text.
  CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      filename     = g_path
      filetype     = 'ASC'
      item         = 'Export Invoice'
      mode         = 'A'
    IMPORTING
      ACT_FILENAME = g_file
    TABLES
      DATA_TAB     = i_text.
  IF g_file IS INITIAL. EXIT. ENDIF.

  clear:g_tabix,g_vbeln.
  loop at it_vbrk where flag = 'X'.
    refresh:i_text. clear:i_text.
    g_tabix = g_tabix + 1.
    clear:g_text.
    if g_tabix = 1.
      g_vbeln = it_vbrk-vbeln.
      CALL FUNCTION 'Z_GET_CHINESE_CHAR'
        EXPORTING
          NUM  = g_tabix
        IMPORTING
          CHAR = g_text.
      concatenate '//' 'オ・セン' g_text ':' into i_text-text.
      append i_text.

      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = g_file
          filetype = 'ASC'
          APPEND   = 'X'
        TABLES
          data_tab = i_text.

      g_bs = '1'.
      perform frm_down_h.
      out_vbrk-num = l_tabix.
      condense out_vbrk-num.
      concatenate out_vbrk-vbeln out_vbrk-c1 out_vbrk-num   out_vbrk-c2
                  out_vbrk-name1 out_vbrk-c3 out_vbrk-stceg out_vbrk-c4
                  out_vbrk-text1 out_vbrk-c5 out_vbrk-text2 out_vbrk-c6
                  out_vbrk-text3 out_vbrk-c7 out_vbrk-check out_vbrk-c8
                  out_vbrk-payer into t_text-text.
      append t_text.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = g_file
          filetype = 'ASC'
          APPEND   = 'X'
        TABLES
          data_tab = t_text.
    endif.

    perform frm_down_i.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = g_file
        filetype = 'ASC'
        APPEND   = 'X'
      TABLES
        data_tab = t_text.

    if sy-subrc  = 0.
      i_ZFI031-vbeln1 = g_vbeln.
      i_zfi031-vbeln = it_vbrk-vbeln.
      i_zfi031-intyp = it_vbrk-intyp.
      i_ZFI031-UNAME = sy-uname.
      i_ZFI031-datum = sy-datum.
      append i_zfi031.
      delete it_vbrk.
    endif.
  endloop.

  loop at i_zfi031.
    move-corresponding i_zfi031 to zfi031.
    modify zfi031 .
    clear zfi031.
  endloop.

ENDFORM.                    " frm_save_zf2
*&---------------------------------------------------------------------*
*&      Form  FRM_INIT
*&---------------------------------------------------------------------*
FORM FRM_INIT .
  clear:r_fkarts[],r_fkartc[],r_fkartr[],r_kvgr1,R_FKART."s_fkart[].
  R_FKART-sign = 'I'.
  R_FKART-option = 'EQ'.
  R_FKART-LOW = 'ZF2'. append R_FKART.
* R_FKART-LOW = 'ZF1'.  append R_FKART.
  R_FKART-LOW = 'ZF'.  append R_FKART.
*  R_FKART-LOW = 'ZRE'.  append R_FKART.
*  R_FKART-LOW = 'ZRE1'. append r_fkart.
*  R_FKART-LOW = 'ZRE2'. append r_fkart.

  if p_ck_1 = 'X'.
    r_fkarts-sign = 'I'.
    r_fkarts-option = 'EQ'.
    r_fkarts-LOW = 'ZF'.  append r_fkarts.
    r_fkarts-LOW = 'ZF2'. append r_fkarts.
    r_fkarts-LOW = 'ZL1'. append r_fkarts.
    r_fkarts-LOW = 'ZL3'.append r_fkarts.
    R_fkart[] = r_fkarts[].
  endif.

  if p_ck_2 = 'X'.
    r_fkartc-sign = 'I'.
    r_fkartc-option = 'EQ'.
    r_fkartc-LOW = 'ZG1'.   append r_fkartc.
    r_fkartc-LOW = 'ZG3'.  append r_fkartc.
    r_fkartc-LOW = 'ZRE'.  append r_fkartc.
    r_fkartc-LOW = 'ZRE2'. append r_fkartc.
    R_fkart[] = r_fkartc[].
  endif.

*  if p_ck_3 = 'X'.
*    r_fkartr-sign = 'I'.
*    r_fkartr-option = 'EQ'.
*
*
*    R_fkart[] = r_fkartr[].
*  endif.

ENDFORM.                    " FRM_INIT
 
   
引用:http://www.abaptech.com/wp-content/uploads/2009/01/.txt

 

转载于:https://www.cnblogs.com/wequst/archive/2009/06/25/1510918.html

你可能感兴趣的:(项目记录: 金税接口[转载])