抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

在使用BDC录屏的过程中,查了一些资料。发现了一些有意思的东西,比如现在常用的Call Transaction的优缺点和BDC Insert等。BDC在文件服务器上生成的日志文件等操作。现将其记录如下。

SAP BDC批量导入数据

一、BDC简介

BDC即Batch Data Conversion。当我们需要大量并且重复的输入保存变更删除数据的操作,且没有对应的BAPI可以使用的时候,可以使用BDC的方式进行。但是如果有可以使用的BAPI的话,则建议优先使用BAPI进行操作。因为BAPI的效率相较于BDC会高一些。

但是BDC相较于LSMW、CATT等其他数据传输方式要更加灵活。

二、创建BDC录屏

本次为了和下面BDC日志的优化相匹配,所以从事务码SM35开始介绍。

1.事务码SM35

SM35事务码是列出了所有通过BDC所执行的会话记录。

1.事务码SM35界面

点击上面红色框圈中的记录按钮,会进入事务码SHDB的界面。

2.事务码SHDB

点击新建记录按钮,创建BDC录屏。本次使用事务码MM02进行录屏。

2.事务码SHDB界面

3.创建录屏

在事务码处填入需要录制的TCODE。在记录处填写本次录屏的名称。

3.创建录屏界面

4.事务码选择屏幕

填入资产子编号公司代码字段的值,然后按回车键。进入资产维护界面。

4.AS02选择屏幕 5.MM02选择视图

5.修改物料描述

修改完资产描述字段和资产主号文本字段值后点击保存按钮。

5.AS02修改资产描述

6.生成事务记录

点击完保存按钮后,系统会将你刚刚的操作生成记录。如下图所示,从上到下是操作的顺序和输入的字段值。

6.记录生成界面
  • 字段名称:屏幕操作中所具体对应的动作。
    • BDC_CURSOR:当你点击某一个字段或或部分按钮时,对应的字段名称。
    • BDC_OKCODE:当你触发PAI相关的事件之后,会在字段名称列显示该名称。
    • BDC_SUBSCR:当你点击某一个页签或切换屏幕时会显示该字段名称,因为该字段名称指代的就是屏幕号字段。
  • 字段指:字段名所对应的参数内容,如按钮的命令、输入框的值等。
7.记录字段说明

确认完生成的记录没有问题之后,点击最上面工具栏中的保存按钮。保存记录流程。

三、生成批量导入程序

1.生成批量导入程序

点击返回按钮,进入到当前BDC录屏的界面。点击上面的程序按钮,可以生成BDC批量导入数据的程序。

8.生成批导程序设置界面
  • 从文件中读取:表示测试数据来自于SAP服务器上的文件。
  • 从记录中传输:表示测试数据来自内存中,比如内表或数据库表等。
  • 测试数据:如果需要生成测试数据文件,则需要设定文件名,将会在服务器上的系统用户文件路径中创建一个数据集文件用于保存测试数据。

点击对勾按钮,设置程序属性。设置完成后点击源代码按钮,既可以查看和修改生成的BDC批导程序代码。

10.程序属性设置

2.生成的核心代码

直接生成好的程序还是需要我们再手动对其进行修改,以满足不同的需求。

下面展示一下批导程序中的核心逻辑部分。下图所示的部分就是BDC批导的操作流程,将这些流程全部封装到一个内表中,然后在最后调用事务码,事务码就会按照单步BDC的操作流程对内表中封装的数据进行操作。

11.批导程序核心逻辑

3.批导代码讲解

(1)BDC_DYNPRO

① 含义

PERFORM BDC_DYNPRO USING ‘SAPLMGMM’ ‘0060’.

定位到当前屏幕SAPLMGMM程序的 0600 Screen

②源码
1
2
3
4
5
6
7
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.

(2)BDC_FIELD

① 含义

PERFORM BDC_FIELD USING ‘BDC_CURSOR’ ‘RMMG1-MATNR’.

将光标移动到RMMG1-MATNR输入框中。


PERFORM BDC_FIELD USING ‘BDC_OKCODE’ ‘=ENTR’.

触发按钮逻辑,按钮事件的Function Code值为 =ENTR(回车)。


PERFORM BDC_FIELD USING ‘RMMG1-MATNR’ RECORD-MATNR_001.

