注销凭证与自定义屏幕

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了注销凭证与自定义屏幕相关的知识,希望对你有一定的参考价值。

注意注销凭证FB03    (事务代码SHDB)

自定义屏幕的功能代码与标准程序要对应一致

REPORT ZWGX006.

TABLES BKPF.
DATA OK_CODE TYPE OKCODE.


TYPESBEGIN OF TY_TAB,
         CHECKBOX TYPE CHAR01.
        INCLUDE TYPE BKPF.
TYPES END OF TY_TAB.
DATA LT_TAB TYPE STANDARD TABLE OF TY_TAB.
DATA LS_TAB LIKE LINE OF LT_TAB.  ""**屏幕中的复选框

DATA: LT_FCAT TYPE LVC_T_FCAT,
      LS_FCAT TYPE LVC_S_FCAT,
      I_LAYO  TYPE LVC_S_LAYO.

DATA:G_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
     G_GRID      TYPE REF TO CL_GUI_ALV_GRID.

DATA LT_MSG TYPE STANDARD TABLE OF BDCMSGCOLL.
DATA BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

START-OF-SELECTION.
  PERFORM GET_DATA.
  PERFORM SET_LAYO.
  PERFORM SET_FCAT.

  CALL SCREEN 2017.
*&---------------------------------------------------------------------*
*&      Module  STATUS_2017  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2017 OUTPUT.
*  SET PF-STATUS ‘xxxxxxxx‘.
*  SET TITLEBAR ‘xxx‘.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2017  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2017 INPUT.

  CASE OK_CODE.
    WHEN‘ANN01‘.
      LEAVE PROGRAM.
    WHEN ‘ANN02‘.
      PERFORM SET_WRITE-OFF.
    WHEN OTHERS.
  ENDCASE.

ENDMODULE.

*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*


FORM GET_DATA.
  SELECT * FROM BKPF INTO CORRESPONDING FIELDS OF
    TABLE LT_TAB UP TO 50 ROWS.
ENDFORM.


*&---------------------------------------------------------------------*
*&      Form  SET_LAYO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_LAYO .
  I_LAYO-ZEBRA ‘X‘.
  I_LAYO-CWIDTH_OPT ‘X‘.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SET_FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_FCAT .""复选框
  CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE‘
    EXPORTING
*     I_BUFFER_ACTIVE        =
      I_STRUCTURE_NAME       ‘BKPF‘
