Programming

How to define variable in SAPscript

You can define variable in SAPscript by apply statement ’DEFINE’.

Example: We will define variable name = ’TXT1’ and initial value = ’Text1’. After we already define it, we will write a value of field.


/: DEFINE &TXT1& = ’Text1’
*  Test Define Text = &TXT1&
img10

The Output is

 img11

How to debugging SAPscript form

Go to transaction SE71 and input form name that you want to debug.

img7

Select menu Utilities -> Activate Debugger.

img5

System will generate message that debugger success or fail.

img6

After you run program that call this form, system will skip to form debugger.

How to convert timezone in PHP

I noticed that many people tried to find how to convert timezone in PHP in this site but found none. I wrote this trick to help them simplify the problem using very basic feature of PHP. Generally, your server might be set in such a timezone, e.g. GMT+7, and your users may locate in another timzone, e.g. GMT-7. What you need is to allow users to customize view of date/time in webboard, portal, blog, or any interactive websites. This is very basic but impression idea to help user reading and understanding your content easier.

If you notice the characteristic of each timezone, there is a reference point or so called GMT or UTC. They are the same point. That means every timezones are relative to this reference point. Each point is represented by offset of hours and minutes in form "SHHMM" while S denotes the sign of this offset, HH denotes the offset in hour and MM denotes the offset in minutes. For example, Bangkok timezone is GMT+7 which represents by +0700. Don’t worry everybody know where they are. You can leave the task to choose appropriate timezone to the end-user. My trick is to convert offset string into second so that standard function time() can recognize that offset correctly.

How to import & export SAPscript form

You can import and export SAPscript form by using report ’RSTXSCRP’.

img2

You can specify form name in field ’Object name’.

img4

About mode options:

img3

ABAP/4 Example Code: Factorial


DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
  PERFORM factorial USING p_num
                    CHANGING output.
  WRITE:/ output.
*&---------------------------------------------------------------------*
*&      Form  factorial
*&---------------------------------------------------------------------*
*       text
*-----------------------------------

ABAP/4 Example Code: Fibonacci


DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
  PERFORM fibonacci USING p_num
                    CHANGING output.
  WRITE:/ output.
*&---------------------------------------------------------------------*
*&      Form  fibonacci
*&---------------------------------------------------------------------*
*       text
*---------------------------------------