IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> ACDOCA表数据修正 -> 正文阅读

[开发工具]ACDOCA表数据修正

需求:acdoca和bseg数据不一致,bseg客户供应商字段有值,而acdoca为空

可能是由于项目之前做的增强,直接对源代码进行修改,导致acdoca数据和bseg不一致。

解决方法:找到了一个sap提供的类cl_fins_acdoc_change,经过测试,可以对acdoca数据进行修正。

代码如下:

*&---------------------------------------------------------------------*
*& Report ZFI_UPDATE_ACDOCA
*&---------------------------------------------------------------------*
*& 仅用于部分acdoca客户供应商字段为空的凭证
*&---------------------------------------------------------------------*
REPORT zfi_update_acdoca.

TABLES:acdoca,bseg.

"红绿灯
CONSTANTS:gc_red     LIKE icon-internal VALUE '@5C@',
          gc_yellow  LIKE icon-internal VALUE '@5D@',
          gc_green   LIKE icon-internal VALUE '@5B@',
          gc_status  TYPE slis_formname VALUE 'FRM_STATUS',
          gc_command TYPE slis_formname VALUE 'FRM_COMMAND'.

TYPES:BEGIN OF ty_data,
        sel,
        rldnr       TYPE acdoca-rldnr,
        rbukrs      TYPE acdoca-rbukrs,
        gjahr       TYPE acdoca-gjahr,
        belnr       TYPE acdoca-belnr,
        buzei       TYPE acdoca-buzei,
        docln       TYPE acdoca-docln,
        koart       TYPE acdoca-koart,
        racct       TYPE acdoca-racct,
        mwskz       TYPE acdoca-mwskz,
        bttype      TYPE acdoca-bttype,
        kunnr       TYPE acdoca-kunnr,
        bseg_kunnr  TYPE acdoca-kunnr,
        kunnr_name1 TYPE ze_kunnr_name,
        lifnr       TYPE acdoca-lifnr,
        bseg_lifnr  TYPE acdoca-lifnr,
        lifnr_name1 TYPE ze_lifnr_name,
        budat       TYPE acdoca-budat,
        blart       TYPE acdoca-blart,
        sgtxt       TYPE acdoca-sgtxt,
      END OF ty_data,
      ty_t_data TYPE TABLE OF ty_data.

DATA:gs_data     TYPE ty_data,
     gt_data     TYPE ty_t_data,
     gs_lay      TYPE lvc_s_layo,           " layout
     gt_fieldcat TYPE lvc_t_fcat,           " fieldcat
     gs_fieldcat TYPE lvc_s_fcat.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.

  PARAMETERS: p_gjahr TYPE acdoca-gjahr DEFAULT sy-datum+0(4) OBLIGATORY." 会计年度
  SELECT-OPTIONS: s_belnr FOR acdoca-belnr,   " 会计凭证
                  s_bukrs FOR acdoca-rbukrs.  " 公司代码

  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN BEGIN OF LINE.
*第一个RADIOBUTTON
    SELECTION-SCREEN POSITION 1.
    PARAMETERS:p1 RADIOBUTTON GROUP r1 DEFAULT 'X' USER-COMMAND ucl.
    SELECTION-SCREEN COMMENT 3(15) TEXT-002 .

*第二个RADIOBUTTON
    SELECTION-SCREEN POSITION 25.
    PARAMETERS:p2 RADIOBUTTON GROUP r1.
    SELECTION-SCREEN COMMENT 27(15) TEXT-003 .
  SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  PERFORM frm_get_data.            " 获取数据

END-OF-SELECTION.
  PERFORM frm_alv_dis.             " alv展示
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_get_data .

  DATA:lr_koart TYPE rseloption,
       lr_lifnr TYPE rseloption,
       lr_kunnr TYPE rseloption.

  REFRESH gt_data.

  CASE 'X'.
    WHEN p1.
*如果KOART=D,限定ACDOCA-KUNNR=空,
      lr_koart = VALUE #( ( sign = 'I' option = 'EQ' low = 'D' )  ).
      lr_kunnr = VALUE #( ( sign = 'I' option = 'EQ' low = '' )  ).
    WHEN p2.
