Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185409
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2008-07-02 22:19:24

网友: 本站网友
请问白大哥, 改写事物码FBL3N报表程序, 有如下问题请教:
1. FBL3N, 行项目选择有3种状态分别是: 未清项目, 已清项目, 全部项目, 不知在哪个表哪个字段中维护它们的标识?
2.根据G/L Account和Company Code来做AP 未清帐、AP已清帐、AP全部的报表,  是要用到BSEG(簇表),大家都知道BSEG是不能直接inner join的,  在我们系统中, BSEG表记录数目有2527918条, 如果直接操作BSEG会很慢, 于是, 网上找了些资料看看, 说BSIK和BSAK可以替代BSEG, 为何在表BSIK中没有BSEG中的Company Code? (BSEG有公司代码3000, 在BSIK却没有公司代码3000)? 并且发现BSIK数据只有1215条记录, 是否应付未清BSIK需要维护才有数据?
3.想使用BSIS来处理, 但不知哪个字段标识应付, 应收?

Blog作者的回复:
有个以前写的针对FBL1N的,你就凑合看看吧,原理是一样的。
BSIK, BSAK  分别是供应商(K)的未清已清项存放的表   
BSIS, BSAS  分别是总账(S)的未清已清项存放的表     
BSID, BSAD  分别是客户(D)的未清已清项存放的表     

 
 
*&---------------------------------------------------------------------*
*& Report  Z_BARRY_FBL1N
*&
*&---------------------------------------------------------------------*
*& FBL1N
*&---------------------------------------------------------------------*
REPORT  z_barry_fbl1n.
TYPE-POOLS: slis.
TABLES: bsik.
DATA: gd_fieldcat TYPE slis_t_fieldcat_alv.
DATA: sla TYPE slis_layout_alv ,
      ivariant LIKE disvariant,
      iexit(1)  TYPE c,
      i_repid LIKE sy-repid .
DATA: BEGIN OF itab OCCURS 0,
        lifnr LIKE lfa1-lifnr ,
        bukrs LIKE bsik-bukrs ,
        belnr LIKE bsik-belnr ,
        budat LIKE bsik-budat ,
        bldat LIKE bsik-bldat ,
        cpudt LIKE bsik-cpudt ,
        augdt LIKE bsak-augdt , "清帐日期
        shkzg LIKE bsik-shkzg ,"借贷 Barry
        dmbtr LIKE bsik-dmbtr ,
      END OF itab.
SELECT-OPTIONS: s_bukrs FOR bsik-bukrs OBLIGATORY ,
                s_lifnr FOR bsik-lifnr OBLIGATORY ,
                s_cpudt FOR bsik-cpudt .
SELECTION-SCREEN BEGIN OF BLOCK status WITH FRAME TITLE text-022.
*     open items:
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS x_opsel LIKE itemset-xopsel RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(20) text-023 FOR FIELD x_opsel.
SELECTION-SCREEN END OF LINE.
PARAMETERS pa_stida LIKE rfpdo-allgstid DEFAULT sy-datlo.
SELECTION-SCREEN SKIP.
*     cleared items:
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS x_clsel LIKE itemset-xclsel RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(25) text-024 FOR FIELD x_clsel.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS so_augdt FOR bsik-augdt NO DATABASE SELECTION.
PARAMETERS pa_stid2 LIKE rfpdo-allgstid.
SELECTION-SCREEN SKIP.
*     all items:
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS x_aisel LIKE itemset-xaisel RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(20) text-025 FOR FIELD x_aisel.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS so_budat FOR bsik-budat NO DATABASE SELECTION.
SELECTION-SCREEN END OF BLOCK status.
PARAMETERS:  p_vari   LIKE disvariant-variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
  PERFORM for_variant.
START-OF-SELECTION.
  PERFORM getdata.
  PERFORM outdata.
*&---------------------------------------------------------------------*
*  &      Form  GETDATA
*&---------------------------------------------------------------------*
FORM getdata.
  IF x_opsel = 'X'.
    SELECT
        bsik~bukrs
        bsik~lifnr
        bsik~belnr
        bsik~shkzg
        bsik~budat
        bsik~bldat
        bsik~cpudt
        bsik~dmbtr
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM bsik
    WHERE bsik~bukrs IN s_bukrs AND
          bsik~lifnr IN s_lifnr AND
          bsik~cpudt IN s_cpudt AND
          bsik~budat <= pa_stida   .
    SELECT
        bsak~bukrs
        bsak~lifnr
        bsak~belnr
        bsak~shkzg
        bsak~augdt
        bsak~budat
        bsak~bldat
        bsak~cpudt
        bsak~dmbtr
    APPENDING CORRESPONDING FIELDS OF TABLE itab
    FROM bsak
    WHERE bsak~bukrs IN s_bukrs  AND
          bsak~lifnr IN s_lifnr  AND
          bsak~cpudt IN s_cpudt  AND
          bsak~augdt BETWEEN '00010101' AND '99991231' AND
          bsak~budat <= pa_stida AND
          bsak~augdt > pa_stida  .
  ELSEIF x_clsel = 'X'.
    IF pa_stid2 IS INITIAL.
      SELECT
          bsak~bukrs
          bsak~lifnr
          bsak~belnr
          bsak~shkzg
          bsak~augdt
          bsak~budat
          bsak~bldat
          bsak~cpudt
          bsak~dmbtr
      APPENDING CORRESPONDING FIELDS OF TABLE itab
      FROM bsak
      WHERE bsak~bukrs IN s_bukrs  AND
            bsak~lifnr IN s_lifnr  AND
            bsak~cpudt IN s_cpudt  AND
            bsak~augdt > pa_stid2  AND
            bsak~augdt IN so_augdt  .
    ELSE.
      SELECT
          bsak~bukrs
          bsak~lifnr
          bsak~belnr
          bsak~shkzg
          bsak~augdt
          bsak~budat
          bsak~bldat
          bsak~cpudt
          bsak~dmbtr
      APPENDING CORRESPONDING FIELDS OF TABLE itab
      FROM bsak
      WHERE bsak~bukrs IN s_bukrs  AND
            bsak~lifnr IN s_lifnr  AND
            bsak~cpudt IN s_cpudt  AND
            bsak~budat <= pa_stid2 AND
            bsak~augdt > pa_stid2  AND
            bsak~augdt IN so_augdt  .
    ENDIF.
  ELSE.
    SELECT
        bsik~bukrs
        bsik~lifnr
        bsik~belnr
        bsik~shkzg
        bsik~budat
        bsik~bldat
        bsik~cpudt
        bsik~dmbtr
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM bsik
    WHERE bsik~bukrs IN s_bukrs  AND
          bsik~lifnr IN s_lifnr  AND
          bsik~cpudt IN s_cpudt  AND
          bsik~budat IN so_budat AND
          bsik~budat <= '99991231' .
    SELECT
        bsak~bukrs
        bsak~lifnr
        bsak~belnr
        bsak~shkzg
        bsak~augdt
        bsak~budat
        bsak~bldat
        bsak~cpudt
        bsak~dmbtr
    APPENDING CORRESPONDING FIELDS OF TABLE itab
    FROM bsak
    WHERE bsak~bukrs IN s_bukrs AND
          bsak~lifnr IN s_lifnr AND
          bsak~cpudt IN s_cpudt AND
          bsak~augdt BETWEEN '00010101' AND '99991231' AND
          bsak~budat IN so_budat .
  ENDIF.
