Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

Using Vendor master and SAP Script

Former Member
0 Likes
1,545

Hi,

I got a new requirement using Vendor master. That is to

Create a new program for vendor details. This program is useful to send the vendor details by mail to any mail ID given in the selection Screen. The program should able to handle the multiple vendors in a single selection.

Main Logic is :

Fetch the data from the Vendor master table and use a sap script.

send the same spool to email mentioned in the selection screen.

Print should be handled in the login language.

Pls help me by some ideas.

12 REPLIES 12
Read only

Former Member
0 Likes
1,410

Hi Meenakshi,

Is it mandatory to go with scripts,

why because, we can achieve this easily by using smartforms.

We will be having the control parameter in smartform function module, using that we can get the data in OTF format. Then, by using the SO_NEW_DOCUMENT_ATT_SEND_API1 fm we can send the attachment as a mail. or by using the cl_document_bcs class we can do this.

Hope this will help you.

Read only

0 Likes
1,410

Hi Gowtham,

Yes....Need to be done in script

Read only

0 Likes
1,410

Hi Gowtham,

How about using the function module SO_OBJECT_SEND....Have any idea about this

Read only

matt
Active Contributor
0 Likes
1,410

No. Use class CL_BCS and it's associated classes. Please search for details on how to use it - there's a wealth of material on this site if you will search.

Read only

Former Member
0 Likes
1,410

Hi Meenakshi,

When you are creating from scratch go for smartform instead of script.Things will be much simpler.

Create a driver program with selection screen & assign tcode ot it.

Create a smartform or script  which is called from driver program.

Once the script/smartform is displayed you can capture spool and sent mail.

Read only

0 Likes
1,410

Hi Sai,

Thanx for replying me. But in our company they are following script only. No other way to go for smart form

Read only

0 Likes
1,410

Hi meenakshi,.

You will get the spool number in CLOSE_FORM function module.

After getting the spool number. Pass that number to CONVERT_ABAPSPOOLJOB_2_PDF fm to get the PDF data. Then follow the previous procedure as i mentioned in the above post to send it as the attachment.

Read only

0 Likes
1,410

Hi Gowtham,

I am getting run time error while execution....since iam new to these fm.....can u suggest me the proper way....this is my code

TABLES : lfa1.                       "Vendor Master (General Section)

*  ----------------------------------------------------------------------*

*  &                    DATA DECLARATION                                 *

*  ----------------------------------------------------------------------*

   DATA : V_LIFNR TYPE LIFNR.

   data : i_itcpp LIKE itcpp,

          w_erreur TYPE i VALUE 0.

   data : gd_bytecount LIKE tst01-dsize.

*  ----------------------------------------------------------------------*

*  &                    TYPE DECLARATION                                 *

*  ----------------------------------------------------------------------*

   TYPES : BEGIN OF ty_lfa1,

           LIFNR TYPE   LIFNR,

           LAND1  TYPE LAND1_GP,

           NAME1  TYPE NAME1_GP,

           NAME2  TYPE NAME2_GP,

           NAME3  TYPE NAME3_GP,

           NAME4  TYPE NAME4_GP,

           ORT01  TYPE ORT01_GP,

           ORT02  TYPE ORT02_GP,

           PFACH  TYPE PFACH,

           PSTL2  TYPE PSTL2,

           PSTLZ  TYPE PSTLZ,

           REGIO  TYPE REGIO,

           SORTL  TYPE SORTL,

           STRAS  TYPE STRAS_GP,

           SPRAS  TYPE SPRAS,

           ADRNR  TYPE ADRNR,

   END OF ty_lfa1.

*  ----------------------------------------------------------------------*

*  &                   Binary store for PDF                              *

*  ----------------------------------------------------------------------*

   DATA: BEGIN OF it_pdf_output OCCURS 0 .

           INCLUDE STRUCTURE tline.

   DATA: END OF it_pdf_output.

*  ----------------------------------------------------------------------*

*  &                        Constant                                     *