*如果KOART=K,限定ACDOCA-LIFNR=空,
      lr_koart = VALUE #( ( sign = 'I' option = 'EQ' low = 'K' )  ).
      lr_lifnr = VALUE #( ( sign = 'I' option = 'EQ' low = '' )  ).
    WHEN OTHERS.
  ENDCASE.

  SELECT a~rldnr,
         a~rbukrs,
         a~gjahr,
         a~belnr,
         a~buzei,
         a~docln,
         a~koart,
         a~racct,
         a~mwskz,
         a~bttype,
         a~kunnr,
         b~kunnr AS bseg_kunnr,
         c~name1 AS kunnr_name1,
         a~lifnr,
         b~lifnr AS bseg_lifnr,
         d~name1 AS lifnr_name1,
         a~budat,
         a~blart,
         a~sgtxt
    FROM acdoca AS a
    LEFT OUTER JOIN bseg AS b
      ON a~rbukrs = b~bukrs
     AND a~belnr  = b~belnr
     AND a~gjahr  = b~gjahr
     AND a~buzei  = b~buzei
    LEFT OUTER JOIN kna1 AS c
      ON b~kunnr = c~kunnr
    LEFT OUTER JOIN lfa1 AS d
      ON b~lifnr = d~lifnr
    INTO CORRESPONDING FIELDS OF TABLE @gt_data
   WHERE a~gjahr = @p_gjahr
     AND a~rbukrs IN @s_bukrs
     AND a~belnr  IN @s_belnr
     AND a~koart  IN @lr_koart
     AND a~kunnr  IN @lr_kunnr
     AND a~lifnr  IN @lr_lifnr.

  IF gt_data IS INITIAL.

    MESSAGE '未查询到满足条件数据' TYPE 'S' DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.

  ENDIF.

  SORT gt_data BY rldnr rbukrs gjahr belnr docln.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_alv_dis
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_alv_dis .

  gs_lay-cwidth_opt = 'X'.
  gs_lay-zebra = 'X'.
  gs_lay-no_toolbar = 'X'.
  gs_lay-box_fname = 'SEL'.    " 选择框
  CLEAR :gt_fieldcat[].
  DEFINE add_fieldcat.

    CLEAR:gs_fieldcat.
    gs_fieldcat-fieldname = &2.
    gs_fieldcat-scrtext_l = &1.
    gs_fieldcat-scrtext_m = &1.
    gs_fieldcat-scrtext_s = &1.
    gs_fieldcat-coltext   = &1.
    gs_fieldcat-col_opt   = &3.
    gs_fieldcat-ref_table = &4.
    gs_fieldcat-ref_field = &5.
    gs_fieldcat-edit_mask = &6.

    APPEND gs_fieldcat TO gt_fieldcat.

  END-OF-DEFINITION.

  add_fieldcat '分类账'        'RLDNR'             '' ''         ''           ''.
  add_fieldcat '公司代码'	     'RBUKRS'            '' ''         ''           ''.
  add_fieldcat '年度'	         'GJAHR'             '' ''         ''           ''.
  add_fieldcat '凭证编号'      'BELNR'             '' ''         ''           ''.
  add_fieldcat '行号'	         'BUZEI'             '' ''         ''           ''.
  add_fieldcat '行项目'        'DOCLN'             '' ''         ''           ''.
  add_fieldcat '科目类型'	     'KOART'             '' ''         ''           ''.
  add_fieldcat '科目'	         'RACCT'             '' ''         ''           ''.
  add_fieldcat '税码'          'MWSKZ'             '' ''         ''           ''.
  add_fieldcat '业务交易类型'	 'BTTYPE'            '' ''         ''           ''.
  add_fieldcat '客户'	         'KUNNR'             '' ''         ''           ''.
  add_fieldcat 'BSEG表-客户'	  'BSEG_KUNNR'        '' ''         ''           ''.
  add_fieldcat '客户名称'	     'KUNNR_NAME1'       '' ''         ''           ''.
  add_fieldcat '供应商'        'LIFNR'             '' ''         ''           ''.
  add_fieldcat 'BSEG表-供应商' 'BSEG_LIFNR'        '' ''         ''           ''.
  add_fieldcat '供应商名称'    'LIFNR_NAME1'       '' ''         ''           ''.
  add_fieldcat '过账日期'	     'BUDAT'             '' ''         ''           ''.
  add_fieldcat '凭证类型'	     'BLART'             '' ''         ''           ''.
  add_fieldcat '行项目文本'    'SGTXT'             '' ''         ''           ''.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program       = sy-repid
      i_callback_pf_status_set = gc_status
      i_callback_user_command  = gc_command
      is_layout_lvc            = gs_lay
      it_fieldcat_lvc          = gt_fieldcat
      i_save                   = 'A'
    TABLES
      t_outtab                 = gt_data
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

  IF sy-subrc <> 0.