在输入框名称为RMMG1-MATNR的屏幕字段中填入RECORD-MATNR_001的变量值。

② 源码
1
2
3
4
5
6
7
8
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.

(3)CALL TRANSACTION TCODE

下面的内容是我从这篇SAP ABAP BDC 的使用及代码详解内容里面摘抄过来的,这篇笔记的BDC写的很清楚易懂。

1
2
3
4
CALL TRANSACTION TCODE    				          (调用的事务码)
USING BDCDATA (创建好的BDC录屏数据 TYPE BDCDATA)
OPTIONGS FROM OPTION (调用选项 TYPE CTU_PARAMS)
MESSAGE INTO MESSTAB. (成功与否的消息 TYPE BDCMSGCOLL)

上面的结构体变量OPTION封装了MODE和其他属性。下面对其进行简单介绍。

1
2
3
4
OPTION TYPE CTU_PARAMS
-DISMODE (E:有错误是跳转前台; A:一直前台执行; N:均后台执行)
-UPDMODE(A:异步; S: 同步; L:Local Update)
-RACOMMIT (后台遇到commit work代码时是否结束BDC ,赋值为X时不结束。此处在实际业务中经常碰到问题,注意此参数设置)

后续可以使用下面的Function来判断执行的结果是否成功。

1
2
3
4
5
CALL FUNCTION 'CONERT_BDCMESGCALL_TO_BAPIRET2'
TABLES
IMT_BDC_MESGCOLL = lt_mes
EXT_RETURN = lt_return
根据lt_return的值判断是否执行成功

(4)CALL FUNCTION ‘BDC_INSERT’

这是一种不直接运行,而是将BDC程序生成session,但不立即运行,需要手工或通过RSBDCSUB专用程序来运行会话。优点是通过T-code SM35可以进行运行管理及日志管理,方便查错。缺点是相对上面的方法来说实现起来比较繁琐。

该方法的使用流程如下:

  • 需要在程序中调用 function ‘BDC_INSERT’来把BDCDATA生成SESSION。
  • 通过程序RSBDCSUB来执行SESSION(后续建立JOB中使用,目前手动运行会话)
  • 建立BATCH JOB来定期执行RSBDCSUB,从而实现SESSION自动执行的目的

当然,不使用程序RSBDCSUB和JOB,每次手工在SM35中执行SESSION也是可以的。

1
2
3
4
5
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM02'
TABLES
DYNPROTAB = GT_BDCDATA.

4.程序运行界面

18.程序运行界面

四、BDC测试文件

1.文件监视器

在前面创建程序时选择了生成测试文件,详见上面的生成批量导入程序中的图片。生成这些文件之后可以对这些文件进行操作。

在SM35的界面点击Recoding或记录按钮,进入SHDB的界面(也可以直接使用事务码SHDB直接进入对应界面)。然后在最上面的Menu按钮中点击转到–>文件监视器打开文件路径列表。

12.寻找文件监视器

2.测试文件路径

SAP会为每个文件夹存放的路径定义一个“目录参数的名称”,如用户所创建的文件存放在SAP应用服务器的“DIR_SAPUSERS”下。

13.文件存放路径

双击可以查看到该文件下的所有文件,比如本次创建的测试数据文件 MM02_BDCLOG_CYH

14.测试数据文件目录

双击进入查看测试文件中测试数据的内容。

15.测试数据文件内容

3.下载测试文件到本地

使用事务码CG3Y,将本次的测试文件下载到本地。

16.下载测试文件到本地

4.上传本地文件到服务器

使用事务码CG3Z,将在本地的测试文件上传到文件服务器。

17.上传测试文件到服务器

五、源码

1.全部代码

(1)Master Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
*&---------------------------------------------------------------------*
*& Report ZBDCMM02_CYH
*&---------------------------------------------------------------------*
*& Module / Submodule: ABAP / New Train
*&---------------------------------------------------------------------*
*T_CODE : N/A *
*CREATER : KF543 *
*CREATE ON : 2023.08.08 *
*TYPE : Report *
*Description : Two Call Methods for Modifying BDC in Material *
* Description *
************************************************************************
* Change History *
* -------- ---------- ------------- -----------------------------------*
* Version Date Change By Description *
* -------- ---------- ------------- -----------------------------------*
* N 2023.08.08 KF543 Creater *
************************************************************************
REPORT ZBDCMM02_CYH MESSAGE-ID ZMESCLA_CYH.