*  ----------------------------------------------------------------------*

   CONSTANTS : c_no(1) TYPE c VALUE ' ' ,

               c_device(4) TYPE c VALUE 'LOCL'.

*  ----------------------------------------------------------------------*

*  &                    INTERNAL TABLE  DECLARATION                      *

*  ----------------------------------------------------------------------*

   DATA : IT_LFA1 TYPE STANDARD TABLE OF TY_LFA1,

          WA_LFA1 TYPE TY_LFA1.

*  ----------------------------------------------------------------------*

*  &                    Selection Screen DECLARATION                     *

*  ----------------------------------------------------------------------*

   SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

   SELECT-OPTIONS : S_LIFNR FOR V_LIFNR.

   PARAMETERS : p_email LIKE SOMLRECI1-RECEIVER.

   SELECTION-SCREEN END OF BLOCK B1.

*  ----------------------------------------------------------------------*

*  &                    Start of selection                               *

*  ----------------------------------------------------------------------*

   SELECT LIFNR

         LAND1

         NAME1

         NAME2

         NAME3

         NAME4

         ORT01

         ORT02

         PFACH

         PSTL2

         PSTLZ

         REGIO

         SORTL

         STRAS

         SPRAS

         ADRNR

     FROM LFA1

     INTO TABLE IT_LFA1

     WHERE lifnr in s_lifnr

     and SPRAS = sy-langu.                   "Message language

   PERFORM TRAITEMENT.

   PERFORM conversion.

*  &---------------------------------------------------------------------*

*  &      Form  TRAITEMENT

*  &---------------------------------------------------------------------*

*         text

*  ----------------------------------------------------------------------*

*    -->  p1        text

*    <--  p2        text

*  ----------------------------------------------------------------------*

   FORM TRAITEMENT .

     PERFORM open_form.

     PERFORM write_form.

     PERFORM close_form.

   ENDFORM.                    " TRAITEMENT

*  &---------------------------------------------------------------------*

*  &      Form  OPEN_FORM

*  &---------------------------------------------------------------------*

*         text

*  ----------------------------------------------------------------------*

*    -->  p1        text

*    <--  p2        text

*  ----------------------------------------------------------------------*

   FORM OPEN_FORM .

*

*    DATA: var_dialog TYPE char1.

*    var_dialog = ' '.

     CALL FUNCTION 'OPEN_FORM'

      EXPORTING

*       APPLICATION                       = 'TX'

*       ARCHIVE_INDEX                     =

*       ARCHIVE_PARAMS                    =

*       DEVICE                            = 'PRINTER'

*       DIALOG                            = var_dialog

        FORM                              = 'ZPHF_VMS1'

        LANGUAGE                          = sy-langu        "Message language

*       OPTIONS                           =

*       MAIL_SENDER                       =

*       MAIL_RECIPIENT                    =

*       MAIL_APPL_OBJECT                  =

*       RAW_DATA_INTERFACE                = '*'

*       SPONUMIV                          =

*     IMPORTING

*       LANGUAGE                          = sy-langu

*       NEW_ARCHIVE_PARAMS                =

*       RESULT                            =

*     EXCEPTIONS

*       CANCELED                          = 1

*       DEVICE                            = 2

*       FORM                              = 3

*       OPTIONS                           = 4

*       UNCLOSED                          = 5

*       MAIL_OPTIONS                      = 6

*       ARCHIVE_ERROR                     = 7

*       INVALID_FAX_NUMBER                = 8

*       MORE_PARAMS_NEEDED_IN_BATCH       = 9

*       SPOOL_ERROR                       = 10

*       CODEPAGE                          = 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.

   ENDFORM.                    " OPEN_FORM

*  &---------------------------------------------------------------------*

*  &      Form  WRITE_FORM

*  &---------------------------------------------------------------------*

*         text

*  ----------------------------------------------------------------------*

*    -->  p1        text

*    <--  p2        text

