码迷,mamicode.com
首页 > 其他好文 > 详细

SAP中方会计凭证打印解决方案

时间:2015-11-26 12:22:34      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

 

中方会计凭证由于 编码格式 以及 科目对照关系 是无法直接使用SAP自带的凭证打印功能的,如下为客户开发的一个解决方案,供各位参考

 

1).需要定制几个Table的结构 

zc0000fit0009【科目对照表】

技术分享

 

2).

   1 REPORT  zc0000fir0013 NO STANDARD PAGE HEADING
   2                       LINE-COUNT 65
   3                       LINE-SIZE 80.
   4 *---------------------------------------------------------------------*
   5 *   TABLES
   6 *---------------------------------------------------------------------*
   7 TABLES: bkpf,zc0000fit0009.
   8 
   9 TYPE-POOLS: slis.
  10 
  11 *---------------------------------------------------------------------*
  12 *   Types (ty_)
  13 *---------------------------------------------------------------------*
  14 TYPES:
  15       BEGIN OF gty_bkpf,
  16         bukrs    TYPE bkpf-bukrs,    "Company Code
  17         belnr    TYPE bkpf-belnr,    "Accounting Document Number
  18         gjahr    TYPE bkpf-gjahr,    "Fiscal Year
  19         blart    TYPE bkpf-blart,    "document type
  20         budat    TYPE bkpf-budat,    "Payment time
  21         monat    TYPE bkpf-monat,    "Fiscal Period
  22         cpudt    TYPE bkpf-cpudt,    "Day Was Entered
  23         usnam    TYPE bkpf-usnam,    "User Name
  24 *start add alex han 20130604
  25         ppnam TYPE bkpf-ppnam,
  26 *end add alex han 20130604
  27         xblnr    TYPE bkpf-xblnr,    "Reference Document Number
  28         bktxt    TYPE bkpf-bktxt,    "Document Header Text
  29         waers    TYPE bkpf-waers,    "Currency Key
  30         kursf    TYPE bkpf-kursf,    "Exchange rate
  31       END OF gty_bkpf,
  32 
  33       BEGIN OF gty_bseg,
  34         bukrs    TYPE bkpf-bukrs,    "Company Code
  35         belnr    TYPE bkpf-belnr,    "Accounting Document Number
  36         gjahr    TYPE bkpf-gjahr,    "Fiscal Year
  37         buzei    TYPE bseg-buzei,    "Number of Line
  38         hkont    TYPE bseg-hkont,    "General Ledger Account
  39         kostl    TYPE bseg-kostl,    "Cost Center
  40         prctr    TYPE bseg-prctr,    "Profit Center
  41         wrbtr    TYPE bseg-wrbtr,    "Amount in Document Currency
  42         dmbtr    TYPE bseg-dmbtr,    "amount in local currency
  43         shkzg    TYPE bseg-shkzg,    "Debit/Credit Indicator
  44         zuonr    TYPE bseg-zuonr,    "Assignment Number
  45         sgtxt    TYPE bseg-sgtxt,    "Item Text
  46         lifnr    TYPE bseg-lifnr,    "vendor
  47         kunnr    TYPE bseg-kunnr,    "customer
  48         koart    TYPE bseg-koart,    "Account Type
  49         aufnr    TYPE bseg-aufnr,    "ORER
  50 *& Start of Insertion CR0158 by Davy on 2013/08/14
  51         fkber    TYPE bseg-fkber,    "function area
  52 *& End of Insertion CR0158 by Davy on 2013/08/14
  53       END OF gty_bseg,
  54 
  55       BEGIN OF gty_head,
  56         bukrs    TYPE bkpf-bukrs,    "Company Code
  57         belnr    TYPE bkpf-belnr,    "SAP Document Number
  58         gjahr    TYPE bkpf-gjahr,    "Fiscal Year
  59         budat    TYPE char30,        "posting date
  60         name1    TYPE comp_txt,          "company name
  61         prcnr    TYPE zc0000fit0009-prcnr,"PRC number
  62         prctp    TYPE zc0000fit0008-prctp,"PRC Doc.Type Name
  63         prctt    TYPE zc0000fit0008-prctt,"PRC Doc.Type Title
  64         acmgr    TYPE text10,            "Acc mgr
  65         dbchk    TYPE text10,            "double check
  66         usnam    TYPE bkpf-usnam,        "user name
  67         ppnam    TYPE bkpf-ppnam,
  68 *&  Begin of Modification CR00222 BY YE_S on 2013/12/02
  69         persnumber TYPE adrp-persnumber,  "人员编号
  70         name_first TYPE adrp-name_first,  "
  71         name_last  TYPE adrp-name_last,   "
  72 *&  End of Modification CR00222 BY YE_S on 2013/12/02
  73       END OF gty_head,
  74 
  75       BEGIN OF gty_item,
  76         bukrs    TYPE bkpf-bukrs,    "Company Code
  77         belnr    TYPE bkpf-belnr,    "Accounting Document Number
  78         gjahr    TYPE bkpf-gjahr,    "Fiscal Year
  79         hkont    TYPE bseg-hkont,    "General Ledger Account
  80         kostl    TYPE bseg-kostl,    "Cost Center
  81         lifnr    TYPE bseg-lifnr,    "vendor
  82         kunnr    TYPE bseg-kunnr,    "customer
  83         shkzg    TYPE bseg-shkzg,    "Debit/Credit Indicator
  84         xblnr    TYPE bkpf-xblnr,    "Reference Document Number #01
  85         bktxt    TYPE bkpf-bktxt,    "Document Header Text
  86         sgtxt    TYPE bseg-sgtxt,    "Item Text
  87         zuonr    TYPE bseg-zuonr,    "Assignment Number
  88         prctr    TYPE bseg-prctr,    "Profit Center  #01
  89         name1    TYPE zc0000fit0007-prcnm1,"PRC Name1 #02
  90         name2    TYPE ad_name2,       "PRC_Name2” + “CostCenter #03
  91         waers    TYPE bkpf-waers,    "Currency Key #04
  92         wrbtr    TYPE bseg-wrbtr,    "Amount in Document Currency #05
  93         dmbtr    TYPE bseg-dmbtr,    "amount in local currency #07/8
  94         kursf    TYPE bkpf-kursf,    "Exchange rate #06
  95       END OF gty_item,
  96 
  97     BEGIN OF gty_list,
  98         sel(1)   TYPE c,             "selection flag
  99         bukrs    TYPE bkpf-bukrs,    "Company Code
 100         belnr    TYPE bkpf-belnr,    "Accounting Document Number
 101         gjahr    TYPE bkpf-gjahr,    "Fiscal Year
 102         blart    TYPE bkpf-blart,    "document type
 103         budat    TYPE bkpf-budat,    "Payment time
 104         monat    TYPE bkpf-monat,    "Fiscal Period
 105         cpudt    TYPE bkpf-cpudt,    "Day Was Entered
 106         usnam    TYPE bkpf-usnam,    "User Name
 107 *start add by alex han 20130604
 108         ppnam    TYPE bkpf-ppnam,
 109 *end add by alex han 20130604
 110         xblnr    TYPE bkpf-xblnr,    "Reference Document Number
 111         bktxt    TYPE bkpf-bktxt,    "Document Header Text
 112         waers    TYPE bkpf-waers,    "Currency Key
 113         kursf    TYPE bkpf-kursf,    "Exchange rate
 114         prcnr    TYPE zc0000fit0009-prcnr,"PRC number
 115         prctp    TYPE zc0000fit0008-prctp,"PRC Doc.Type Name
 116         name1    TYPE comp_txt,          "company name
 117         pflag    TYPE char10,            "print flag
 118        END OF gty_list,
 119 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 120        BEGIN OF gty_ska,
 121          saknr   TYPE ska1-saknr,
 122          xbilk   TYPE ska1-xbilk,
 123          txt50   TYPE skat-txt50,
 124        END OF gty_ska.
 125 *& End of Insertion CR0000 by Zoey on 2014/08/25
 126 
 127 *---------------------------------------------------------------------*
 128 *   Internal Tables (git_)
 129 *---------------------------------------------------------------------*
 130 DATA:
 131   git_t001   TYPE STANDARD TABLE OF t001 WITH HEADER LINE,  "#EC *
 132   git_bkpf   TYPE STANDARD TABLE OF gty_bkpf WITH HEADER LINE, "#EC *
 133   git_bseg   TYPE STANDARD TABLE OF gty_bseg WITH HEADER LINE, "#EC *
 134   git_list   TYPE STANDARD TABLE OF gty_list WITH HEADER LINE, "#EC *
 135   git_head   TYPE STANDARD TABLE OF gty_head WITH HEADER LINE, "#EC *
 136   git_item   TYPE STANDARD TABLE OF gty_item WITH HEADER LINE, "#EC *
 137   git_prcnm  TYPE STANDARD TABLE OF zc0000fit0007 WITH HEADER LINE,"#EC*
 138   git_prctp  TYPE STANDARD TABLE OF zc0000fit0008 WITH HEADER LINE,"#EC*
 139   git_prclg  TYPE STANDARD TABLE OF zc0000fit0009 WITH HEADER LINE,"#EC*
 140   git_upd09  TYPE STANDARD TABLE OF zc0000fit0009 WITH HEADER LINE,"#EC*
 141   git_header TYPE STANDARD TABLE OF gty_head WITH HEADER LINE, "#EC *
 142   git_detail TYPE STANDARD TABLE OF gty_item WITH HEADER LINE, "#EC *
 143 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 144   git_ska    TYPE STANDARD TABLE OF gty_ska WITH HEADER LINE. "#EC *
 145 *& End of Insertion CR0000 by Zoey on 2014/08/25
 146 
 147 * ALV Related
 148 DATA: git_fieldcat  TYPE slis_t_fieldcat_alv,
 149       git_comments  TYPE slis_t_listheader,
 150       git_events    TYPE slis_t_event.
 151 
 152 * Work Area
 153 DATA: gwa_fieldcat  TYPE slis_fieldcat_alv.
 154 DATA: gwa_output    TYPE gty_list.
 155 *---------------------------------------------------------------------*
 156 *   Global Variables (gv_)
 157 *---------------------------------------------------------------------*
 158 DATA: g_repid TYPE sy-repid,    "PROGRAM
 159       g_amtup TYPE char100.
 160 
 161 *----------------------------------------------------------------------*
 162 ** Range Declaration
 163 *----------------------------------------------------------------------*
 164 RANGES: r_lifnr FOR ekko-lifnr,
 165         r_ebeln FOR ekko-ebeln.
 166 
 167 *---------------------------------------------------------------------*
 168 *   Constants (c_)
 169 *---------------------------------------------------------------------*
 170 CONSTANTS:
 171   c_e                TYPE char1          VALUE E,
 172   c_x                TYPE char1          VALUE X,
 173   c_perct            TYPE char1          VALUE %,
 174   c_sign_i           TYPE char1          VALUE I,
 175   c_option_eq        TYPE char2          VALUE EQ,
 176   c_03               TYPE char2          VALUE 03,
 177   c_sel              TYPE field_name     VALUE SEL,
 178   c_bukrs            TYPE field_name     VALUE BUKRS,
 179   c_belnr            TYPE field_name     VALUE BELNR,
 180   c_gjahr            TYPE field_name     VALUE GJAHR,
 181   c_blart            TYPE field_name     VALUE BLART,
 182   c_budat            TYPE field_name     VALUE BUDAT,
 183   c_monat            TYPE field_name     VALUE MONAT,
 184   c_cpudt            TYPE field_name     VALUE CPUDT,
 185   c_usnam            TYPE field_name     VALUE USNAM,
 186 *START-ADD BY ALEX HAN20130604
 187    c_ppnam            TYPE field_name     VALUE PPNAM,
 188 *END-ADD BY ALEX HAN 20130604
 189   c_xblnr            TYPE field_name     VALUE XBLNR,
 190   c_bktxt            TYPE field_name     VALUE BKTXT,
 191   c_waers            TYPE field_name     VALUE WAERS,
 192   c_kursf            TYPE field_name     VALUE KURSF,
 193   c_prctp            TYPE field_name     VALUE PRCTP,
 194   c_prcnr            TYPE field_name     VALUE PRCNR,
 195   c_name1            TYPE field_name     VALUE NAME1,
 196   c_hkont            TYPE field_name     VALUE HKONT,
 197   c_kostl            TYPE field_name     VALUE KOSTL,
 198   c_prctr            TYPE field_name     VALUE PRCTR,
 199   c_wrbtr            TYPE field_name     VALUE WRBTR,
 200   c_dmbtr            TYPE field_name     VALUE DMBTR,
 201   c_zuonr            TYPE field_name     VALUE ZUONR,
 202   c_shkzg            TYPE field_name     VALUE SHKZG,
 203   c_sgtxt            TYPE field_name     VALUE SGTXT,
 204   c_pflag            TYPE field_name     VALUE PFLAG,
 205   c_save_all         TYPE c LENGTH 1     VALUE A,
 206   c_ddictxt_l        TYPE c LENGTH 1     VALUE L,
 207   c_ddictxt_m        TYPE c LENGTH 1     VALUE M,
 208   c_ddictxt_s        TYPE c LENGTH 1     VALUE S,
 209   c_formname         TYPE tdsfname       VALUE ZC0000FIS0001,
 210   c_pf_set           TYPE slis_formname  VALUE PF_STATUS_SET,
 211   c_user_command     TYPE slis_formname  VALUE USER_COMMAND_ALV,
 212 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 213   c_a001             TYPE ktopl          VALUE A001,
 214   c_zh               TYPE spras          VALUE 1.
 215 *& End of Insertion CR0000 by Zoey on 2014/08/25
 216 *---------------------------------------------------------------------*
 217 *   Macro
 218 *---------------------------------------------------------------------*
 219 DEFINE set_fc.
 220   clear gwa_fieldcat.
 221   gwa_fieldcat-tabname = GIT_REP.
 222   gwa_fieldcat-fieldname   = &1.
 223   gwa_fieldcat-cfieldname  = &2.
 224   gwa_fieldcat-seltext_l   = &3.
 225   gwa_fieldcat-do_sum      = &4.
 226   gwa_fieldcat-ddictxt     = c_ddictxt_l.
 227   if  gwa_fieldcat-fieldname(5) = PERCT.
 228     gwa_fieldcat-just = R.
 229   endif.
 230   if gwa_fieldcat-fieldname = BUKRS or
 231      gwa_fieldcat-fieldname = BELNR or
 232      gwa_fieldcat-fieldname = GJAHR.
 233     gwa_fieldcat-key = c_x.
 234   endif.
 235   append gwa_fieldcat to git_fieldcat.
 236 END-OF-DEFINITION.
 237 
 238 *---------------------------------------------------------------------*
 239 *   Selection screen data
 240 *       select-options (s_)
 241 *       parameters     (p_)
 242 *       radio buttons  (rb_)
 243 *       checkboxes     (cb_)
 244 *       pushbuttons    (pb_)
 245 *---------------------------------------------------------------------*
 246 SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.
 247 SELECT-OPTIONS:
 248   s_bukrs FOR bkpf-bukrs OBLIGATORY,
 249   s_belnr FOR bkpf-belnr OBLIGATORY,
 250   s_prcnr FOR zc0000fit0009-prcnr,
 251   s_gjahr FOR bkpf-gjahr OBLIGATORY,
 252   s_blart FOR bkpf-blart OBLIGATORY,
 253   s_budat FOR bkpf-budat NO-EXTENSION OBLIGATORY,
 254   s_cpudt FOR bkpf-cpudt NO-EXTENSION ."NO INTERVALS
 255 *START-Modify by davy 2013/06/14
 256 SELECT-OPTIONS:
 257   s_usnam FOR bkpf-usnam NO-EXTENSION NO INTERVALS,
 258   s_ppnam FOR bkpf-ppnam NO-EXTENSION NO INTERVALS.
 259 *PARAMETERS:
 260 *  p_usnam  TYPE bkpf-usnam,
 261 *START-ADD BY ALEX 20130604
 262 *  p_ppnam  TYPE bkpf-ppnam .
 263 *END-ADD BY ALEX 20130604
 264 *START-Modify by davy 2013/06/14
 265 SELECTION-SCREEN END OF BLOCK blk1.
 266 
 267 SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-t02. "#EC *
 268 PARAMETERS:
 269   p_cmpnm  TYPE comp_txt OBLIGATORY,
 270   p_acmgr  TYPE text10,
 271   p_dbchk  TYPE text10.
 272 SELECTION-SCREEN END OF BLOCK blk2.
 273 
 274 *---------------------------------------------------------------------*
 275 *  Initialization
 276 *---------------------------------------------------------------------*
 277 INITIALIZATION.
 278   PERFORM init_data.
 279 
 280 *---------------------------------------------------------------------*
 281 *  AT SELECTION-SCREEN
 282 *---------------------------------------------------------------------*
 283 AT SELECTION-SCREEN.
 284   PERFORM check_data.
 285 
 286 *---------------------------------------------------------------------*
 287 *  TOP-OF-PAGE
 288 *---------------------------------------------------------------------*
 289 *TOP-OF-PAGE.
 290 
 291 ***********************************************************************
 292 *    START-OF-SELECTION PROCESSING                                    *
 293 ***********************************************************************
 294 START-OF-SELECTION.
 295 * get data from database tabl
 296   PERFORM get_data.
 297 *  process data in internal table
 298   PERFORM process_data.
 299 
 300 ***********************************************************************
 301 *    END-OF-SELECTION PROCESSING                                      *
 302 ***********************************************************************
 303 END-OF-SELECTION.
 304   IF NOT git_list[] IS INITIAL.
 305     IF sy-batch = c_x.
 306       PERFORM print_data_background.
 307     ELSE.
 308 *  output the final data
 309       PERFORM display_data.
 310     ENDIF.
 311   ELSE.
 312     MESSAGE s099(ba) DISPLAY LIKE c_e WITH text-m01..
 313   ENDIF.
 314 
 315 *&---------------------------------------------------------------------*
 316 *&      Form  INIT_DATA
 317 *&---------------------------------------------------------------------*
 318 *       text
 319 *----------------------------------------------------------------------*
 320 *  -->  p1        text
 321 *  <--  p2        text
 322 *----------------------------------------------------------------------*
 323 FORM init_data .
 324 
 325   g_repid = sy-repid.
 326 
 327   CLEAR: git_bkpf,git_bseg,git_list,git_head,git_item,
 328          git_prctp,git_prcnm,git_prclg.
 329 
 330   REFRESH: git_bkpf,git_bseg,git_list,git_head,git_item,
 331            git_prctp,git_prcnm,git_prclg.
 332 
 333 ENDFORM.                    " INIT_DATA
 334 
 335 *&---------------------------------------------------------------------*
 336 *&      Form  CHECK_DATA
 337 *&---------------------------------------------------------------------*
 338 *       text
 339 *----------------------------------------------------------------------*
 340 *  -->  p1        text
 341 *  <--  p2        text
 342 *----------------------------------------------------------------------*
 343 FORM check_data .
 344 * check the company code valid
 345   REFRESH git_t001.
 346   SELECT * FROM t001 INTO TABLE git_t001
 347    WHERE bukrs IN s_bukrs.
 348   IF sy-subrc <> 0.
 349     MESSAGE e006(zc001) WITH s_bukrs-low s_bukrs-high.
 350   ENDIF.
 351 
 352   LOOP AT git_t001.
 353     AUTHORITY-CHECK OBJECT F_BKPF_BUK
 354               ID BUKRS FIELD git_t001-bukrs
 355               ID ACTVT FIELD 03.
 356     IF sy-subrc <> 0.
 357       MESSAGE e099(ba) WITH text-m02.
 358     ENDIF.
 359   ENDLOOP.
 360 
 361 ENDFORM.                    " CHECK_DATA
 362 
 363 *&---------------------------------------------------------------------*
 364 *&      Form  GET_DATA
 365 *&---------------------------------------------------------------------*
 366 *       text
 367 *----------------------------------------------------------------------*
 368 *  -->  p1        text
 369 *  <--  p2        text
 370 *----------------------------------------------------------------------*
 371 FORM get_data .
 372 * Get voucher doucment header data
 373   SELECT
 374                bukrs        "Company Code
 375                belnr        "Accounting Document Number
 376                gjahr        "Fiscal Year
 377                blart        "document type
 378                budat        "posting date
 379                monat        "Fiscal Period
 380                cpudt        "Day Was Entered
 381                usnam        "User Name
 382 *START ADD ALEX HAN 20130604
 383                ppnam
 384 *END ADD ALEX HAN 20130604
 385                xblnr        "Reference Document Number
 386                bktxt        "Document Header Text
 387                waers        "Currency Key
 388                kursf        "Exchange rate
 389           FROM bkpf
 390           INTO TABLE git_bkpf
 391           WHERE bukrs IN s_bukrs
 392             AND belnr IN s_belnr
 393             AND gjahr IN s_gjahr
 394             AND blart IN s_blart
 395             AND budat IN s_budat
 396             AND cpudt IN s_cpudt
 397             AND usnam IN s_usnam
 398 *START-ADD BY ALEXHAN 20130604
 399             AND ppnam IN s_ppnam.
 400 *END-ADD BY ALEX HAN 20130604
 401 
 402   IF git_bkpf[] IS INITIAL.
 403     MESSAGE s099(ba) DISPLAY LIKE c_e WITH text-m01.
 404     STOP.
 405   ELSE.
 406 
 407     SELECT
 408           bukrs        "Company Code
 409           belnr        "Accounting Document Number
 410           gjahr        "Fiscal Year
 411           buzei        "Number of Line
 412           hkont        "General Ledger Account
 413           kostl        "Cost Center
 414           prctr        "Profit Center
 415           wrbtr        "Amount in Document Currency
 416           dmbtr        "amount in local currency
 417           shkzg        "Debit/Credit Indicator
 418           zuonr        "Assignment Number
 419           sgtxt        "Item Text
 420           lifnr        "vendor
 421           kunnr        "customer
 422           koart        "acct type
 423           aufnr        "ORDER
 424 *& Start of Insertion CR0158 by Davy on 2013/08/14
 425           fkber        "function area
 426 *& End of Insertion CR0158 by Davy on 2013/08/14
 427      FROM bseg INTO TABLE git_bseg
 428       FOR ALL ENTRIES IN git_bkpf
 429      WHERE bukrs = git_bkpf-bukrs
 430        AND belnr = git_bkpf-belnr
 431        AND gjahr = git_bkpf-gjahr.
 432 
 433   ENDIF.
 434 
 435 * get SAP account number and PRC number
 436   SELECT * INTO TABLE git_prcnm FROM zc0000fit0007
 437    WHERE hkont <> ‘‘.
 438 
 439 * get Document type and PRC document type mapping table
 440   SELECT * INTO TABLE git_prctp FROM zc0000fit0008
 441    WHERE blart <> ‘‘.
 442 
 443 * get PRC number
 444   SELECT * INTO TABLE git_prclg FROM zc0000fit0009
 445    WHERE bukrs IN s_bukrs
 446      AND belnr IN s_belnr
 447      AND gjahr IN s_gjahr.
 448 *     AND prcnr IN s_prcnr.
 449 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 450   SELECT a~saknr a~xbilk b~txt50 INTO TABLE git_ska FROM ska1 AS a
 451     JOIN skat AS b ON a~saknr = b~saknr
 452     FOR ALL ENTRIES IN git_bseg
 453     WHERE  a~ktopl = c_a001
 454      AND   a~saknr = git_bseg-hkont
 455      AND   b~spras = c_zh.
 456 *& End of Insertion CR0000 by Zoey on 2014/08/25
 457 ENDFORM.                    " GET_DATA
 458 *&---------------------------------------------------------------------*
 459 *&      Form  PROCESS_DATA
 460 *&---------------------------------------------------------------------*
 461 *       text
 462 *----------------------------------------------------------------------*
 463 *  -->  p1        text
 464 *  <--  p2        text
 465 *----------------------------------------------------------------------*
 466 FORM process_data.
 467   DATA: l_amt      TYPE wertv8.
 468   DATA: l_func     TYPE csks-func_area.
 469   DATA: l_name1    TYPE kna1-name1.
 470   DATA: l_xbilk    TYPE ska1-xbilk.
 471   DATA: lit_item   TYPE STANDARD TABLE OF gty_item WITH HEADER LINE.
 472   DATA: lit_bseg   TYPE STANDARD TABLE OF gty_bseg WITH HEADER LINE.
 473   DATA: l_kostl    TYPE bseg-kostl,
 474         l_aufnr    TYPE bseg-aufnr.
 475 
 476 * collect the PRC Doc.Type Name and title
 477   SORT git_prctp BY blart.
 478   SORT git_prclg BY bukrs belnr gjahr.
 479   SORT git_t001 BY bukrs.
 480 
 481   LOOP AT git_bkpf.
 482     MOVE-CORRESPONDING git_bkpf TO git_list.
 483     READ TABLE git_prctp WITH KEY blart = git_bkpf-blart.
 484     IF sy-subrc = 0.
 485       git_list-prctp = git_prctp-prctp.
 486     ENDIF.
 487 
 488     git_list-name1 = p_cmpnm.
 489 
 490     IF git_list-name1 IS INITIAL.
 491       READ TABLE git_t001 WITH KEY bukrs = git_bkpf-bukrs
 492                                    BINARY SEARCH.
 493       IF sy-subrc = 0.
 494         git_list-name1 = git_t001-butxt.
 495       ENDIF.
 496     ENDIF.
 497 
 498     READ TABLE git_prclg WITH KEY bukrs = git_bkpf-bukrs
 499                                   belnr = git_bkpf-belnr
 500                                   gjahr = git_bkpf-gjahr.
 501     IF sy-subrc = 0.
 502       git_list-prcnr = git_prclg-prcnr.
 503       git_list-pflag = text-h17.
 504     ELSE.
 505 
 506       PERFORM set_next_prcno USING git_bkpf-bukrs
 507                                    git_bkpf-gjahr
 508                                    git_bkpf-monat
 509                           CHANGING git_list-prcnr.
 510       git_list-pflag = text-h18.
 511     ENDIF.
 512 
 513     READ TABLE git_t001 WITH KEY  bukrs = git_bkpf-bukrs.
 514     IF git_bkpf-waers <> git_t001-waers. " AND
 515       PERFORM convert_rate USING git_bkpf-waers git_bkpf-kursf
 516                           CHANGING git_list-kursf.
 517     ELSE.
 518       MOVE git_list-kursf TO git_list-kursf.
 519     ENDIF.
 520 
 521     APPEND git_list.
 522     CLEAR git_list.
 523   ENDLOOP.
 524 
 525 * for print header data
 526   LOOP AT git_list.
 527 
 528     MOVE-CORRESPONDING git_list TO git_head.
 529 
 530     CONCATENATE git_list-budat(4) text-t03 git_list-budat+4(2) text-t04
 531     git_list-budat+6(2) text-t05 INTO  git_head-budat.
 532 
 533     READ TABLE git_prctp WITH KEY blart = git_list-blart.
 534     IF sy-subrc = 0.
 535       git_head-prctt = git_prctp-prctt.
 536     ENDIF.
 537 
 538     git_head-acmgr = p_acmgr.
 539     git_head-dbchk = p_dbchk.
 540 
 541     APPEND git_head.
 542     CLEAR git_head.
 543   ENDLOOP.
 544 
 545   SORT git_bkpf BY bukrs belnr gjahr.
 546   SORT git_prcnm BY hkont kostl.
 547 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 548   SORT git_ska   BY saknr.
 549 *& End of Insertion CR0000 by Zoey on 2014/08/25
 550   REFRESH lit_bseg.
 551   lit_bseg[] = git_bseg[].
 552 
 553   SORT lit_bseg BY bukrs belnr gjahr lifnr kunnr.
 554 
 555 *  collect voucher data for list
 556   LOOP AT git_bseg.
 557     MOVE-CORRESPONDING git_bseg TO git_item.
 558     READ TABLE git_bkpf WITH KEY bukrs = git_bseg-bukrs
 559                                  belnr = git_bseg-belnr
 560                                  gjahr = git_bseg-gjahr.
 561     IF sy-subrc = 0.
 562       MOVE:
 563         git_bkpf-xblnr TO git_item-xblnr,
 564         git_bkpf-bktxt TO git_item-bktxt,
 565         git_bkpf-waers TO git_item-waers.
 566       READ TABLE git_t001 WITH KEY  bukrs = git_bseg-bukrs.
 567       IF git_bkpf-waers <> git_t001-waers. " AND
 568         PERFORM convert_rate USING git_bkpf-waers git_bkpf-kursf
 569                             CHANGING git_item-kursf.
 570       ELSE.
 571         MOVE git_bkpf-kursf TO git_item-kursf.
 572       ENDIF.
 573 
 574       IF git_bkpf-waers = git_t001-waers.
 575         CLEAR git_item-wrbtr.
 576       ENDIF.
 577     ENDIF.
 578 
 579     READ TABLE git_prcnm WITH KEY hkont = git_bseg-hkont.
 580     IF sy-subrc = 0.
 581       IF git_prcnm-prccd1 = COSTCENTER.
 582 *   first class account
 583         SELECT SINGLE func_area INTO l_func FROM csks
 584          WHERE kostl = git_bseg-kostl
 585            AND bukrs = git_bseg-bukrs.                      "#EC *
 586         IF sy-subrc = 0.
 587           SELECT SINGLE prcnm1 INTO git_item-name1
 588             FROM zc0000fit0010
 589             WHERE func_area = l_func.
 590         ENDIF.
 591 
 592         git_item-name2 = git_prcnm-prcnm2.
 593         IF NOT git_bseg-kostl IS INITIAL.
 594 *          CONCATENATE git_item-name2 git_bseg-kostl
 595 *                 INTO git_item-name2 SEPARATED BY space.
 596 *& Start of Insertion CR0158 by Davy on 2013/08/14
 597         ELSE.
 598           IF git_item-name1 IS INITIAL.
 599             SELECT SINGLE prcnm1 INTO git_item-name1
 600               FROM zc0000fit0010
 601               WHERE func_area = git_bseg-fkber.
 602           ENDIF.
 603 *& End of Insertion CR0158 by Davy on 2013/08/14
 604         ENDIF.
 605 *       interanl order
 606         IF NOT git_bseg-aufnr IS INITIAL.
 607           CLEAR l_aufnr.
 608           CALL FUNCTION CONVERSION_EXIT_ALPHA_OUTPUT
 609             EXPORTING
 610               input  = git_bseg-aufnr
 611             IMPORTING
 612               output = l_aufnr.
 613           CONCATENATE git_item-name2 l_aufnr
 614                  INTO git_item-name2 SEPARATED BY space.
 615         ENDIF.
 616 
 617       ELSE.
 618         git_item-name1 = git_prcnm-prcnm1.
 619         git_item-name2 = git_prcnm-prcnm2.
 620 
 621         CLEAR l_name1.
 622 
 623         IF git_bseg-lifnr <> ‘‘ AND git_bseg-koart = K.
 624           SELECT SINGLE name1 INTO l_name1 FROM lfa1
 625             WHERE lifnr = git_bseg-lifnr.
 626         ENDIF.
 627         IF git_bseg-kunnr <> ‘‘ AND git_bseg-koart = D.
 628           SELECT SINGLE name1 INTO l_name1 FROM kna1
 629           WHERE kunnr = git_bseg-kunnr.
 630         ENDIF.
 631 
 632         IF NOT l_name1 IS INITIAL.
 633           CONCATENATE git_item-name2 - l_name1 INTO git_item-name2.
 634         ENDIF.
 635 
 636       ENDIF.
 637 *& Start of Insertion CR0000 by Zoey on 2014/08/25
 638 
 639     ELSE.
 640 
 641 *  If GL account XXXXXX is not maintained in mapping table
 642 *     ZC0000FIT0007
 643       READ TABLE git_ska WITH KEY saknr = git_bseg-hkont.
 644 *     Balance sheet account
 645       IF git_ska-xbilk IS NOT INITIAL.
 646         PERFORM frm_Balance.
 647 
 648       ELSE.
 649 *     Profit & Loss account
 650         PERFORM frm_Profit.
 651 
 652       ENDIF.
 653 *& End of Insertion CR0000 by Zoey on 2014/08/25
 654     ENDIF.
 655 
 656     APPEND git_item.
 657     CLEAR git_item.
 658   ENDLOOP.
 659 
 660   CLEAR l_amt.
 661   REFRESH lit_item.
 662   SORT git_item BY bukrs belnr gjahr hkont kostl.
 663   DATA: l_flag TYPE c.
 664   CLEAR l_flag.
 665 
 666   LOOP AT git_item.
 667 
 668     AT NEW shkzg.
 669       CLEAR l_flag.
 670     ENDAT.
 671 
 672     MOVE git_item-bukrs TO lit_item-bukrs .
 673     MOVE git_item-belnr TO lit_item-belnr .
 674     MOVE git_item-gjahr TO lit_item-gjahr .
 675     MOVE git_item-hkont TO lit_item-hkont .
 676     MOVE git_item-kostl TO lit_item-kostl .
 677     MOVE git_item-xblnr TO lit_item-xblnr .
 678 
 679     IF l_flag IS INITIAL.
 680       MOVE git_item-bktxt TO lit_item-bktxt .
 681       MOVE git_item-sgtxt TO lit_item-sgtxt .
 682       MOVE git_item-zuonr TO lit_item-zuonr .
 683     ENDIF.
 684 
 685     MOVE git_item-prctr TO lit_item-prctr .
 686     MOVE git_item-name1 TO lit_item-name1 .
 687     MOVE git_item-name2 TO lit_item-name2 .
 688     MOVE git_item-waers TO lit_item-waers .
 689     MOVE git_item-kursf TO lit_item-kursf .
 690     MOVE git_item-shkzg TO lit_item-shkzg .
 691     lit_item-dmbtr = lit_item-dmbtr  + git_item-dmbtr.
 692     lit_item-wrbtr = lit_item-wrbtr  + git_item-wrbtr.
 693 
 694     l_flag = c_x.
 695     AT END OF shkzg.
 696       APPEND lit_item.
 697       CLEAR lit_item.
 698     ENDAT.
 699 
 700   ENDLOOP.
 701 
 702   REFRESH git_item.
 703   git_item[] = lit_item[].
 704 
 705 ENDFORM.                    " PROCESS_DATA
 706 
 707 *&---------------------------------------------------------------------*
 708 *&      Form  DISPLAY_DATA
 709 *&---------------------------------------------------------------------*
 710 *       text
 711 *----------------------------------------------------------------------*
 712 *  -->  p1        text
 713 *  <--  p2        text
 714 *----------------------------------------------------------------------*
 715 FORM display_data .
 716 
 717 * Local Variable
 718   DATA: l_repid      TYPE sy-repid,
 719         l_prntparams TYPE slis_print_alv.
 720 * Local Work Area
 721   DATA: lwa_layout    TYPE slis_layout_alv,
 722         lwa_variant   TYPE disvariant.
 723 
 724 * Create ALV Field Catalog/Comment/Event
 725   PERFORM create_fieldcatalog.
 726   PERFORM alv_set_variant CHANGING lwa_variant.
 727 
 728 * Assign Program ID
 729   l_repid = sy-repid.
 730 * Layout
 731   lwa_layout-box_fieldname = SEL.
 732   lwa_layout-zebra = c_x.
 733   lwa_layout-colwidth_optimize = c_x.
 734 
 735 * Call ALV
 736   CALL FUNCTION REUSE_ALV_GRID_DISPLAY
 737     EXPORTING
 738       i_callback_program       = g_repid
 739       i_callback_pf_status_set = c_pf_set
 740       i_callback_user_command  = c_user_command
 741       it_events                = git_events
 742       is_layout                = lwa_layout
 743       it_fieldcat              = git_fieldcat
 744       i_save                   = c_save_all
 745       is_print                 = l_prntparams
 746       is_variant               = lwa_variant
 747     TABLES
 748       t_outtab                 = git_list
 749     EXCEPTIONS
 750       program_error            = 1
 751       OTHERS                   = 2.                         "#EC *
 752 
 753 ENDFORM.                    " DISPLAY_DATA
 754 *&---------------------------------------------------------------------*
 755 *&      Form  CREATE_FIELDCATALOG
 756 *&---------------------------------------------------------------------*
 757 *       text
 758 *----------------------------------------------------------------------*
 759 *  -->  p1        text
 760 *  <--  p2        text
 761 *----------------------------------------------------------------------*
 762 FORM create_fieldcatalog .
 763 * Create Field Catalog
 764   DATA: lit_fieldcat  TYPE slis_t_fieldcat_alv.
 765 
 766   CALL FUNCTION REUSE_ALV_FIELDCATALOG_MERGE
 767    EXPORTING
 768       i_program_name               = g_repid
 769       i_internal_tabname           = GTY_LIST
 770 *      i_client_never_display       = c_x
 771       i_inclname                   = g_repid
 772     CHANGING
 773       ct_fieldcat                  = lit_fieldcat
 774    EXCEPTIONS
 775      inconsistent_interface       = 1
 776      program_error                = 2
 777      OTHERS                       = 3
 778             .
 779   IF sy-subrc <> 0.
 780 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 781 *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 782   ENDIF.
 783 
 784   set_fc: c_bukrs    c_bukrs  text-h01 ‘‘."Company Code
 785   set_fc: c_belnr    c_belnr  text-h02 ‘‘."Accounting Document Number
 786   set_fc: c_gjahr    c_gjahr  text-h03 ‘‘."Fiscal Year
 787   set_fc: c_blart    c_blart  text-h04 ‘‘."document type
 788   set_fc: c_budat    ‘‘  text-h05 ‘‘."Payment time
 789   set_fc: c_monat    ‘‘  text-h06 ‘‘."Fiscal Period
 790   set_fc: c_cpudt    ‘‘  text-h07 ‘‘."Day Was Entered
 791   set_fc: c_usnam    ‘‘  text-h08 ‘‘."User Name
 792 *start-add by alex han 20130604
 793   set_fc: c_ppnam    ‘‘  text-h19 ‘‘."Parked BY
 794 *end-add by alex han 20130604
 795   set_fc: c_xblnr    ‘‘  text-h09 ‘‘."Reference Document Number
 796   set_fc: c_bktxt    ‘‘  text-h10 ‘‘."Document Header Text
 797   set_fc: c_waers    ‘‘  text-h11 ‘‘."Currency Key
 798   set_fc: c_kursf    ‘‘  text-h12 ‘‘."Exchange rate
 799   set_fc: c_prcnr    ‘‘  text-h14 ‘‘."PRC number
 800   set_fc: c_prctp    ‘‘  text-h13 ‘‘."PRC Doc.Type Name
 801   set_fc: c_name1    ‘‘  text-h15 ‘‘. "company name
 802   set_fc: c_pflag    ‘‘  text-h16 ‘‘. "company name
 803 
 804 ENDFORM.                    " CREATE_FIELDCATALOG
 805 *&---------------------------------------------------------------------*
 806 *&      Form  f_alv_set_variant
 807 *&---------------------------------------------------------------------*
 808 *       text
 809 *----------------------------------------------------------------------*
 810 *      -->P_LWA_VAR  text
 811 *----------------------------------------------------------------------*
 812 FORM alv_set_variant CHANGING p_lwa_var TYPE disvariant.
 813 
 814 * Assign Variant
 815   p_lwa_var-report      = sy-repid.
 816   p_lwa_var-handle      = space.
 817   p_lwa_var-log_group   = space.
 818   p_lwa_var-username    = sy-uname.
 819   p_lwa_var-variant     = space.
 820   p_lwa_var-text        = space.
 821   p_lwa_var-dependvars  = space.
 822 
 823 ENDFORM.                    " f_alv_set_variant
 824 
 825 *&---------------------------------------------------------------------*
 826 *&      Form  PF_STATUS_SET
 827 *&---------------------------------------------------------------------*
 828 *       text
 829 *----------------------------------------------------------------------*
 830 *  -->  p1        text
 831 *  <--  p2        text
 832 *----------------------------------------------------------------------*
 833 FORM pf_status_set USING pt_extab TYPE slis_t_extab.
 834   SET PF-STATUS PF_STATUS EXCLUDING pt_extab.
 835 
 836 ENDFORM.                    " PF_STATUS_SET
 837 
 838 *&---------------------------------------------------------------------*
 839 *&  Form  f_user_command_alv
 840 *&---------------------------------------------------------------------*
 841 *   User Commnad From ALV Screen
 842 *----------------------------------------------------------------------*
 843 FORM user_command_alv USING r_ucomm     LIKE sy-ucomm
 844                             ps_selfield TYPE slis_selfield.
 845 ** Local Variable
 846   DATA: l_belnr TYPE bkpf-belnr,
 847         l_bukrs TYPE bkpf-bukrs,
 848         l_gjahr TYPE bkpf-gjahr.
 849   DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
 850   CALL FUNCTION GET_GLOBALS_FROM_SLVC_FULLSCR
 851     IMPORTING
 852       e_grid = lo_grid.
 853   CALL METHOD lo_grid->check_changed_data.
 854 
 855 * Check User Command
 856   CASE r_ucomm.
 857     WHEN &IC1.  " Double Click
 858 **     Set Parameters
 859       CHECK ps_selfield-fieldname = c_belnr.
 860       l_belnr =  ps_selfield-value.
 861       READ TABLE git_list INDEX ps_selfield-tabindex.
 862       IF sy-subrc = 0.
 863         l_bukrs = git_list-bukrs.
 864         l_gjahr = git_list-gjahr.
 865       ENDIF.
 866 
 867       SET PARAMETER ID: BLN FIELD l_belnr .
 868       SET PARAMETER ID: BUK FIELD l_bukrs .
 869       SET PARAMETER ID: GJR FIELD l_gjahr .
 870       CALL TRANSACTION FB03 AND SKIP FIRST SCREEN.
 871       CLEAR r_ucomm.
 872 
 873     WHEN PRNT OR &PRT.
 874       READ TABLE git_list WITH KEY sel = c_x.
 875       IF sy-subrc = 0.
 876         PERFORM print_voucher USING c_x ‘‘..
 877         ps_selfield-refresh = c_x.
 878       ELSE.
 879         MESSAGE s099(ba) DISPLAY LIKE E WITH text-m04.
 880       ENDIF.
 881 
 882     WHEN OTHERS.
 883   ENDCASE.
 884 ENDFORM.                    " f_user_command_alv
 885 *&---------------------------------------------------------------------*
 886 *&      Form  PRINT_VOUCHER
 887 *&---------------------------------------------------------------------*
 888 *       text
 889 *----------------------------------------------------------------------*
 890 *      -->P_C_X  text
 891 *      -->P_0891   text
 892 *----------------------------------------------------------------------*
 893 FORM print_voucher  USING    pu_preview TYPE tdpreview
 894                              pu_tdimmed TYPE tdimmed.
 895   DATA: lv_fm_name       TYPE rs38l_fnam,
 896         lv_ldest         TYPE usr01-spld,
 897         lwa_controlpara  TYPE ssfctrlop,
 898         lwa_output       TYPE ssfcompop.
 899   DATA:
 900 *& Start of Insertion CR00158 by Davy on 2013/08/06
 901         ls_ssfcresop     TYPE ssfcresop,
 902 *& End of Insertion CR00158 by Davy on 2013/08/06
 903         ls_ssfcrescl     TYPE ssfcrescl,
 904         ls_ssfctrlop     TYPE ssfctrlop,
 905         ls_ssfcompop     TYPE ssfcompop.
 906 
 907   DATA: ls_output_info    TYPE  ssfcrescl,
 908         ls_output_options TYPE  ssfcresop.
 909 
 910   CLEAR lv_ldest.
 911   SELECT SINGLE spld FROM usr01 INTO lv_ldest
 912    WHERE bname = sy-uname.
 913 
 914   lwa_controlpara-langu  = sy-langu.
 915   lwa_controlpara-no_dialog  = c_x.
 916   lwa_controlpara-device = PRINTER.
 917   lwa_output-tddest      = lv_ldest.
 918   lwa_controlpara-preview = pu_preview.
 919   lwa_output-tdimmed = pu_tdimmed.
 920 
 921 *Get Smartform Function Name
 922   CALL FUNCTION SSF_FUNCTION_MODULE_NAME
 923     EXPORTING
 924       formname           = c_formname
 925     IMPORTING
 926       fm_name            = lv_fm_name
 927     EXCEPTIONS
 928       no_form            = 1
 929       no_function_module = 2
 930       OTHERS             = 3.
 931 
 932   IF sy-subrc <> 0.
 933     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 934     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 935     RETURN.
 936   ENDIF.
 937 
 938 *--->Setup output options berfore call smartforms
 939   ls_ssfctrlop-device = PRINTER.
 940   ls_ssfctrlop-preview = c_x.
 941   ls_ssfctrlop-langu = sy-langu.
 942   ls_ssfcompop-tddest = lv_ldest.                           "‘LO01‘.
 943   ls_ssfcompop-tdimmed = c_x.
 944   ls_ssfcompop-tdnewid = c_x.
 945 
 946 *Open spool
 947 *& Start of Insertion CR00158 by Davy on 2013/08/06
 948   CLEAR ls_ssfcresop.
 949 *& End of Insertion CR00158 by Davy on 2013/08/06
 950   CALL FUNCTION SSF_OPEN
 951     EXPORTING
 952       control_parameters = ls_ssfctrlop
 953       output_options     = ls_ssfcompop
 954       user_settings      =  
 955 *& Start of Insertion CR00158 by Davy on 2013/08/06
 956             IMPORTING
 957        job_output_options = ls_ssfcresop  "add importing parameters
 958 *& End of Insertion CR00158 by Davy on 2013/08/06
 959     EXCEPTIONS
 960       formatting_error   = 1
 961       internal_error     = 2
 962       send_error         = 3
 963       user_canceled      = 4.
 964   CHECK sy-subrc = 0.
 965 
 966 *--->Call Smartforms by Function Mode Name
 967   CLEAR ls_ssfctrlop.
 968   ls_ssfctrlop-no_open = c_x.
 969   ls_ssfctrlop-no_close = c_x.
 970 
 971   LOOP AT git_list WHERE sel = c_x.
 972 
 973     REFRESH git_header.
 974     REFRESH git_detail.
 975     git_header[] = git_head[].
 976     git_detail[] = git_item[].
 977 
 978     DELETE git_header WHERE bukrs <> git_list-bukrs.
 979     DELETE git_header WHERE belnr <> git_list-belnr.
 980     DELETE git_header WHERE gjahr <> git_list-gjahr.
 981 
 982     DELETE git_detail WHERE bukrs <> git_list-bukrs.
 983     DELETE git_detail WHERE belnr <> git_list-belnr.
 984     DELETE git_detail WHERE gjahr <> git_list-gjahr.
 985 
 986 *& Start of Insertion CR00158 by Davy on 2013/08/06
 987 * Reset prc number
 988     IF ls_ssfcresop-tdpreview IS INITIAL. "Print mode
 989       PERFORM update_prc_log.
 990     ENDIF.
 991 *& End of Insertion CR00158 by Davy on 2013/08/06
 992 
 993     CLEAR: ls_output_info,ls_output_options.
 994 *Open Smartforms
 995     CALL FUNCTION lv_fm_name
 996       EXPORTING
 997         control_parameters = ls_ssfctrlop "lwa_controlpara
 998         output_options     = lwa_output
 999         user_settings      = ‘‘