*----------------------------------------------------------------------*
* Include
*----------------------------------------------------------------------*
INCLUDE ZBDCMM02_CYH_TOP.
INCLUDE ZBDCMM02_CYH_SCR.
INCLUDE ZBDCMM02_CYH_CLA.
INCLUDE ZBDCMM02_CYH_PBO.
INCLUDE ZBDCMM02_CYH_PAI.
INCLUDE ZBDCMM02_CYH_F01.

*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.


*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN OUTPUT.


*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN.


*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH.
PERFORM SEARCH_HELP_FPATH CHANGING P_FPATH.

*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
"校验文件路径
PERFORM CHECK_FILE_PATH.
"获取Excel中的数据
PERFORM GET_EXCEL_DATA.
"校验上传的数据
PERFORM CHECK_UPLOAD_DATA.

*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
"调用BDC
PERFORM CALL_BDC.
"运行结果
PERFORM DISPLAY_RESULT.

(2)Include TOP 全局变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
*&---------------------------------------------------------------------*
*& 包含 ZBDCMM02_CYH_TOP
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Constants
*----------------------------------------------------------------------*
CONSTANTS:
GC_X TYPE C LENGTH 1 VALUE 'X',
GC_S TYPE C LENGTH 1 VALUE 'S',
GC_E TYPE C LENGTH 1 VALUE 'E',
GC_NULL TYPE C LENGTH 1 VALUE '',
GC_MM02 TYPE C LENGTH 4 VALUE 'MM02'.

*----------------------------------------------------------------------*
* Variables
*----------------------------------------------------------------------*
DATA:
GV_RUNFLAG TYPE C, "运行标记,只运行一次的标记
GV_MESSAGE TYPE C. "异常终止代码流程标记

*----------------------------------------------------------------------*
* Structure
*----------------------------------------------------------------------*
DATA:
BEGIN OF GS_TABLE, "存放修改数据的结构,与Excel中结构对应
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF GS_TABLE,
BEGIN OF GS_FMESG, "Session日志的Message结构
MART LIKE APQLE-MART,
MID LIKE APQLE-MID,
MNR LIKE APQLE-MNR,
MSGV1 LIKE APQLE-MSGV1,
MSGV2 LIKE APQLE-MSGV2,
MSGV3 LIKE APQLE-MSGV3,
MSGV4 LIKE APQLE-MSGV4,
END OF GS_FMESG.
DATA:
GS_BDCTAB TYPE BDCDATA, "存放有BDC操作的结构
GS_MESSAGE TYPE BDCMSGCOLL,"事务码调用返回的Message结构
GS_MESSAGEP TYPE ESP1_MESSAGE_WA_TYPE."最后弹框展示Message的结构

*----------------------------------------------------------------------*
* Internal Table
*----------------------------------------------------------------------*
DATA:
GT_BDCTAB TYPE TABLE OF BDCDATA,"存放有BDC操作的内表
GT_TABLE LIKE TABLE OF GS_TABLE,
GT_FMESG LIKE TABLE OF GS_FMESG,
GT_MESSAGE TYPE TABLE OF BDCMSGCOLL,
GT_MESSAGEP TYPE ESP1_MESSAGE_TAB_TYPE.

(3)Include SCR 选择屏幕

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
*&---------------------------------------------------------------------*
*& 包含 ZBDCMM02_CYH_SCR
*&---------------------------------------------------------------------*
"执行模式
SELECTION-SCREEN BEGIN OF BLOCK K01 WITH FRAME TITLE TEXT-T01.
SELECTION-SCREEN BEGIN OF LINE.
"执行模式:
PARAMETERS:
P_TEXT NO-DISPLAY.
SELECTION-SCREEN COMMENT 1(23) TEXT-001 FOR FIELD P_TEXT.

"调用事务码
SELECTION-SCREEN POSITION 32.
PARAMETERS:
P_TCODE RADIOBUTTON GROUP GR01 USER-COMMAND UC1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 34(23) TEXT-R01 FOR FIELD P_TCODE.

"调用Function
SELECTION-SCREEN POSITION 57.
PARAMETERS:
P_CFUNC RADIOBUTTON GROUP GR01 .
SELECTION-SCREEN COMMENT 59(20) TEXT-R02 FOR FIELD P_CFUNC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK K01.