*  ----------------------------------------------------------------------*

   FORM WRITE_FORM .

     CALL FUNCTION 'WRITE_FORM'

      EXPORTING

        ELEMENT                        = 'HEADER1'

*     FUNCTION                       = 'SET'

*     TYPE                           = 'BODY'

        WINDOW                         = 'HEADER'.

     CALL FUNCTION 'WRITE_FORM'

      EXPORTING

        ELEMENT                        = 'LINE'

*     FUNCTION                       = 'SET'

*     TYPE                           = 'BODY'

        WINDOW                         = 'LINE_HD'.

     LOOP AT IT_LFA1 INTO WA_LFA1.

       CALL FUNCTION 'WRITE_FORM'

        EXPORTING

          ELEMENT                        = 'MAIN1'

*     FUNCTION                       = 'SET'

*     TYPE                           = 'BODY'

          WINDOW                         = 'MAIN'.

     ENDLOOP.

   ENDFORM.                    " WRITE_FORM

*  &---------------------------------------------------------------------*

*  &      Form  CLOSE_FORM

*  &---------------------------------------------------------------------*

*         text

*  ----------------------------------------------------------------------*

*    -->  p1        text

*    <--  p2        text

*  ----------------------------------------------------------------------*

   FORM CLOSE_FORM .

     CALL FUNCTION 'CLOSE_FORM'

     IMPORTING

     RESULT                         = i_itcpp

*     RDI_RESULT                     =

*   TABLES

*     OTFDATA                        =

      EXCEPTIONS

      UNOPENED                       = 1

      BAD_PAGEFORMAT_FOR_PRINT       = 2

      SEND_ERROR                     = 3

      SPOOL_ERROR                    = 4

      CODEPAGE                       = 5

        OTHERS                         = 1

               .

     IF SY-SUBRC <> 0.

       w_erreur = w_erreur + 1.

     ENDIF.

   ENDFORM.                    " CLOSE_FORM

*  &---------------------------------------------------------------------*

*  &      Form  CONVERSION

*  &---------------------------------------------------------------------*

*         text

*  ----------------------------------------------------------------------*

*    -->  p1        text

*    <--  p2        text

*  ----------------------------------------------------------------------*

   FORM CONVERSION .

   CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

     EXPORTING

       SRC_SPOOLID                    = i_itcpp

      NO_DIALOG                      = c_no

      DST_DEVICE                     = c_device

*     PDF_DESTINATION                =

*     NO_BACKGROUND                  =

*     GET_SIZE_FROM_FORMAT           =

    IMPORTING

      PDF_BYTECOUNT                  = gd_bytecount

*     PDF_SPOOLID                    =

*     LIST_PAGECOUNT                 =

*     BTC_JOBNAME                    =

*     BTC_JOBCOUNT                   =

*     BIN_FILE                       =

    TABLES

      PDF                            = it_pdf_output

    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.

Read only

0 Likes
1,410

Hi Meenakshi,

Pass only spool number to the convert_abapspooljob_2_pdf fm.

refer this thread http://scn.sap.com/thread/680829

Read only

0 Likes
1,410

Not sure what you are trying to do.....

If you only require to pass Vendor details like name and other things.....why not create an excel file or a CSV file and forward the same to recepients via CL_BCS?

Anyways....you can get OTF data in Sapscripts also

All you need to do is in OPTIONS parameter of OPEN_FORM there is a field called TDGETOTF. Pass a value of 'X' to it

In CLOSE_FORM...you will obtain the OTF data as a tables parameter

Call the FM CONVERT_OTF_2_PDF to convert the OTF data into PDF....

Infact you can use CONVERT_OTF  to get data and then pass the same to recepients via CL_BCS class

Read only

0 Likes
1,410

Dear Gowtham,

CONVERT_ABAPSPOOLJOB_2_PDF can be used for Report list output ,Kindly use CONVERT_OTFSPOOLJOB_2_PDF for the Form  spools , else you can use program RSTXPDFT4 for downloading spool to PDF

Read only

Former Member
0 Likes
1,410

This message was moderated.