1000         im_report          = sy-repid
1001       IMPORTING
1002         job_output_info    = ls_output_info
1003         job_output_options = ls_output_options
1004       EXCEPTIONS
1005         formatting_error   = 1
1006         internal_error     = 2
1007         send_error         = 3
1008         user_canceled      = 4
1009         OTHERS             = 5.
1010     IF sy-subrc <> 0.
1011       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
1012       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
1013       RETURN.
1014     ENDIF.
1015 
1016 *& Start of Deletion CR00158 by Davy on 2013/08/06
1017 *    PERFORM update_prc_log.
1018 *& End of Deletion CR00158 by Davy on 2013/08/06
1019 
1020   ENDLOOP.
1021 
1022 *Close spool
1023   CALL FUNCTION SSF_CLOSE
1024     IMPORTING
1025       job_output_info = ls_ssfcrescl.
1026 
1027 
1028   IF NOT ls_ssfcrescl-spoolids[] IS INITIAL OR
1029      ls_ssfcrescl-outputdone <> ‘‘.
1030     PERFORM modify_table TABLES git_upd09.
1031 *    MODIFY zc0000fit0009 FROM TABLE git_upd09.
1032 *    IF sy-subrc = 0.
1033 *      COMMIT WORK.
1034 *    ELSE.
1035 *      ROLLBACK WORK.
1036 *      MESSAGE s099(ba) DISPLAY LIKE c_e WITH text-m03.
1037 *    ENDIF.
1038 
1039     git_list-pflag = text-h17.
1040     MODIFY git_list TRANSPORTING pflag WHERE sel = c_x.
1041 
1042   ENDIF.
1043 
1044   REFRESH git_upd09.
1045 
1046 ENDFORM.                    " PRINT_VOUCHER
1047 *&---------------------------------------------------------------------*
1048 *&      Form  UPDATE_PRC_LOG
1049 *&---------------------------------------------------------------------*
1050 *       text
1051 *----------------------------------------------------------------------*
1052 *  -->  p1        text
1053 *  <--  p2        text
1054 *----------------------------------------------------------------------*
1055 FORM update_prc_log .
1056   DATA: lv_seq    TYPE txnum.
1057   DATA: lv_prcnr  TYPE zc0000fit0009-prcnr.
1058   DATA: lwa_prclg TYPE zc0000fit0009.
1059   DATA: lit_list  TYPE STANDARD TABLE OF zc0000fit0009 WITH HEADER LINE.
1060 *& Start of Insertion CR00158 by Davy on 2013/08/06
1061   DATA: lwa_header TYPE gty_head.
1062 *& End of Insertion CR00158 by Davy on 2013/08/06
1063 
1064   SELECT SINGLE * INTO lwa_prclg FROM zc0000fit0009
1065   WHERE bukrs = git_list-bukrs
1066     AND belnr = git_list-belnr
1067     AND gjahr = git_list-gjahr.
1068   CHECK sy-subrc <> 0.
1069 
1070   CLEAR: lv_seq,lv_prcnr.
1071   REFRESH lit_list.
1072   lit_list[] = git_upd09[].
1073   DELETE lit_list WHERE bukrs <> git_list-bukrs.
1074   DELETE lit_list WHERE gjahr <> git_list-gjahr.
1075   DELETE lit_list WHERE monat <> git_list-monat.
1076   SORT lit_list BY prcnr DESCENDING.
1077 
1078   READ TABLE lit_list INDEX 1.
1079   IF sy-subrc = 0 AND lit_list-prcnr <> ‘‘.
1080     lv_seq  = lit_list-prcnr+6(5).
1081 
1082   ELSE.
1083 
1084     SELECT MAX( prcnr ) INTO lv_prcnr FROM zc0000fit0009
1085     WHERE bukrs = git_list-bukrs
1086       AND gjahr = git_list-gjahr
1087       AND monat = git_list-monat.
1088     IF sy-subrc = 0.
1089       lv_seq  = lv_prcnr+6(5).
1090     ENDIF.
1091 
1092   ENDIF.
1093 
1094   lv_seq = lv_seq + 1.
1095   CLEAR lv_prcnr.
1096 
1097   CONCATENATE git_list-gjahr git_list-monat lv_seq INTO lv_prcnr.
1098   lwa_prclg-prcnr = lv_prcnr.
1099   lwa_prclg-bukrs = git_list-bukrs.
1100   lwa_prclg-belnr = git_list-belnr.
1101   lwa_prclg-gjahr = git_list-gjahr.
1102   lwa_prclg-monat = git_list-monat.
1103 
1104 *& Start of Insertion CR00158 by Davy on 2013/08/06
1105 * Reset the PRC number
1106   lwa_header-prcnr = lv_prcnr.
1107   MODIFY git_header FROM lwa_header TRANSPORTING prcnr
1108    WHERE bukrs = git_list-bukrs
1109      AND belnr = git_list-belnr
1110      AND gjahr = git_list-gjahr.
1111 *& End of Insertion CR00158 by Davy on 2013/08/06
1112 
1113   APPEND lwa_prclg TO git_upd09.
1114   CLEAR lwa_prclg.
1115 
1116 ENDFORM.                    " UPDATE_PRC_LOG
1117 *&---------------------------------------------------------------------*
1118 *&      Form  CONV_AMOUNT
1119 *&---------------------------------------------------------------------*
1120 *       text
1121 *----------------------------------------------------------------------*
1122 *      -->P_VA1  text
1123 *      <--P_STR  text
1124 *----------------------------------------------------------------------*
1125 FORM conv_amount USING value(pv_source)
1126                  CHANGING value(pv_result).
1127   DATA: scr(30) TYPE c, res(60) TYPE c,fen(2) TYPE c .
1128   DATA: len TYPE i, c1 TYPE i, c2 TYPE i, c3 TYPE i, c4 TYPE i.
1129   DATA: d1(1) TYPE c, d2(1) TYPE c, d3 TYPE i.
1130   DATA: digit(2) TYPE c, weight(2) TYPE c.
1131   DATA: leroy(4) TYPE c VALUE 零元.
1132   DATA: lfen(2)  TYPE c VALUE .
1133   DATA: lint(2)  TYPE c VALUE .
1134   DATA: rule1(20) TYPE c VALUE 零壹贰叁肆伍陆柒捌玖.
1135   DATA: rule2(30) TYPE c VALUE 分角元拾佰仟万拾佰仟亿拾佰仟万.
1136   scr = pv_source * 100.
1137   CONDENSE scr NO-GAPS.
1138   IF scr = 0.
1139     res = leroy. "‘零元‘.
1140   ELSE.
1141     len = STRLEN( scr ).
1142     c1 = 0.
1143     d1 = 0.
1144     CLEAR res.
1145     DO len TIMES.
1146       c1 = c1 + 1.
1147       c2 = len - c1.
1148       d2 = scr+c2(1) .
1149       IF d2 = 0.
1150         d3 = 0.
1151       ELSE.
1152         d3 = d2.
1153       ENDIF.
1154       digit = rule1+d3(1) .
1155       c3 = ( c1 - 1 ) .
1156       weight = rule2+c3(1) .
1157       IF d2 = 0.
1158         IF c1 = 3.
1159           digit = ‘‘.
1160         ELSEIF c1 = 7.
1161           digit = ‘‘.
1162           IF len > 10 .
1163             c4 = len - 10.
1164             IF scr+c4(4) = 0000.
1165               weight = ‘‘.
1166             ENDIF.
1167           ENDIF.
1168         ELSEIF c1 = 11.
1169           digit = ‘‘.
1170         ELSEIF d1 = 0.
1171           digit = ‘‘.
1172           weight = ‘‘.
1173         ELSE.
1174           weight = ‘‘.
1175         ENDIF.
1176       ENDIF.
1177       CONCATENATE digit weight res INTO res .
1178       d1 = d2.
1179     ENDDO.
1180   ENDIF.
1181   len = STRLEN( res ) - 1.
1182   fen = res+len(1).
1183   IF fen <> lfen. "‘分‘ .
1184     CONCATENATE res lint  INTO pv_result."‘整‘
1185   ELSE.
1186     pv_result = res.
1187   ENDIF.
1188 ENDFORM.                    " CONV_AMOUNT
1189 *&---------------------------------------------------------------------*
1190 *&      Form  SET_NEXT_PRCNO
1191 *&---------------------------------------------------------------------*
1192 *       text
1193 *----------------------------------------------------------------------*
1194 *      -->P_GIT_BKPF_BUKRS  text
1195 *      -->P_GIT_BKPF_GJAHR  text
1196 *      -->P_GIT_BKPF_MONAT  text
1197 *      <--P_GIT_LIST_PRCNR  text
1198 *----------------------------------------------------------------------*
1199 FORM set_next_prcno  USING    p_git_bkpf_bukrs
1200                               p_git_bkpf_gjahr
1201                               p_git_bkpf_monat
1202                      CHANGING p_git_list_prcnr.
1203 
1204   DATA: lv_seq    TYPE txnum.
1205   DATA: lv_prcnr  TYPE zc0000fit0009-prcnr.
1206   DATA: lit_list  TYPE STANDARD TABLE OF gty_list WITH HEADER LINE.
1207 
1208   CLEAR p_git_list_prcnr.
1209   CLEAR: lv_seq,lv_prcnr.
1210   REFRESH lit_list.
1211 
1212   lit_list[] = git_list[].
1213   DELETE lit_list WHERE bukrs <> p_git_bkpf_bukrs.
1214   DELETE lit_list WHERE gjahr <> p_git_bkpf_gjahr.
1215   DELETE lit_list WHERE monat <> p_git_bkpf_monat.
1216   SORT lit_list BY prcnr DESCENDING.
1217 
1218 * read table git_prclg2 with key bukrs = p_git_bkpf_bukrs
1219 *                                gjahr = p_git_bkpf_gjahr
1220 *                                monat = p_git_bkpf_monat.
1221 
1222   READ TABLE lit_list INDEX 1.
1223   IF sy-subrc = 0 AND lit_list-prcnr <> ‘‘.
1224     lv_seq  = lit_list-prcnr+6(5).
1225 
1226   ELSE.
1227 
1228     SELECT MAX( prcnr ) INTO lv_prcnr FROM zc0000fit0009
1229     WHERE bukrs = p_git_bkpf_bukrs
1230       AND gjahr = p_git_bkpf_gjahr
1231       AND monat = p_git_bkpf_monat.
1232     IF sy-subrc = 0.
1233       lv_seq  = lv_prcnr+6(5).
1234     ENDIF.
1235 
1236   ENDIF.
1237 
1238   lv_seq = lv_seq + 1.
1239   CLEAR lv_prcnr.
1240 
1241   CONCATENATE p_git_bkpf_gjahr p_git_bkpf_monat lv_seq INTO lv_prcnr.
1242   p_git_list_prcnr = lv_prcnr.
1243 
1244 ENDFORM.                    " SET_NEXT_PRCNO
1245 *&---------------------------------------------------------------------*
1246 *&      Form  PF_SMART_GET_DATA
1247 *&---------------------------------------------------------------------*
1248 *       text
1249 *----------------------------------------------------------------------*
1250 *      -->P_IM_HEADER  text
1251 *      -->P_IM_DETAIL  text
1252 *----------------------------------------------------------------------*
1253 *&---------------------------------------------------------------------*
1254 *&      Form  pf_smart_get_data
1255 *&---------------------------------------------------------------------*
1256 FORM pf_smart_get_data TABLES im_header im_detail.
1257   im_header[] = git_header[].
1258 *  im_detail[] = git_detail[].
1259   LOOP AT git_detail.
1260     MOVE-CORRESPONDING git_detail TO im_detail.
1261     APPEND im_detail.
1262     CLEAR im_detail.
1263   ENDLOOP.
1264 ENDFORM.                    "pf_smart_get_data
1265 *&---------------------------------------------------------------------*
1266 *&      Form  PRINT_DATA_BACKGROUND
1267 *&---------------------------------------------------------------------*
1268 *       text
1269 *----------------------------------------------------------------------*
1270 *  -->  p1        text
1271 *  <--  p2        text
1272 *----------------------------------------------------------------------*
1273 FORM print_data_background .
1274   DATA: lv_fm_name      TYPE rs38l_fnam,
1275         lv_ldest        TYPE usr01-spld,
1276         lwa_controlpara TYPE ssfctrlop,
1277         lwa_output      TYPE ssfcompop.
1278   DATA:
1279           ls_ssfcrescl TYPE ssfcrescl,
1280           ls_ssfctrlop TYPE ssfctrlop,
1281           ls_ssfcompop TYPE ssfcompop.
1282 
1283   CLEAR lv_ldest.
1284   SELECT SINGLE spld FROM usr01 INTO lv_ldest
1285    WHERE bname = sy-uname.
1286 
1287   lwa_controlpara-langu  = sy-langu.
1288   lwa_controlpara-no_dialog  = c_x.
1289   lwa_controlpara-device = PRINTER.
1290   lwa_output-tddest      = lv_ldest.
1291   lwa_controlpara-preview = ‘‘.
1292   lwa_output-tdimmed = c_x.
1293   lwa_controlpara-no_dialog = c_x.
1294 
1295 *Get Smartform Function Name
1296   CALL FUNCTION SSF_FUNCTION_MODULE_NAME
1297     EXPORTING
1298       formname           = c_formname
1299     IMPORTING
1300       fm_name            = lv_fm_name
1301     EXCEPTIONS
1302       no_form            = 1
1303       no_function_module = 2
1304       OTHERS             = 3.
1305 
1306   IF sy-subrc <> 0.
1307     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
1308     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
1309     RETURN.
1310   ENDIF.
1311 
1312 *--->Setup output options berfore call smartforms
1313   ls_ssfctrlop-device = PRINTER.
1314   ls_ssfctrlop-preview = c_x.
1315   ls_ssfctrlop-langu = sy-langu.
1316   ls_ssfcompop-tddest = lv_ldest.                           "‘LO01‘.
1317   ls_ssfcompop-tdimmed = c_x.
1318   ls_ssfcompop-tdnewid = c_x.
1319   ls_ssfcompop-tdnoprev = c_x.
1320 
1321 *Open spool
1322   CALL FUNCTION SSF_OPEN
1323     EXPORTING
1324       control_parameters = ls_ssfctrlop
1325       output_options     = ls_ssfcompop
1326       user_settings      =  
1327     EXCEPTIONS
1328       formatting_error   = 1
1329       internal_error     = 2
1330       send_error         = 3
1331       user_canceled      = 4.
1332   CHECK sy-subrc = 0.
1333 
1334 *--->Call Smartforms by Function Mode Name
1335   CLEAR ls_ssfctrlop.
1336   ls_ssfctrlop-no_open = c_x.
1337   ls_ssfctrlop-no_close = c_x.
1338 
1339   LOOP AT git_list.
1340 
1341     REFRESH git_header.
1342     REFRESH git_detail.
1343     git_header[] = git_head[].
1344     git_detail[] = git_item[].
1345 
1346     DELETE git_header WHERE bukrs <> git_list-bukrs.
1347     DELETE git_header WHERE belnr <> git_list-belnr.
1348     DELETE git_header WHERE gjahr <> git_list-gjahr.
1349 
1350     DELETE git_detail WHERE bukrs <> git_list-bukrs.
1351     DELETE git_detail WHERE belnr <> git_list-belnr.
1352     DELETE git_detail WHERE gjahr <> git_list-gjahr.
1353 
1354 *Open Smartforms
1355     CALL FUNCTION lv_fm_name
1356       EXPORTING
1357         control_parameters = ls_ssfctrlop "lwa_controlpara
1358         output_options     = lwa_output
1359         user_settings      = ‘‘
1360         im_report          = sy-repid
1361       EXCEPTIONS
1362         formatting_error   = 1
1363         internal_error     = 2
1364         send_error         = 3
1365         user_canceled      = 4
1366         OTHERS             = 5.
1367     IF sy-subrc <> 0.
1368       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
1369       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
1370       RETURN.
1371     ENDIF.
1372 
1373     PERFORM update_prc_log.
1374   ENDLOOP.
1375 
1376 *Close spool
1377   CALL FUNCTION SSF_CLOSE
1378     IMPORTING
1379       job_output_info = ls_ssfcrescl.
1380 
1381   IF NOT ls_ssfcrescl-spoolids[] IS INITIAL OR
1382      ls_ssfcrescl-outputdone <> ‘‘.
1383     PERFORM modify_table TABLES git_upd09.
1384 *    MODIFY zc0000fit0009 FROM TABLE git_upd09.
1385 *    IF sy-subrc = 0.
1386 *      COMMIT WORK.
1387 *    ELSE.
1388 *      ROLLBACK WORK.
1389 *      MESSAGE s099(ba) DISPLAY LIKE c_e WITH text-m03.
1390 *    ENDIF.
1391   ENDIF.
1392 
1393   REFRESH git_upd09.
1394 
1395 ENDFORM.                    " PRINT_DATA_BACKGROUND
1396 *&---------------------------------------------------------------------*
1397 *&      Form  CONVERT_RATE
1398 *&---------------------------------------------------------------------*
1399 *       text
1400 *----------------------------------------------------------------------*
1401 *      -->P_GIT_BKPF_WAERS  text
1402 *      <--P_GIT_ITEM_KURSF  text
1403 *----------------------------------------------------------------------*
1404 FORM convert_rate  USING    p_git_bkpf_waers p_git_bkpf_kursf
1405                    CHANGING p_git_item_kursf.
1406 
1407   DATA: v_amount(16) TYPE p DECIMALS 6.
1408 
1409   v_amount = p_git_bkpf_kursf.
1410 
1411   TABLES: tcurx.
1412 
1413   SELECT SINGLE * FROM tcurx WHERE currkey = p_git_bkpf_waers.
1414   IF sy-subrc = 0.
1415     v_amount = v_amount * 10 ** ( tcurx-currdec - 2 ).
1416   ENDIF.
1417 
1418   p_git_item_kursf = v_amount.
1419 
1420 ENDFORM.                    " CONVERT_RATE
1421 *&---------------------------------------------------------------------*
1422 *&      Form  MODIFY_TABLE
1423 *&---------------------------------------------------------------------*
1424 *       text
1425 *----------------------------------------------------------------------*
1426 *      -->P_GIT_UPD09  text
1427 *----------------------------------------------------------------------*
1428 FORM modify_table  TABLES   p_git_upd09 STRUCTURE zc0000fit0009.
1429   "Insert correct name for <...>.
1430   DATA: wa_upd09 TYPE zc0000fit0009.
1431 
1432   CHECK NOT p_git_upd09[] IS INITIAL.
1433 
1434   LOOP AT p_git_upd09 INTO wa_upd09.
1435 
1436     CALL FUNCTION ENQUEUE_EZ_ZC0000FIT0009
1437       EXPORTING
1438         mode_zc0000fit0009 = X
1439         mandt              = sy-mandt
1440         bukrs              = wa_upd09-bukrs
1441         belnr              = wa_upd09-belnr
1442         gjahr              = wa_upd09-gjahr
1443       EXCEPTIONS
1444         foreign_lock       = 1
1445         system_failure     = 2
1446         OTHERS             = 3.
1447     IF sy-subrc <> 0.
1448       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
1449               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
1450     ENDIF.
1451 
1452     MODIFY zc0000fit0009 FROM wa_upd09.
1453     IF sy-subrc = 0.
1454       COMMIT WORK.
1455     ELSE.
1456       ROLLBACK WORK.
1457       MESSAGE s099(ba) DISPLAY LIKE c_e WITH text-m03.
1458     ENDIF.
1459 
1460     CALL FUNCTION DEQUEUE_EZ_ZC0000FIT0009
1461       EXPORTING
1462         mode_zc0000fit0009 = X
1463         mandt              = sy-mandt
1464         bukrs              = wa_upd09-bukrs
1465         belnr              = wa_upd09-belnr
1466         gjahr              = wa_upd09-gjahr.
1467 
1468   ENDLOOP.
1469 
1470 ENDFORM.                    " MODIFY_TABLE
1471 *&---------------------------------------------------------------------*
1472 *&      Form  FRM_BALANCE
1473 *&---------------------------------------------------------------------*
1474 *       text
1475 *----------------------------------------------------------------------*
1476 *  -->  p1        text
1477 *  <--  p2        text
1478 *----------------------------------------------------------------------*
1479 form FRM_BALANCE .
1480   DATA: l_func     TYPE csks-func_area.
1481   DATA: l_name1    TYPE kna1-name1.
1482   SPLIT git_ska-txt50 AT - INTO git_item-name1 git_item-name2.
1483   IF git_bseg-lifnr <> ‘‘ AND git_bseg-koart = K.
1484     SELECT SINGLE name1 INTO l_name1 FROM lfa1
1485       WHERE lifnr = git_bseg-lifnr.
1486   ENDIF.
1487   IF git_bseg-kunnr <> ‘‘ AND git_bseg-koart = D.
1488     SELECT SINGLE name1 INTO l_name1 FROM kna1
1489     WHERE kunnr = git_bseg-kunnr.
1490   ENDIF.
1491 
1492   IF NOT l_name1 IS INITIAL.
1493     CONCATENATE git_item-name2 - l_name1 INTO git_item-name2.
1494   ENDIF.
1495 endform.                    " FRM_BALANCE
1496 *&---------------------------------------------------------------------*
1497 *&      Form  FRM_PROFIT
1498 *&---------------------------------------------------------------------*
1499 *       text
1500 *----------------------------------------------------------------------*
1501 *  -->  p1        text
1502 *  <--  p2        text
1503 *----------------------------------------------------------------------*
1504 form FRM_PROFIT .
1505   DATA: l_func     TYPE csks-func_area.
1506   DATA: l_name1    TYPE kna1-name1,
1507         l_aufnr    TYPE bseg-aufnr.
1508 * first class account
1509   SELECT SINGLE func_area INTO l_func FROM csks
1510    WHERE kostl = git_bseg-kostl
1511      AND bukrs = git_bseg-bukrs.                      "#EC *
1512   IF sy-subrc = 0.
1513     SELECT SINGLE prcnm1 INTO git_item-name1
1514       FROM zc0000fit0010
1515       WHERE func_area = l_func.
1516   ENDIF.
1517   git_item-name2 = git_ska-txt50.
1518 * interanl order
1519   IF NOT git_bseg-aufnr IS INITIAL.
1520     CLEAR l_aufnr.
1521     CALL FUNCTION CONVERSION_EXIT_ALPHA_OUTPUT
1522       EXPORTING
1523         input  = git_bseg-aufnr
1524       IMPORTING
1525         output = l_aufnr.
1526     CONCATENATE git_item-name2 l_aufnr
1527            INTO git_item-name2 SEPARATED BY space.
1528 
1529   ENDIF.
1530 endform.                    " FRM_PROFIT

 

SAP中方会计凭证打印解决方案

标签:

原文地址:http://www.cnblogs.com/SlashOut/p/4997025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!