"上传文件
SELECTION-SCREEN BEGIN OF BLOCK K02 WITH FRAME TITLE TEXT-T02.
PARAMETERS:
P_FPATH TYPE STRING.
SELECTION-SCREEN END OF BLOCK K02.

(4)Include F01 逻辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
*&---------------------------------------------------------------------*
*& 包含 ZBDCMM02_CYH_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form SEARCH_HELP_FPATH
*&---------------------------------------------------------------------*
*& text 获取文件上传路径
*&---------------------------------------------------------------------*
*& <-- P_FPATH
*&---------------------------------------------------------------------*
FORM SEARCH_HELP_FPATH CHANGING VALUE(PV_PATH) TYPE STRING.
*--------------------------Variables-----------------------------------*
DATA:
LV_DEF_PATH TYPE STRING,
LT_FILE_TABLE TYPE FILETABLE,
LV_RC TYPE I,
LV_ACTION TYPE I.
*----------------------------Logic-------------------------------------*
CLEAR GV_MESSAGE.
CL_GUI_FRONTEND_SERVICES=>DIRECTORY_GET_CURRENT(
CHANGING CURRENT_DIRECTORY = LV_DEF_PATH ).

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Upload File'
DEFAULT_EXTENSION = 'xls'
DEFAULT_FILENAME = 'Export'
FILE_FILTER = CL_GUI_FRONTEND_SERVICES=>FILETYPE_EXCEL
INITIAL_DIRECTORY = LV_DEF_PATH
CHANGING
FILE_TABLE = LT_FILE_TABLE
RC = LV_RC
USER_ACTION = LV_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
"Error when uploading the document
MESSAGE TEXT-E01 TYPE GC_S DISPLAY LIKE GC_E.
GV_MESSAGE = GC_X.
EXIT.
ENDIF.

"用户取消上传操作
IF LV_ACTION = CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL.
GV_MESSAGE = GC_X.
EXIT.
ENDIF.

CHECK LT_FILE_TABLE IS NOT INITIAL.
READ TABLE LT_FILE_TABLE INTO DATA(LS_FILE) INDEX 1.
CHECK SY-SUBRC EQ 0.
IF STRLEN( LS_FILE ) GE 128.
"The lengtn of file path should be less than 128.
"文件路径长度不可大于128
MESSAGE TEXT-E02 TYPE GC_S DISPLAY LIKE GC_E.
ELSE.
PV_PATH = LS_FILE.
TRANSLATE PV_PATH TO UPPER CASE.
ENDIF.

FREE: LT_FILE_TABLE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_FILE_PATH
*&---------------------------------------------------------------------*
*& text 校验上传文件路径或文件格式
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CHECK_FILE_PATH .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_DROP TYPE C LENGTH 1 VALUE '.',
LC_XLS TYPE C LENGTH 3 VALUE 'XLS',
LC_XLSX TYPE C LENGTH 4 VALUE 'XLSX'.
DATA:
LV_LINES TYPE I,
LV_FTYPE TYPE STRING,
LT_FTYPE TYPE TABLE OF STRING.
*----------------------------Logic-------------------------------------*
"根据点区分文件类型
SPLIT P_FPATH AT LC_DROP INTO TABLE LT_FTYPE.
"获取最后一行数据Index
LV_LINES = LINES( LT_FTYPE ).
"获取文件类型
READ TABLE LT_FTYPE INTO LV_FTYPE INDEX LV_LINES.
IF SY-SUBRC EQ 0.
IF LV_FTYPE NE LC_XLS AND
LV_FTYPE NE LC_XLSX.
"上传文件类型异常
MESSAGE S000 WITH TEXT-E01 DISPLAY LIKE GC_E.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
FREE: LT_FTYPE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_EXCEL_DATA
*&---------------------------------------------------------------------*
*& text 获取Excel中的数据,并调用格式转换Function转换物料编号格式
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM GET_EXCEL_DATA .
*--------------------------Variables-----------------------------------*
DATA:
LV_PATH TYPE RLGRAP-FILENAME,
LT_DATA LIKE GT_TABLE,
LT_ROWTAB TYPE TRUXS_T_TEXT_DATA.
*----------------------------Logic-------------------------------------*
REFRESH: GT_TABLE.

