2021.07.11 【ABAP随笔】采购订单Message输出打印

Title

采购订单Message输出打印

很多业务中需要在完成订单的时候来进行单据打印的输出操作,比如新建采购订单的时候,需要输出采购订单的PDF或者使用邮件功能来将采购订单发送给制定人员

SAP 有标准MESSAGE输出的配置功能-TCODE NACE

下面我们就根据采购订单保存时生成一个message smartforms 来说明一下

一 Nace配置

  • 设置输出类型

从NEU复制一个到ZNEU目前我们是对于功能1打印输出来做定制化,所以需要选中ZNEU,双击处理程序(保存采购订单后调用的程序FORM)

⽬前我们是对于功能1打印输出来做定制化,所以需要选中ZNEU,双击处理程序(保存 采购订单后调⽤的程序FORM)

发现它是使⽤SAPFM06P使⽤ADOBE FORM来输出的,这⾥对于我们⼀般的ABAPer 来说,使⽤smartforms会⽐较熟练,所以我们创建⼀个:ZTAB_ZHU_PO_OUT_FORM 程序 来调⽤我⾃⼰定义的smartforms来输出打印 设置如下图

  • 设置条件记录

  • 选择我们创建的ZNEU输出类型

选择根据采购组织和供应商来确定Message 的输出

当我们第一进入时,可以选择左上角输出定价菜单→创建

添加一条条件记录如下图所示:其中VN是供应商功能类型,媒介1表示打印输出,调度时间4表示需要立即输出

同时我们可以点击通讯来对某个供应商设置打印属性设置:

如下图可以对采购组织1310 和供应商133000273的订单输出设置打印设备为LP01,且立即打印

  • 设置过程

设置完毕后退出,点击过程来添加设置好的输出类型

可以选择原来的过程进行添加,也可以单独创建一个过程

在新添加的过程ZRMBEF中添加ZNEU 需求为101

  • SPRO配置

接下来还要在SPRO→物料管理→采购→消息→输出控制→信息类型→定义采购订单的消息类型,添加ZNEU的输出类型

该配置是在采购订单创建和修改时自动在消息中追加一条Message 输出

如下图是订单在修改之后或者创建时自动添加的一条未处理Message输出

同时在SPRO→物料管理→采购→消息→输出控制→信息类型→信息确定方案 ,将过程RMBEF1修改为之前定义的过程ZRMBEF

当配置和程序都完毕时,我们去ME21N创建对应供应商的采购订单

当保存PO时,弹出框调用WINDOWS本地打印机输出为PDF

 

