How to Send Internal table to SAP Spool using Function Modules or Methods?

Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
Kiran

This is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT  Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
  MTEXT(25) type C,
  PERNR like PA0001-PERNR,
  ABKRS like PA0001-ABKRS,
  ENAME like PA0001-ENAME,
  USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
      W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
      P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
      MY_MONTH type T549Q-PABRP,
      STR_MY_MONTH(2) type C,
      MY_YEAR type T549Q-PABRJ,
      STR_MY_YEAR(4) type C,
      CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
      ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
        INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
   CMD like PC408-LTYPE value '/:',  "command
   TXT like PC408-LTYPE value 's',   "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
  NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like  LVC_S_1022 occurs 10 with header line,
      DOCDATA like SODOCCHGI1,
      OBJTXT like SOLISTI1 occurs 10 with header line,
      OBJPACK like SOPCKLSTI1 occurs 1 with header line,
      RECLIST like SOMLRECI1 occurs 1 with header line,
      OBJHEAD like SOLISTI1 occurs 1 with header line,
      it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      gd_buffer type string,
      l_no_of_bytes TYPE i,
      l_pdf_spoolid LIKE tsp01-rqident,
      l_jobname     LIKE tbtcjob-jobname.
data: file_length  type int4,
      spool_id     type rspoid,
      line_cnt     type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN                                                  *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
  s_ABKRS = PNPXABKR.
  S_PABRP = PNPPABRP.
  s_pabrj = PNPPABRJ.
  w_begda = PN-BEGDA.
  w_endda = PN-ENDDA.
get pernr.
*                                 "Check active employees
  rp-provide-from-last p0000 space pn-begda  pn-endda.
  CHECK P0000-STAT2 IN PNPSTAT2.
*                                 "Check Payslip Mail flag
  rp-provide-from-last p0655 space pn-begda  pn-endda.
  CHECK P0655-ESSONLY = 'X'.
  rp-provide-from-last p0001 space pn-begda  pn-endda.
*                                 "Find email address
  RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
  if p0105-usrid_LONG ne ''.
    ITAB-PERNR      = P0001-PERNR.
    ITAB-ABKRS      = P0001-ABKRS.
    ITAB-ENAME      = P0001-ENAME.
    ITAB-USRID_LONG = P0105-USRID_LONG.
    append itab.
    clear itab.
  endif.
  "SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
  write : / 'Payroll Area        : ', S_ABKRS.
  write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
  write : / 'System Time         : ', SY-UZEIT.
  write : / 'User Name           : ', SY-UNAME.
  write : / SY-ULINE.
  sort ITAB by PERNR.
  loop at ITAB.
    clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
    refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
*                                                  Retrieve Payroll results sequence number for this run
    select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
                                    and FPBEG ge W_BEGDA
                                    and FPEND le W_ENDDA
                                    and SRTZA eq 'A'.
*                                                  Produce payslip for those payroll results
    if SY-SUBRC = 0.
      call function 'GET_PAYSLIP'
        EXPORTING
          EMPLOYEE_NUMBER = ITAB-PERNR
          SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
          PAYSLIP_VARIANT = PAY_VAR
        IMPORTING
          RETURN          = RETURN
          P_INFO          = P_INFO
        TABLES
          P_FORM          = P_FORM.
      check RETURN is initial.
*                                                 remove linetype from generated payslip
      loop at p_form.
        objbin = p_form-linda.
        append objbin.
        line_cnt = line_cnt + 1.
      endloop.
      file_length = line_cnt * 1022.
*                                                 create spool file of paylsip
      CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
        EXPORTING
          i_file_length = file_length
        IMPORTING
          e_spoolid     = spool_id
        TABLES
          it_textdata   = objbin.
      IF sy-subrc EQ 0.
        WRITE spool_id.
      ENDIF.
      DESCRIBE table objbin.
      DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID                    = spool_id
          NO_DIALOG                      = ' '
          DST_DEVICE                     = 'MAIL'