LV_PATH = P_FPATH.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = GC_X
I_TAB_RAW_DATA = LT_ROWTAB
I_FILENAME = LV_PATH
TABLES
I_TAB_CONVERTED_DATA = LT_DATA
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
"获取Excel数据失败
MESSAGE S000 WITH TEXT-E02 DISPLAY LIKE GC_E.
ENDIF.

DELETE ADJACENT DUPLICATES FROM LT_DATA COMPARING MATNR.
LOOP AT LT_DATA INTO DATA(LS_DATA).
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = LS_DATA-MATNR
IMPORTING
OUTPUT = LS_DATA-MATNR
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2.
CLEAR: LS_DATA.
ENDLOOP.
MOVE-CORRESPONDING LT_DATA TO GT_TABLE.
FREE: LT_ROWTAB,LT_DATA.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& text 对上传的数据进行校验,本次为了查看Error信息内容就不写了
*& 但是为了提醒这一步在上传过程中不能省略所以留一个空Form
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CHECK_UPLOAD_DATA .
*--------------------------Variables-----------------------------------*

*----------------------------Logic-------------------------------------*

ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALL_BDC
*&---------------------------------------------------------------------*
*& text 编写批量操作流程与数据
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CALL_BDC .
REFRESH:GT_MESSAGEP.

IF P_CFUNC IS NOT INITIAL.
PERFORM OPEN_GROUP.
ENDIF.

"填充BDC数据
LOOP AT GT_TABLE INTO GS_TABLE.
REFRESH: GT_BDCTAB,GT_MESSAGE.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
GS_TABLE-MATNR.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(02)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4004'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
GS_TABLE-MAKTX.

"根据选择调用合适的事务码
CASE GC_X.
WHEN P_TCODE.
"事务码形式调用
PERFORM CALL_TRANSACTION_CODE.
WHEN P_CFUNC.
"Session形式调用
PERFORM CALL_FUNCTION.
WHEN OTHERS.
ENDCASE.

CLEAR: GS_TABLE.
ENDLOOP.

IF P_CFUNC IS NOT INITIAL.
PERFORM CLOSE_GROUP.
PERFORM RUN_SESSION.
PERFORM GET_SESSION_STATE.
PERFORM SET_MESSAGE_VALUE.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR GS_BDCTAB.
GS_BDCTAB-PROGRAM = PROGRAM.
GS_BDCTAB-DYNPRO = DYNPRO.
GS_BDCTAB-DYNBEGIN = 'X'.
APPEND GS_BDCTAB TO GT_BDCTAB.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR GS_BDCTAB.
GS_BDCTAB-FNAM = FNAM.
GS_BDCTAB-FVAL = FVAL.
APPEND GS_BDCTAB TO GT_BDCTAB.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALL_TRANSACTION_CODE
*&---------------------------------------------------------------------*
*& text 通过调用事务码形式,执行批量操作
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CALL_TRANSACTION_CODE .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_A TYPE C LENGTH 1 VALUE 'A',
LC_N TYPE C LENGTH 1 VALUE 'N'.
DATA:
LS_OPTION TYPE CTU_PARAMS.
*----------------------------Logic-------------------------------------*
"DISMODE (E:有错误是跳转前台; A:一直前台执行; N:均后台执行)
"UPDMODE(A:异步; S: 同步; L:Local Update)
"RACOMMIT (后台遇到commit work代码时是否结束BDC ,赋值为X时不结束。此处在实际业务中经常碰到问题,注意此参数设置)
"设置属性
LS_OPTION-DISMODE = LC_N.
LS_OPTION-UPDMODE = LC_A.
LS_OPTION-RACOMMIT = GC_X.

CALL TRANSACTION GC_MM02
USING GT_BDCTAB
OPTIONS FROM LS_OPTION
MESSAGES INTO GT_MESSAGE.
IF SY-SUBRC NE 0.
"BDC调用失败
MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E.
* EXIT.
ENDIF.

LOOP AT GT_MESSAGE INTO GS_MESSAGE.
GS_MESSAGEP-LINENO = SY-TABIX.
GS_MESSAGEP-MSGID = GS_MESSAGE-MSGID.
GS_MESSAGEP-MSGNO = GS_MESSAGE-MSGNR.
GS_MESSAGEP-MSGTY = GS_MESSAGE-MSGTYP.
GS_MESSAGEP-MSGV1 = GS_MESSAGE-MSGV1.
GS_MESSAGEP-MSGV2 = GS_MESSAGE-MSGV2.
GS_MESSAGEP-MSGV3 = GS_MESSAGE-MSGV3.
GS_MESSAGEP-MSGV4 = GS_MESSAGE-MSGV4.