*     I_CLIENT_NEVER_DISPLAY = ‘X‘
*     I_BYPASSING_BUFFER     =
*     I_INTERNAL_TABNAME     =
    CHANGING
      CT_FIELDCAT            = LT_FCAT[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE 1
      PROGRAM_ERROR          2
      OTHERS                 3.
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

  LS_FCAT-FIELDNAME ‘CHECKBOX‘.
  LS_FCAT-CHECKBOX = ABAP_TRUE.
  LS_FCAT-EDIT = ABAP_TRUE.
  LS_FCAT-SCRTEXT_S ‘冲销凭证‘.
  APPEND LS_FCAT TO LT_FCAT.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Module  DISPLAY  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE DISPLAY OUTPUT.

  DATA G_FIRST(1TYPE C.

  IF NOT G_CONTAINER IS BOUND.
    CREATE OBJECT G_CONTAINER
      EXPORTING
*       PARENT                      =
        CONTAINER_NAME              ‘CONTAINER1‘
*       STYLE                       =
*       LIFETIME                    = lifetime_default
*       REPID                       =
*       DYNNR                       =
*       NO_AUTODEF_PROGID_DYNNR     =
      EXCEPTIONS
        CNTL_ERROR                  1
        CNTL_SYSTEM_ERROR           2
        CREATE_ERROR                3
        LIFETIME_ERROR              4
        LIFETIME_DYNPRO_DYNPRO_LINK 5
        OTHERS                      6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

  IF NOT G_GRID IS BOUND.
    CREATE OBJECT G_GRID
      EXPORTING
*       I_SHELLSTYLE      = 0
*       I_LIFETIME        =
        I_PARENT          = G_CONTAINER
*       I_APPL_EVENTS     = space
*       I_PARENTDBG       =
*       I_APPLOGPARENT    =
*       I_GRAPHICSPARENT  =
*       I_NAME            =
*       I_FCAT_COMPLETE   = SPACE
      EXCEPTIONS
        ERROR_CNTL_CREATE 1
        ERROR_CNTL_INIT   2
        ERROR_CNTL_LINK   3
        ERROR_DP_CREATE   4
        OTHERS            5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.



  IF G_FIRST = SPACE.
    G_FIRST ‘x‘.



    CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
*       I_BUFFER_ACTIVE               =
*       I_BYPASSING_BUFFER            =
*       I_CONSISTENCY_CHECK           =
*       I_STRUCTURE_NAME              =
*       IS_VARIANT                    =
*       I_SAVE                        =
*       I_DEFAULT                     = ‘X‘
        IS_LAYOUT                     = I_LAYO
*       IS_PRINT                      =
*       IT_SPECIAL_GROUPS             =
*       IT_TOOLBAR_EXCLUDING          =
*       IT_HYPERLINK                  =
*       IT_ALV_GRAPHICS               =
*       IT_EXCEPT_QINFO               =
*       IR_SALV_ADAPTER               =
      CHANGING
        IT_OUTTAB                     = LT_TAB[]
        IT_FIELDCATALOG               = LT_FCAT[]
*       IT_SORT                       =
*       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION 1
        PROGRAM_ERROR                 2
        TOO_MANY_LINES                3
        OTHERS                        4.
    IF SY-SUBRC <> 0.
*       Implement suitable error handling here
    ENDIF.

  ENDIF.

ENDMODULE.

*&---------------------------------------------------------------------*
*&      Form  SET_WRITE-OFF
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

form set_write-off.
  clear ls_tab.
  clear lt_fcat[].
  clear ls_fcat.
CALL METHOD G_GRID->CHECK_CHANGED_DATA.
LOOP AT LT_tab into ls_tab.
  if ls_tab-checkbox ‘x‘.
*    perform bdc_dynpro      using ‘SAPMF05A‘ ‘0100‘.
*perform bdc_field       using ‘BDC_CURSOR‘
*                              ‘RF05A-NEWKO‘.
*perform bdc_field       using ‘BDC_OKCODE‘
*                              ‘/00‘.
*perform bdc_field       using ‘BKPF-BLDAT‘
*                              ‘2017.08.09‘.
*perform bdc_field       using ‘BKPF-BLART‘
*                              ‘SA‘.
*perform bdc_field       using ‘BKPF-BUKRS‘
*                              Ls_TAB-BUKRS.
*perform bdc_field       using ‘BKPF-BUDAT‘
*                              ‘2017.08.09‘.
*perform bdc_field       using ‘BKPF-MONAT‘
*                              ‘8‘.
*perform bdc_field       using ‘BKPF-WAERS‘
*                              ‘CNY‘.
*perform bdc_field       using ‘RF05A-NEWBS‘
*                             ‘40‘.
*perform bdc_field       using ‘RF05A-NEWKO‘
*                             ‘10020111‘.
*perform bdc_dynpro      using ‘SAPMF05A‘ ‘0300‘.
*perform bdc_field       using ‘BDC_CURSOR‘
*                              ‘RF05A-NEWKO‘.
*perform bdc_field       using ‘BDC_OKCODE‘
*                              ‘/00‘.
*perform bdc_field       using ‘BSEG-WRBTR‘
*                            ‘888‘.
*perform bdc_field       using ‘RF05A-NEWBS‘
*                           ‘50‘.
*perform bdc_field       using ‘RF05A-NEWKO‘
*                              ‘10010101‘.
*perform bdc_dynpro      using ‘SAPMF05A‘ ‘0300‘.
*perform bdc_field       using ‘BDC_CURSOR‘
*                              ‘BSEG-WRBTR‘.
*perform bdc_field       using ‘BDC_OKCODE‘
*                              ‘=BU‘.
*perform bdc_field       using ‘BSEG-WRBTR‘
*                             ‘888‘.


    perform bdc_dynpro      using ‘SAPMF05A‘ ‘0105‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RF05A-BELNS‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘=BU‘.
perform bdc_field       using ‘RF05A-BELNS‘
                               LS_TAB-BELNR.
perform bdc_field       using ‘BKPF-BUKRS‘
                              LS_TAB-BELNR.
perform bdc_field       using ‘RF05A-GJAHS‘
                                LS_TAB-GJAHR.
perform bdc_field       using ‘UF05A-STGRD‘
                              LS_TAB-BELNR.
perform bdc_dynpro      using ‘SAPMF05A‘ ‘0105‘.
perform bdc_field       using ‘BDC_OKCODE‘
                              ‘/ERW‘.
perform bdc_field       using ‘BDC_CURSOR‘
                              ‘RF05A-BELNS‘.
perform bdc_dynpro      using ‘SAPLSPO1‘ ‘0200‘.
perform bdc_field       using ‘BDC_OKCODE‘                               
‘=YES‘.




ENDIF.
ENDLOOP.
if sy-subrc 0.   
MESSAGE ‘冲销成功‘ TYPE ‘I‘."如何添加字段信息在message里  “ 设置系统变量 并赋值变量SY-MSGV1   
ENDIF.
*  CALL TRANSACTION ‘FB08‘ USING BDCDATA
*      MODE ‘A‘ UPDATE ‘A‘
*      MESSAGES INTO LT_MSG.

ENDFORM.



FORM BDC_field USING fnam fval.
*  *  DATA NODATA TYPE CHAR01 VALUE ‘/‘.
*  IF FVAL <> NODATA.   

clear bdcdata.   bdcdata
-fnam = fnam.   bdcdata
-fval = fval.   
APPEND bdcdata.
*  *  ENDIF.   
ENDFORM.   


form bdc_dynpro USING program dynpro.     
clear bdcdata.     bdcdata
-program program.     bdcdata
-dynpro dynpro.     bdcdata
-dynbegin ‘x‘.     
APPEND bdcdata.     
ENDFORM.

 

 

运行结果如下

技术分享

 

技术分享

技术分享

 

 

自定义屏幕

技术分享

 











































































































































































































































































































以上是关于注销凭证与自定义屏幕的主要内容,如果未能解决你的问题,请参考以下文章

Flutter:将命名路由与自定义页面路由构建器一起使用?

iPad的选股区域与自定义div覆盖冲突

控件架构与自定义控件详解 + ListView使用技巧 + Scroll分析

Android Facebook sdk 覆盖登录按钮

JSF 自定义复合组件与自定义经典组件有啥区别

NSMutableArray 与自定义对象?