*      PDF_DESTINATION                =
*    IMPORTING
*      PDF_BYTECOUNT                  = l_no_of_bytes
*      PDF_SPOOLID                    = l_pdf_spoolid
*      LIST_PAGECOUNT                 =
*      BTC_JOBNAME                    =
*      BTC_JOBCOUNT                   =
        TABLES
          PDF                            = pdf
        EXCEPTIONS
          ERR_NO_ABAP_SPOOLJOB           = 1
          ERR_NO_SPOOLJOB                = 2
          ERR_NO_PERMISSION              = 3
          ERR_CONV_NOT_POSSIBLE          = 4
          ERR_BAD_DESTDEVICE             = 5
          USER_CANCELLED                 = 6
          ERR_SPOOLERROR                 = 7
          ERR_TEMSEERROR                 = 8
          ERR_BTCJOB_OPEN_FAILED         = 9
          ERR_BTCJOB_SUBMIT_FAILED       = 10
          ERR_BTCJOB_CLOSE_FAILED        = 11
          OTHERS                         = 12
      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
*Download PDF file C Drive
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'C:\itab_to_pdf.pdf'
      filetype = 'BIN'
    TABLES
      data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
*  LOOP AT pdf.
*    TRANSLATE pdf USING ' ~'.
*    CONCATENATE gd_buffer pdf INTO gd_buffer.
*  ENDLOOP.
*  TRANSLATE gd_buffer USING '~ '.
*  DO.
*    it_mess_att = gd_buffer.
*    APPEND it_mess_att.
*    SHIFT gd_buffer LEFT BY 255 PLACES.
*    IF gd_buffer IS INITIAL.
*      EXIT.
*    ENDIF.
*  ENDDO.
      OBJHEAD = 'Objhead'.
      append OBJHEAD.
* preparing email subject
      concatenate W_ENDDA(6)
                ' Payslip-'
                ITAB-ENAME+0(28)
                ITAB-PERNR+4(4) ')'
             into DOCDATA-OBJ_DESCR.
      DOCDATA-OBJ_NAME = 'Pay Slip'.
      DOCDATA-OBJ_LANGU = SY-LANGU.
      OBJTXT = 'Pay Slip.'.
      append OBJTXT.
*prepare email lines
      OBJTXT = DOCDATA-OBJ_DESCR.
      append OBJTXT.
      OBJTXT = 'Please find enclosed your current payslip.'.
      append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
      read table OBJTXT index 3.
*    DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
      clear OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = 3.
      OBJPACK-DOC_TYPE = 'RAW'.
      append OBJPACK.
* Create Message Attachment
      ATT_TYPE = 'PDF'.
      describe table OBJBIN lines TAB_LINES.
      read table OBJBIN index TAB_LINES.
*    OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = ATT_TYPE.
      OBJPACK-OBJ_NAME = 'ATTACHMENT'.
      OBJPACK-OBJ_DESCR = 'Payslip'.
      append OBJPACK.
* Create receiver list refresh RECLIST.
      clear RECLIST.
      RECLIST-RECEIVER = itab-USRID_long.
      translate RECLIST-RECEIVER to lower case.
      RECLIST-REC_TYPE = 'U'.
      append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
      call function 'SO_DOCUMENT_SEND_API1'
        exporting
          DOCUMENT_DATA = DOCDATA
          PUT_IN_OUTBOX = 'X'
          COMMIT_WORK = 'X'
* IMPORTING
*   SENT_TO_ALL =
*   NEW_OBJECT_ID =
        tables
          PACKING_LIST  = OBJPACK
          OBJECT_HEADER = OBJHEAD
          CONTENTS_BIN  = pdf
          CONTENTS_TXT  = OBJTXT
*   CONTENTS_HEX =
*   OBJECT_PARA =
*   OBJECT_PARB =
          RECEIVERS = RECLIST
        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.
      if SY-SUBRC NE 0.
        ITAB-MTEXT = 'Message Not Sent to : '.
      else.
        ITAB-MTEXT = 'Message Sent to : '.
      endif.
*    else.
*      ITAB-MTEXT = 'Message Not Sent to : '.
*    endif.
    else.
      "SY-SUBRC Not = 0
      ITAB-MTEXT = 'Payroll data not found : '.
    endif.
    "end of SY-SUBRC = 0.
    modify ITAB.
  endloop. "end loop at ITAB
  sort ITAB by MTEXT PERNR.
  loop at ITAB.
    at new MTEXT.
      uline.
      write : / ITAB-MTEXT color 4 intensified on.
      write : / 'Emp. Code' color 2 intensified on,
             12 'Emp. Name' color 2 intensified on,
             54 'Email ID' color 2 intensified on.
    endat.
    write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
  endloop.