APPEND GS_MESSAGEP TO GT_MESSAGEP.
CLEAR: GS_MESSAGE,GS_MESSAGEP.
ENDLOOP.
* SORT GT_MESSAGE BY MSGTYP.
* READ TABLE GT_MESSAGE INTO GS_MESSAGE WITH KEY MSGTYP = GC_E.
* IF SY-SUBRC EQ 0.
* MESSAGE ID GS_MESSAGE-MSGID TYPE GC_S NUMBER GS_MESSAGE-MSGNR
* WITH GS_MESSAGE-MSGV1 GS_MESSAGE-MSGV2
* GS_MESSAGE-MSGV3 GS_MESSAGE-MSGV4
* DISPLAY LIKE GC_E.
* ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALL_FUNCTION
*&---------------------------------------------------------------------*
*& text 在批量输入会话中插入批量输入事务
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CALL_FUNCTION .
*--------------------------Variables-----------------------------------*
DATA:
LV_TCODE TYPE TSTC-TCODE.
*----------------------------Logic-------------------------------------*
LV_TCODE = GC_MM02.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = LV_TCODE
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = GT_BDCTAB
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
"BDC调用失败
MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E.
EXIT.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_RESULT
*&---------------------------------------------------------------------*
*& text 弹框显示最后的运行结果
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM DISPLAY_RESULT .
CHECK GT_MESSAGEP IS NOT INITIAL.
CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
TABLES
I_MESSAGE_TAB = GT_MESSAGEP.
FREE: GT_MESSAGEP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
*& text 打开批量输入会话
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM OPEN_GROUP .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
DATA:
LV_HOLDDATE TYPE SY-DATUM,
LV_USER TYPE C LENGTH 12.
*----------------------------Logic-------------------------------------*
LV_USER = SY-UNAME.
* LV_HOLDDATE = SY-DATUM.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LC_GROUP
HOLDDATE = LV_HOLDDATE
"' '=Delete,'X'=keep after processing
KEEP = GC_X
USER = LV_USER
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
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.
*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
*& text 关闭批量输入会话
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
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.
*&---------------------------------------------------------------------*
*& Form RUN_SESSION
*&---------------------------------------------------------------------*
*& text 调用RSBDCSUB执行Session进程
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM RUN_SESSION .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
*----------------------------Logic-------------------------------------*
SUBMIT RSBDCSUB WITH MAPPE EQ LC_GROUP
WITH VON EQ SY-DATUM
WITH BIS EQ SY-DATUM
WITH FEHLER EQ '.'
EXPORTING LIST TO MEMORY
AND RETURN.
WAIT UP TO 5 SECONDS.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_SESSION_STATE
*&---------------------------------------------------------------------*
*& text 从数据库表中获取Session日志信息
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM GET_SESSION_STATE .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
*----------------------------Logic-------------------------------------*
REFRESH:GT_FMESG.
SELECT MAX( M~CREDATE ) AS CREDATE, MAX( M~CRETIME ) AS CRETIME,
I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4
FROM APQI AS M
INNER JOIN APQLE AS I
ON M~QID = I~QID
INTO CORRESPONDING FIELDS OF TABLE @GT_FMESG
WHERE M~GROUPID = @LC_GROUP
AND I~TCODE = @GC_MM02
AND I~MID <> @GC_NULL
GROUP BY I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4.
IF SY-SUBRC NE 0.
"Session尚未运行完成,请等待
MESSAGE S000 WITH TEXT-E04 DISPLAY LIKE GC_E.
IF GV_RUNFLAG IS INITIAL.
GV_RUNFLAG = GC_X."仅执行一次的标记
WAIT UP TO 5 SECONDS.
PERFORM GET_SESSION_STATE.
ELSE.
"Session运行异常
MESSAGE S000 WITH TEXT-E05 DISPLAY LIKE GC_E.
EXIT.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_MESSAGE_VALUE
*&---------------------------------------------------------------------*
*& text 将Session日志中的Message信息更新到弹框Message的内表中
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM SET_MESSAGE_VALUE .
CHECK GT_FMESG IS NOT INITIAL.
REFRESH: GT_MESSAGEP.
CLEAR: GS_MESSAGEP,GS_FMESG.
LOOP AT GT_FMESG INTO GS_FMESG.
GS_MESSAGEP-LINENO = SY-TABIX.
GS_MESSAGEP-MSGID = GS_FMESG-MID.
GS_MESSAGEP-MSGNO = GS_FMESG-MNR.
GS_MESSAGEP-MSGTY = GS_FMESG-MART.
GS_MESSAGEP-MSGV1 = GS_FMESG-MSGV1.
GS_MESSAGEP-MSGV2 = GS_FMESG-MSGV2.
GS_MESSAGEP-MSGV3 = GS_FMESG-MSGV3.
GS_MESSAGEP-MSGV4 = GS_FMESG-MSGV4.
INSERT GS_MESSAGEP INTO TABLE GT_MESSAGEP.
CLEAR: GS_FMESG,GS_MESSAGEP.
ENDLOOP.

