类似IW32挂附件的方法实现(此文章将几个INCLUDE及其SCREEN都放到了一起)

*&---------------------------------------------------------------------*
*& Module pool       Z_TEST_ATTACHMENT2                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  最重要的是move 'BUS2012'     to is_object-OBJTYPE.                                                                   *
*&   BUS2012这个参数决定了附件是在采购订单还是在工单上                                                                  *
*&---------------------------------------------------------------------*

PROGRAM  Z_TEST_ATTACHMENT2                      .

INCLUDE Z_ATTACHMENT2_PBO.

INCLUDE Z_ATTACHMENT2_PAI.

INCLUDE Z_ATTACHMENT2_SUB_INC.

 

*----------------------------------------------------------------------*
***INCLUDE Z_ATTACHMENT2_PAI .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
  CASE SY-UCOMM.
    WHEN 'CREATE'.
      PERFORM FRM_CREATE_ATTACHMENT.
    WHEN 'DISPLAY'.
      PERFORM FRM_DISPLAY_ATTACMENT.
    WHEN OTHERS.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_EXIT INPUT.
  CASE SY-UCOMM.
    WHEN 'BACK' OR '&EX' OR 'RW'.
      LEAVE PROGRAM.
    WHEN OTHERS.
      LEAVE PROGRAM.
  ENDCASE.

ENDMODULE.                 " USER_EXIT  INPUT

 

*----------------------------------------------------------------------*
***INCLUDE Z_ATTACHMENT2_PBO .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
  SET PF-STATUS 'STATUS_9000'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_9000  OUTPUT

 

*----------------------------------------------------------------------*
***INCLUDE Z_ATTACHMENT2_SUB_INC .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  FRM_CREATE_ATTACHMENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CREATE_ATTACHMENT .

*SRGBTBREL,此数据库表用来取得有几张附件

  data :
  IP_SERVICE TYPE  SGS_SRVNAM,
  IS_OBJECT TYPE  BORIDENT,
  IP_NO_COMMIT TYPE  SGS_CMODE,
  IP_POPUP TYPE  SGS_CMODE,
  IP_RWMOD TYPE  SGS_RWMOD ,
  IT_SERVICE_SELECTION  TYPE  TGOS_SELS .

  move 'PCATTA_CREA' to ip_service.
  move '4500015390'  to is_object-OBJKEY.
  move 'BUS2012'     to is_object-OBJTYPE.
  move 'E'           to ip_rwmod.

  CALL FUNCTION 'GOS_EXECUTE_SERVICE'
    EXPORTING
      IP_SERVICE                 = ip_service
      IS_OBJECT                  = is_object
      IP_NO_COMMIT               = space
      IP_POPUP                   = space
      IP_RWMOD                   = ip_rwmod
*      IT_SERVICE_SELECTION       =
*    IMPORTING
*      EP_EVENT                   =
*      EP_STATUS                  =
*      EP_ICON                    =
    EXCEPTIONS
      EXECUTION_FAILED           = 1
      OTHERS                     = 2
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*  DATA ls_service TYPE sgos_modl.
*  DATA lp_name TYPE sgs_srvnam.
*  data lp_function type ui_func.
*  DATA lp_answer TYPE sgs_flag.
*  DATA lo_container TYPE REF TO cl_gui_container.
*  DATA lp_return TYPE i.
*  CLASS cl_gui_cfw DEFINITION LOAD.
*
*  CALL METHOD go_model->get_service_by_name
*    EXPORTING
*      ip_service_name = 'PCATTA_CREA'
*    IMPORTING
*      es_service      = ls_service.
*  ls_service-function = lp_function.
*  CALL METHOD me->dispatch_service
*    EXPORTING
*      io_container      = lo_container
*      is_service        = ls_service
*    EXCEPTIONS
*      execution_failed  = 1
*      container_ignored = 2
*      OTHERS            = 3.
*  IF sy-subrc <> 0.
*    CASE sy-subrc.
*      WHEN 2.
*      WHEN OTHERS.
*        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*    ENDCASE.

ENDFORM.                    " FRM_CREATE_ATTACHMENT
*&---------------------------------------------------------------------*
*&      Form  FRM_DISPLAY_ATTACMENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_DISPLAY_ATTACMENT .
  data :
  IP_SERVICE TYPE  SGS_SRVNAM,
  IS_OBJECT TYPE  BORIDENT,
  IP_NO_COMMIT TYPE  SGS_CMODE,
  IP_POPUP TYPE  SGS_CMODE,
  IP_RWMOD TYPE  SGS_RWMOD ,
  IT_SERVICE_SELECTION  TYPE  TGOS_SELS .

  move 'VIEW_ATTA' to ip_service.
  move '4500015390'  to is_object-OBJKEY.
  move 'BUS2012'     to is_object-OBJTYPE.
  move 'E'           to ip_rwmod.

  CALL FUNCTION 'GOS_EXECUTE_SERVICE'
    EXPORTING
      IP_SERVICE                 = ip_service
      IS_OBJECT                  = is_object
      IP_NO_COMMIT               = space
      IP_POPUP                   = space
      IP_RWMOD                   = ip_rwmod
*      IT_SERVICE_SELECTION       =
*    IMPORTING
*      EP_EVENT                   =
*      EP_STATUS                  =
*      EP_ICON                    =
    EXCEPTIONS
      EXECUTION_FAILED           = 1
      OTHERS                     = 2
            .
  IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " FRM_DISPLAY_ATTACMENT


 

****************************************************************                                
*   THIS FILE IS GENERATED BY THE SCREEN PAINTER.              *                                
*   NEVER CHANGE IT MANUALLY, PLEASE !                         *                                
****************************************************************                                
%_DYNPRO                                
Z_TEST_ATTACHMENT2                                
9000                                
700                                
             40                                
%_HEADER                                
Z_TEST_ATTACHMENT2                      9000 9000      0  0192 37  0  0 27120  0G 1                              20120510141737                                
%_DESCRIPTION                                
t                                
%_FIELDS                                
  CHAR  20 80 10 00 00 00 255   1 O   0   0   0    0       0   0        ____________________  
%_FLOWLOGIC                                
                                
PROCESS BEFORE OUTPUT.                                
  MODULE STATUS_9000.                                
*                                
PROCESS AFTER INPUT.                                
  MODULE USER_COMMAND_9000.                                
  MODULE USER_EXIT AT EXIT-COMMAND.                                
%_PARAMS                                
                                

你可能感兴趣的:(类似IW32挂附件的方法实现(此文章将几个INCLUDE及其SCREEN都放到了一起))