Wednesday, April 27, 2011

Example of POP UP CALCULATOR in ABAP

REPORT  ZPOPUPCALCULATOR.

DATA: X_VALUE(15) TYPE C.

call function 'FITRV_CALCULATOR'

  IMPORTING
    OUTPUT_VALUE               = X_VALUE
  EXCEPTIONS
    INVALID_INPUT              = 1
    CALCULATION_CANCELED       = 2
    OTHERS                     = 3.

IF SY-SUBRC = 0.
   WRITE:/ 'Output IS: ', X_VALUE.
ENDIF.

Example of POP UP CALCULATOR in ABAP

REPORT  ZPOPUPCALCULATOR.

DATA: X_VALUE(15) TYPE C.

call function 'FITRV_CALCULATOR'

  IMPORTING
    OUTPUT_VALUE               = X_VALUE
  EXCEPTIONS
    INVALID_INPUT              = 1
    CALCULATION_CANCELED       = 2
    OTHERS                     = 3.

IF SY-SUBRC = 0.
   WRITE:/ 'Output IS: ', X_VALUE.
ENDIF.

Sunday, April 24, 2011

Use of Colors in List using ABAP Program


The options COLOR, INTENSIFIED, and INVERSE of the FORMAT statement influence the colors of the output list.
To set colors in the program, use:
Syntax
FORMAT COLOR <n> [ON] INTENSIFIED [ON|OFF] INVERSE [ON|OFF].
To set colors at runtime, use:
Syntax
FORMAT COLOR = <c> INTENSIFIED = <int> INVERSE = <inv>.
These formatting options do not apply to horizontal lines created by ULINE. They have the following functions:
  • COLOR sets the color of the line background. If, in addition, INVERSE ON is set, the system changes the foreground color instead of the background color.
For <n> you can set either a color number or a color specification. Instead of color number 0, however, you must use OFF. If you set the color numbers at runtime, all values of <c> that are less than zero or greater than seven, lead to undefined results. The following table summarizes the different possibilities:

<n>
<C>
color
Intended for
OFF
or  COL_BACKGROUND
0
depends on GUI
Background
1
or COL_HEADING
1
gray-blue
Header
2
or COL_NORMAL
2
light gray
List bodies
3
or COL_TOTAL
3
yellow
Totals
4
or COL_KEY
4
blue-green
Key column
5
or COL_POSITIVE
5
green
Positive threshold
6
or COL_NEGATIVE
6
red
Negative threshold
7
or COL_GROUP
7
violet
Control levels







The default setting is COLOR OFF.
  • INTENSIFIED determines the color palette for the line background.
With one exception (COLOR OFF), the color palette for the line background specified above can be intensified or normal. The default setting is INTENSIFIED ON. For COLOR OFF, the system changes the foreground color instead of the background color. If, in addition, INVERSE ON is set, then INTENSIFIED OFF has no effect (again with the exception of COLOR OFF).
  • INVERSE affects the foreground color.
With one exception (COLOF OFF), the system takes the COLOR specified from an inverse color palette and uses it as foreground color. The background color remains unchanged. For COLOR OFF, INVERSE has no effect, since this would set the foreground and the background to the same color.

Wednesday, April 20, 2011

how to Insert Logo in SmartForm ?

Follow the given steps in order to add a logo,

1) In Smart Forms Editor, In left pane, right Click any Page (say Page1) and  select Create -> Window, Give it a name and Description (Say Window1)

2) Right Click on Window (Window 1) and select Create -> Graphics, Give it a name and description

3) In general Attributes, Select Name, get search help (F4) , you will find a list of pictures

4) Select any picture and set its Resolution in DPI

5) Press F9 to open Smart Forms Builder, Select window (Window1) and In Output options window set, size and position of the Logo

6) Set any other parameters if required, save and activate.

7) If there is only 1 Window in the forms, set it as Main Window in general attributes.

8) User T-Code SE78 to upload new pictures and logos.

Tuesday, April 19, 2011

Example of CONCATENATE

DATA: tmp1(2)  VALUE  ‘AB’,
         tmp2(3)  VALUE  ‘CDE’,
         tmp3(10).
CONCATENATE  tmp1  tmp2  INTO  tmp3.
CONCATENATE  tmp1  tmp2  INTO  tmp3
                             SEPARATED  BY  ‘ ‘.


output:

ABCDE

AB CDE

Example of CONDENSE for removing spaces

Example of CONDENSE for removing spaces

Removing Spaces(CONDENSE)
* Condense
DATA: tmp(20)  VALUE  ‘I     am a      boy’.
CONDENSE  tmp.
CONDENSE  tmp  NO-GAPS.

output:

Iamaboy

Manipulating Character Data in ABAP Programming

* Substrings with offsets
DATA  tmp(10)  VALUE  ‘ABCDEFGHIJ’.
DATA  tmp1(2).
WRITE:    tmp+3(7),
               tmp+1(4),
               tmp+0(8),
               tmp+7(3).