FREE: GT_FMESG.
ENDFORM.

2.事务码调用

虽然上面已经给出过所有的代码了,但是此处再单独将事务码调用的代码单独提出来。方便阅读。通过这种形式执行BDC操作十分简便,但是如果想要将在执行的日志信息记录下来的话则需要自己再新建一个日志表,将执行的结果存放到日志表中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
*&---------------------------------------------------------------------*
*& Form CALL_TRANSACTION_CODE
*&---------------------------------------------------------------------*
*& text 通过调用事务码形式,执行批量操作
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CALL_TRANSACTION_CODE .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_A TYPE C LENGTH 1 VALUE 'A',
LC_N TYPE C LENGTH 1 VALUE 'N'.
DATA:
LS_OPTION TYPE CTU_PARAMS.
*----------------------------Logic-------------------------------------*
"DISMODE (E:有错误是跳转前台; A:一直前台执行; N:均后台执行)
"UPDMODE(A:异步; S: 同步; L:Local Update)
"RACOMMIT (后台遇到commit work代码时是否结束BDC ,赋值为X时不结束。此处在实际业务中经常碰到问题,注意此参数设置)
"设置属性
LS_OPTION-DISMODE = LC_N.
LS_OPTION-UPDMODE = LC_A.
LS_OPTION-RACOMMIT = GC_X.

CALL TRANSACTION GC_MM02
USING GT_BDCTAB
OPTIONS FROM LS_OPTION
MESSAGES INTO GT_MESSAGE.
IF SY-SUBRC NE 0.
"BDC调用失败
MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E.
* EXIT.
ENDIF.

LOOP AT GT_MESSAGE INTO GS_MESSAGE.
GS_MESSAGEP-LINENO = SY-TABIX.
GS_MESSAGEP-MSGID = GS_MESSAGE-MSGID.
GS_MESSAGEP-MSGNO = GS_MESSAGE-MSGNR.
GS_MESSAGEP-MSGTY = GS_MESSAGE-MSGTYP.
GS_MESSAGEP-MSGV1 = GS_MESSAGE-MSGV1.
GS_MESSAGEP-MSGV2 = GS_MESSAGE-MSGV2.
GS_MESSAGEP-MSGV3 = GS_MESSAGE-MSGV3.
GS_MESSAGEP-MSGV4 = GS_MESSAGE-MSGV4.

APPEND GS_MESSAGEP TO GT_MESSAGEP.
CLEAR: GS_MESSAGE,GS_MESSAGEP.
ENDLOOP.
ENDFORM.

3.通过Session执行

本方式的执行过程较为复杂和麻烦,但是优点则是可以制作成一个后台JOB程序定时进行批量操作。他们的日志信息会被存入数据库表APQIAPQLE中。之后可以通过这两个表将日志信息读取出来。或者也可以直接使用事务码SM35去Session界面查看日志信息,如下图所示。

20.SM35 Session界面

选择要查看的Session信息,然后按照下图所示的内容选择,即可查看到当前Session的日志信息。

21.Session日志界面

