ALV报表——抓取工单长文

ABAP抓取工单长文

 

运行效果:

 

代码:

*&---------------------------------------------------------------------*
*& Report ZPPR9999
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZPPR9999.

TABLES: AFKO.
DATA : L_AUFNR          TYPE AUFNR.
DATA : L_TDOBNAME     TYPE TDOBNAME.
DATA: LT_LINES TYPE TABLE OF TLINE WITH HEADER LINE.
DATA:BEGIN OF GT_AFKO OCCURS 0,
  AUFNR LIKE AFKO-AUFNR,
  TEXT    TYPE STRING,
END OF GT_AFKO.


TYPE-POOLS: SLIS.
DATA: GS_LAYOUT     TYPE SLIS_LAYOUT_ALV,
          GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

SELECT-OPTIONS: S_AUFNR FOR AFKO-AUFNR.

START-OF-SELECTION.

     PERFORM GET_DATA.
     PERFORM ALV_SHOW.
END-OF-SELECTION.

FORM GET_DATA.
  DATA : L_INDEX LIKE SY-TABIX.

  SELECT AUFNR INTO CORRESPONDING FIELDS OF TABLE GT_AFKO
             FROM AFKO
             WHERE AUFNR IN S_AUFNR.

  LOOP AT GT_AFKO.
     L_INDEX = SY-TABIX.

     L_AUFNR = GT_AFKO-AUFNR.
     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
         INPUT         = L_AUFNR
       IMPORTING
         OUTPUT        = L_AUFNR.

     CONCATENATE SY-MANDT L_AUFNR INTO L_TDOBNAME.          .

     CALL FUNCTION 'READ_TEXT'
       EXPORTING
*        CLIENT                        = SY-MANDT
         ID                            = 'KOPF'
         LANGUAGE                      = SY-LANGU
         NAME                          = L_TDOBNAME
         OBJECT                        =  'AUFK'
*        ARCHIVE_HANDLE                = 0
*        LOCAL_CAT                     = ' '
*      IMPORTING
*        HEADER                        =
*        OLD_LINE_COUNTER              =
       TABLES
         LINES                         = LT_LINES[]
       EXCEPTIONS
         ID                            = 1
         LANGUAGE                      = 2
         NAME                          = 3
         NOT_FOUND                     = 4
         OBJECT                        = 5
         REFERENCE_CHECK               = 6
         WRONG_ACCESS_TO_ARCHIVE       = 7
         OTHERS                        = 8.

         LOOP AT LT_LINES.
           CONCATENATE GT_AFKO-TEXT LT_LINES-TDLINE
                 INTO GT_AFKO-TEXT.
         ENDLOOP.
         CLEAR LT_LINES[].

         MODIFY GT_AFKO INDEX L_INDEX.
  ENDLOOP.
ENDFORM.

FORM ALV_SHOW .

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = SY-CPROG
      I_INTERNAL_TABNAME     = 'GT_AFKO'
      I_CLIENT_NEVER_DISPLAY = 'X'
      I_INCLNAME             = SY-CPROG
    CHANGING
      CT_FIELDCAT            = GT_FIELDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.

    DELETE GT_FIELDCAT WHERE FIELDNAME = 'SEL'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      IS_LAYOUT                = GS_LAYOUT
      IT_FIELDCAT              = GT_FIELDCAT[]
      I_SAVE                   = 'A'
    TABLES
      T_OUTTAB                 =  gt_afko
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.

ENDFORM.

  

 

转载于:https://www.cnblogs.com/StephenAmell/p/9010666.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值