ABAP DMEO 通过工单号读取内部对象号

*&---------------------------------------------------------------------*
*& Report  YDEMO_013
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YDEMO_013 MESSAGE-ID ZTEST_001.

TABLES:AUFK.
DATA:LT_STATUS LIKE TABLE OF JSTAT WITH HEADER LINE.

DATA:GS_LAYOUT TYPE LVC_S_LAYO.
*PARAMETERS:P_CLIENT LIKE
PARAMETERS:P_AUFNR LIKE AFKO-AUFNR,
           P_OBJNR LIKE JSTO-OBJNR,
           P_ONLY  LIKE JEST-INACT.

PARAMETERS:RB_01 RADIOBUTTON GROUP G1 DEFAULT 'X',
           RB_02 RADIOBUTTON GROUP G1.


PARAMETERS:P_OBTYP LIKE JSTO-OBTYP,
           P_STSMA LIKE JSTO-STSMA,
           P_STONR LIKE TJ30-STONR.

INITIALIZATION.

*IF

START-OF-SELECTION.
  SELECT SINGLE OBJNR INTO P_OBJNR
    FROM AUFK
   WHERE AUFNR = P_AUFNR.
  IF SY-SUBRC NE 0.

    MESSAGE I002."WITH '没有找到对象号!'.
    CALL TRANSACTION 'ABAPDOCU'.
    STOP.

  ELSE.
    CLEAR:LT_STATUS,LT_STATUS[].
    CALL FUNCTION 'STATUS_READ'
      EXPORTING
*   CLIENT                 = SY-MANDT
        OBJNR                  = P_OBJNR
*   ONLY_ACTIVE            = ' '
     IMPORTING
       OBTYP                  = P_OBTYP
       STSMA                  = P_STSMA
       STONR                  = P_STONR
     TABLES
       STATUS                 = LT_STATUS
* EXCEPTIONS
*   OBJECT_NOT_FOUND       = 1
*   OTHERS                 = 2
              .
    IF SY-SUBRC <> 0.
* Implement suitable error handling here
    ENDIF.
  ENDIF.

  IF RB_02 EQ 'X'.
    LOOP AT LT_STATUS.
      WRITE:/(10) LT_STATUS-STAT,
            (20) LT_STATUS-INACT.
    ENDLOOP.

  ELSE.

    GS_LAYOUT-CWIDTH_OPT   = 'X'.
    GS_LAYOUT-SEL_MODE     = 'A'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        I_STRUCTURE_NAME         = 'JSTAT'
        I_CALLBACK_PROGRAM       = SY-REPID
        I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
        I_CALLBACK_USER_COMMAND  = 'ALV_USER_COMMAND'
*       IS_LAYOUT_LVC            = GS_LAYOUT
      TABLES
        T_OUTTAB                 = LT_STATUS.


  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  SET_PF_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM SET_PF_STATUS USING UT_EXCLUDE TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'ALV_STATUS'.
ENDFORM.                    "SET_PF_STATUS

*&---------------------------------------------------------------------*
*&      Form  ALV_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM ALV_USER_COMMAND USING UV_UCOMM TYPE SYUCOMM US_SELFIELD TYPE SLIS_SELFIELD.
  DATA:LO_GRID TYPE REF TO CL_GUI_ALV_GRID.
  CASE UV_UCOMM.
    WHEN 'ADD'.
      INSERT INITIAL LINE INTO LT_STATUS INDEX 1.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          E_GRID = LO_GRID.
      CALL METHOD LO_GRID->REFRESH_TABLE_DISPLAY .

    WHEN 'EXIT'.
      LEAVE TO LIST-PROCESSING.

    WHEN '&F03' OR '&F12' OR '&F15'.
      LEAVE TO SCREEN 0.

    WHEN OTHERS.
  ENDCASE.
ENDFORM.                    "ALV_USER_COMMAND

 

上一篇:Global variable in ABAP function group


下一篇:NC6.5总账凭证与辅助的数据表关系