Google Search - Blog...........

Rounding Off A Value To A Particular Decimal Length

data: nu(10) type p decimals 4.
data: nu1(5) type p decimals 2.

nu = '4.017'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2
INPUT = nu

* SIGN = ' '

IMPORTING
OUTPUT = nu1

* EXCEPTIONS
* NPUT_INVALID = 1
* OVERFLOW = 2

*TYPE_INVALID = 3

* OTHERS = 4

ABAP - Download Data Into Excel Sheet Using FM WS_DOWNLOAD.

REPORT zmm_basic_data .

************************************************************************

Report to View Detail Of Material Master BASIC DATA.
Start Date 07.05.2007
Request No.-GR3K931783

************************************************************************

TABLES: mara,marc,makt.

DATA: gi_mara LIKE mara OCCURS 1 WITH HEADER LINE,
gi_marc LIKE marc OCCURS 1 WITH HEADER LINE,
gi_makt LIKE makt OCCURS 1 WITH HEADER LINE.
DATA: BEGIN OF gi_download OCCURS 1,
matnr LIKE mara-matnr,"material no
maktx LIKE makt-maktx,"material description
matkl LIKE mara-matkl,"material group
werks LIKE marc-werks,"plant
ekgrp LIKE marc-ekgrp,"purchasing group
spart LIKE mara-spart,"division
meins LIKE mara-meins,"base uit of measure
bismt LIKE mara-bismt,"old material no.
prdha LIKE mara-prdha,"product hierarchy
brgew LIKE mara-brgew,"gross weight
ntgew LIKE mara-ntgew,"net weight
gewei LIKE mara-gewei,"weight unit
volum LIKE mara-volum,"volume
voleh LIKE mara-voleh,"volume unit
zeinr LIKE mara-zeinr,"document no.
zeiar LIKE mara-zeiar,"document type
zeivr LIKE mara-zeivr,"document version
zeifo LIKE mara-zeifo,"page format of document
blanz LIKE mara-blanz,"number of sheets
spras LIKE makt-spras,"language key
END OF gi_download.

DATA: BEGIN OF gi_fieldnames OCCURS 1,
mandt(50),
END OF gi_fieldnames.

*file path and file name data declaration.
DATA: stripped_name LIKE rlgrap-filename,
file_path LIKE rlgrap-filename.
DATA: inpath LIKE ltran-path01,
file LIKE ltran-file01,
outpath LIKE ltran-path02.



Field Symbols ************
FIELD-SYMBOLS LIKE gi_mara.
FIELD-SYMBOLS LIKE gi_marc.
FIELD-SYMBOLS LIKE gi_makt.
FIELD-SYMBOLS LIKE gi_download.


SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN: SKIP.
SELECT-OPTIONS: s_werks FOR marc-werks.
SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECT-OPTIONS: s_matkl FOR mara-matkl.
SELECT-OPTIONS: s_spart FOR mara-spart.
SELECTION-SCREEN: SKIP.
PARAMETER fnm TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN: SKIP.

SELECTION-SCREEN: END OF BLOCK b1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR fnm.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = fnm
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


*For fetching the baisc data.

START-OF-SELECTION.

*******************************************************************
*Getting the general data based on material no,division and material
*group.
*******************************************************************
SELECT * FROM mara INTO TABLE gi_mara
WHERE matnr IN s_matnr
AND spart IN s_spart
AND matkl IN s_matkl.

*******************************************************************
*Getting the plant data based on material no,plant and purchasing
*group.
*******************************************************************

IF NOT gi_mara[] IS INITIAL.
SELECT * FROM marc INTO TABLE gi_marc
FOR ALL ENTRIES IN gi_mara
WHERE matnr EQ gi_mara-matnr
AND werks IN s_werks
AND ekgrp IN s_ekgrp.
ENDIF.

***********************************************************
*Getting the material description based on material no
***********************************************************


IF NOT gi_mara[] IS INITIAL.
SELECT * FROM makt INTO TABLE gi_makt
FOR ALL ENTRIES IN gi_mara
WHERE matnr = gi_mara-matnr.
ENDIF.




Fetching all data into single internal table ********
SORT gi_mara BY matnr.
SORT gi_makt BY matnr.
SORT gi_marc BY matnr.

******Transfering the data into gi_download********