* IMPLEMENT SUITABLE ERROR HANDLING HERE
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_STATUS
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_status USING p_extab TYPE slis_t_extab.

  DATA lt_fcode TYPE TABLE OF sy-ucomm.
  DATA(lv_title) = ''.
  SET PF-STATUS 'ST1' EXCLUDING lt_fcode."隐藏功能按钮
  SET TITLEBAR  'TI1' WITH lv_title.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_COMMAND
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_command USING p_ucomm TYPE sy-ucomm
                       ps_selfield  TYPE slis_selfield.

  DATA: lo_grid TYPE REF TO cl_gui_alv_grid,
        lv_code LIKE sy-ucomm.

  lv_code = p_ucomm.
  CLEAR:p_ucomm.

  CASE lv_code.
    WHEN 'ZCHG'.
      PERFORM frm_change_acdoca. 
  ENDCASE.

  ps_selfield-refresh = 'X'.
*刷新alv屏幕数据
  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = lo_grid.

  CALL METHOD lo_grid->check_changed_data.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_change_acdoca
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_change_acdoca .

  DATA: lo_acdoc_change  TYPE REF TO cl_fins_acdoc_change,
        lt_change_fields TYPE finst_fieldname,
        ls_change_fields LIKE LINE OF lt_change_fields,
        lt_acdoca_upd    TYPE finst_acdoca,
        lt_acdoca_sort   TYPE if_fins_acdoc_util_types=>tt_acdoca_sorted WITH HEADER LINE.

  CLEAR:lt_acdoca_sort,lt_acdoca_upd.

  " 需要更新字段
  ls_change_fields = 'KUNNR'.
  COLLECT ls_change_fields INTO lt_change_fields.

  ls_change_fields = 'LIFNR'.
  COLLECT ls_change_fields INTO lt_change_fields.

  ls_change_fields = 'MWSKZ'.
  COLLECT ls_change_fields INTO lt_change_fields.

  SORT gt_data BY rldnr rbukrs gjahr belnr docln.
  LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_data>) WHERE sel = 'X'.

    APPEND VALUE #( rldnr   = <fs_data>-rldnr
                    rbukrs  = <fs_data>-rbukrs
                    gjahr   = <fs_data>-gjahr
                    belnr   = <fs_data>-belnr
                    docln   = <fs_data>-docln
                    mwskz   = '' " 销售/购买税代码
                    lifnr   = <fs_data>-bseg_lifnr
                    kunnr   = <fs_data>-bseg_kunnr ) TO lt_acdoca_sort.

  ENDLOOP.
  IF sy-subrc NE 0.
    MESSAGE '请选择行' TYPE 'S' DISPLAY LIKE 'E'.
    EXIT.
  ENDIF.

  IF lt_acdoca_sort[] IS NOT INITIAL.

    lt_acdoca_upd = lt_acdoca_sort[].
    CREATE OBJECT lo_acdoc_change.

    lo_acdoc_change->set_support_mode(
       EXPORTING
         it_change_fields = lt_change_fields ).

    lo_acdoc_change->change_acdoca(
       EXPORTING
         it_change_fields     = lt_change_fields
         it_acdoca_upd        = lt_acdoca_upd
         iv_write_change_docs = abap_false
         iv_direct_update     = abap_true ).

    COMMIT WORK.
    MESSAGE '更新成功' TYPE 'S'.

  ENDIF.

ENDFORM.
  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-04-18 18:03:22  更:2022-04-18 18:07:08 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/14 14:58:58-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码