Monday, March 5, 2018

Renaming Selection Text of Fields on Selection Screen

Here is a little tricks for you to change the name of the field text label in selection screen.
A Simple Case Requirement when you can handle 2 types of documents like Sales Document and Billing Document, then you want to change the label of the VBELN into sales/billing according the the selection of a radio button you have chosen. Well you can simply follow the following steps:

  1. Define Seltext table and workarea
    
        DATA it_seltexts TYPE TABLE OF rsseltexts.
        DATA wa_seltexts TYPE rsseltexts. 
    
    
  2. You can set a new selection text for several fields by inserting the record into it_seltexts table
    
         wa_seltexts-kind = ' '. "Type of the field P/S (Parameters /Select Options)
         wa_seltexts-name = ' ' "Name of the field
         wa_seltexts-text = ' '. "Seletion text of the field
         INSERT wa_seltexts INTO TABLE it_seltexts.
    
    
  3. Finally, Call modify function to execute the changes according the it_seltexts table
    
         CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
           EXPORTING
             program  = sy-repid
           TABLES
             seltexts = it_seltexts
     *           EXCEPTIONS
     *       PROGRAM_NOT_FOUND                 = 1
     *       PROGRAM_CANNOT_BE_GENERATED       = 2
     *       OTHERS   = 3
           .
         IF sy-subrc <> 0.
        ENDIF. 
    
    

Thursday, January 11, 2018

Turn on default MS Word Editor in Smartforms SAP S/4HANA

If you are here, means that you encountered the slow performance when opening the text editor on smartforms, on the previous SAP ECC 6.0 System, you can apply Note OSS 2221815_2221815 – SAPscript Legacy Text Editor , and then change the preference on rscpseteditor program.


However, since you are using SAP S/4 Hana, you cannot do this anymore, regardless if you are using SAP GUI 7.4 or 7.5. you need some extra configuration a.k.a. Enhancement. How is it done?



  1. Go to SE24
  2. Open Class CL_COS_UTILITIES 
  3. Go to method IS_S4H
  4. Create an enhancement at the end of the method
  5. Insert the following code
  6. IF SY-TCODE = 'SMARTFORMS' OR SY-TCODE = 'SE71'.
      RV_IS_S4H = abap_false.
    ENDIF.
    
    
    
The method is used by SAP to check whether the system is S/4 HANA or not, hence the enhancement tricks SAP GUI to tell that it is not S/4 HANA System when you open/use TCODE SMARTFORMS or SE71

Thursday, December 7, 2017

Simple use of Fiori Theme Designer