MOVE  tmp+4(2)  TO  tmp1.


output:

DEFGHIJ

BCDE
ABCDEFGH
HIJ

ABAP SHIFT Statement


* SHIFT Statement
DATA  tmp(5)  VALUE  ‘12345’.
SHIFT  tmp.
SHIFT  tmp  BY  2  PLACES.
SHIFT  tmp  BY  2  PLACES  CIRCULAR.
SHIFT  tmp  UP  TO  ‘3’.
SHIFT  tmp  UP  TO  ‘3’  RIGHT.
SHIFT  tmp  UP  TO  ‘3’  RIGHT  CIRCULAR.
SHIFT  tmp  RIGHT  DELETING  TRAILING  SPACE.
SHIFT  tmp  LEFT  DELETING  LEADING  SPACE.

output:

2345
345
34512
345
123
45123

Monday, April 11, 2011

Calling SMARTFORMS from your ABAP program


REPORT ZSMARTFORM.
* Calling SMARTFORMS from your ABAP program.
* Collecting all the table data in your program, and pass once to SMARTFORMS
* SMARTFORMS
* Declare your table type in: -
* Global Settings -> Form Interface
* Global Definitions -> Global Data
* Main Window -> Table -> DATA
*

TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
        INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
   MOVE-CORRESPONDING MKPF TO INT_MKPF.
   APPEND INT_MKPF.
ENDSELECT.
* At the end of your program.
* Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
  exporting
    formname                 = 'ZSMARTFORM'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
  IMPORTING
    FM_NAME                  = FM_NAME
  EXCEPTIONS
    NO_FORM                  = 1
    NO_FUNCTION_MODULE       = 2
    OTHERS                   = 3.
if sy-subrc <> 0.
   WRITE: / 'ERROR 1'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.


call function FM_NAME
* EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  TABLES
    GS_MKPF                    = INT_MKPF
  EXCEPTIONS
    FORMATTING_ERROR           = 1
    INTERNAL_ERROR             = 2
    SEND_ERROR                 = 3
    USER_CANCELED              = 4
    OTHERS                     = 5.
if sy-subrc <> 0.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

Wednesday, April 6, 2011

Simple ALV Report

*&---------------------------------------------------------------------*
*& Report  ZSIMPLE_ALV_REPORT
*& developed by: Salah Uddin
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZSIMPLE_ALV_REPORT.
tables spfli.

DATA itab TYPE TABLE OF spfli.

select * into table itab from spfli.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_structure_name   = 'spfli'

TABLES
t_outtab           = itab.


Output:








Monday, April 4, 2011

Automatic refresh report

*&---------------------------------------------------------------------*
*& Report  ZAUTO_REFRESH_TEST
*& developed by: Salah Uddin
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZAUTO_REFRESH_TEST.
DATA: g_init_once,
      ok_code(20),
      g_ref_from_timer.

TYPES: BEGIN OF t_vbak,
  vbeln TYPE vbak-vbeln,
  erdat TYPE vbak-erdat,

 END OF t_vbak.

DATA: it_vbak TYPE STANDARD TABLE OF t_vbak INITIAL SIZE 0,
      wa_vbak TYPE t_vbak.


IF g_init_once <> 'X'.
  g_init_once = 'X'.
  CALL FUNCTION 'Z_ENQUE_SLEEP'
     STARTING NEW TASK 'WAIT'
     PERFORMING when_finished ON END OF TASK.

ENDIF.

WRITE:/ 'wait for 10 sec....'.

AT USER-COMMAND.
  CASE ok_code.
    WHEN 'FCT_R'.
      SELECT vbeln erdat
       UP TO 10 ROWS
        FROM vbak
        INTO TABLE it_vbak.
      WRITE:/ sy-uzeit. "Time
      LOOP AT it_vbak INTO wa_vbak.
        WRITE:/ wa_vbak-vbeln, wa_vbak-vbeln.
      ENDLOOP.
      sy-lsind = 0.
      IF g_ref_from_timer = 'X'.

        CALL FUNCTION 'Z_ENQUE_SLEEP'
          STARTING NEW TASK 'INFO'
          PERFORMING when_finished ON END OF TASK.

        g_ref_from_timer = ''.
      ENDIF.
  ENDCASE.


  FORM when_finished USING taskname.
  RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'.

  g_ref_from_timer = 'X'.

* Trigger an event to run the at user-command
  SET USER-COMMAND 'FCT_R'.
  ok_code = 'FCT_R'.
  sy-ucomm = 'FCT_R'.

ENDFORM.                 

Drop Down lists in the selection parameters

PROGRAM ztest.   TYPE-POOLS : vrm.   DATA : name TYPE vrm_id,        list TYPE vrm_values,        value LIKE LINE OF list. ...