Posted: Sun Nov 25, 2007 12:38 pm Post subject: Use %-list at the end of an abap to print,mail and download
How to use %-list at the end of an abap to print,send as a mail and download the list, created by the abap
Code:
REPORT ZPCTLIST.
************************************************************
* This little program uses the %_list internal table to
* do various things with a list that is created by an
* ABAP: save it on UNIX, save it on the pc, print it out
* and send it out as an express mail. This method can save
* a lots of hassle, because the form routines has to be
* called only once, at the end of the report.
***********************************************************
INCLUDE <%_LIST>.
DATA: PARAMS LIKE PRI_PARAMS, VALID.
DATA: BEGIN OF DATA_TAB OCCURS 20,
LINE(255),
END OF DATA_TAB.
DATA: BEGIN OF EMAIL_DATA.
INCLUDE STRUCTURE SODOCCHGI1.
DATA: END OF EMAIL_DATA.
DATA: BEGIN OF EMAIL_SEND OCCURS 10.
INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF EMAIL_SEND.
* Write to screen
WRITE: / 'First line on the screen'.
* Hundreds of lines of code ...
WRITE: / 'Second line on the screen'.
* Hundreds of lines of code ...
WRITE: / 'Third line on the screen'.
* AND AT THE AND OF THE PROGRAM:
PERFORM SAVE_ON_UNIX.
PERFORM SAVE_ON_PC.
PERFORM PRINT_IT_OUT.
PERFORM SEND_EXPERESS_MAIL.
*---------------------------------------------------------------------*
* FORM SAVE_ON_UNIX *
*---------------------------------------------------------------------*
FORM SAVE_ON_UNIX.
OPEN DATASET '/usr/sap/trans/listtest' FOR OUTPUT IN TEXT MODE.
LOOP AT %_LIST.
TRANSFER %_LIST-LINE TO '/usr/sap/trans/listtest'.
ENDLOOP.
CLOSE DATASET '/usr/sap/trans/listtest'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM SAVE_ON_PC *
*---------------------------------------------------------------------*
FORM SAVE_ON_PC.
LOOP AT %_LIST.
DATA_TAB-LINE = %_LIST-LINE.
APPEND DATA_TAB.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'c:\listtest'
TABLES
DATA_TAB = DATA_TAB.
ENDFORM.
*---------------------------------------------------------------------*
* FORM PRINT_IT_OUT *
*---------------------------------------------------------------------*
FORM PRINT_IT_OUT.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = 'AA01'
LIST_NAME = 'List'
LIST_TEXT = 'List from %_list'
IMMEDIATELY = ' '
RELEASE = 'X'
NEW_LIST_ID = 'X'
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = PARAMS
VALID = VALID.
IF VALID <> SPACE.
NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG.
LOOP AT %_LIST.
WRITE: / %_LIST-LINE.
ENDLOOP.
ENDIF.
NEW-PAGE PRINT OFF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM SEND_EXPERESS_MAIL *
*---------------------------------------------------------------------*
FORM SEND_EXPERESS_MAIL.
EMAIL_DATA-OBJ_NAME = 'MESSAGE'.
EMAIL_DATA-OBJ_DESCR = 'TEST MAIL THAT USES %_LIST'.
EMAIL_DATA-OBJ_LANGU = 'E'.
EMAIL_DATA-SENSITIVTY = 'P'.
EMAIL_DATA-OBJ_PRIO = '1'.
EMAIL_DATA-NO_CHANGE = 'X'.
EMAIL_DATA-PRIORITY = '1'.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.