So these days, i am improving my knowledge in Fiori and UI5. It is quite a great innovation to have SAP Front-end in a very stunning and beautiful web. Hence, I would like to share a simple tutorial to apply a theme using Fiori Theme Designer Feature.
  1. Open Your Fiori Theme Designer using 
    • TCODE: /UI5/THEME_DESIGNER
      Use slash n or o to open it (/n/UI5/THEME_DESIGNER)
    • URL: http://<server>:<port>/sap/bc/theming/theme-designer?sap-client=<client>

  2. Once you in the Theme Designer, click Create a new Theme button and complete the required fields.
  3. After that, you will be redirected to the theme editor, you can add target page which is an fiori application to be customised by fill in the app URL (This step is optional and can be done later)
  4. In this tutorial, we do not designing theme for an app, but for the general Fiori Interface, hence we can continue skip previous step and click Home on the left, and then start designing the interface using the properties on the right. You might want to use expert mode and CSS mode too if necessary.

  5. Once you enjoy designing and satisfied with the interface, you can continue by clicking Theme->Save and Build
  6. After the theme has been built, you can assign the theme to Fiori in Tcode /UI2/NWBC_CFG_SAP (Optional)
  7. Try to open your Fiori Launchpad and Hard Reload your browser. You should get new interface of your custom theme.

    If you do not assign the theme on step 6, you can try the theme by appending ?sap-theme=<theme-name> to the original Fiori URL
    (https://<server>:<port>/sap/bc/ui5_ui5/sap/ui5_srm_sc_apv/index.html?saptheme=<theme-name>)

Wednesday, December 6, 2017

Text to Speech in ABAP

1. Define the text, ole and voice object


DATA : ole   TYPE ole2_object,
       voice TYPE ole2_object,
       text   TYPE string.

2. Create the object

CREATE OBJECT voice 'SAPI.SpVoice'.


3. Define the text to be voiced

text = 'Hello World'.

4. Call the method

CALL METHOD OF voice 'Speak' = ole
  EXPORTING #1 = text. 


Spell Digit Numbers in Indonesia

There is a function module SPELL_AMOUNT that allow us to spell digit numbers in words, however cannot use it in other language other than english or denmark unless we maintain it.

To maintain it, we simply add data in tcode OBA9 and add the following data

ID
0
0
NOL ;
ID
0
1
SATU ;
ID
0
2
DUA ;
ID
0
3
TIGA ;
ID
0
4
EMPAT ;
ID
0
5
LIMA ;
ID
0
6
ENAM ;
ID
0
7
TUJUH ;
ID
0
8
DELAPAN ;
ID
0
9
SEMBILAN ;
ID
1
0
SEPULUH ;
ID
1
1
SEBELAS ;
ID
1
2
DUA BELAS ;
ID
1
3
TIGA BELAS ;
ID
1
4
EMPAT BELAS ;
ID
1
5
LIMA BELAS ;
ID
1
6
ENAM BELAS ;
ID
1
7
TUJUH BELAS ;
ID
1
8
DELAPAN BELAS ;
ID
1
9
SEMBILAN BELAS ;
ID
2
0
DUA PULUH ;
ID
2
1
DUA PULUH SATU ;
ID
2
2
DUA PULUH DUA ;
ID
2
3
DUA PULUH TIGA ;
ID
2
4
DUA PULUH EMPAT ;
ID
2
5
DUA PULUH LIMA ;
ID
2
6
DUA PULUH ENAM ;
ID
2
7
DUA PULUH TUJUH ;
ID
2
8
DUA PULUH DELAPAN ;
ID
2
9
DUA PULUH SEMBILAN ;
ID
3
0
TIGA PULUH ;
ID
3
1
TIGA PULUH SATU ;
ID
3
2
TIGA PULUH DUA ;
ID
3
3
TIGA PULUH TIGA ;
ID
3
4
TIGA PULUH EMPAT ;
ID
3
5
TIGA PULUH LIMA ;
ID
3
6
TIGA PULUH ENAM ;
ID
3
7
TIGA PULUH TUJUH ;
ID
3
8
TIGA PULUH DELAPAN ;
ID
3
9
TIGA PULUH SEMBILAN ;
ID
4
0
EMPAT PULUH ;
ID
4
1
EMPAT PULUH SATU ;
ID
4
2
EMPAT PULUH DUA ;
ID
4
3
EMPAT PULUH TIGA ;
ID
4
4
EMPAT PULUH EMPAT ;
ID
4
5
EMPAT PULUH LIMA ;
ID
4
6
EMPAT PULUH ENAM ;
ID
4
7
EMPAT PULUH TUJUH ;
ID
4
8
EMPAT PULUH DELAPAN ;
ID
4
9
EMPAT PULUH SEMBILAN ;
ID
5
0
LIMA PULUH ;
ID
5
1
LIMA PULUH SATU ;
ID
5
2
LIMA PULUH DUA ;
ID
5
3
LIMA PULUH TIGA ;
ID
5
4
LIMA PULUH EMPAT ;
ID
5
5
LIMA PULUH LIMA ;
ID
5
6
LIMA PULUH ENAM ;
ID
5
7
LIMA PULUH TUJUH ;
ID
5
8
LIMA PULUH DELAPAN ;
ID
5
9
LIMA PULUH SEMBILAN ;
ID
6
0
ENAM PULUH ;
ID
6
1
ENAM PULUH SATU ;
ID
6
2
ENAM PULUH DUA ;
ID
6
3
ENAM PULUH TIGA ;
ID
6
4
ENAM PULUH EMPAT ;
ID
6
5
ENAM PULUH LIMA ;
ID
6
6
ENAM PULUH ENAM ;
ID
6
7
ENAM PULUH TUJUH ;
ID
6
8
ENAM PULUH DELAPAN ;
ID
6
9
ENAM PULUH SEMBILAN ;
ID
7
0
TUJUH PULUH ;
ID
7
1
TUJUH PULUH SATU ;
ID
7
2
TUJUH PULUH DUA ;
ID
7
3
TUJUH PULUH TIGA ;
ID
7
4
TUJUH PULUH EMPAT ;
ID
7
5
TUJUH PULUH LIMA ;
ID
7
6
TUJUH PULUH ENAM ;
ID
7
7
TUJUH PULUH TUJUH ;
ID
7
8
TUJUH PULUH DELAPAN ;
ID
7
9
TUJUH PULUH SEMBILAN ;
ID
8
0
DELAPAN PULUH ;
ID
8
1
DELAPAN PULUH SATU ;
ID
8
2
DELAPAN PULUH DUA ;
ID
8
3
DELAPAN PULUH TIGA ;
ID
8
4
DELAPAN PULUH EMPAT ;
ID
8
5
DELAPAN PULUH LIMA ;
ID
8
6
DELAPAN PULUH ENAM ;
ID
8
7
DELAPAN PULUH TUJUH ;
ID
8
8
DELAPAN PULUH DELAPAN ;
ID
8
9
DELAPAN PULUH SEMBILAN ;
ID
9
0
SEMBILAN PULUH ;
ID
9
1
SEMBILAN PULUH SATU ;
ID
9
2
SEMBILAN PULUH DUA ;
ID
9
3
SEMBILAN PULUH TIGA ;
ID
9
4
SEMBILAN PULUH EMPAT ;
ID
9
5
SEMBILAN PULUH LIMA ;
ID
9
6
SEMBILAN PULUH ENAM ;
ID
9
7
SEMBILAN PULUH TUJUH ;
ID
9
8
SEMBILAN PULUH DELAPAN ;
ID
9
9
SEMBILAN PULUH SEMBILAN ;
ID
H
1
SERATUS ;
ID
H
2
DUA RATUS ;
ID
H
3
TIGA RATUS ;
ID
H
4
EMPAT RATUS ;
ID
H
5
LIMA RATUS ;
ID
H
6
ENAM RATUS ;
ID
H
7
TUJUH RATUS ;
ID
H
8
DELAPAN RATUS ;
ID
H
9
SEMBILAN RATUS ;
ID
K
1
SATU TRILIUN ;
ID
K
=
TRILIUN ;
ID
K
>
TRILIUN ;
ID
L
1
SATU MILYAR ;
ID
L
=
MILYAR ;
ID
L
>
MILYAR ;
ID
M
1
SATU JUTA ;
ID
M
=
JUTA ;
ID
M
>
JUTA ;
ID
T
1
SERIBU ;
ID
T
>
RIBU ;

Next, we can use the FM to our code.


CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
  amount   = gs_0100-total    " Amount/Number to Be Spelled Out
  currency = 'IDR'    " Currency for Amounts, Blank for Numbers
  filler   = space    " Filler for Padding the Output Field
  language = 'i'    " Language Indicator
IMPORTING
  in_words = v_in_words.    " Character String with Amount/Number Spelled Out