ENDFORM.                    " GETDATA
*&---------------------------------------------------------------------*
*  &      Form  outdata
*&---------------------------------------------------------------------*
FORM outdata.
  PERFORM fieldcat_init .
  sla-colwidth_optimize = 'X'.
  sla-zebra             = 'X'.
  i_repid = sy-repid.
  ivariant-variant = p_vari.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = i_repid
      it_fieldcat             = gd_fieldcat[]
      i_save                  = 'A'
      is_variant              = ivariant
      is_layout               = sla
      i_callback_user_command = 'USER_COMMAND'
    TABLES
      t_outtab                = itab
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
ENDFORM.                    " outdata
*---------------------------------------------------------------------*
*       FORM fieldcat_init                                            *
*---------------------------------------------------------------------*
FORM fieldcat_init .
  PERFORM frm_catlg_set USING: 'LIFNR'     'LIFNR'(001)  ,
                               'BUKRS'     'BUKRS'(002)  ,
                               'BELNR'     'BELNR'(004)  ,
                               'BUDAT'     'BUDAT'(015) ,
                               'BLDAT'     'BLDAT'(016) ,
                               'CPUDT'     'CPUDT'(017) ,
                               'AUGDT'     'AUGDT'(018) ,
                               'SHKZG'     'SHKZG'(019) ,
                               'DMBTR'     'DMBTR'(020) .
ENDFORM.                    "fieldcat_init
*---------------------------------------------------------------------*
*       FORM frm_catlg_set                                            *
*---------------------------------------------------------------------*
FORM frm_catlg_set USING p_field
                         p_text.
  DATA: ls_fieldcat TYPE slis_fieldcat_alv.
  ls_fieldcat-fieldname     =  p_field.
  ls_fieldcat-seltext_l     =  p_text.
  IF p_field = 'LIFNR'.
    ls_fieldcat-ref_fieldname = 'LIFNR'.
    ls_fieldcat-ref_tabname = 'LFA1'.
  ENDIF.
  APPEND ls_fieldcat TO gd_fieldcat .
  CLEAR ls_fieldcat .
ENDFORM.                    "frm_catlg_set
*&--------------------------------------------------------------------*
*  &      Form  user_command
*&--------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                    rs_selfield TYPE slis_selfield.
  READ TABLE itab INDEX rs_selfield-tabindex.
  CASE r_ucomm.
    WHEN '&IC1'. "双击
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
  DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = lr_grid.
  CALL METHOD lr_grid->check_changed_data.
  rs_selfield-refresh = 'X'.  "自动刷新
ENDFORM. "user_com
*&--------------------------------------------------------------------*
*  &      Form  FOR_VARIANT
*&--------------------------------------------------------------------*
FORM for_variant.
  ivariant-report = sy-repid.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = ivariant
      i_save     = 'A'
    IMPORTING
      e_exit     = iexit
      es_variant = ivariant
    EXCEPTIONS
      not_found  = 2.
  IF sy-subrc = 2.
    MESSAGE ID sy-msgid TYPE 'S'      NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF iexit = space.
      p_vari = ivariant-variant.
    ENDIF.
  ENDIF.
ENDFORM.                    "FOR_VARIANT
 
 
***************************文本符号
001 供应商
002 公司
004 凭证号码
015 凭证记帐日期
016 凭证中的凭证日期
017 会计凭证输入日期
018 清帐日期
019 借贷
020 金额
023 未清项目
024 已清项目
025 全部项目
 
**************************选择文本
PA_STID2 到关键日未清
PA_STIDA 到关键日未清
P_VARI 选择显示格式
SO_AUGDT 清帐日期
SO_BUDAT 记帐日期
S_BUKRS 公司代码
S_CPUDT 输入日期
S_LIFNR 供应商
X_AISEL 全部项目
X_CLSEL 已清项目
X_OPSEL 未清项目
阅读(6724) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~