Saturday, December 19, 2009

Page Number Running In Background Code Example




REPORT zpage1 NO STANDARD PAGE HEADING LINE-SIZE 80
LINE-COUNT 55.

TABLES: SFLIGHT.

SELECT-OPTIONS: CARRIER FOR SFLIGHT-CARRID.

DATA: IVBAP TYPE STANDARD TABLE OF SFLIGHT WITH HEADER LINE,
TAB_ENTRIES TYPE I,
TOTAL_PAGES TYPE P DECIMALS 3,
TOTAL_NUMBER_OF_PAGES TYPE P DECIMALS 0,
HEADER_LINE_COUNT TYPE I VALUE 3.

SELECT * FROM SFLIGHT INTO TABLE IVBAP WHERE CARRID IN CARRIER.

DESCRIBE TABLE IVBAP LINES TAB_ENTRIES.

TOTAL_PAGES = ( TAB_ENTRIES / SY-LINCT ).
TOTAL_PAGES = ( ( ( TOTAL_PAGES * HEADER_LINE_COUNT )
+ TAB_ENTRIES ) / SY-LINCT ).
TOTAL_NUMBER_OF_PAGES = CEIL( TOTAL_PAGES ).

LOOP AT IVBAP.

WRITE:/ IVBAP-CARRID,
IVBAP-PLANETYPE.

ENDLOOP.

TOP-OF-PAGE.

WRITE:/ 'LIST OF SALES ORDERS',
45 'Page',
SY-PAGNO,
'of' NO-GAP,
TOTAL_NUMBER_OF_PAGES.
ULINE.
SKIP.

Friday, December 11, 2009

Send System Message to User

There is few ways we can send message to user who log in in the SAP client.

There is one builtin function TH_POPUP that we can used to send message to the user.

Go to call function transaction SE37 and execute this function

Overlaying Character Fields

Overlaying Character Fields

Is good to use if you want to fill the number for certain format.

e.g if the data contain value 65 and the format data should be 65000

The OVERLAY statement overlays one string with another:
OVERLAY c1 WITH c2 [ONLY str].

This statement overlays all positions in field c1containing letters which occur in str with the contents of c2. c2remains unchanged. If you omit ONLY str , all positions of c1 containing spaces are overwritten.
If at least one character in c1 was replaced, sy-subrc is set to 0. In all other cases, sy-subrc is set to 4. If c1 is longer than c2, it is overlaid only in the length of c2.
Example

DATA: t(10) TYPE c VALUE 'a c e g i ',

string LIKE t,
over(10) TYPE c VALUE
'ABCDEFGHIJ',
str(2) TYPE c VALUE 'ai'.
string = t.
WRITE string.
WRITE / over.
OVERLAY string WITH over.
WRITE / string.
string = t.
OVERLAY string WITH over ONLY str.
WRITE / string.
Output:
a c e g i
ABCDEFGHIJ
aBcDeFgHiJ
A c e g I