Similar Messages

  • How to get internal table from SAP Data Provider C#

    Hello.
    ABAP:
       DATA: lt_t001 TYPE TABLE OF t001.
       DATA: url(1000) TYPE c.
      SELECT * INTO TABLE lt_t001 FROM t001.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type                 = 'APPLICATION'
          subtype           = 'X-R3TABLE'
        TABLES
          data                 = lt_t001
        CHANGING
          url                    = url
        EXCEPTIONS
          OTHERS           = 4.
    C#:
    using SAPDataProvider;
    using SAPTableFactoryCtrl;
    public void SetDataFromUrl(string url)
                SAPDataProviderClass p = new SAPDataProviderClass();
                p.SetDataFromURL("APPLICATION", "X-R3TABLE", url);
                ISapDPR3Table tbl = p.GetDataAsR3Table("APPLICATION", "X-R3TABLE");
                SAPTableFactoryClass tf = new SAPTableFactoryClass();
                Table tb = (Table)tf.NewTable();
                tb.ISAPrfcITab = tbl.DataTable; // Exception !!!!!!
    How to get internal table from SAP Data Provider ?

    Hi Sergey,
    I'm trying to do the same, have you found a solution to solved it?
    thanks for your help.
    Regards.
    Jonathan

  • Accessing internal table of main program inside function module...

    I have function module say ZFUNC and main program say ZMAIN and internal table defined as IT_TAB inside ZMAIN but not passed as parameter to Function module ZFUNC.
    If I want to access the field value of IT_TAB of  main program ZMAIN inside ZFUNC during debugging then, I simply put <b>(ZMAIN)IT_TAB-amount</b> in ABAP debugger and then change it when the debugger is inside ZFUNC.
    How can I write code to change the value of internal table of main program in function module ZFUNC instead of doing in debugger ? I guess I have to use some field symbols, but not sure. Please suggest.
    Regards,
    Rajesh.

    Yes, you do need to use a field symbol.  Say for example, you had a internal table called IMARC in your program and you want to access it later in a funciton module, you would do something like this.
      data: xmarc type marc.
      field-symbols: <imarc> type marc_upl_tt.
    * Assign an internal table
      field = '(ZPROGRAM_NAME)IMARC[]'.
      assign (field) to <imarc>.
      loop at <imarc> into xmarc.
        write: / xmarc-matnr, xmarc-werks.
      endloop.
    Regards,
    Rich Heilman

  • How to create Billing Plan in sales order using Function module /BAPI

    hi,
    How to create Billing Plan in sales order using Function module /BAPI
    i hv check few FM such
    BILLING_SCHEDULE_READ
    BILLING_SCHEDULE_GET_NUMBER
    BILLING_SCHEDULE_SAVE
    But unable to create billing plan for a sales order.....any other method to create???

    Hi,
    Use this link.
    Create sales order with billing plan via LSMW and BAPI BUS2032
    BAPI or Function to update Billing Plan in Sales Order Items
    Hope this will help you.
    Regards,
    Vijay

  • Pass internal tables in Export  Parameters of  Function Module

    Hi
    How to pass internal tables through export parametes of the calling function module. i
    think i can pass it by reference ....
    if so can anyone suggest how to do it?

    Hi,
    You can Export values of an Internal table in two ways, by :
    1) specifying in Tables tab
    (Not recommended since it's an obsolete in ECC 6.0)
    If used, will reduce the performance of the FM
    Tables are always passed by reference
    2) specifying in Exports tab.
    The parameter should be a Table type (created in se11)
    having a Line type that refers to the structure of the data.
    Pass by Value is not used for Normal Function modules.
    Used usually for RFC enabled FMs.
    Cheers,
    Remi

  • How to send Internal table records to Idoc Inbound posting FM to create Ido

    Hello Experts,
    I have all the data necessary to create shipments in one internal table inside my ABAP program.
    I can use BAPI_SHIPMENT_CREATE to create shipments. But associated with this BAPi there is one ALE message type SHIPMENT_CREATEFROMDATA. Now my requirement is to use this message type to cretae my shipments via idocs for one scenario for some of the records in the internal table.
    For this message type, I got the inbound function module IDOC_INPUT_SHIPMENT_CREATEFROM from TBDBE table.
    Can anybody please let me know how to send the data from the internal table to this inbound function  module?
    Becasue it has mandatory parameters INPUT_METHOD, MASS_PROCESSING. What values should be passed to these parameters if the data has to be sent to this function module?
    Regards.

    Hi Ravikanth,
    Thankyou very much for your quick reply.
    So If I split my internal table data and populate IDOC_DATA and IDOC_CONTROL and pass to the inbound function module directly in my ABAP program, will that be going to create idocs and post shipments?
    I mean is it enough to call the Inbound posting function module directly in my ABAP program or any other FMs to be called to take care of ALE settings and shipment creation?
    Please confirm.
    REgards.

  • How to send internal table data through mail from report in foreground

    hi all,
    iam trying  to convert the internal table data into excel format and sending it through mail by runnning the report in foreground.
    mail is going sucessfully with excel format,but iam facing the problem in the excel format of the material column as follows:
    the matrno shows the wrong format -2.63E+11  instead of displaying correct format-263215000000.
    Pls suggest the alternative process for the above mentioned problem.
    Thanks,
    Sivagopal R.

    Hi Siva,
      Try to copy 263215000000 in one of the cells of excel sheet and press enter.It will automatically convert into -2.63E+11 .
      This means the default formatting of the excel sheet makes this happen.If you convert the format of the cell to "NUMBER" then u will get the required result.
      But I doubt whether or not it is possible through ABAP programming.
    Regards,
    Vimal.

  • Send Internal Table Vaue to Spool Output

    Hi,
      i have a requirement. when i execute my program the output should be display in the spool. is there any function module avaliable to pass all internal table values from report program to spool?
    give me your hints please.
    thanks
    john.

    Hi John,
    You can try this code on a test program
    CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
      EXPORTING
        i_file_length            = 255
    * IMPORTING
    *   E_SPOOLID                =
      tables
        it_textdata              = gt_output_table
    * EXCEPTIONS
    *   SPOOL_ERROR              = 1
    *   PARAMETERS_INVALID       = 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.
    You can either hardocde the value of file length or calculate the value of the file length and pass the internal table against parameter it_textdata              .
    Hope this helps
    CHeers
    VJ

  • (internal) Tables obsolete as parameter in function modules,

    Hi
    As you probably can see by the question, my ABAP Knowledge isn't exactly overwhelming !
    <i>anyway:</i>
    I'm trying to create a function module in NW2004s, This functionmodule should take an internal table, based on a structure as (import) parameter.
    In the earlier version, I've done this by defining it under the TAB 'Tables' in the function builder - But know its telling me that "<i>Tables Parameters are obsolete</i>", and that I should define it under "Changing" instead.
    I have tried that, but I'm only allowed to pass a single line, and if I try to do a Loop, in the function module, it tells me that ity isn't created as an internal table.
    So please - what is the "best practice" here ?
    Regards
    Morten Nielsen

    Hi All,
    I followed Steps 1 and 2 but when I use the following select statement I get a dump with the error enclosed.
    Step1. Created a structure ZDFKKCOHI which is a replica of DFKKCOHI.
    Step2. Created a table type ZDFKKCOHITABLE with line type as ZDFKKCOHI.
    Step3. In my function module I have a changing parameter ZDFKKCOHIPARAM of type ZDFKKCOHITABLE.
    Step 4. When I use the following select clause I am getting a dump.
    DATA: wa_zdfkkcohi LIKE LINE OF zdfkkcohiparam.
      SELECT *
      FROM dfkkcohi
      INTO  CORRESPONDING FIELDS OF TABLE zdfkkcohiparam
      WHERE cotyp EQ zcotyp
      AND gpart EQ zgpart
      AND corr_status EQ zcorr_status.
      LOOP AT zdfkkcohiparam INTO wa_zdfkkcohi.
    *Move IT_ZDFKKCOHI to ZDFKKCOHIOUT.
    *Append ZDFKKCOHIOUT.
    *Clear IT_ZDFKKCOHI.
      ENDLOOP.
    What could be wrong?
    Thanks for all your help in advance.
    Regards,
    Divya

  • (internal) Tables obsolete as parameter in function modules in ECC 6.0

    Hi All,
    I followed Steps 1 and 2 in the thread  but when I use the following select statement I get a dump with the error enclosed.
    Step1. Created a structure ZDFKKCOHI which is a replica of DFKKCOHI.
    Step2. Created a table type ZDFKKCOHITABLE with line type as ZDFKKCOHI.
    Step3. In my function module I have a changing parameter ZDFKKCOHIPARAM of type ZDFKKCOHITABLE.
    Step 4. When I use the following select clause I am getting a dump.
    DATA: wa_zdfkkcohi LIKE LINE OF zdfkkcohiparam.
    SELECT *
    FROM dfkkcohi
    INTO CORRESPONDING FIELDS OF TABLE zdfkkcohiparam
    WHERE cotyp EQ zcotyp
    AND gpart EQ zgpart
    AND corr_status EQ zcorr_status.
    LOOP AT zdfkkcohiparam INTO wa_zdfkkcohi.
    *Move IT_ZDFKKCOHI to ZDFKKCOHIOUT.
    *Append ZDFKKCOHIOUT.
    *Clear IT_ZDFKKCOHI.
    ENDLOOP.
    Error: Das laufende ABAP-Programm wollte eine Open SQL-Anweisung ausführen,
    bei der die Treffermenge mit 'INTO CORRESPONDING FIELDS' in
    namensgleiche Felder der Zielbereichs gestellt werden soll. Hierbei
    müssen die namensgleichen Felder des Zielbereichs einen flachen Typ
    haben, oder vom Typ STRING oder XSTRING sein.
    Im vorliegenden Fall enthält der Zielbereich " " aber ein
    namensgleiches Feld "MANDT " mit dem verbotenen internen Typ "l".
    What could be wrong?
    Thanks for all your help in advance.
    Regards,
    Divya

    Translating the error message -;)
    The running ABAP-program wanted to carry out an opus SQL-direction, with which the hit quantity with 'INTO
    CORRESPONDING FIELDS' is supposed to be placed into name same fields the goal area.  Herewith the name same
    fields of the goal area must have be a flat type, or of the type STRING or XSTRING. 
    In the existing case, the goal area "" contains however a name same field "MANDT" with the forbidden internal type "l".
    You should check you structures and assign the correct TYPE to the fields -:)
    Greetings,
    Blag.

  • How do I insert a logo in ALV using Function Modules?

    hai !
           i want to display the logo on the grid .
        can any one suggest me which function i should use?
        any  help will be appreciated.

    Hi,
    Look at the sample code to display LOGO.
      call function 'REUSE_ALV_GRID_DISPLAY'
         exporting
           i_callback_program      = i_repid
           i_callback_user_command = 'USER_COMMAND_PERNR'
           it_fieldcat             = header
           is_layout               = gt_layout
           i_callback_top_of_page  = 'TOP-OF-PAGE1'
           i_grid_title            = xyz
           it_sort                 = gt_sort[]
           i_default               = 'X'
           i_save                  = 'U'
           is_variant              = gt_variant
           it_events               = gt_events
          tables
           t_outtab                = t_output.
      clear t_output.
    Form TOP-OF-PAGE1
    form top-of-page1.
      data: header type slis_t_listheader,
      wa type slis_listheader. "infield like wa-info, nline type n.
    TITLE AREA
      wa-typ = 'S'.
      wa-info = text-h04.
      append wa to header.
      wa-typ = 'S'.
      write sy-datum to wa-info mm/dd/yyyy.
      concatenate text-h03 wa-info into wa-info separated by space.
      append wa to header.
      wa-typ = 'S'.
      concatenate text-h02 sy-uname into wa-info separated by space.
      append wa to header.
      wa-typ = 'S'.
      concatenate text-h01 sy-repid into wa-info separated by space.
      append wa to header.
    ********" LOGO
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = header
                i_logo             = 'ENJOYSAP_LOGO'.
    *********" LOGO
    endform.
    Here in TOP-OF-PAGE form it will show you the Prog name,Date, User Name.
    Just you need to give the text in it.
    You can refer the below link also.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm
    Thanks.
    If this helps you reward with points.
    Message was edited by: KDeepak

  • How to Convert internal table data into text output and send mail in ABAP

    Hi All,
    Good Morning.
    Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
    But thought of doing it without excel.
    I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!.  Instead I  want to send this output to User's mails as Normal mail body with No attachments.
    Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
    as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
    Best Regards
    Dileep VT

    here's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
    notice we use gt_text as "mail body"
    TRY.
    *     -------- create persistent send request ------------------------
           gv_send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create text to be sent
           wa_line = text-001.
           APPEND wa_line TO gt_text.
           CLEAR wa_line.
           APPEND wa_line TO gt_text.
           LOOP AT gt_fail ASSIGNING <fs_fail>.
             MOVE <fs_fail>-retry_count TO gv_count.
             CONCATENATE text-002
                         <fs_fail>-setting_id
                         text-003
                         gv_count
                         INTO wa_line SEPARATED BY space.
             APPEND wa_line TO gt_text.
             CLEAR wa_line.
           ENDLOOP.
           APPEND wa_line TO gt_text.
           wa_line = text-007.
           APPEND wa_line TO gt_text.
    *     create actual document
           gv_document = cl_document_bcs=>create_document(
                           i_type    = 'RAW'
                           i_text    = gt_text
                           i_length  = '12'
                           i_subject = 'Failed Precalculation Settings!' ).
    *     add document to send request
           CALL METHOD gv_send_request->set_document( gv_document ).
    *     --------- set sender -------------------------------------------
           gv_sender = cl_sapuser_bcs=>create( sy-uname ).
           CALL METHOD gv_send_request->set_sender
             EXPORTING
               i_sender = gv_sender.
    *     --------- add recipient (e-mail address) -----------------------
           LOOP AT s_email INTO wa_email.
             MOVE wa_email-low TO gv_email.
             gv_recipient = cl_cam_address_bcs=>create_internet_address(
                                               gv_email ).
             CALL METHOD gv_send_request->add_recipient
               EXPORTING
                 i_recipient = gv_recipient
                 i_express   = 'X'.
           ENDLOOP.
    *     ---------- set to send immediately -----------------------------
           CALL METHOD gv_send_request->set_send_immediately( 'X' ).
    *     ---------- send document ---------------------------------------
           CALL METHOD gv_send_request->send(
             EXPORTING
               i_with_error_screen = 'X'
             RECEIVING
               result              = gv_sent_to_all ).
           IF gv_sent_to_all = 'X'.
             WRITE text-004.
           ENDIF.
           COMMIT WORK.
    *   exception handling
         CATCH cx_bcs INTO gv_bcs_exception.
           WRITE: text-005.
           WRITE: text-006, gv_bcs_exception->error_type.
           EXIT.
       ENDTRY.
    with the following declarations
    * TABLES                                                               *
    TABLES:
       adr6,
       rsr_prec_sett.
    * INTERNAL TABLES & WORK AREAS                                         *
    DATA:
       gt_fail          TYPE SORTED TABLE OF rsr_prec_sett
                             WITH UNIQUE KEY setting_id run_date,
       gt_text          TYPE bcsy_text,
       wa_fail          LIKE LINE OF gt_fail,
       wa_line(90)      TYPE c.
    FIELD-SYMBOLS:
       <fs_fail>        LIKE LINE OF gt_fail.
    * VARIABLES                                                            *
    DATA:
       gv_count(4)      TYPE n,
       gv_send_request  TYPE REF TO cl_bcs,
       gv_document      TYPE REF TO cl_document_bcs,
       gv_sender        TYPE REF TO cl_sapuser_bcs,
       gv_recipient     TYPE REF TO if_recipient_bcs,
       gv_email         TYPE adr6-smtp_addr,
       gv_bcs_exception TYPE REF TO cx_bcs,
       gv_sent_to_all   TYPE os_boolean.
    * SELECTION-SCREEN                                                     *
    SELECT-OPTIONS:
       s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
    DATA:
       wa_email         LIKE LINE OF s_email.

  • Sending email and alert notifcation using function module

    Hi All,
    I am trying to send email and alert notification messages using function modules in CRM. I am unable to send mail using 'SO_DOCUMENT_SEND_API1'. Getting a short dump message "dictionary mismatch". If anyone knows any FM which can be used for sending mails, please let me know. I also want to send alert messages using some FM. Please let me know any FM in this case as well.
    All help appreciated. This is urgent and please get back to me soon.
    Thanks
    Deno

    Hi Ranjit,
    Thanks a lot for the reply. I already tried these FMs and getting the error message
    Trigger Location of Runtime Error
        Program                                 SAPLBUPA_INTERFACE_TDTRANS
        Include                                 LBUPA_INTERFACE_TDTRANSTOP
        Row                                     4
    I dont know the reason behind the error. The SO_document_send FM is used inside all these FMs. So It wont work.
    Thanks
    Deno

  • How to send attachment mail in sap

    hi all,
    please guide me how to use function module named SO_NEW_DOCUMENT_ATT_SEND_API1.
    i have text files in internal table.
    please guide me how can i send files in my internal table as in attachment.

    Manish,
    Just copy paste the below code as given into a report only changing the email address of receipient to your email address to testing.
    That is line:
    lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
    Then I think your SCOT is not configured for automatic execution hence once you have run your report go to transaction SCOT and press (Ctrl + F7) to start send process.
    A mail will be sent to your email address specified in the receipient list and a copy of it also placed in your SBWP Outbox.
    Let me know if you need further help, else reward neccessary points.
    Code
    *& Report  ZMFV_ROUGH_PAD
    REPORT  zmfv_rough_pad.
    DATA :
    li_attachment TYPE TABLE OF soli, " hold attachment contents
    li_pdf        TYPE TABLE OF tline, " hold data from spool in PDF format
    li_objpack    TYPE TABLE OF sopcklsti1, " hold email body, attachment details
    li_objtxt     TYPE TABLE OF solisti1, " hold message contents
    li_reclist    TYPE TABLE OF somlreci1. " hold email reciever details
    DATA :
    lwa_attachment    LIKE LINE OF li_attachment,
    lwa_pdf           LIKE LINE OF li_pdf,
    lwa_objpack       LIKE LINE OF li_objpack,
    lwa_objtxt        LIKE LINE OF li_objtxt,
    lwa_reclist       LIKE LINE OF li_reclist,
    lwa_document_data TYPE sodocchgi1. " hold document details like title, size etc.
    DATA :
    lv_sent_to_all     TYPE c, " flag to check if mail is sent to all
    l_att_lines        TYPE i, " hold number of lines in attachment table
    lv_spool_desc(68)  TYPE c. " hold description of spool
    CONSTANTS : lc_email_txt TYPE solisti1-line VALUE 'Find attached Payment Advice sent by this email.',
    lc_sensitivity TYPE sodocchgi1-sensitivty VALUE 'O',
    lc_raw         TYPE sopcklsti1-doc_type VALUE 'RAW',
    lc_pdf         TYPE sopcklsti1-doc_type VALUE 'PDF',
    lc_transf_bin  TYPE sopcklsti1-transf_bin VALUE 'X',
    lc_email       TYPE sopcklsti1-obj_name VALUE 'Email',
    lc_ext_id      TYPE somlreci1-rec_type VALUE 'U',
    lc_outbox      TYPE sonv-flag VALUE 'X',
    lc_obj_name    TYPE sodocchgi1-obj_name VALUE 'Email Test',
    lc_1           TYPE n VALUE '1',
    lc_0           TYPE n VALUE '0'.
    CLEAR: lwa_attachment,
    lwa_pdf,
    lwa_reclist,
    lwa_objtxt,
    lwa_objpack,
    lwa_document_data.
    REFRESH : li_attachment,
    li_pdf,
    li_reclist,
    li_objtxt,
    li_objpack.
    Build attachment table
    lwa_attachment-line = 'YOUR TEXT FROM INTERNAL TABLE LINES'.
    APPEND lwa_attachment TO li_attachment.
    Body of email
    CLEAR lwa_objtxt.
    MOVE lc_email_txt TO lwa_objtxt.
    APPEND lwa_objtxt TO li_objtxt.
    Title of the email
    lwa_document_data-obj_descr = 'Title of email'.
    lwa_document_data-sensitivty = lc_sensitivity.
    lwa_document_data-expiry_dat = sy-datum + 15.
    lwa_document_data-doc_size = STRLEN( lwa_objtxt ).
    lwa_document_data-obj_name = lc_obj_name.
    e-mail body
    CLEAR lwa_objpack.
    lwa_objpack-head_start = lc_1.
    lwa_objpack-head_num = lc_0.
    lwa_objpack-body_start = lc_1.
    lwa_objpack-body_num = lc_1.
    lwa_objpack-doc_type = lc_raw.
    lwa_objpack-doc_size = STRLEN( lwa_objtxt ).
    APPEND lwa_objpack TO li_objpack.
    For e-mail attachment
    DESCRIBE TABLE li_attachment LINES l_att_lines.
    CLEAR lwa_attachment.
    READ TABLE li_attachment INDEX l_att_lines INTO lwa_attachment.
    CLEAR lwa_objpack.
    lwa_objpack-transf_bin = lc_transf_bin.
    lwa_objpack-head_start = lc_1.
    lwa_objpack-head_num = lc_1.
    lwa_objpack-body_start = lc_1.
    lwa_objpack-body_num = l_att_lines.
    lwa_objpack-doc_type = lc_raw.
    lwa_objpack-obj_name = lc_email.
    lwa_objpack-obj_descr = lv_spool_desc.
    lwa_objpack-doc_size = ( 255 * ( l_att_lines - 1 ) ) + STRLEN( lwa_attachment-line ).
    APPEND lwa_objpack TO li_objpack.
    make recipient list
    CLEAR lwa_reclist.
    lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
    lwa_reclist-rec_type = lc_ext_id. " To external email id
    lwa_reclist-COM_TYPE = 'INT'.     " Internet mail
    APPEND lwa_reclist TO li_reclist.
    send mail with attachment
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = lwa_document_data
        put_in_outbox              = lc_outbox
        commit_work                = 'X'
      IMPORTING
        sent_to_all                = lv_sent_to_all
      TABLES
        packing_list               = li_objpack
        contents_bin               = li_attachment
        contents_txt               = li_objtxt
        receivers                  = li_reclist
      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.
    IF sy-subrc = 0.
      WRITE: 'Success'.
    ENDIF.

  • How to send database table

    how to send database table one sever to another server in the form of  tms request.
    i want send a particular database table one server to another as a request.
    give solution plz
    Message was edited by:
            mahesh

    Hi Mahesh,
    Technically it is possible to transport entries of every table in SAP even if changes dont prompt for a transport request. Do the following. Create a customising/workbench request. It depends of the table whose entires you wish to transport. .If you wish you can just  use workbench transport for all tables.
    After you have created the transport click on the request and in menu bar choose Request/Task and then Display object list. Goto change mode.
    Click on Inset line icon in application tool bar. A new line for input will come up.
    In PGMID give the value R3TR
    In Obj give value TABU
    In Object Name give the name of the table.
    After that double click on table name entry. You will come to the screen: Transport organizer:Change Key List.
    Here again choose insert line. A new line with table  name and key as the column headers will come up.
    Double click on the empty input field for the key. In the next screen you will get options to fill in the key.
    You can insert key as per your choice. However one thing needs to be remembered. If you put * in any field SAP wont allow you fill in value in later fields as only a final asterisk can be used as a generic entry.
    Please try out this option. I use this option to transport RFC destinations as well profile parameters across systems.
    Please award points if the answer was of help to you.
    Regards.
    Ruchit.

Maybe you are looking for

  • Having problems syncing 1st gen Ipod nano.

    I have a 1st gen Ipod nano (i'm pretty sure it's a 1st gen) that I gave to my mother because I got an Ipod touch. She has her own Itunes accout on her own computer and is trying to connect my old Ipod to her computer/itunes so she can use it and down

  • URL linking to a folder in

    How to a build a url link to a folder in XIR2?

  • Having variations of same business process, How to model?

    Customer has several variations of the same business process. How to model them in Solution manager's project implementation tools? I actually created this same question in 'Business process expert' forum, so please read the whole story there and ear

  • Deploying my EP project into server(EP 7.3) getting this error

    hi , while deploying into ep7.3  im getting this error, i cant able post full message error due to some restructions of forum. Exception ID:12:57_17/10/11_0023_1001450 [EXCEPTION] com.sapportals.portal.prt.component.PortalComponentException: Error in

  • Why is the macintosh hd icon flashing?

    Hello all, Weird thing started happening last night: the "Macintosh HD" icon on my Macbook Air started flashing on my desktop. It happens at exact 1 minute intervals - the icon will disappear for a quarter second then reappear. I still have full func