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:
First time run program:
Restart the program:
No Comments