IF s_werks] IS INITIAL and s_ekgrp[ IS INITIAL.
LOOP AT gi_mara ASSIGNING .
MOVE-CORRESPONDING TO gi_download.
READ TABLE gi_marc ASSIGNING
WITH KEY matnr = -matnr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE -werks TO gi_download-werks.
MOVE -ekgrp TO gi_download-ekgrp.
ENDIF.

READ TABLE gi_makt ASSIGNING
WITH KEY matnr = -matnr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE -maktx TO gi_download-maktx.
MOVE -spras TO gi_download-spras.
ENDIF.
APPEND gi_download.
CLEAR gi_download.
ENDLOOP.

ELSE.
LOOP AT gi_marc ASSIGNING .
READ TABLE gi_mara ASSIGNING
WITH KEY matnr = -matnr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE-CORRESPONDING TO gi_download.
ENDIF.

READ TABLE gi_makt ASSIGNING
WITH KEY matnr = -matnr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE -maktx TO gi_download-maktx.
MOVE -spras TO gi_download-spras.
ENDIF.

MOVE -werks TO gi_download-werks.
MOVE -ekgrp TO gi_download-ekgrp.
APPEND gi_download.
CLEAR gi_download.

ENDLOOP.

ENDIF.

IF gi_download[] IS INITIAL.
MESSAGE i001(sa) WITH 'Data not found'.
LEAVE LIST-PROCESSING.
ENDIF.

********Downloading the basic data*********

gi_fieldnames-mandt = 'Material no'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.

gi_fieldnames-mandt = 'Material description'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.

gi_fieldnames-mandt = 'Material group'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Plant'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Purchasing group'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Division'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Base uit of measure'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Old material no.'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Product hierarchy'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Gross weight'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Net weight'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Weight unit'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Volume'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Volume unit'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document no.'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document type'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Document version'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Page format of document'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Number of sheets'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.
gi_fieldnames-mandt = 'Language key'.
APPEND gi_fieldnames.
CLEAR gi_fieldnames.

CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = fnm
IMPORTING
stripped_name = stripped_name
file_path = file_path
EXCEPTIONS
x_error = 1
OTHERS = 2.


IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR fnm.
CONCATENATE file_path stripped_name INTO fnm.

CLEAR: inpath,file,stripped_name,file_path,outpath.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = fnm
filetype = 'DAT'
TABLES
data_tab = gi_download
fieldnames = gi_fieldnames
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE i003(sa) WITH 'File downloaded successfuly' fnm.
ENDIF.



ALSO READ:

- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.

- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.

- Sample Program For Creating XML File On Presentation Server.

- Uploading Multiple Files At One Time.


RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.


ABAP - Function Module For Calling Smartforms.


You should use 'SSF_FUNCTION_MODULE_NAME' & call function fm_name in your program & not others.

*&---------------------------------------------------------------------*
*& Report ZTACA_DRIVER_SMARTFORM *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZTACA_DRIVER_SMARTFORM .

Tables : sflight.
Data : fm_name TYPE rs38l_fnam.

*data : Begin of it_flttab occurs 0,
* carrid type sflight-carrid,
* connid type sflight-connid,
* fldate type sflight-fldate,
* seatsmax type sflight-seatsmax,
* seatsocc type sflight-seatsocc,
* End of it_flttab.

data : it_flttab like table of sflight.
Data : g_salary type i .
* it_flttab type standard table of ty_flt.
g_salary = 1000.


select carrid connid fldate seatsmax seatsocc from sflight into
corresponding fields of table it_flttab.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZTACA_SMFORM2'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = fm_name
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
.
IF sy-subrc <> 0.
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
salary = g_salary
TABLES
it_flttab = it_flttab
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.

ABAP - Sample Program To Search For Standard or Customised Smartforms.

*&---------------------------------------------------------------------*
*& Report : ZTEST_SEARCH_FORMNAME
*
*& Created by : SHYAM BABU SAH.
*& date : 17.01 2007.
*
*&---------------------------------------------------------------------*
*& This program will help you to search the SMARTFORM either Standard
* Or Customer created in your compatiable language.
* *
*&---------------------------------------------------------------------*
REPORT ZTEST_SEARCH_FORMNAME .
TYPE-POOLS: SLIS.
TABLES: STXFADM, STXFADMT.
DATA: BEGIN OF ITAB OCCURS 0,
FORMNAME LIKE STXFADM-FORMNAME,
MASTERLANG LIKE STXFADM-MASTERLANG,
DEVCLASS LIKE STXFADM-DEVCLASS,
VERSION LIKE STXFADM-VERSION,
FIRSTUSER LIKE STXFADM-FIRSTUSER,
FIRSTDATE LIKE STXFADM-FIRSTDATE,
FIRSTTIME LIKE STXFADM-FIRSTTIME,
LASTUSER LIKE STXFADM-LASTUSER,
LASTDATE LIKE STXFADM-LASTDATE,
FORMTYPE LIKE STXFADM-FORMTYPE,
CAPTION LIKE STXFADMT-CAPTION,
END OF ITAB.

DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_DEV FOR STXFADM-DEVCLASS NO INTERVALS.
SELECT-OPTIONS: S_FORM FOR STXFADM-FORMNAME NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS: P_LANG LIKE T002-SPRAS DEFAULT 'EN'.
SELECTION-SCREEN END OF BLOCK B1.

PERFORM F_SELECT_DATA.
PERFORM F_LAYOUT.
PERFORM F_FIELDCAT.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*& Form f_select_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM F_SELECT_DATA . SELECT A~FORMNAME A~MASTERLANG A~DEVCLASS A~VERSION A~FIRSTUSER A~FIRSTDATE A~FIRSTTIME A~LASTUSER A~LASTDATE A~FORMTYPE B~CAPTION FROM STXFADM AS A INNER JOIN STXFADMT AS B ON A~FORMNAME = B~FORMNAME INTO TABLE ITAB WHERE A~DEVCLASS IN S_DEV AND A~FORMNAME IN S_FORM AND B~LANGU = P_LANG. IF SY-SUBRC = 0. SORT ITAB BY FORMNAME. ELSE. MESSAGE I398(00) WITH 'No Form Exits for this selection criteria'. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. " f_select_data *&---------------------------------------------------------------------* *& Form display *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM DISPLAY . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = SYST-CPROG IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FIELDCAT TABLES T_OUTTAB = ITAB. IF SY-SUBRC <> 0.
ENDIF.

ENDFORM. " display
*&---------------------------------------------------------------------*
*& Form f_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM F_FIELDCAT . DATA: WA_COL TYPE I VALUE 1. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-003. " Form Name WA_FIELDCAT-FIELDNAME = 'FORMNAME'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-004. " Smart form Text WA_FIELDCAT-FIELDNAME = 'CAPTION'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-005. "Package WA_FIELDCAT-FIELDNAME = 'DEVCLASS'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-006. "First User WA_FIELDCAT-FIELDNAME = 'FIRSTUSER'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-007. "First Date WA_FIELDCAT-FIELDNAME = 'FIRSTDATE'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-008. "Version WA_FIELDCAT-FIELDNAME = 'VERSION'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-009. "Master Language WA_FIELDCAT-FIELDNAME = 'MASTERLANG'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. WA_FIELDCAT-COL_POS = WA_COL + 1. WA_FIELDCAT-SELTEXT_L = TEXT-010. "Last User WA_FIELDCAT-FIELDNAME = 'LASTUSER'. WA_FIELDCAT-TABNAME = 'ITAB'. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT. ENDFORM. " f_fieldcat *&---------------------------------------------------------------------* *& Form f_layout *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F_LAYOUT .

WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM. " f_layout

ABAP - Checkbox In Selection Screen.

report ztestmail.


Parameters:
p_check as checkbox default 'X' user-command comm,
p_field type mara-matnr.

At selection-screen output.

if p_check = 'X'.
Loop at screen.
if screen-name cs 'P_FIELD'.
screen-active = 1.
Modify screen.
Endif.
Endloop.
Elseif p_check = ' '.
Loop at screen.
if screen-name cs 'P_FIELD'.
screen-active = 0.
Modify screen.
Endif.
Endloop.
Endif.



ABAP - Sample Program On Sending E-Mail To External Mailbox.

Sending External email through SAP
What is the FM for sending the external email through SAP by attaching layout set to it?

These are the FM for sending external email :-

SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments via RFC

SO_NEW_DOCUMENT_ATT_SEND_API1
(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
SAPoffice: Send new document with attachments via RFC
Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.

SO_NEW_DOCUMENT_SEND_API1
SAPoffice: Send new document



--------------------------------------------------------------------------------

How to send a report to an external mail-id?
Try this sample code :-

REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.

DATA : BEGIN OF ITAB OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.

DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.

START-OF-SELECTION.

SELECT PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM PA0001
WHERE PERNR < recextnam =" 'EXTERNAL-MAIL-ID@YAHOO.COM'.">
* EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-

APPEND receiver_list.

* General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
* Mail subject
w_object_hd_change-objdes = 'Message subject'.

* Mail body
APPEND 'Message content' TO message_content.

* Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.

CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment.

ABAP - Sample Code On ALV Display With Colors.

REPORT ztest_alv_perc_13317.
TYPE-POOLS: slis.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
l_layout TYPE slis_layout_alv.


TYPES: BEGIN OF ty_itab,
field1(10),
qty1 TYPE i,
qty2 TYPE i,
qty3 TYPE i,
END OF ty_itab.

DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,
itab1 TYPE ty_itab.

START-OF-SELECTION.
itab-field1 = 'FIRST'.
itab-qty1 = 21.
itab-qty2 = 12.
itab-qty3 = 53.
APPEND itab.

itab-field1 = 'SECOND'.
itab-qty1 = 12.
itab-qty2 = 31.
itab-qty3 = 05.
APPEND itab.

itab-field1 = 'THIRD'.
itab-qty1 = 34.
itab-qty2 = 16.
itab-qty3 = 75.
APPEND itab.

wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-EMPHASIZE = 'C320'.
wa_fieldcat-tabname = 'ITAB'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'QTY1'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-EMPHASIZE = 'C321'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'QTY2'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-EMPHASIZE = 'C520'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'QTY3'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-EMPHASIZE = 'C621'.
APPEND wa_fieldcat TO it_fieldcat.



CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.



ALSO READ:

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

- ALV Subtotals In Different Blocks.

- ALV With Page Numbers & Subtotals.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


ABAP - List Of Standard Report Programs.

BALVBT01
Example SAP program for displying multiple ALV reports on one page


BCALV_GRID_DEMO
ALV Dialog grid demo (4.6)


SHOW_COLO
Displays all colours available


SHOW_ICON
Displays all icon available


RGUGBR00
Substitution/Validation and rules utility


RKCTSEAR
Search source code of various programs for up to two strings. Also see RPR_ABAP_SOURCE_SCAN or use search in source functionality via SE80


RPCIFU01
Display File


RPCIFU03
Download Unix File to PC


RPCIFU04
Upload PC File to Unix File


RPR_ABAP_SOURCE_SCAN
Search ABAP code for a string. Much more flexible than RSRSCAN1 or RKCTSEAR


RSBDCBTC
Submit a BDC job with an internal batch number and wait for the end of the batch input session


RSBDCDRU
Prints the contents of a Batch Input session. No options for error transactions only


RSBDCOS0
Execute OS Command (Logged in SYSLOG and Trace Files)


RSBDCSUB
Process batch input sessions automatically


RSBTCDEL
Delete batch jobs


RSCONN01
SAPconnect: Start Email Send Process


RSCSAUTH
Maintain/Restore Authorization Groups


RSINCL00
Extended ABAP Program Reference List


RSMODRES
Restore enhancement projects after upgarde


RSORAREL
Check Oracle Version


RSPARAM
Display all instance parameters


RSPO0041
Delete Old Spool Requests


RSSNAPDL
Reorganization Program for Table SNAP of Short Dumps


RSTRANSP
Transport Report Variants


RSTXFCON
SAPscript: Conversion of Page Format for Forms


RSTXPDFT4
Convert spool request to PDF document


RSTXPDFT5
GUI download of a spool request


RSTXSCRP
SAPscript Export to Dataset / SAPscript Import from Dataset (Upload and download SAPScript layout sets)


RSTXTRAN
Transfer of SAPscript Texts(standard texts) to a transport


RSUSR003
Check the Passwords of Users SAP* and DDIC in All Clients


RSUSR006
List of Users with Incorrect Logons
REKH0004

SAP demo program that shows how to do 2d 3D, and 4D graphics.

RGUGBR00

Substitution/Validation utility


RHGEN00

Regen PD and PA inconsistencies



RHGRENZ0



Delimit IT1000 and related 1001s. Program will delete any 1001 infotypes whose start date is after the delimit date.



RHGRENZ1
Extend the end date on delimited records. Very useful when you delimit a bunch of records incorrectly, and need to change the end date.



RHGRENZ2
Delimit IT1001 only.



RKCTSEAR
Search source code for up to two strings. Also see RSRSCAN1 and RPR_ABAP_SOURCE_SCAN.



RPDTRA00
List all HR transactions.



RPR_ABAP_SOURCE_SCAN

Search ABAP code for a string. Has many more options for selecting the ABAPs to search than RSRSCAN1 or RKCTSEAR.


RPUAUD00

HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster.


RPUAUDDL

HR Report to delete audit data from the PCL4 Audit Cluster.


RPUDELPN

Delete all info for an employee number, including cluster data and infotypes


RPUP1D00/10

View/Delete data from PCL1 Cluster


RPUP2D00/10

View/Delete data from PCL2 Cluster


RPUP3D00/10

View/Delete data from PCL3 Cluster


RPUP4D00/10

View/Delete data from PCL4 Cluster


RSABAPIV

Mass print/display of ABAP/4 help text


RSAVGL00
Table adjustment across clients


RSBDCBTC
Submit a BDC job with an internal batch number and wait for the end of the batch input session.


RSBDCDRU
Prints the contents of a Batch Input session. No options for error transactions only.


RSBDCOS0
Execute UNIX commands. Looks similar to the old SAPMSOS0 program that disappeared in 3.0


RSBDCSUB
Release batch input sessions automatically


RSBTCDEL
Clean the old background job records


RSSDOCTB
R/3 Table Manual - prints a list of all fields in the selected tables with the field name and the field documentation.


RSCLTCOP
Copy tables across clients


RSDBCREO
Clean batch input session log


RSINCL00
Extended program list


RSNASTED
Process message control output for entries in the NAST table


RSORAREL
Get the Oracle Release


RSPARAM
Display all instance parameters


RSPO0041
Removing old spooling objects


RSRSCAN1
Search source code for a given string. Will also search includes. Also see RKCTSEAR and RPR_ABAP_SOURCE_SCAN.


RSSNAPDL
Clean the old ABAP error dumps


RSTBSERV
Compare a contents of a table between clients


RSTXFCON
Converts SAPScript page formats


RSTXSCRP
Save a SAPScript layout set to disk, and load it back into SAP.


RSTXSCRP
Transport SAPscript files across systems


RSTXSCRP
Upload and download SAPScript layout sets


RSTXTPDF4
Pass the spool number of a report's output to this program to have the output converted to PDF format.


RSTXTRAN
Add standard texts to a transport so they can be moved between systems.


RSUSR003
Check the passwords of users SAP* and DDIC in all clients


RSUSR006
List users last login


RSWBO052
Change development class of a sapscript (provided by Alan Cecchini)


RSWBO060
put objects into a request and transport it to any other system

BCALV_GRID_DEMO
ALV Dialog grid demo (4.6)


SHOW_COLO
Displays all colours available


SHOW_ICON
Displays all icon available


RGUGBR00
Substitution/Validation and rules utility


RKCTSEAR
Search source code of various programs for up to two strings. Also see RPR_ABAP_SOURCE_SCAN or use search in source functionality via SE80


RPCIFU01
Display File


RPCIFU03
Download Unix File to PC


RPCIFU04
Upload PC File to Unix File


RPR_ABAP_SOURCE_SCAN
Search ABAP code for a string. Much more flexible than RSRSCAN1 or RKCTSEAR


RSBDCBTC
Submit a BDC job with an internal batch number and wait for the end of the batch input session


RSBDCDRU
Prints the contents of a Batch Input session. No options for error transactions only


RSBDCOS0
Execute OS Command (Logged in SYSLOG and Trace Files)


RSBDCSUB
Process batch input sessions automatically


RSBTCDEL
Delete batch jobs


RSCONN01
SAPconnect: Start Email Send Process


RSCSAUTH
Maintain/Restore Authorization Groups


RSINCL00
Extended ABAP Program Reference List


RSMODRES
Restore enhancement projects after upgarde


RSORAREL
Check Oracle Version


RSPARAM
Display all instance parameters


RSPO0041
Delete Old Spool Requests


RSSNAPDL
Reorganization Program for Table SNAP of Short Dumps


RSTRANSP
Transport Report Variants


RSTXFCON
SAPscript: Conversion of Page Format for Forms


RSTXPDFT4
Convert spool request to PDF document


RSTXPDFT5
GUI download of a spool request


RSTXSCRP
SAPscript Export to Dataset / SAPscript Import from Dataset (Upload and download SAPScript layout sets)


RSTXTRAN
Transfer of SAPscript Texts(standard texts) to a transport


RSUSR003
Check the Passwords of Users SAP* and DDIC in All Clients


RSUSR006
List of Users with Incorrect Logons


RSVARFIT
Adjust Variants to Modified Selections


RSVTPROT
Evaluation of change logs


RSWBO052
Change Object Directory Entries


RSWBO060
Include Objects in a Transport Request


SAPMSUU0
Program for user maintenance(SU01), Maybe useful if you do not have access to the actual SU01 transaction code.

ABAP - Submit Command -Syntax & Example.

REPORT report1.

DATA text TYPE c LENGTH 10.

SELECTION-SCREEN BEGIN OF SCREEN 1100.
SELECT-OPTIONS: selcrit1 FOR text,
selcrit2 FOR text.
SELECTION-SCREEN END OF SCREEN 1100.

...


Calling program

REPORT report2.

DATA: text TYPE c LENGTH 10,
rspar_tab TYPE TABLE OF rsparams,
rspar_line LIKE LINE OF rspar_tab,
range_tab LIKE RANGE OF text,
range_line LIKE LINE OF range_tab.

...

rspar_line-selname = 'SELCRIT1'.
rspar_line-kind = 'S'.
rspar_line-sign = 'I'.
rspar_line-option = 'EQ'.
rspar_line-low = 'ABAP'.
APPEND rspar_line TO rspar_tab.

range_line-sign = 'E'.
range_line-option = 'EQ'.
range_line-low = 'H'.
APPEND range_line TO range_tab.

range_line-sign = 'E'.
range_line-option = 'EQ'.
range_line-low = 'K'.
APPEND range_line TO range_tab.

SUBMIT report1 USING SELECTION-SCREEN '1100'
WITH SELECTION-TABLE rspar_tab
WITH selcrit2 BETWEEN 'H' AND 'K'
WITH selcrit2 IN range_tab
AND RETURN.

SAP ABAP - List Of Standard System Tables With Details.

ADCP Person/Address assignment (central address administration)
ADIRACCESS Table to store keys for TADIR objects
ADR2 Telephone numbers (central address admin.)
ADRP Persons (central address administration)
APQD DATA DEFINITION Queue
APQI Queue info definition
D010SINF ABAP- Information about ABAP program source code
E071 Change and Transport System- Object Entries of Requests/Tasks
E07T Change and Transport System- Short Texts for Requests/Tasks
ENLFDIR Additional Attributes for Function Modules
INDX System table INDX
NAST Message Status
STXH STXD SAPscript text file header
T005 Countries
T005S Taxes- Region (Province) Key
T005U Taxes- Region Key- Texts
T006 Units of Measurement
T015M Names of the months
T247 Month name and short text
T777A Building Addresses
TADIR Directory of Repository Objects
TBTCO Job status overview table
TBTCP Batch job step overview
TFDIR Function Module
TFTIT Function Module Short Text
TSP03L Spool- Long device names
TSTC SAP Transaction Codes
TSTCT Transaction Code Texts
TUTYP User Types in Current Price List in SAP System
TUZUS Special versions
TVARV Table of variables in selection criteria
TVDIR View Directory
US930 Data Relevant to Measurement for User Master Record
USR01 User master record (runtime data)
USR02 Logon data
USR04 User master authorizations
USR06 Additional Data per User
USR14 Surchargeable Language Versions per User
USR21 Assign user name address key
ARCH_OBJ Objects for archiving and reorganization
BTCUED Description of user event IDs for background processing
BTXSUPB BSI- Upgrade-Information
CCCFLOW Client Copy Control Flow
DBSTATC DB Optimizer Control (Statistics Creation)
DEVACCESS Table for development users
DEVL OBSOLETE- Do not use (See TCETRAL)
E070 Change and Transport System- Header of Requests/Tasks
E070L CTS- Index for Assigning Numbers to Requests/Tasks
INSTVERS Documentation for installation Status and History
PAT03 Patch Directory
SDBAC DBA Action Table
T100 Messages
TAPLT Program Application Long Texts
TASYS OBSOLETE- Do not use, see TCEDELI
TDEVC Development Classes
TEMSE Temp Sequential table.
TLOCK Change and Transport System- Lock Table
TNAPR Processing programs for output. Can be very handy to find the print program for a SAPScript.
TNAST Printed output control table
TPFET Table of profile parameters
TPFHT Profile header, administration data for profiles in DB
TPROT Table contains all DD tables to be logged
TRBAT Communication Table for Transport Control
TRDIRT Title texts for programs in TRDIR
TRESN Table of Naming Conventions in ABAP Workbench
TRJOB Job ID for Coordinating Batch-ABAP/UNIX for Transports
TSP03C Spool- Device Description Extension
TST03 TemSe data
TSYST OBSOLETE- Do not use (see TCESYST)
TWSYS OBSOLETE- Do not use (See TCETRAL)
USOBT Relation transaction - authorization object
USR03 User address data
USR05 User Master Parameter ID
USR12 User master authorization values
USR40 Table for illegal passwords
USR41 User master- Additional data
UST04 User masters
VARIT Variant texts
VARID Variant directory
D010TAB Table for Use Report---Tables
DD02L SAP tables
DD02T R/3 DD- SAP table texts
DD03L Table Fields
DD03T DD- Texts for fields (language dependent)
EDIDC IDOC Control Records
EDIDOT Short description of IDoc types
EDID2 IDOC segments (version 3.1)
EDID4 IDOC segments (version 4.6)
EDSEA EDI- Table of all segments of current release
VRSX2 Central Table for Version Management (Report Source)
TSE05 Can add parameters to the INSERT COMMAND (IC). Then, when you insert command, your info appears in the editor. Useful for comment blocks, common section of code, etc.
CDPOS Change document items
CDHDR Change document header
T529A governs the foreground sequence of infotypes the system will use to prompt the user during online and batch processing. You will have to code your BDC to follow that sequence of creating infotypes.
T588Z governs the dynamic event processing that will only take place during online user inputs. For BDC's you will have to create separate BDC's to handle any infotypes that are inserted dynamically by this table.
T588M Infotype Screen Control

SAP ABAP - Sample Program On Payment Reminder.

make sure to include the pnp ldb.
REPORT zpar_paymentreminder
NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65.


*----------------------------------------------------------------------*
* T A B L E S *
*----------------------------------------------------------------------*
TABLES: pernr, "Standard Selections
pa0001, "Org. Assignment
pa0002, "Personal Data
pa0015, "Additional Payments
somlreci1, "API Recipient List
t512t. "Wage Type Texts

*----------------------------------------------------------------------*
* T Y P E - P O O L S *
*----------------------------------------------------------------------*
TYPE-POOLS : slis.

*----------------------------------------------------------------------*
* I N F O T Y P E S *
*----------------------------------------------------------------------*
INFOTYPES: 0001, "Org assignment
0002, "Personal Data
0015. "Additional Payments

*----------------------------------------------------------------------*
* T Y P E S *
*----------------------------------------------------------------------*
*- Type diclaration to hold payment reminder details
TYPES : BEGIN OF ty_payments,
pernr(10) TYPE c, "EE Number
lastn(40) TYPE c, "EE L name
vorna(40) TYPE c, "EE F name
lgart(10) TYPE c, "Wage type
lgtxt(25) TYPE c, "Wage type text
estdt(20) TYPE c, "Date of origion
betrg(20) TYPE c, "Wage type amount
waers(10) TYPE c, "Currency
zuord(20) TYPE c, "Assignment number
spernr(10) TYPE c, "Supervisor
slastn(40) TYPE c, "Supervisor L name
svorna(40) TYPE c, "Supervisor F name
END OF ty_payments,
tt_payments TYPE STANDARD TABLE OF ty_payments.

*- Types diclaration to hold wage type texts
TYPES : BEGIN OF ty_wtext,
lgart TYPE t512t-lgart, "Wage type
lgtxt TYPE t512t-lgtxt, "Wage type text
END OF ty_wtext,
tt_wtext TYPE STANDARD TABLE OF ty_wtext.

*- Types diclaration to hold supervisor fname lname
TYPES :BEGIN OF ty_supervisor,
pernr(8) TYPE c,
lastn(40) TYPE c,
vorna(40) TYPE c,
END OF ty_supervisor,
tt_supervisor TYPE STANDARD TABLE OF ty_supervisor.

*----------------------------------------------------------------------*
* S T R U C T U R E S *
*----------------------------------------------------------------------*
*- Structure to hold payments
DATA : gf_payments TYPE ty_payments,
*- Structure to hold Output Details in delimited format
gf_output_soli TYPE soli,
*- Structure to hold Imported Object Components
gf_objpack TYPE sopcklsti1,
*- Structure to hold data in single line format
gf_objhead TYPE solisti1,
*- Structure to hold data in single line format
gf_objtxt TYPE solisti1,
*- Structure to hold data for API Recipient List
gf_reclist TYPE somlreci1,
*- Structure to hold email data
gf_doc_chng TYPE sodocchgi1,
*- Structure to hold wage type texts
gf_wtext TYPE ty_wtext,
*- Structure to hold supervisor fname lname
gf_supervisor TYPE ty_supervisor,
*- Structure to hold layout settings
gf_layo TYPE slis_layout_alv.

*----------------------------------------------------------------------*
* I N T E R N A L T A B L E S *
*----------------------------------------------------------------------*
*- Inernal table to hold payments
DATA : it_payments TYPE tt_payments,
*- Internal Table to hold Output Details in delimited format
it_output_soli TYPE TABLE OF soli,
*- Internal Table to hold Imported Object Components
it_objpack TYPE TABLE OF sopcklsti1,
*- Internal Table to hold data in single line format
it_objhead TYPE TABLE OF solisti1,
*- Internal Table to hold data in single line format
it_objtxt TYPE TABLE OF solisti1,
*- Internal Table to hold data for API Recipient List
it_reclist TYPE TABLE OF somlreci1,
*- Internal Table to hold wage type texts
it_wtext TYPE tt_wtext,
*- Internal Table to hold supervisor fname lname
it_supervisor TYPE tt_supervisor,
*- Inernal Tabel to hold list headings
it_list TYPE slis_t_listheader,
*- Internal Table to hold events
it_events TYPE slis_t_event,
*- Internal Table to hold fieldcatalog
it_fcat TYPE slis_t_fieldcat_alv.

*----------------------------------------------------------------------*
* C O N S T A N T S *
*----------------------------------------------------------------------*
CONSTANTS : c_molga(2) TYPE c VALUE '10', "Country Grouping
c_int(3) TYPE c VALUE 'INT', "Internet mail address
c_doc_type(3) TYPE c VALUE 'RAW', "Code for document class
c_excel(3) TYPE c VALUE 'XLS', "Code for document class
c_rec_type TYPE c VALUE 'U', "Recipient type
c_express TYPE c VALUE 'X'. "Send express

*----------------------------------------------------------------------*
* S E L E C T I O N S C R E E N S *
*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK bl_pay WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_lgart FOR pa0015-lgart. "Wage type
PARAMETERS : p_days TYPE i. "Number of days prior

SELECTION-SCREEN END OF BLOCK bl_pay.

SELECTION-SCREEN BEGIN OF BLOCK bl_emopt WITH FRAME TITLE text-002.

PARAMETERS : p_email AS CHECKBOX. "Send mail
PARAMETERS : p_send TYPE adr6-smtp_addr DEFAULT 'HR DIRECT'."Sender
SELECT-OPTIONS : s_rec FOR somlreci1-receiver NO INTERVALS."Emailaddress

SELECTION-SCREEN END OF BLOCK bl_emopt.

*----------------------------------------------------------------------*
* S T A R T O F S E L E C T I O N *
*----------------------------------------------------------------------*
START-OF-SELECTION.

perform refresh_all.


*- Number of days to check prior
p_days = p_days - 1.
pnpendda = pnpendda + p_days.

*- Wage type texts
PERFORM wagetype_texts.

*- Get event
GET pernr.

*- Read latest record from Org. Assignment
rp-provide-from-last p0001 space pnpbegda pnpendda.
*- Read latest record from Personal Data
rp-provide-from-last p0002 space pnpbegda pnpendda.

*- Importing Supervisor details
PERFORM supervisor_flname.
*- Payment reminder details
PERFORM payment_reminder_details.

*----------------------------------------------------------------------*
* E N D O F S E L E C T I O N *
*----------------------------------------------------------------------*
END-OF-SELECTION.

*- Payment reminder mail attachments
PERFORM mail_details.

*- Send mail
IF NOT it_payments[] IS initial.
IF p_email = 'X'.
PERFORM send_mail.
ENDIF.
ENDIF.

*&---------------------------------------------------------------------*
*& Form wagetype_texts
*&---------------------------------------------------------------------*
* This routine for getting wagetype texts
*----------------------------------------------------------------------*
FORM wagetype_texts .

*- Get wage type text
SELECT lgart "Wage type
lgtxt "Wage type text
FROM t512t
INTO TABLE it_wtext
WHERE sprsl = sy-langu
AND molga = c_molga
AND lgart IN s_lgart.

IF sy-subrc = 0.
SORT it_wtext BY lgart.
ENDIF.

ENDFORM. " wagetype_texts

*&---------------------------------------------------------------------*
*& Form supervisor_flname
*&---------------------------------------------------------------------*
* This routine for getting supervisor fname lname
*----------------------------------------------------------------------*
FORM supervisor_flname .

*- Get supervisor Fname Lname
IF NOT p0001-mstbr IS initial.
SELECT pernr "Supervisor
nachn "Supervisor L name
vorna "Supervisor F name
FROM pa0002
INTO TABLE it_supervisor
WHERE pernr = p0001-mstbr
AND begda <= pnpendda AND endda >= pnpbegda.
ENDIF.

ENDFORM. " supervisor_flname

*&---------------------------------------------------------------------*
*& Form payment_reminder_details
*&---------------------------------------------------------------------*
* This routine for populating Payment reminder details
*----------------------------------------------------------------------*
FORM payment_reminder_details .

*- Local declarations
DATA : l_estdt(10) TYPE c. "Date
*- Clear
CLEAR l_estdt.

LOOP AT p0015 INTO p0015 WHERE begda <= pnpendda AND endda >= pnpbegda
AND lgart IN s_lgart.

gf_payments-pernr = p0015-pernr. "EE Number
gf_payments-lastn = p0002-nachn. "EE L name
gf_payments-vorna = p0002-vorna. "EE F name
gf_payments-lgart = p0015-lgart. "Wage type

*- Wage type text
READ TABLE it_wtext INTO gf_wtext
WITH KEY lgart = p0015-lgart
binary search
transporting lgtxt.
IF sy-subrc = 0.
gf_payments-lgtxt = gf_wtext-lgtxt. "Wage type text
ENDIF.
*- Date of origion
IF NOT p0015-begda IS initial.
WRITE p0015-begda TO l_estdt.
ENDIF.
gf_payments-estdt = l_estdt. "Date of origion
gf_payments-betrg = p0015-betrg. "Wagetype amount
gf_payments-waers = p0015-waers. "Currency
gf_payments-zuord = p0015-zuord. "Assignment number
*- Supervisor details
READ TABLE it_supervisor INTO gf_supervisor WITH KEY
pernr = p0001-mstbr.
gf_payments-spernr = gf_supervisor-pernr. "Supervisor
gf_payments-slastn = gf_supervisor-lastn. "Supervisor L name
gf_payments-svorna = gf_supervisor-vorna. "Supervisor F name

*- Append
APPEND gf_payments TO it_payments.
*-Clear
CLEAR gf_payments.

ENDLOOP.

ENDFORM. " payment_reminder_details

*&---------------------------------------------------------------------*
*& Form mail_details
*&---------------------------------------------------------------------*
* This routine for header and payment reminder details to send mail
*----------------------------------------------------------------------*
FORM mail_details .

*- Local declarations
DATA : lf_string TYPE string. "To hold output data

*- Clear
CLEAR lf_string.

*- Header data of payment reminder
PERFORM move_header_details_data.

*- Payments reminder data
LOOP AT it_payments INTO gf_payments.

CONCATENATE gf_payments-pernr gf_payments-lastn gf_payments-vorna
gf_payments-lgart gf_payments-lgtxt gf_payments-estdt
gf_payments-betrg gf_payments-waers gf_payments-zuord
gf_payments-spernr gf_payments-slastn gf_payments-svorna
INTO lf_string SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.

CONCATENATE cl_abap_char_utilities=>newline lf_string
INTO lf_string.
*- Move
MOVE lf_string TO gf_output_soli-line.
*- Append
APPEND gf_output_soli TO it_output_soli.
*- Clear
CLEAR : gf_output_soli, lf_string.
ENDLOOP.

ENDFORM. " mail_details

*&---------------------------------------------------------------------*
*& Form move_header_details_data
*&---------------------------------------------------------------------*
* This routine for header details for mail attachment
*----------------------------------------------------------------------*
FORM move_header_details_data .

*- Local declarations
DATA : lf_string TYPE string. "To hold output data

CONCATENATE text-003 text-004 text-005 text-006
text-007 text-008 text-009 text-010
text-011 text-012 text-013 text-014
INTO lf_string SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.

*- Move
MOVE lf_string TO gf_output_soli-line.
*- Append
APPEND gf_output_soli TO it_output_soli.
*- Clear
CLEAR : gf_output_soli, lf_string.

ENDFORM. " move_header_details_data

*&---------------------------------------------------------------------*
*& Form send_mail
*&---------------------------------------------------------------------*
* Sending payment reminder details to employee with attachment
*----------------------------------------------------------------------*
FORM send_mail.

*- Local declarations
DATA: l_lines TYPE sy-tabix, "To hold number of records
l_msg_lines TYPE sy-tabix. "To hold number of records

*- Clear
CLEAR : l_lines, l_msg_lines.

*- Creation of the document to be sent
gf_doc_chng-obj_name = text-022.
gf_doc_chng-obj_descr = text-022.

*- Body of mail data
PERFORM move_body_mail_data.

DESCRIBE TABLE it_objtxt LINES l_msg_lines.
READ TABLE it_objtxt INTO gf_objtxt INDEX l_msg_lines.
gf_doc_chng-doc_size = ( l_msg_lines - 1 ) * 255 + STRLEN( gf_objtxt )
.
*- Creation of the entry for the compressed document
gf_objpack-transf_bin = ' '.
gf_objpack-head_start = 1.
gf_objpack-head_num = 0.
gf_objpack-body_start = 1.
gf_objpack-body_num = l_msg_lines.
gf_objpack-doc_type = c_doc_type.
*- Append
APPEND gf_objpack TO it_objpack.
*- Clear
CLEAR gf_objpack.

*- Creation of the document attachment
*- Describe
DESCRIBE TABLE it_output_soli LINES l_lines.

*- Don't create attachment if no data is present
IF l_lines <> 0.
LOOP AT it_output_soli INTO gf_output_soli.
gf_objtxt = gf_output_soli.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.
ENDLOOP.

*- Object header
gf_objhead-line = text-022.
*- Append
APPEND gf_objhead TO it_objhead.
*- Clear
CLEAR gf_objhead.

*- Creation of the entry for the compressed attachment
gf_objpack-transf_bin = ' '.
gf_objpack-head_start = 1.
gf_objpack-head_num = 1.
gf_objpack-body_start = l_msg_lines + 1.
gf_objpack-body_num = l_lines.
gf_objpack-doc_type = c_excel.
gf_objpack-obj_name = text-023.
gf_objpack-obj_descr = text-023.
gf_objpack-doc_size = l_lines * 255.
*- Append
APPEND gf_objpack TO it_objpack.
*- Clear
CLEAR gf_objpack.
ENDIF.

*- Completing the recipient list
LOOP AT s_rec.
gf_reclist-receiver = s_rec-low.
gf_reclist-rec_type = c_rec_type.
gf_reclist-express = c_express.
*- Append
APPEND gf_reclist TO it_reclist.
*- Clear
CLEAR gf_reclist.
ENDLOOP.

* gf_reclist-receiver = text-026.
* gf_reclist-rec_type = c_rec_type.
* gf_reclist-express = c_express.
**- Append
* APPEND gf_reclist TO it_reclist.
**- Clear
* CLEAR gf_reclist.


CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = gf_doc_chng
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = it_objpack
OBJECT_HEADER = it_objhead
CONTENTS_TXT = it_objtxt
RECEIVERS = it_reclist
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 8.

IF sy-subrc <> 0.
WRITE:/ text-024.
ELSE.
*- Display the Email Id and details for which email was send.
PERFORM display_payments_reminder.
ENDIF.

IF sy-subrc = 0.
*- Calling the program to send the email
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = c_int
AND RETURN.
ENDIF.

ENDFORM. " send_mail

*&---------------------------------------------------------------------*
*& Form move_body_mail_data
*&---------------------------------------------------------------------*
* This routine for body of the mail
*----------------------------------------------------------------------*
FORM move_body_mail_data .

*- Local declarations
DATA : l_begda(10) TYPE c, "Begin date
l_endda(10) TYPE c. "End date

*- Clear
CLEAR : l_begda, l_endda.

*- Report run dates
WRITE pnpbegda TO l_begda.
WRITE pnpendda TO l_endda.

CONCATENATE text-015 l_begda 'for' l_endda
INTO gf_objtxt-line SEPARATED BY space.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = space.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-016.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-017.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-018.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-019.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-020.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = text-021.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = space.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

gf_objtxt-line = space.
*- Append
APPEND gf_objtxt TO it_objtxt.
*- Clear
CLEAR gf_objtxt.

ENDFORM. " move_body_mail_data

*&---------------------------------------------------------------------*
*& Form display_payments_reminder
*&---------------------------------------------------------------------*
* This routine for display email details for which email was send
*----------------------------------------------------------------------*
FORM display_payments_reminder .

*- Fieldcatalog
PERFORM fill_fieldcatalog.
*- Events
PERFORM fill_events.
*- Display output
PERFORM display_output.

ENDFORM. " display_payments_reminder

*&---------------------------------------------------------------------*
*& Form fill_fieldcatalog
*&---------------------------------------------------------------------*
* This routine for field attributes
*----------------------------------------------------------------------*
FORM fill_fieldcatalog .

*- Local data
DATA : l_cnt TYPE i.
DATA : lf_fcat LIKE LINE OF it_fcat. "Fieldcatalog


*- EE Number.
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'PERNR'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-003.
APPEND lf_fcat TO it_fcat.

*- EE L name
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'LASTN'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-004.
APPEND lf_fcat TO it_fcat.

*- EE F name
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'VORNA'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-005.
APPEND lf_fcat TO it_fcat.

*- Wage type
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'LGART'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-006.
APPEND lf_fcat TO it_fcat.

*- Wage type text
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'LGTXT'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-007.
APPEND lf_fcat TO it_fcat.

*- Date of origion
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'ESTDT'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-008.
APPEND lf_fcat TO it_fcat.

*- Wage type amount
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'BETRG'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-009.
APPEND lf_fcat TO it_fcat.

*- Currency
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'WAERS'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-010.
APPEND lf_fcat TO it_fcat.

*- Assignment number
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'ZUORD'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-011.
APPEND lf_fcat TO it_fcat.

*- Supervisor
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'SPERNR'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-012.
APPEND lf_fcat TO it_fcat.

*- Supervisor l name
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'SLASTN'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-013.
APPEND lf_fcat TO it_fcat.

*- Supervisor f name
ADD 1 TO l_cnt.
CLEAR lf_fcat.
lf_fcat-fieldname = 'SVORNA'.
lf_fcat-tabname = 'IT_PAYMENTS'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-seltext_l = text-014.
APPEND lf_fcat TO it_fcat.


ENDFORM. " fill_fieldcatalog

*&---------------------------------------------------------------------*
*& Form fill_events
*&---------------------------------------------------------------------*
* This routine for events
*----------------------------------------------------------------------*
FORM fill_events .

*- Local declarations
DATA : lf_event LIKE LINE OF it_events. "Events
*- Clear
CLEAR : lf_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = it_events
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.

IF sy-subrc EQ 0.
*- Read events table
READ TABLE it_events INTO lf_event WITH KEY name = slis_ev_top_of_page.
*- Move
MOVE 'TOP_OF_PAGE' TO lf_event-form.
*- Append
APPEND lf_event TO it_events.
*- Clear
CLEAR lf_event.
ENDIF.

ENDFORM. " fill_events

*&---------------------------------------------------------------------*
*& Form display_output
*&---------------------------------------------------------------------*
* This routine for display output
*----------------------------------------------------------------------*
FORM display_output .

*- Local declarations
DATA : l_repid TYPE sy-repid. "Report name
*- Move
l_repid = sy-repid.

*- Layout settings
gf_layo-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = l_repid
IS_LAYOUT = gf_layo
IT_FIELDCAT = it_fcat
I_SAVE = 'X'
IT_EVENTS = it_events
TABLES
T_OUTTAB = it_payments
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

ENDFORM. " display_output

*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* This routine for heading
*----------------------------------------------------------------------*
FORM top_of_page.

*- Local declarations
DATA : lf_list LIKE LINE OF it_list. "List heading
*- Clear
CLEAR lf_list.

lf_list-typ = 'H'.
lf_list-info = text-025.
*- Append
APPEND lf_list TO it_list.
*- Clear
CLEAR lf_list.

LOOP AT s_rec.
lf_list-typ = 'S'.
lf_list-info = s_rec-low.
*- Append
APPEND lf_list TO it_list.
*- Clear
CLEAR lf_list.
ENDLOOP.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_list.

ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form refresh_all
*&---------------------------------------------------------------------*
FORM refresh_all .
CLEAR : gf_payments, gf_wtext, it_payments[], it_wtext[],
gf_supervisor, it_supervisor[].
ENDFORM. " refresh_all

ABAP - Function Module To Find The Week Number - 'DATE_GET_WEEK' .

data: week type SCAL-WEEK .
parameters:p_date type SCAL-date .

CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = p_date
IMPORTING
WEEK = week.

write:/ 'the week no is', week+4(2) .

ABAP - Function Module To Find The Week Days - 'WEEKDAY_GET'.

report .

data:WEEKDAY type T246 .


parameters:p_test type sy-subrc .

data: it_WEEKDAY type t246 occurs 0 with header line .

CALL FUNCTION 'WEEKDAY_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE = p_test
TABLES
weekday = it_WEEKDAY .

write:/ it_weekday-LANGT .

ABAP - Sample Program On ALV Tree.

REPORT z_simpletree.

* type pool declarations for tree
TYPE-POOLS : fibs,stree.

*Data declaration for additional node information
DATA : t_node TYPE snodetext.

*Internal table and wa decl for nodes
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.

*Internal table and wa decl for Education table PA0022
DATA : it_0022 TYPE STANDARD TABLE OF pa0022 INITIAL SIZE 0,
wa_0022 TYPE pa0022.

*Internal table and wa decl for text table t517x
DATA : it_517x TYPE STANDARD TABLE OF t517x INITIAL SIZE 0,
wa_517x TYPE t517x.

*Internal table and wa decl for text table t517T
DATA : it_517t TYPE STANDARD TABLE OF t517t INITIAL SIZE 0,
wa_517t TYPE t517t.

*Internal table and wa decl for text table t519T
DATA : it_519t TYPE STANDARD TABLE OF t519t INITIAL SIZE 0,
wa_519t TYPE t519t.

*initialization event
INITIALIZATION.

*Start of selection event
START-OF-SELECTION.

*Select the data for tree
PERFORM fetch_data.

*Build the hierarchy for tree
PERFORM build_hierarchy.

*Build Tree for display
PERFORM build_tree.

*&--------------------------------------------------------------*
*& Form fetch_data
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text *---------------------------------------------------------------*

FORM fetch_data .
*select data from PA0022

SELECT * FROM pa0022 INTO CORRESPONDING FIELDS OF TABLE it_0022
UP TO 50 ROWS.

*select data from T517x
SELECT * FROM t517x INTO CORRESPONDING FIELDS OF TABLE it_517x
WHERE langu = 'E'.

*select data from T517T
SELECT * FROM t517t INTO CORRESPONDING FIELDS OF TABLE it_517t
WHERE sprsl = 'E'.

*select data from T519t
SELECT * FROM t519t INTO CORRESPONDING FIELDS OF TABLE it_519t
WHERE sprsl = 'E'.

ENDFORM. " fetch_data

*&----------------------------------------------------------------* *& Form build_hierarchy *&----------------------------------------------------------------* * text *----------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------*

FORM build_hierarchy .

*Building the nodes and hierarchy for tree
CLEAR : it_node[], wa_node.
wa_node-type = 'T'.
wa_node-name = 'Education'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = 'Infotype 0022'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.

*Filling the values of internal table into tree
LOOP AT it_0022 INTO wa_0022.
wa_node-type = 'P'.
wa_node-name = 'PERNR'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_0022-pernr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.

*Filling the text of T517t

READ TABLE it_517t INTO wa_517t WITH KEY slart = wa_0022-slart.
wa_node-type = 'P'.
wa_node-name = wa_0022-slart.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.

*Filling the text of T519t

READ TABLE it_519t INTO wa_519t WITH KEY slabs = wa_0022-slabs.
wa_node-type = 'P'.
wa_node-name = wa_0022-slabs.
wa_node-tlevel = '04'.
wa_node-nlength = '8'.
wa_node-color = '2'.
wa_node-text = wa_519t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.

*Filling the text of T517x
READ TABLE it_517x INTO wa_517x WITH KEY faart = wa_0022-sltp1.
wa_node-type = 'P'.
wa_node-name = wa_0022-sltp1.
wa_node-tlevel = '05'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517x-ftext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.

wa_node-type = 'P'.
wa_node-tlevel = '06'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = '% Completed'.
wa_node-tlength ='15'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
ENDLOOP.

ENDFORM. " build_hierarchy

*&---------------------------------------------------------------* *& Form build_tree *&---------------------------------------------------------------* * text *----------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------*

FORM build_tree .

*Fm for constructing the tree

CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*FM for displaying the tree

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-repid
check_duplicate_name = '1'
color_of_node = '4'
color_of_mark = '3'
color_of_link = '1'
color_of_match = '5'
node_length = 30
text_length = 75
use_control = 'L'.ENDFORM. " build_tree



ALSO READ:

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

- ALV Subtotals In Different Blocks.

- ALV With Page Numbers & Subtotals.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


ABAP- Convert Data In Excel (.XLS) Format & Mail It.

Here i'm posting u sample code try to execute it. It will convert all the data in the related tables to excel format and transfer it to respective mail id

code&---------------------------------------------------------------------
*& Report ZTESTMAIL *
*& *
&---------------------------------------------------------------------
*& *
*& *
&---------------------------------------------------------------------

REPORT ZTESTMAIL .

tables: ekko.

parameters: p_email type somlreci1-receiver default
'praveen.srrec@gmail.com'.

types: begin of t_ekpo,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
aedat type ekpo-aedat,
matnr type ekpo-matnr,
end of t_ekpo.
data: it_ekpo type standard table of t_ekpo initial size 0,
wa_ekpo type t_ekpo.

types: begin of t_charekpo,
ebeln(10) type c,
ebelp(5) type c,
aedat(8) type c,
matnr(18) type c,
end of t_charekpo.
data: wa_charekpo type t_charekpo.

data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_attach type standard table of solisti1 initial size 0
with header line.


data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,

w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1,
gd_error type sy-subrc,
gd_reciever type sy-subrc.
t_object_header = 'Text.xls'. append t_object_header.

************************************************************************
*START_OF_SELECTION
start-of-selection.


Retrieve sample data from table ekpo
perform data_retrieval.


Populate table with detaisl to be entered into .xls file
perform build_xls_data_table.

************************************************************************
*END-OF-SELECTION
end-of-selection.


Populate message body text
perform populate_email_message_body.


Send file by email as .xls speadsheet
perform send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.


Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.

&---------------------------------------------------------------------
*& Form DATA_RETRIEVAL
&---------------------------------------------------------------------


Retrieve data form EKPO table and populate itab it_ekko
----------------------------------------------------------------------
form data_retrieval.
select ebeln ebelp aedat matnr
up to 10 rows
from ekpo
into table it_ekpo.
endform. " DATA_RETRIEVAL

&---------------------------------------------------------------------
*& Form BUILD_XLS_DATA_TABLE
&---------------------------------------------------------------------


Build data table for .xls document
----------------------------------------------------------------------
form build_xls_data_table.
*CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
*con_tab TYPE x VALUE '09'. "OK for non Unicode

*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>horizontal_tab,
con_cret type c value cl_abap_char_utilities=>cr_lf.

concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
into it_attach separated by con_tab.
concatenate con_cret it_attach into it_attach.
append it_attach.

loop at it_ekpo into wa_charekpo.
concatenate wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
into it_attach separated by con_tab.
concatenate con_cret it_attach into it_attach.
append it_attach.
endloop.
endform. " BUILD_XLS_DATA_TABLE


&---------------------------------------------------------------------
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
&---------------------------------------------------------------------


Send email
----------------------------------------------------------------------
form send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.

data: ld_error type sy-subrc,
ld_reciever type sy-subrc,
ld_mtitle like sodocchgi1-obj_descr,
ld_email like somlreci1-receiver,
ld_format type so_obj_tp ,
ld_attdescription type so_obj_nam ,
ld_attfilename type so_obj_des ,
ld_sender_address like soextreci1-receiver,
ld_sender_address_type like soextreci1-adr_typ,
ld_receiver like sy-subrc.

ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.



Fill the document data.
w_doc_data-doc_size = 1.


Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.


Fill the document data and get size of attachment
clear w_doc_data.
read table it_attach index w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + strlen( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
clear t_attachment.
refresh t_attachment.
t_attachment] = pit_attach[.


Describe the body of the message
clear t_packing_list.
refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
describe table it_message lines t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.


Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.

describe table t_attachment lines t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
append t_packing_list.


Add the recipients email address
clear t_receivers.
refresh t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
append t_receivers.

call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
object_header = t_object_header
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.


Populate zerror return code
ld_error = sy-subrc.


Populate zreceiver return code
loop at t_receivers.
ld_receiver = t_receivers-retrn_code.
endloop.
endform.

&---------------------------------------------------------------------
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
&---------------------------------------------------------------------


Instructs mail send program for SAPCONNECT to send email.
----------------------------------------------------------------------
form initiate_mail_execute_program.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM

&---------------------------------------------------------------------
*& Form POPULATE_EMAIL_MESSAGE_BODY
&---------------------------------------------------------------------


Populate message body text
----------------------------------------------------------------------
form populate_email_message_body.
refresh it_message.
it_message = 'Please find attached a list test ekpo records'.
append it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY


*PARAMETERS: psubject(40) type c default 'Testing',
*p_email(40) type c default 'praveen.srrec@gmail.com'. "use ur email id
*
*data: it_packing_list like sopcklsti1 occurs 0 with header line,
*it_contents like solisti1 occurs 0 with header line,
*it_receivers like somlreci1 occurs 0 with header line,
*it_attachment like solisti1 occurs 0 with header line,
*gd_cnt type i,
*gd_sent_all(1) type c,
*gd_doc_data like sodocchgi1,
*gd_error type sy-subrc.
*
*data: it_message type standard table of SOLISTI1 initial size 0
*with header line.
*
************************************************************************
**START-OF-SELECTION.
*START-OF-SELECTION.
*
*Perform populate_message_table.
*
**Send email message, although is not sent from SAP until mail send
**program has been executed(rsconn01)
*PERFORM send_email_message.
*
**Instructs mail send program for SAPCONNECT to send email(rsconn01)
*perform initiate_mail_execute_program.
*
*
**&---------------------------------------------------------------------
**
**& Form POPULATE_MESSAGE_TABLE
**&---------------------------------------------------------------------
**



Adds text to email text table
**----------------------------------------------------------------------
**
*form populate_message_table.
*Append 'Line1' to it_message.
*Append 'Line2' to it_message.
*Append 'Line3' to it_message.
*Append 'Test- 1' to it_message.
*endform. " POPULATE_MESSAGE_TABLE
*
*
**&---------------------------------------------------------------------
**
**& Form SEND_EMAIL_MESSAGE
**&---------------------------------------------------------------------
**


Send email message
**----------------------------------------------------------------------
**
*form send_email_message.


Fill the document data.
*gd_doc_data-doc_size = 1.


DATA: TAB_LINES LIKE sy-tabix.
**


DESCRIBE TABLE it_message LINES TAB_LINES.
READ TABLE it_message INDEX TAB_LINES.
gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
**.
*


Populate the subject/generic message attributes
*gd_doc_data-obj_langu = sy-langu.
*gd_doc_data-obj_name = 'SAPRPT'.
*gd_doc_data-obj_descr = psubject.
*gd_doc_data-sensitivty = 'F'.
*


Describe the body of the message
Information about structure of data tables
*clear it_packing_list.
*refresh it_packing_list.
*it_packing_list-transf_bin = space.
*it_packing_list-head_start = 1.
*it_packing_list-head_num = 0.
*it_packing_list-body_start = 1.
*describe table it_message lines it_packing_list-body_num.
*it_packing_list-doc_type = 'RAW'.
*append it_packing_list.
*


Add the recipients email address
*clear it_receivers.
*refresh it_receivers.
*it_receivers-receiver = p_email.
*it_receivers-rec_type = 'U'.


it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
*append it_receivers.
*


Call the FM to post the message to SAPMAIL
*call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
*exporting
*document_data = gd_doc_data
*put_in_outbox = 'X'
*importing
*sent_to_all = gd_sent_all
*tables
*packing_list = it_packing_list
*contents_txt = it_message
*receivers = it_receivers
*exceptions
*too_many_receivers = 1
*document_not_sent = 2
*document_type_not_exist = 3
*operation_no_authorization = 4
*parameter_error = 5
*x_error = 6
*enqueue_error = 7
*others = 8.
*


Store function module return code
*gd_error = sy-subrc.
*


Get it_receivers return code
*loop at it_receivers.
*endloop.
*endform. " SEND_EMAIL_MESSAGE
*
*
**&---------------------------------------------------------------------
**& Form INITIATE_MAIL_EXECUTE_PROGRAM
**&---------------------------------------------------------------------


Instructs mail send program for SAPCONNECT to send email.
**----------------------------------------------------------------------
*
*form initiate_mail_execute_program.
*wait up to 2 seconds.
*if gd_error eq 0.
*submit rsconn01 with mode = 'INT'
*with output = 'X'
*and return.
*endif.
*endform. " INITIATE_MAIL_EXECUTE_PROGRAM
[/code]


ALSO READ:

- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.

- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.

- Sample Program For Creating XML File On Presentation Server.

- Uploading Multiple Files At One Time.


RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.


ABAP - Transporting Rows & Columns In ALV Grid Report.

*&---------------------------------------------------------------------*
*& Report Z_TRANPOSEALV *
*& Author : Swarna.S.
*&---------------------------------------------------------------------*
*& AS: This simple ALV report display is in a transposed way
*& Publised at SAPTechnical.com
*&---------------------------------------------------------------------*

REPORT Z_TRANSPOSEALV .

* Type pools declaration for ALV
TYPE-POOLS: slis.

*Declarations for ALV, dynamic table and col no for transpose
DATA: l_col TYPE sy-tabix,
l_structure TYPE REF TO data,
l_dyntable TYPE REF TO data,
wa_lvc_cat TYPE lvc_s_fcat,
lt_lvc_cat TYPE lvc_t_fcat,
lt_fieldcatalogue TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_layout TYPE slis_layout_alv.

*Field symbols declarations
FIELD-SYMBOLS :
TYPE ANY,
TYPE ANY,
TYPE ANY,
TYPE ANY,
TYPE STANDARD TABLE,
TYPE STANDARD TABLE.

*Input the name of the table
PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY.

*Initialization event
INITIALIZATION.

*Start of selection event
START-OF-SELECTION.

* Create internal table of dynamic type
CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN l_dyntable->* TO .

*select statement to select data from the table as input into
*our dynamic internal table.
*Here i have restricted only till 5 rows.
*You can set a variable and give no of rows to be fetched
*The variable can be set in your select statement
SELECT * INTO CORRESPONDING FIELDS OF TABLE
FROM (p_table) up to 5 rows.

*Fieldcatalogue definitions
wa_lvc_cat-fieldname = 'COLUMNTEXT'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.

wa_fieldcat-fieldname = 'COLUMNTEXT'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
wa_fieldcat-key = 'X'..
APPEND wa_fieldcat TO lt_fieldcat.

DESCRIBE TABLE .
DO sy-tfill TIMES.
* For each line, a column 'VALUEx' is created in the fieldcatalog
* Build Fieldcatalog
WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.
CONCATENATE 'VALUE' wa_lvc_cat-fieldname
INTO wa_lvc_cat-fieldname.
wa_lvc_cat-ref_field = 'VALUE'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.

* Build Fieldcatalog
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = wa_lvc_cat-fieldname.
wa_fieldcat-ref_fieldname = 'VALUE'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
APPEND wa_fieldcat TO lt_fieldcat.

ENDDO.

* Create dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_lvc_cat
IMPORTING
ep_table = l_dyntable. ASSIGN l_dyntable->* TO .

* Create structure as structure of the internal table
CREATE DATA l_structure LIKE LINE OF .
ASSIGN l_structure->* TO.

* Create structure = structure of the internal table
CREATE DATA l_structure LIKE LINE OF .
ASSIGN l_structure->* TO .

* Create field catalog from our table structure
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
CHANGING
ct_fieldcat = lt_fieldcatalogue
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

DESCRIBE TABLE lt_fieldcatalogue.

* Fill the internal to display
DO sy-tfill TIMES.
IF sy-index = 1.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.
ENDIF.

* For each field of it_table
ASSIGN COMPONENT 1 OF STRUCTURE
TO .
IF sy-subrc NE 0. EXIT .ENDIF.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.

* Fill 1st column
= wa_fieldcat-seltext_m.
IF IS INITIAL.
= wa_fieldcat-fieldname.
ENDIF.

*Filling the other columns

LOOP AT INTO .
l_col = sy-tabix + 1.
ASSIGN COMPONENT sy-index OF STRUCTURE TO .
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT l_col OF STRUCTURE
TO
.
IF sy-subrc NE 0. EXIT .ENDIF.
WRITE TO LEFT-JUSTIFIED.
ENDLOOP.

APPEND
TO .
ENDDO.

*Layout for ALV output
lt_layout-zebra = 'X'.
lt_layout-no_colhead = 'X'..
lt_layout-colwidth_optimize ='X'.
lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'.

*ALV Grid output for display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = lt_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = .



ALSO READ:

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

- ALV Subtotals In Different Blocks.

- ALV With Page Numbers & Subtotals.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.