下面介绍一下通过Session调用和执行的逻辑添加位置。下图中红框圈出来的就是通过Session调用的代码逻辑。流程是需要先打开批量输入会话 -> 调用BDC_INSERT Function 在批量输入会话中插入批量输入事务 -> 关闭批量输入会话 -> 调用RSBDCSUB程序运行Session(不运行Session的话就一直是一个进程) -> 从数据库中查询Session日志信息 -> 将Session的日志信息放入弹框Message内表中。

19.Session逻辑截图

(1)打开批量输入会话

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FORM OPEN_GROUP .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
DATA:
LV_HOLDDATE TYPE SY-DATUM,
LV_USER TYPE C LENGTH 12.
*----------------------------Logic-------------------------------------*
LV_USER = SY-UNAME.
* LV_HOLDDATE = SY-DATUM.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LC_GROUP
HOLDDATE = LV_HOLDDATE
"' '=Delete,'X'=keep after processing
KEEP = GC_X
USER = LV_USER
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
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.

(2)在批量输入会话中插入批量输入事务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
FORM CALL_FUNCTION .
*--------------------------Variables-----------------------------------*
DATA:
LV_TCODE TYPE TSTC-TCODE.
*----------------------------Logic-------------------------------------*
LV_TCODE = GC_MM02.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = LV_TCODE
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = GT_BDCTAB
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
"BDC调用失败
MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E.
EXIT.
ENDIF.

ENDFORM.

(3)关闭批量输入会话

1
2
3
4
5
6
7
8
9
10
11
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
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.

(4)调用RSBDCSUB程序运行Session

1
2
3
4
5
6
7
8
9
10
11
12
13
FORM RUN_SESSION .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
*----------------------------Logic-------------------------------------*
SUBMIT RSBDCSUB WITH MAPPE EQ LC_GROUP
WITH VON EQ SY-DATUM
WITH BIS EQ SY-DATUM
WITH FEHLER EQ '.'
EXPORTING LIST TO MEMORY
AND RETURN.
WAIT UP TO 5 SECONDS.
ENDFORM.

(5)获取Session日志信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
FORM GET_SESSION_STATE .
*--------------------------Variables-----------------------------------*
CONSTANTS:
LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'.
*----------------------------Logic-------------------------------------*
REFRESH:GT_FMESG.
SELECT MAX( M~CREDATE ) AS CREDATE, MAX( M~CRETIME ) AS CRETIME,
I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4
FROM APQI AS M
INNER JOIN APQLE AS I
ON M~QID = I~QID
INTO CORRESPONDING FIELDS OF TABLE @GT_FMESG
WHERE M~GROUPID = @LC_GROUP
AND I~TCODE = @GC_MM02
AND I~MID <> @GC_NULL
GROUP BY I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4.
IF SY-SUBRC NE 0.
"Session尚未运行完成,请等待
MESSAGE S000 WITH TEXT-E04 DISPLAY LIKE GC_E.
IF GV_RUNFLAG IS INITIAL.
GV_RUNFLAG = GC_X."仅执行一次的标记
WAIT UP TO 5 SECONDS.
PERFORM GET_SESSION_STATE.
ELSE.
"Session运行异常
MESSAGE S000 WITH TEXT-E05 DISPLAY LIKE GC_E.
EXIT.
ENDIF.
ENDIF.
ENDFORM.

(6)展示Session日志信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
FORM SET_MESSAGE_VALUE .
CHECK GT_FMESG IS NOT INITIAL.
REFRESH: GT_MESSAGEP.
CLEAR: GS_MESSAGEP,GS_FMESG.
LOOP AT GT_FMESG INTO GS_FMESG.
GS_MESSAGEP-LINENO = SY-TABIX.
GS_MESSAGEP-MSGID = GS_FMESG-MID.
GS_MESSAGEP-MSGNO = GS_FMESG-MNR.
GS_MESSAGEP-MSGTY = GS_FMESG-MART.
GS_MESSAGEP-MSGV1 = GS_FMESG-MSGV1.
GS_MESSAGEP-MSGV2 = GS_FMESG-MSGV2.
GS_MESSAGEP-MSGV3 = GS_FMESG-MSGV3.
GS_MESSAGEP-MSGV4 = GS_FMESG-MSGV4.
INSERT GS_MESSAGEP INTO TABLE GT_MESSAGEP.
CLEAR: GS_FMESG,GS_MESSAGEP.
ENDLOOP.

FREE: GT_FMESG.
ENDFORM.

六、参考资料

评论