二 代码部分

 重点关注以下几点内容:

  • 在采购订单保存成功之后,后台程序仅仅会调用 ZTAB_ZHU_PO_OUT_FORM中的FORM enter_neu.
  • 使用Function 'ME_READ_PO_FOR_PRINTING' 来获取当前PO的信息,都放在doc的返回参数中
  • 程序中TNAPR存放着调用程序,SMARTFORMS的信息,所以smartforms为TNAPR-SFORM
  • 在程序中发生错误或者打印成功后,使用Function 'NAST_PROTOCOL_UPDATE' 来更新NAST表,NAST表为记录所有OUTPUT Message 状态的表
  1 *&---------------------------------------------------------------------*
  2 *& Report ZTAB_ZHU_PO_OUT_FORM
  3 *&---------------------------------------------------------------------*
  4 *&
  5 *&---------------------------------------------------------------------*
  6 REPORT ztab_zhu_po_out_form.
  7 
  8 INCLUDE rvadtabl.
  9 DATA:
 10   xscreen,                           "Output on printer or screen
 11   nast_anzal   LIKE nast-anzal,      "Number of outputs (Orig. + Cop.)
 12   nast_tdarmod LIKE nast-tdarmod.    "Archiving only one time
 13 
 14 * Type Pools
 15 TYPE-POOLS: meein.
 16 
 17 * DDIC-Tabellen
 18 DATA:
 19   addr1_sel LIKE addr1_sel,
 20   addr1_val LIKE addr1_val.
 21 
 22 DATA:
 23   cdhdr    TYPE cdhdr,
 24   cdshw    TYPE cdshw,
 25   gs_dd04t TYPE dd04t,
 26   ekes     TYPE ekes,
 27   eket     TYPE eket,
 28   ekko     TYPE ekko,
 29   ekpo     TYPE ekpo,
 30   gs_elbp  TYPE elbp,
 31   esuh     TYPE esuh,
 32   komg     TYPE komg,
 33   komk     TYPE komk,
 34   komp     TYPE komp,
 35   konp     TYPE konp,
 36   gs_lfa1  TYPE lfa1,
 37   gs_lfm1  TYPE lfm1,
 38   mdpa     TYPE mdpa,
 39   gs_t001  TYPE t001,
 40   gs_t001n TYPE t001n,
 41   t001w    TYPE t001w,
 42   gs_t005  TYPE t005,
 43   gs_t100  TYPE t100,
 44   t161m    TYPE t161m,
 45   t166c    TYPE t166c,
 46   gs_t166t TYPE t166t,
 47   gs_t685b TYPE t685b,
 48   gs_tinct TYPE tinct,
 49   wyt3     TYPE wyt3.
 50 
 51 
 52 * Interne Tabellen
 53 DATA:
 54   i_cdhdr LIKE cdhdr OCCURS 0 WITH HEADER LINE,
 55   i_cdshw LIKE cdshw OCCURS 0 WITH HEADER LINE,
 56   i_dd03l LIKE dd03l OCCURS 0 WITH HEADER LINE,
 57   i_ekes  LIKE ekes  OCCURS 0 WITH HEADER LINE,
 58   i_eket  LIKE eket  OCCURS 0 WITH HEADER LINE,
 59   i_ekpo  LIKE ekpo  OCCURS 0 WITH HEADER LINE,
 60   i_konp  LIKE konp  OCCURS 0 WITH HEADER LINE,
 61   i_mdsb  LIKE mdsb  OCCURS 0 WITH HEADER LINE,
 62   i_nast  LIKE nast  OCCURS 0 WITH HEADER LINE,
 63   i_t001w LIKE t001w OCCURS 0 WITH HEADER LINE,
 64   i_t161m LIKE t161m OCCURS 0 WITH HEADER LINE,
 65   i_t166c LIKE t166c OCCURS 0 WITH HEADER LINE,
 66   i_t166k LIKE t166k OCCURS 0 WITH HEADER LINE,
 67   i_t166p LIKE t166p OCCURS 0 WITH HEADER LINE,
 68   i_t166t LIKE t166t OCCURS 0 WITH HEADER LINE,
 69   i_ttext LIKE ttext OCCURS 0 WITH HEADER LINE,
 70   i_ttxit LIKE ttxit OCCURS 0 WITH HEADER LINE,
 71   i_wyt3  LIKE wyt3  OCCURS 0 WITH HEADER LINE.
 72 
 73 DATA: gs_cdshw TYPE cdshw.
 74 
 75 DATA:
 76   i2_cdred LIKE cdred OCCURS 0 WITH HEADER LINE,
 77   i2_cdshw LIKE cdshw OCCURS 0 WITH HEADER LINE,
 78   i2_eket  LIKE eket  OCCURS 0 WITH HEADER LINE,
 79   i2_konp  LIKE konp  OCCURS 0 WITH HEADER LINE,
 80   i2_mdpm  LIKE mdpm  OCCURS 0 WITH HEADER LINE,
 81   i2_mdsb  LIKE mdsb  OCCURS 0 WITH HEADER LINE.
 82 
 83 DATA:
 84   tkomv    LIKE komv  OCCURS 0 WITH HEADER LINE,
 85   tkomvd   LIKE komvd OCCURS 0 WITH HEADER LINE,
 86   tkomvd_2 LIKE komvd OCCURS 0 WITH HEADER LINE.
 87 
 88 DATA:
 89    ls_doc TYPE meein_purchase_doc_print.
 90 
 91 * Smartforms Rückgabestrukturen
 92 DATA:
 93 *   document_output_info TYPE ssfcrespd,
 94   job_output_info TYPE ssfcrescl,
 95 *   job_output_options   TYPE ssfcresop,
 96   spoolids        TYPE rspoid.
 97 
 98 * Sonstige Variable
 99 DATA:
