thitima's blog

Date Mask Template in command SET DATE MASK for SAPscript

Syntax

/: SET DATE MASK = ’template’
Template    Description
DD Day 2 digits
DDD Short name of day
DDDD Long name of day
MM Month 2 digits
MMM Short name of month
MMMM Long name of month
YY Year 2 digits
YYYY Year 4 digits

Example

SAPscript
img14

How to initial value of SELECT-OPTIONS in ABAP/4

We can initial value of SELECT-OPTIONS in event INITIALIZATION.

Example

TABLES: sflight.
SELECT-OPTIONS: s_carrid FOR sflight-carrid.
INITIALIZATION.
  s_carrid-sign = ’I’.
  s_carrid-option = ’EQ’.
  s_carrid-low = ’AA’.
  APPEND s_carrid.
  s_carrid-low = ’AB’.
  APPEND s_carrid.
  s_carrid-low = ’AC’.
  APPEND s_carrid.

The output is:

 img12

Loop ... Assigning & Loop ... Into in ABAP/4

Loop ... Into

LOOP AT itab INTO wa_tab.
  ...
  ...
...
wa_tab-fld1 = ’X’.
MODIFY itab FROM wa_tab.

ENDLOOP.

Loop ... Assigning


LOOP AT itab ASSIGNING .
  ...
  ...
...
-fld1 = ’X’.


ENDLOOP.
Loop ... Assigning is faster than Loop ... Into because when you modify field-symbol, system automatically update data in internal table. 

ABAP/4 Example Code: Download ABAP Spool to PDF

*** This program receive spool id and destination file name ***
DATA: it_pdf TYPE TABLE OF TLINE WITH HEADER LINE,
      gv_string TYPE string.


PARAMETERS: p_spool LIKE TSP01-RQIDENT,
            p_file LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION ’KD_GET_FILENAME_ON_F4’
    EXPORTING
*     PROGRAM_NAME        = SYST-REPID
*   &nb

ABAP/4 Example Code: Download OTF Spool to PDF

*** This program receive spool id and destination file name ***
DATA: it_pdf TYPE TABLE OF TLINE WITH HEADER LINE,
      gv_string TYPE string.

PARAMETERS: p_spool LIKE TSP01-RQIDENT,
            p_file LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION ’KD_GET_FILENAME_ON_F4’
    EXPORTING
*     PROGRAM_NAME        = SYST-REPID
*     DYNPRO_N

How to define macro in ABAP/4

We can define macro by apply statement DEFINE ... END-OF-DEFINITION.

Example


DATA: itab TYPE TABLE OF sflight WITH HEADER LINE.
RANGES: r_carrid FOR sflight-carrid.
DEFINE append_range.
  &1-sign = &2.
  &1-option = &3.
  &1-low = &4.
  append &1.
END-OF-DEFINITION.
INITIALIZATION.
  append_range r_carrid ’I’ ’EQ’ ’AA’.
  append_range r_carrid ’I’ ’EQ’ ’AB’.
START-OF-SELECTION.
  SELECT * FROM sflight INTO TABLE itab
           WHERE carrid in r_carrid.
  IF SY-SUBRC = 0.
    LOOP AT itab.
      WRITE:/ itab-carrid, itab-connid, itab-fldate.
    ENDLOOP.
  ENDIF.
Note: You can define parameters only 9 (&1 ...