SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Use %-list at the end of an abap to print,mail and download



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 25, 2007 12:38 pm    Post subject: Use %-list at the end of an abap to print,mail and download Reply with quote

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'.

  EMAIL_SEND-RECEIVER = 'KABAIIM'.
  EMAIL_SEND-REC_TYPE = 'B'.
  EMAIL_SEND-EXPRESS = 'X'.
  APPEND EMAIL_SEND.

  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
       EXPORTING
            DOCUMENT_DATA  = EMAIL_DATA
            DOCUMENT_TYPE  = 'RAW'
            PUT_IN_OUTBOX  = 'X'
       TABLES
            OBJECT_CONTENT = DATA_TAB
            RECEIVERS      = EMAIL_SEND.
ENDFORM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.