100   c1,
101   gv_tdid        TYPE tdid,
102   c10(10),
103   c20(20),
104   c80(80),
105   c100(100),
106   ix_from_memory TYPE char1,
107   xdruvo         LIKE t166k-druvo,
108   xindex         LIKE sy-index,
109   xobjcl         LIKE cdhdr-objectclas,
110   xobjid         LIKE cdhdr-objectid,
111   xretco         LIKE sy-subrc,
112   xrolln         LIKE dd04t-rollname,
113   xspool         TYPE rspoid,
114   xsubrc         LIKE sy-subrc,
115   xtdid          TYPE stxh-tdid,
116   xtdnam         TYPE stxh-tdname,
117   xxaend         TYPE meein_xaend,
118   zaehl          TYPE i.
119 
120 DATA: ls_repid TYPE repid,
121       ls_bukrs TYPE bukrs,
122       lv_adrnr TYPE lfa1-adrnr.
123 
124 TYPES: tt_mmpa TYPE TABLE OF mmpa.
125 
126 FIELD-SYMBOLS: <xmmpa>    TYPE tt_mmpa,
127                <ls_xmmpa> TYPE mmpa.
128 
129 DATA ls_xekpa TYPE msgpa. "ekpa.
130 
131 * Startroutine Nachricht NEU
132 FORM entry_neu USING return_code TYPE i
133                      us_screen   TYPE c.
134   CLEAR: xsubrc.
135 
136   xretco  = return_code.
137   xscreen = us_screen.
138 
139   PERFORM processing USING us_screen
140                   CHANGING xsubrc.
141 
142   IF xsubrc NE 0.
143     return_code = 1.
144   ELSE.
145     return_code = 0.
146   ENDIF.
147 ENDFORM.                    "ENTRY_NEU
148 
149 FORM processing USING proc_screen TYPE c
150              CHANGING cf_retcode  TYPE i.
151   DATA:
152     lf_fm_name        TYPE rs38l_fnam,
153     lf_formname       TYPE tdsfname,
154     ls_addr_key       LIKE addr_key,
155     ls_composer_param TYPE ssfcompop,
156     ls_control_param  TYPE ssfctrlop,
157     ls_recipient      TYPE swotobjid,
158     ls_sender         TYPE swotobjid.
159 
160 * Sonderroutine bei Ausgabe Mail mit Anlagen
161 * ( Aufruf aus ZAMMMP0001 )
162   CLEAR xspool.
163 
164 * Löschen Flag "CX_FROM_MEMORY"
165   CLEAR: cf_retcode, ix_from_memory.
166 
167 * Datenbeschaffung
168   CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
169     EXPORTING
170       ix_nast        = nast
171       ix_screen      = proc_screen
172     IMPORTING
173       ex_retco       = cf_retcode
174       doc            = ls_doc
175 *     ex_nast        = xnast
176     CHANGING
177       cx_druvo       = xdruvo
178       cx_from_memory = ix_from_memory.
179   CHECK cf_retcode = 0.
180 
181 
182 * Übernahme Änderungen in int. Tabelle für Smartforms
183   PERFORM aenderungsbelege.
184 
185   SELECT SINGLE * FROM lfa1 INTO gs_lfa1
186        WHERE lifnr = nast-parnr.
187 
188   lf_formname = tnapr-sform.
189 
190 * Aufbereitung Druckparameter
191   PERFORM set_print_param USING ls_addr_key
192                                 gs_lfa1-land1
193                        CHANGING ls_control_param
194                                 ls_composer_param
195                                 ls_recipient
196                                 ls_sender
197                                 cf_retcode.
198 
199 *  Bestimmung Funktionsbaustein für Smartforms-Formular
200   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
201     EXPORTING
202       formname           = lf_formname
203     IMPORTING
204       fm_name            = lf_fm_name
205     EXCEPTIONS
206       no_form            = 1
207       no_function_module = 2
208       OTHERS             = 3.
209 
210   IF sy-subrc NE 0.
211     cf_retcode = sy-subrc.
212     PERFORM protocol_update.
213   ENDIF.
214 
215   CHECK cf_retcode = 0.
216 
217   nast_tdarmod = nast-tdarmod.
218   nast_anzal =
219   ls_composer_param-tdnewid = 'X'.
220 
221   ls_composer_param-tdcopies = nast-anzal.
222 
223 *  Aufruf Smartforms-FB
224   CALL FUNCTION lf_fm_name
225     EXPORTING
226       archive_index      = toa_dara
227       archive_parameters = arc_params
228       control_parameters = ls_control_param
229       mail_recipient     = ls_recipient
230       mail_sender        = ls_sender
231       output_options     = ls_composer_param
232       user_settings      = space
233       ekko               = ls_doc-xekko
234       nast               = nast
235     IMPORTING
236 *     document_output_info = document_output_info
237       job_output_info    = job_output_info
238 *     job_output_options = job_output_options
239     TABLES
240       t_ekpo             = ls_doc-xekpo
241     EXCEPTIONS
242       formatting_error   = 1
243       internal_error     = 2
244       send_error         = 3
245       user_canceled      = 4
246       OTHERS             = 5.
247 
248 *  Fehlerprotokoll
249   IF sy-subrc NE 0.
250     cf_retcode = sy-subrc.
251     PERFORM protocol_update.
252     PERFORM add_smfrm_prot.
253   ENDIF.
254 
255 *  Ermitteln Spool-Nummer
256   LOOP AT job_output_info-spoolids INTO spoolids.
257     CHECK spoolids NE space.
258 
259     PERFORM protocol_update_spool USING '342' spoolids
260                                         space space space.
261     xspool = spoolids.
262   ENDLOOP.
263 
264 
265 
266   IF NOT nast_tdarmod IS INITIAL.
267     nast-tdarmod = nast_tdarmod.
268     CLEAR nast_tdarmod.
269   ENDIF.
270 
271   IF NOT xspool IS INITIAL.
272     sy-msgid = 'VN'.
273     sy-msgty = 'I'.
274     sy-msgno = '342'.
275     sy-msgv1 = xspool.
276   ENDIF.
277 ENDFORM.
278 *&---------------------------------------------------------------------*
279 *& Form aenderungsbelege
280 *&---------------------------------------------------------------------*
281 *& text
282 *&---------------------------------------------------------------------*
283 *& -->  p1        text
284 *& <--  p2        text
285 *&---------------------------------------------------------------------*
286 FORM aenderungsbelege .
287   REFRESH i_cdshw.
288 
289   LOOP AT ls_doc-xaend INTO xxaend.
290 *  Keine Änderungen aus Bestellbestätigungen
291     CHECK xxaend-tabname NE 'EKES'.
292 
293 *  Keine Änderungen aus Einteilungen (ausser Liefertermin)
294     IF xxaend-tabname = 'EKET'.
295       CHECK xxaend-fname = 'EINDT'.
296     ENDIF.
297 
298 *  Datenübernahme in Änderungsstruktur
299     MOVE-CORRESPONDING xxaend TO i_cdshw.
300 
301 *  Aufbereitung überflüssiger Nachkommastellen
302     REPLACE ',000 ' WITH space INTO i_cdshw-f_old.
303     REPLACE ',000 ' WITH space INTO i_cdshw-f_new.
304 
305 *  Feldbezeichnung in Nachrichtensprache
306     SELECT * FROM dd03l
307        INTO TABLE i_dd03l
308        WHERE tabname   = i_cdshw-tabname
309          AND fieldname = i_cdshw-fname
310        ORDER BY PRIMARY KEY.   "BHS120614(+).
311 
312     IF sy-subrc = 0.
313       READ TABLE i_dd03l INDEX 1.
314 
315       PERFORM lesen_datenelement
316          USING i_dd03l-rollname 'M' i_cdshw-ftext.
317     ENDIF.
318 
319 *  Aufbau Tabelle mit Änderungsbelegen
320     APPEND i_cdshw.
321   ENDLOOP.
322 
323   CHECK sy-subrc NE 0.
324 
325 * Prüfen, ob bereits mindestens 1 verarbeitete Nachricht vorliegt
326   SELECT * FROM nast
327      INTO TABLE i_nast
328      WHERE kappl = nast-kappl
329        AND objky = nast-objky
330        AND kschl = nast-kschl
331        AND vstat = '1'
332        ORDER BY PRIMARY KEY.   "BHS120614(+).
333   CHECK sy-subrc = 0.
334 
335 * Letzte verarbeitete Nachricht wg. Timestamp für Änderungsbelege
336   DESCRIBE TABLE i_nast LINES xindex.
337 
338   IF xindex > 1.
339     SELECT COUNT( * ) FROM nast
340        WHERE kappl = nast-kappl
341          AND objky = nast-objky
342          AND kschl = nast-kschl
343          AND vstat = '0'.
344 
345     IF sy-subrc NE 0.
346       xindex = xindex - 1.
347     ENDIF.
348   ENDIF.
349 
350   READ TABLE i_nast INDEX xindex.
351 
352 * Lesen Änderungsbelege
353   PERFORM lesen_aenderungsbelege USING 'EINKBELEG' nast-objky.
354 ENDFORM.
355 *&---------------------------------------------------------------------*
356 *& Form lesen_aenderungsbelege
357 *&---------------------------------------------------------------------*
358 *& text
359 *&---------------------------------------------------------------------*
360 *&      --> P_
361 *&      --> NAST_OBJKY
362 *&---------------------------------------------------------------------*
363 FORM lesen_aenderungsbelege USING xxobjcl TYPE cdhdr-objectclas
364                                   xxobjid TYPE nast-objky.
365   CHECK nast-kschl = 'NEU '.
366 
367   xobjcl = xxobjcl.
368   xobjid = xxobjid.
369 
370   CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
371     EXPORTING
372       objectclass                = xobjcl
373       objectid                   = xobjid
374       username                   = space
375     TABLES
376       i_cdhdr                    = i_cdhdr
377     EXCEPTIONS
378       no_position_found          = 1
379       wrong_access_to_archive    = 2
380       time_zone_conversion_error = 3
381       OTHERS                     = 4.
382   CHECK sy-subrc = 0.
383 
384   LOOP AT i_cdhdr INTO cdhdr.
385     CHECK cdhdr-udate > i_nast-datvr
386        OR ( cdhdr-udate = i_nast-datvr AND
387             cdhdr-utime > i_nast-uhrvr ).
388 
389     CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
390       EXPORTING
391         changenumber            = cdhdr-changenr
392       TABLES
393         editpos                 = i2_cdshw
394         editpos_with_header     = i2_cdred
395       EXCEPTIONS
396         no_position_found       = 1
397         wrong_access_to_archive = 2
398         OTHERS                  = 3.
399     CHECK sy-subrc = 0.
400 
401 *    APPEND LINES OF i2_cdred TO i_cdred.
402     APPEND LINES OF i2_cdshw TO i_cdshw.
403   ENDLOOP.
404 
405 * Prüfung änderungsrelevante Felder
406   SELECT * FROM t166c
407      INTO TABLE i_t166c.
408 
409   CASE ls_doc-xekko-bstyp.
410     WHEN 'A'.
411       DELETE i_t166c WHERE xanfr NE 'X'.
412     WHEN 'F'.
413       DELETE i_t166c WHERE xbest NE 'X'.
414     WHEN 'K'.
415       DELETE i_t166c WHERE xkont NE 'X'.
416     WHEN 'L'.
417       DELETE i_t166c WHERE xlfpl NE 'X'.
418   ENDCASE.
419 
420 *  Keine Änderungen aus Einteilungen und Bestellbestätigungen
421   DELETE i_cdshw WHERE tabname = 'EKES'.
422 
423   DELETE i_cdshw WHERE tabname = 'EKET'
424                    AND fname  NE 'EINDT'.
425 
426   LOOP AT i_cdshw WHERE chngind = 'U'.
427     READ TABLE i_t166c WITH KEY tname = i_cdshw-tabname
428                                 fname = i_cdshw-fname.
429     IF sy-subrc NE 0.
430       DELETE i_cdshw.
431       CONTINUE.
432     ENDIF.
433 
434 *  Druckaufbereitung
435 *  Aufbereitung überflüssiger Nachkommastellen
436     REPLACE ',000 ' WITH space INTO i_cdshw-f_old.
437     REPLACE ',000 ' WITH space INTO i_cdshw-f_new.
438 
439 *  Feldbezeichnung in Nachrichtensprache
440     SELECT * FROM dd03l
441        INTO TABLE i_dd03l
442        WHERE tabname   = i_cdshw-tabname
443          AND fieldname = i_cdshw-fname
444        ORDER BY PRIMARY KEY.   "BHS120614(+).
445 
446     IF sy-subrc = 0.
447       READ TABLE i_dd03l INDEX 1.
448 
449       PERFORM lesen_datenelement
450          USING i_dd03l-rollname 'M' i_cdshw-ftext.
451     ENDIF.
452 
453     MODIFY i_cdshw.
454   ENDLOOP.
455 ENDFORM.
456 *&---------------------------------------------------------------------*
457 *& Form set_print_param
458 *&---------------------------------------------------------------------*
459 *& text
460 *&---------------------------------------------------------------------*
461 *&      --> LS_ADDR_KEY
462 *&      --> GS_LFA1_LAND1
463 *&      <-- LS_CONTROL_PARAM
464 *&      <-- LS_COMPOSER_PARAM
465 *&      <-- LS_RECIPIENT
466 *&      <-- LS_SENDER
467 *&      <-- CF_RETCODE
468 *&---------------------------------------------------------------------*
469 FORM set_print_param  USING is_addr_key       LIKE addr_key
470                            xxland1           LIKE lfa1-land1
471                   CHANGING cs_control_param  TYPE ssfctrlop
472                            cs_composer_param TYPE ssfcompop
473                            cs_recipient      TYPE swotobjid
474                            cs_sender         TYPE swotobjid
475                            cf_retcode        TYPE sy-subrc.
476   DATA:
477     lf_device TYPE tddevice,
478     lf_repid  TYPE sy-repid,
479     ls_itcpo  TYPE itcpo.
480 
481   lf_repid = sy-repid.
482 
483   CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
484     EXPORTING
485       pi_nast       = nast
486       pi_country    = xxland1
487       pi_addr_key   = is_addr_key
488       pi_repid      = lf_repid
489       pi_screen     = xscreen
490     IMPORTING
491       pe_returncode = cf_retcode
492       pe_itcpo      = ls_itcpo
493       pe_device     = lf_device
494       pe_recipient  = cs_recipient
495       pe_sender     = cs_sender.
496 
497   IF cf_retcode = 0.
498     MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
499 
500     CLEAR cs_composer_param-tddelete.
501     cs_composer_param-tdlifetime = 8.
502 
503     cs_control_param-device    = lf_device.
504     cs_control_param-no_dialog = ''.
505     cs_control_param-preview   = xscreen.
506     cs_control_param-getotf    = ls_itcpo-tdgetotf.
507     cs_control_param-langu     = nast-spras.
508   ENDIF.
509 
510 ENDFORM.
511 *&---------------------------------------------------------------------*
512 *& Form protocol_update
513 *&---------------------------------------------------------------------*
514 *& text
515 *&---------------------------------------------------------------------*
516 *& -->  p1        text
517 *& <--  p2        text
518 *&---------------------------------------------------------------------*
519 FORM protocol_update .
520   IF xscreen NE space.
521     MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
522           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
523     EXIT.
524   ENDIF.
525 
526   CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
527     EXPORTING
528       msg_arbgb = syst-msgid
529       msg_nr    = syst-msgno
530       msg_ty    = syst-msgty
531       msg_v1    = syst-msgv1
532       msg_v2    = syst-msgv2
533       msg_v3    = syst-msgv3
534       msg_v4    = syst-msgv4
535     EXCEPTIONS
536       OTHERS    = 1.
537 ENDFORM.
538 *&---------------------------------------------------------------------*
539 *& Form add_smfrm_prot
540 *&---------------------------------------------------------------------*
541 *& text
542 *&---------------------------------------------------------------------*
543 *& -->  p1        text
544 *& <--  p2        text
545 *&---------------------------------------------------------------------*
546 FORM add_smfrm_prot .
547   DATA:
548     l_s_log     TYPE bal_s_log,
549     l_s_msg     TYPE bal_s_msg,
550     lt_errortab TYPE tsferror,
551     p_loghandle TYPE balloghndl.
552 
553   FIELD-SYMBOLS:
554      <fs_errortab> TYPE LINE OF tsferror.
555 
556 * Fehlertabelle lesen
557   CALL FUNCTION 'SSF_READ_ERRORS'
558     IMPORTING
559       errortab = lt_errortab.
560 
561   SORT lt_errortab.
562 
563 * Hinzufügen Smartforms Protokoll zum Nachrichtenprotokoll
564   LOOP AT lt_errortab ASSIGNING <fs_errortab>.
565     CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
566       EXPORTING
567         msg_arbgb = <fs_errortab>-msgid
568         msg_nr    = <fs_errortab>-msgno
569         msg_ty    = <fs_errortab>-msgty
570         msg_v1    = <fs_errortab>-msgv1
571         msg_v2    = <fs_errortab>-msgv2
572         msg_v3    = <fs_errortab>-msgv3
573         msg_v4    = <fs_errortab>-msgv4
574       EXCEPTIONS
575         OTHERS    = 1.
576   ENDLOOP.
577 
578 * Application log
579   l_s_log-extnumber = sy-uname.
580 
581   CALL FUNCTION 'BAL_LOG_CREATE'
582     EXPORTING
583       i_s_log      = l_s_log
584     IMPORTING
585       e_log_handle = p_loghandle
586     EXCEPTIONS
587       OTHERS       = 1.
588 
589   LOOP AT lt_errortab ASSIGNING <fs_errortab>.
590     MOVE-CORRESPONDING <fs_errortab> TO l_s_msg.
591 
592     CALL FUNCTION 'BAL_LOG_MSG_ADD'
593       EXPORTING
594         i_log_handle = p_loghandle
595         i_s_msg      = l_s_msg
596       EXCEPTIONS
597         OTHERS       = 1.
598   ENDLOOP.
599 ENDFORM.
600 *&---------------------------------------------------------------------*
601 *& Form protocol_update_spool
602 *&---------------------------------------------------------------------*
603 *& text
604 *&---------------------------------------------------------------------*
605 *&      --> P_
606 *&      --> SPOOLIDS
607 *&      --> SPACE
608 *&      --> SPACE
609 *&      --> SPACE
610 *&---------------------------------------------------------------------*
611 FORM protocol_update_spool  USING syst_msgno   TYPE symsgno
612                                  p_ls_spoolid TYPE rspoid
613                                  p_space1     TYPE symsgv
614                                  p_space2     TYPE symsgv
615                                  p_space3     TYPE symsgv.
616   CHECK xscreen = space.
617 
618   syst-msgid = 'VN'.
619   syst-msgno = syst_msgno.
620   syst-msgv1 = p_ls_spoolid.
621 
622   CONDENSE syst-msgv1.
623 
624   CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
625     EXPORTING
626       msg_arbgb = syst-msgid
627       msg_nr    = syst-msgno
628       msg_ty    = syst-msgty
629       msg_v1    = syst-msgv1
630       msg_v2    = p_space1
631       msg_v3    = p_space2
632       msg_v4    = p_space3
633     EXCEPTIONS
634       OTHERS    = 1.
635 ENDFORM.
636 * Literale übernehmen aus Datenelemnten
637 FORM lesen_datenelement USING xxrolln TYPE rollname
638                               xxtext  TYPE char1
639                               xxfeld  TYPE any.
640   SELECT SINGLE * FROM dd04t INTO gs_dd04t
641      WHERE rollname   = xxrolln
642        AND ddlanguage = nast-spras
643        AND as4local   = 'A'
644        AND as4vers    = '0000'.
645   CHECK sy-subrc = 0.
646 
647   CASE xxtext.
648     WHEN 'M'.  xxfeld = gs_dd04t-scrtext_m.
649     WHEN 'L'.  xxfeld = gs_dd04t-scrtext_l.
650     WHEN 'S'.  xxfeld = gs_dd04t-scrtext_s.
651     WHEN 'D'.  xxfeld = gs_dd04t-ddtext.
652     WHEN 'R'.  xxfeld = gs_dd04t-reptext.
653   ENDCASE.
654 ENDFORM.                    "LESEN_DATENELEMENT

posted @ 2021-07-12 00:01  TAB_Zhu  阅读(1939)  评论(0编辑  收藏  举报