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.