Set selection-screen text when the program first run


Sometime we create a new program with selection-screen, and all the selection fields texted with text-element. And after we download the program and then upload to another place with Copy/Paste, the selection fields’ text lost, and in this article will tell you how to init you selection fields’ text in a normal report.

Code as below:

*&---------------------------------------------------------------------*
*& Report  ZBOB_INIT_SL_TXT
*&
*&---------------------------------------------------------------------*
*& Desc: Init selection screen without set text-element
*& Author: 翱翔云天
*& Website: www.abaptech.com
*&---------------------------------------------------------------------*
 
REPORT  ZBOB_INIT_SL_TXT.
 
TABLES: EKKO.
 
* Text object
data: it_txt TYPE STANDARD TABLE OF textpool,
      wa_txt LIKE LINE OF it_txt.
* First time or not indicator
data: txt_flag.
 
* Define selection field
SELECT-OPTIONS: s_ebeln for ekko-ebeln.
 
INITIALIZATION.
* Get selection text
  read TEXTPOOL sy-cprog into it_txt LANGUAGE sy-langu.
* Delete empty entry
  delete it_txt where entry = space and id = 'S'.
  read table it_txt into wa_txt with key key = 'O_IND'.
  if not wa_txt-entry = '        First time'.
*   First time run program, add selection text
    wa_txt-id = 'S'. wa_txt-key = 'S_EBELN'.
    wa_txt-entry = '        Purchase Order'.
    APPEND wa_txt TO it_txt.
 
    wa_txt-id = 'S'. wa_txt-key = 'O_IND'.
    wa_txt-entry = '        First time'.
    APPEND wa_txt TO it_txt.
    INSERT TEXTPOOL sy-cprog FROM it_txt LANGUAGE sy-langu.
    txt_flag = 'X'.
 
    MESSAGE i888(sabapdocu) WITH
     'This is the first time you start this report.'
    'After the next start the '
     'selectiontexts are initialized!'.
  endif.
 
start-of-SELECTION.
  IF txt_flag = 'X'.
*    Information message
    MESSAGE i888(sabapdocu) WITH
     'Restart of Report!'
     'Tis happens only at the first start'.
    SET  SCREEN 0.
    STOP.
  ENDIF.

Result:

Before program run:

image

First time run program:

image

image

Restart the program:

image


About The Author

从事SAP行业有些年头,对SAP技术稍有了解; 如无特别声明,本博客文章为原创,转载请注明; 博主MSN:xuchunbo0901@hotmail.com; 博主邮箱:bob.xu@abaptech.com。

No Comments

Leave A Reply


注意: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。使用'@all ',将会将评论发送给之前所有其它评论者。请务必注意user必须和评论者名相匹配(大小写一致)。

无觅相关文章插件,快速提升流量