SmartForm to be called in Loop

Hi All,
I have a requirement where i need to call smartform in a loop.
I have a customer number as a select option on the selection screen. I am getting all the customers in a internal  table entered on the selection screen and by looping on this internal table I am calling the FM SSF_FUNCTION_MODULE_NAME.
But it is getting executed only for one customer.
Is there any variable or parameter needs to be set. I need this smartform to be called for every customer in the loop.
Please let me know the solution.
Thanks in advance,
Kuldeep.

try this it will definetly work, it is based on invoice change it to your requirement
create a another internal table with output structure
after select-option statement write;
define tb_vbeln internal table with only vbeln field
SELECT VBELN
       FROM
       VBRK
       INTO TABLE TB_VBELN
       WHERE VBELN IN P_VBELN.
then after  ssf_function_module_name
LOOP AT TB_VBELN INTO WA_VBELN.
REFRESH TB_OUTPUT1.
LOOP AT TB_OUTPUT INTO WA_OUTPUT WHERE VBELN = WA_VBELN-VBELN.
  APPEND WA_OUTPUT TO TB_OUTPUT1.
ENDLOOP.
CALL FUNCTION FM_NAME(function module name)
  EXPORTING
  ARCHIVE_INDEX              =
  ARCHIVE_INDEX_TAB          =
  ARCHIVE_PARAMETERS         =
  CONTROL_PARAMETERS         =
  MAIL_APPL_OBJ              =
  MAIL_RECIPIENT             =
  MAIL_SENDER                =
  OUTPUT_OPTIONS             =
  USER_SETTINGS              = 'X'
    P_VBELN                    = WA_OUTPUT-VBELN
IMPORTING
  DOCUMENT_OUTPUT_INFO       =
  JOB_OUTPUT_INFO            =
  JOB_OUTPUT_OPTIONS         =
  TABLES
    TB_ITAB                    = TB_OUTPUT1
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.
ENDLOOP.

Similar Messages

  • Whenever  Transfer order Genarated  Smartform  Should be called?

    HI Guys,
    I have Requirement like Wnenever  we save the Transfer Order number then  MY smartform should be called ? for this i am suing one EXit  LIke  EXIT_RLVSDR40_001  there i am calling my smartform . BUt when Iam trying to save the TO  but this is nnot triggered.   I am using same exit  for printing samrtform  for another country  it is working .    but is it not working now ? can any one please help me on these ?

    resolved

  • Smartforms - How to call more form in one print propgram ?

    Hello expert,
    how is possible call in one time more forms.  The forms are the same, and I have to print ( and print preview ) all togehter
    and not one to one .
    What is the parameters to use ?
    tks,

    U loop ur internal table with 10 document no's in the internal table.
    Now, in the loop u call the Smartform FM..
    eg:
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING  formname           = itab-form_name
                    variant            = ' '
                    direct_call        = ' '
         IMPORTING  fm_name            = fm_name
         EXCEPTIONS no_form            = 1
                    no_function_module = 2
                    OTHERS             = 3.
    LOOP at itab.
    call function fm_name   "smartform Function name
    endloop.
    or, u can also do this, by calling SSF_OPEN & SSF_Close.
    Hope it helps!!
    Rgds,
    Pavan

  • Need help calling and looping custom classes

    Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
    L6:
    public class lab6
    public static void main(String[] args)
    Foreign camount = new Foreign();
    camount = new Foreign();
    camount.get();
    camount.print();
    camount.intake();
    camount.convert();
    camount.vertprint();
    System.out.println(camount);
    Foreign:
    import java.util.Scanner;
    public class Foreign
    private String country;
    private int choice;
    private float dollars;
    private float conversionValue;
    private float conversionAmount;
    public Foreign()
    country = "null";
    choice = 0;
    dollars = 0;
    conversionValue = 0;
    conversionAmount = 0;
    public void get()
         Scanner Keyboard = new Scanner(System.in);
              System.out.println("Foreign Exchange\n\n");
    System.out.println("1 = U.S. to Canada");
    System.out.println("2 = U.S. to Mexico");
    System.out.println("3 = U.S. to Japan");
    System.out.println("4 = U.S. to Euro");
    System.out.println("0 = Quit");
    System.out.print("\nEnter your choice: ");
    choice = Keyboard.nextInt();
    public void print()
    System.out.print("\nYou chose " + choice);
    public void intake()
         Scanner Keyboard = new Scanner(System.in);
              if (choice >= 1 && choice <= 4)
    switch (choice)
              case 1: System.out.println("\nU.S. to Canada");
                        conversionValue = 1.1225f;
                        country = ("Canadian Dollars");
                        break;
              case 2: System.out.println("\nU.S. to Mexico");
                        conversionValue = 10.9685f;
                        country = ("Mexican Pesos");
    break;
              case 3: System.out.println("\nU.S. to Japan");
                        conversionValue = 118.47f;
                        country = ("Japanese Yen");
    break;
              case 4: System.out.println("\nU.S. to Euro");
                        conversionValue = 0.736377f;
                        country = ("European Union Euros");
    break;
                   System.out.print("\nEnter U.S. dollar amount: ");
              dollars = Keyboard.nextFloat();
    public void convert()
    conversionAmount = conversionValue * dollars;
    public void vertprint()
    System.out.println("\nCountry = " + country);
    System.out.println("Rate = " + conversionValue);
    System.out.println("Dollars = " + dollars);
    System.out.println("Value = " + conversionAmount);
    public String toString()
    String line;
    line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
    return line;
    I appreciate any help anyone can give me. This is driving me crazy. Thanks.

    1. first you need to write method to get choice value from Foreign class.
    simply add this method.
       public class Foreign {
          // ... Add this
          public int getChoice() {
             return choice;
       }2. Then in your main, you can obtain with previos method.
    public static void main(String[] args) {
       Foreign camount = new Foreign();
       // remove this. you alredy create an instance in last statement.
       //camount = new Foreign();
       int choice = 0;
       do {
          camount.get();
          choice = camount.getChoice();
          // your process...
       } while (choice != 0);
    }

  • Smartforms:Can i call a Tcod from Driver Prg 4 its o/p 2 be appended

    Hello Smartform Gurus
    I need 2 call 1 tcode from my Driver prog ,which has report o/p that is 2 be appended in my Smartform o/p as a
    appended page .
    Is it possible at all ?
    plz throw some light on this .
    thnx
    Moni

    Hi Moni,
    of course there are several ways to reach your goal.
    I have assumed:
    - your smartform is based on a SAP-document
    - document output is based on standard output determination with output messages
    This is defined in customizing (SPRO) at several places or combined in NACE.
    Anyway, create additional output just after smartform output, take care of same printer, spool name and so on ->  you will end with one (combined) spool request.
    Have a look for output messages, if you are unsure how to get a 'simple' smartform output.
    Regards,
    Christian

  • Smartforms - new page command at loop

    Hi @ll,
    I`ve created a loop over an internal table in which I have insert a command to go to next page. The command is being called correctly but I don`t get data on the next page. I would expext that the loop goes on with the next record. Currently have just one page - could that be the problem?
    What I`m doing wrong?
    Ragards,
    Flo

    Hi,
       In the internal table add one more field called flag and in the driver program populate the value of     flag = 'X'  at the end of every PERNR using Control break statements.
       In the loop and the command give the condition as  Flag = 'X'.
       So the Page break will be triggered when ever the PERNR value will be changed.
    Hope this will help you.
    Regards,
    Venkat.

  • Smartforms - how to call 2nd secondary window page

    Hi
    How to call 2nd secondary window page from Ist Main window. The scenario is i have one main page. I have already called 2nd page thru command line and now want to call another page (i mean third page) from same main window. How do I do?
    Thanx and regards,
    Rajesh Vasudeva

    Hi Rajesh,
    Go for the below link>>>>>
    [http://help.sap.com/search/highlightContent.jsp]
    thnks.

  • Get looped SMARTFORMs Graphic via WD

    Hi Experts,
    i want to get a looped graphic (table containing a text has been constructed in Smartforms) in the PDF.
    the table  will be filled with a text( 10 till 1000 words) in a textedit UI-elemt( dynamic textedit with type TLINE). so each time the user click on 'write text' Button, a new textedit appears and the user can write his text there. in the end if the user have wrote 10 times texts in textedit UI-element( means 10 textedit UI-element will appear in Portal) this should also in  the PDF appears.
    the coding is following, but i dont know where i have to make changes or where shall make loop?
    i hope that everything is clear for you ,
    DATA: fm_name TYPE rs38l_fnam,                
            ls_contp TYPE ssfctrlop,       
            ls_output  TYPE ssfcompop,         
            ls_output_data TYPE ssfcrescl,         
            tab_otf_final TYPE TABLE OF itcoo.
      DATA :  bin_filesize  TYPE i,
              bin_file      TYPE xstring,
              pdf_tab       TYPE TABLE OF tline.
    Set the output parameters
      ls_output_options-tdprinter = 'PDF1'.
    set control parameters to get the output format (OTF) from Smart Forms
      ls_contp-no_dialog = 'X'.
      ls_contp-getotf = 'X'.
      ls_contp-preview = 'X'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
      formname = 'Z_TAD_PAP'
    VARIANT = ' '
    DIRECT_CALL = ' '
      IMPORTING
      fm_name = fm_name
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = ls_control_parameters
          output_options     = ls_output
          user_settings      = space
        IMPORTING
          job_output_info    = ls_output_data
        TABLES
          z_tad_pap_data     = lt_table  (this table is containing my data )
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
    tab_otf_final[] = ls_output_data-otfdata[].
    " Convert OTF data into PDF data
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = bin_filesize
          bin_file              = bin_file
        TABLES
          otf                   = tab_otf_final
          lines                 = pdf_tab
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          OTHERS                = 5.
    cl_wd_runtime_services=>attach_file_to_response(
    i_filename      = 'mail.pdf'
    i_content       =  bin_file
    i_mime_type   =   '/Desktop').
    thank you for help

    hi Kowluri,
    sorry that i didnt answer you so quik, i was busy with other stuff.
    well, what i am looking for, is how to fill my table in SMATRFORMS from WD, i already have an internal Table that contains the data, (this table contains only the data for one textedit UI-elements).
    the problem is , this component (table) in smartforms , should be called more than one time ( the same component) . if the user have wrote 2 or 3  or 4 texts ( each textedit UI-elemet contains a text in the Portal),  all of those texts should be displayed on the PDF , and this component(table) in SMARTFORMS should be called each time for each text.
    i hope that everything is clear, if not , i will explain more
    Best Regards
    Natel

  • Calling the smartform based on checkbox selection in ALV

    Hi
    i displayed the report output in ALV using 'REUSE_ALV_GRID_DISPLAY'. I maintained checkboxes as first column of data.
    and i also added three user defined buttons like check,uncheck,print form. Now my problem is when user selecting the records in ALV using the checkbox,i have to call the smartform based up on user selection of check box.i done but it is coming only for one checkbox.if we select multiple checkboxes it is not coming.but i need smartform has to call for every checkbox user has selected.
    can u suggest on this.all my data in internal table i_data with checkbox field. i'm copying my code here.
    LOOP AT I_DATA.
        READ TABLE I_DATA INTO WA_DATA INDEX FU_SELFIELD-TABINDEX.
        WA_DATA-SEL = 'X'.
        MODIFY I_DATA FROM WA_DATA TRANSPORTING SEL.
        FU_SELFIELD-REFRESH = 'X'.
    MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
      APPEND WA_PRINT TO I_PRINT.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            FORMNAME                 = 'ZHRF1_PTAR1001'
    *       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
    *     ARCHIVE_INDEX              =
    *     ARCHIVE_INDEX_TAB          =
    *     ARCHIVE_PARAMETERS         =
    *     CONTROL_PARAMETERS         =
    *     MAIL_APPL_OBJ              =
    *     MAIL_RECIPIENT             =
    *     MAIL_SENDER                =
    *     OUTPUT_OPTIONS             =
    *     USER_SETTINGS              = 'X'
          FR_DATE                    = PN-BEGDA
          TO_DATE                    = PN-ENDDA
    *   IMPORTING
    *     DOCUMENT_OUTPUT_INFO       =
    *     JOB_OUTPUT_INFO            =
    *     JOB_OUTPUT_OPTIONS         =
        TABLES
          ITAB                       = I_PRINT
    *   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.
    ENDLOOP.
    ENDCASE.
    Moderator Message: Duplicate post locked. Continue with your previous thread.
    Edited by: Suhas Saha on Dec 27, 2011 9:17 AM

    HI arjun,
    according to you code,
    READ TABLE I_DATA INTO WA_DATA INDEX FU_SELFIELD-TABINDEX.
    the fu_selfield-tabindex contains only one number , so its trigger only one check box, it is not correct to loop i_data .
    take the records which are checked and loop that internal table , using check_changed_data u can select multiple records which are checked.
    one importent thing , use sy-subrc after read statement bcz see example
    in second loop if the read statement has failed but the work area contains the data , so beware check sy-subrc= 0 . after read.
    debug your program and check every time FU_SELFIELD-TABINDEX will be same . so reads same record so many time how many times the loop had.
    instead do like this
    loop at i_data into wa_data where check = 'x'.
    MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
    endloop.
    Regards
    Siva

  • Call Smartforms in WD

    Hi all,
    i want to print the data that i have in Portal (WD)  in a PDF via Smartforms, 
    can somebody tell me how can i do this?
    Best Regards

    get the Smartform function module
    call smartform
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME           = '<Smartform name>'
        IMPORTING
          FM_NAME            = LV_FUNC_MOD_NAME
        EXCEPTIONS
          NO_FORM            = 1
          NO_FUNCTION_MODULE = 2
          OTHERS             = 3.
    IF SY-SUBRC <> 0 .
      RETURN.
    ENDIF.
    call LV_FUNC_MOD_NAME   with Control parameter NO_DIALOG,GET_OTF marking X
    *convert the OTF to PDF using
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        FORMAT                = 'PDF'
        MAX_LINEWIDTH         = 132
      IMPORTING
        BIN_FILESIZE          = LV_LENGTH
        BIN_FILE              = LV_XSTRING
      TABLES
        OTF                   = LT_RETURN-OTFDATA
        LINES                 = LT_TLINE
      EXCEPTIONS
        ERR_MAX_LINEWIDTH     = 1
        ERR_FORMAT            = 2
        ERR_CONV_NOT_POSSIBLE = 3
        ERR_BAD_OTF           = 4
        OTHERS                = 5.
    IF SY-SUBRC <> 0.
      RETURN.
    ENDIF.
    now use use runtime service method to push the PDF to browser client
    CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE

  • WHERE clause in a SMARTFORM loop, problems with parenthesis

    Hi all gurus,
    a simple question: I'm coding a LOOP in the form builder for a smartform ... this simple loop should bind text elements to every position of a purchase order. The WHERE clause should be as follows:
    WHERE GUID = WA_ITEM-GUID
    AND ( TDID EQ 'ZDES' OR TDID EQ 'ZDST' ).
    Anyway, in the Form Builder I didn't find a way to add parenthesis; I workarounded the problem with the following query:
    (conditions in lines are in AND conjunction)
    GUID EQ     WA_ITEM-GUID
    TDID      EQ   'ZDES'
    OR
    GUID EQ     WA_ITEM-GUID                                                                               
    TDID      EQ 'ZDST'.
    It's quite a 'bad' way, but it works. I wonder if there's a way to express "complex" WHERE clauses (with addiction of parenthesis) in Form Builder.
    Thanks in advance

    In this case, your solution is the one that works. However in more complex cases with more variables, this can proove difficult to make or mantain.
    What I usually do is use the first part of the condition in the where and then add a condition to the printing area with the rest of the formula. Just remember to document this so that you'll find it easy and it's way more amintainable.
    In this case the loop would contain WHERE GUID = WA_ITEM-GUID and the inside condition TDID EQ 'ZDES' OR TDID EQ 'ZDST. This creates the and between the two blocks.

  • Calling a SmartForm

    Now that I created a SmartForm and I called the FM
    "SSF_FUNCTION_MODULE_NAME",
    How can I call my created Smartform.

    Hi Shaheen,
    1. First call the below FM and pass the name of the Smart Form in Formname and :
    DATA:
      w_fname TYPE rs38l_fnam.             " Form Name
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = 'SMART_FORM_NAME'
    *     VARIANT                  = ' '
    *     DIRECT_CALL              = ' '
        IMPORTING
          fm_name                  = w_fname
        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.
      ELSE.
    *" Subroutine Call to Call the Smart Form .............................
        PERFORM call_smart_form.
      ENDIF.
    2. Goto your SMART FORM, then go to ENVIRONMENT and click on FM name and copy the FM name.
    3. Then in Driver Program click on Pattern and paste the FM name.
    4. Then Replace the Name with w_fname (i.e. Import Parameter from First FM), as shown below:
    CALL FUNCTION w_fname
      EXPORTING
    *   ARCHIVE_INDEX              =
    *   ARCHIVE_INDEX_TAB          =
    *   ARCHIVE_PARAMETERS         =
    *   CONTROL_PARAMETERS         =
    *   MAIL_APPL_OBJ              =
    *   MAIL_RECIPIENT             =
    *   MAIL_SENDER                =
    *   OUTPUT_OPTIONS             =
    *   USER_SETTINGS              = 'X'
        p_vbeln                    = p_vbeln                         " User Parameter
    * IMPORTING
    *   DOCUMENT_OUTPUT_INFO       =
    *   JOB_OUTPUT_INFO            =
    *   JOB_OUTPUT_OPTIONS         =
    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.
    Refer Below Site for More Info:
    http://www.****************/Tips/SmartForms/FMImportance.htm
    Regards,
    Sunil.

  • Printing Dunning Letters using Smartforms

    Hi all,
    I have a requirement wherein I need to print dunning letters using smartforms; the dunning data are extracted in program SAPF150D2;I modified the subroutine OFI_DUN_ACT to call function module FI_PRINT_DUNNING_NOTICE_SMARTF.
    Now I need to extract the dunning data in program SAPF150D2 to be imported to my new form using GET_SF_DUNN_DATA, my question is where do I code the calling of FM GET_SFG_DUNN_DATA? I'm a little bit confused on the step by step process of the dunning data extraction to printing of the form... Thanks...

    In the INITIALIZATION of the Smartforms, after the call to  GET_SF_DUNN_DATA, you have a many informations back, of which the record of MHNK and an internal table of MHND, which you can use to select other informations from database.
    So fill or enrich your own internal table in the initialization.
    I enclose thereafter a sample to help you
    * Load data
      CALL FUNCTION 'GET_SF_DUNN_DATA'
           EXPORTING
                is_sfparam          = is_sfparam
           IMPORTING
                es_mhnk             = mhnk
                es_t001             = t001
                es_knb5             = knb5
                es_lfb5             = lfb5
                es_t047             = t047
                es_t047c            = t047c
                es_t047i            = t047i
                es_t056z            = t056z
                es_f150d            = f150d
                es_fsabe            = fsabe
                es_adrnr            = adrnr
                es_uadrnr           = uadrnr
                es_adrs             = adrs
                es_uadrs            = uadrs
                es_t047b            = t047b
                eb_testprint        = testprint
                e_langu             = langu
                e_lang2             = lang2
                es_f150d_esr        = f150d_esr
                es_paymi            = paymi
                es_paymo            = paymo
           TABLES
                t_mhnd              = th_mhnd
           EXCEPTIONS
                no_parameters_found = 1
                OTHERS              = 2.
    IF sy-subrc <> 0.
      sy-msgid = 'FM'.
      sy-msgty = 'E'.
      sy-msgno = 461.
      RAISE others.
    ENDIF.
    h_t040a-text1 = space.
    show_interest = space.
    LOOP AT th_mhnd INTO mhnd WHERE xzins = ' '.
      show_interest = 'X'.
      EXIT.
    ENDLOOP.
    * Load user information
    DATA: usr21 LIKE usr21, addr3_sel LIKE addr3_sel.
    CLEAR: usr21, addr3_sel, addr3_val, adr6.
    * Charger fiche profil
    SELECT SINGLE * FROM usr21 WHERE bname = sy-uname.
    * Récupérer l'adresse
    MOVE-CORRESPONDING usr21 TO addr3_sel.
    CALL FUNCTION 'ADDR_PERS_COMP_GET'
         EXPORTING
              address_pers_in_comp_selection = addr3_sel
         IMPORTING
              address_pers_in_comp_value     = addr3_val
         EXCEPTIONS
              OTHERS                         = 1.
    * load SMTP address
    CLEAR adr6.
    SELECT SINGLE * FROM adr6
      WHERE addrnumber = usr21-addrnumber
        AND persnumber = usr21-persnumber.
    * date format
    SET COUNTRY adrs-land1.
    * Group similar posts
    DATA: xbseg TYPE bseg,
          xbkpf TYPE bkpf,
          xpost TYPE th_outtab.
    REFRESH: t_post, t_cumul_waers.
    LOOP AT th_mhnd INTO mhnd.
    * Select lines to use
      IF mhnk-gmvdt IS INITIAL.
        IF mhnd-xzalb <> space OR mhnd-mansp <> space.
          CONTINUE.
        ELSEIF t047b-xpost NE 'X' AND mhnd-xfael <> 'X'.
          CONTINUE.
        ENDIF.
      ENDIF.
    * Map data
      CLEAR xpost.
      MOVE-CORRESPONDING mhnd TO xpost.
    * Load text from bseg
      SELECT SINGLE sgtxt INTO xpost-sgtxt FROM bseg
        WHERE bukrs EQ mhnd-bbukrs AND belnr EQ mhnd-belnr
          AND gjahr EQ mhnd-gjahr  AND buzei EQ mhnd-buzei.
      PERFORM edit_text CHANGING xpost-zuonr mhnd-xblnr xpost-sgtxt.
    * if "Payment difference" get the date of original document
      IF mhnd-bschl = '06'.
        SELECT SINGLE bldat INTO xpost-bldat
          FROM bkpf
          WHERE bukrs = mhnd-bukrs
            AND belnr = mhnd-rebzg
            AND gjahr = mhnd-rebzj.
      ENDIF.
    * Collect posts to print
      COLLECT xpost INTO t_post.
    * Collect amount per currency
      MOVE-CORRESPONDING xpost TO cumul.
      COLLECT cumul INTO t_cumul_waers.
    ENDLOOP.
    * Load customer information
    SELECT SINGLE * FROM kna1 INTO kna1
      WHERE kunnr = mhnk-kunnr.
    SELECT SINGLE * FROM knb1 INTO knb1
      WHERE bukrs = mhnk-bukrs
        AND kunnr = mhnk-kunnr.
    * Convert date to text
    PERFORM convert_date USING control_parameters-langu mhnk-laufd
      CHANGING text_date.
    PERFORM convert_date USING control_parameters-langu mhnk-prndt_before
      CHANGING text_prev.
    PERFORM convert_date USING control_parameters-langu mhnk-grdat
      CHANGING text_extr.
    Regards

  • Error while emailing pdf Smartform- help needed

    Hi All,
    I have successsully saved smartform as pdf on my local machine and while trying to send the same as an attachment.i am encountering a run time error in SCOT transaction on pressing send message.
    Error details are as follows:-
    CPIC-CALL: THE SAPECMINIT’’ UNABLE TO DETERMINE HOST ADDRESS
    Source Code:  SAPMSSY1
    CALL ‘RFCIMPORT’
    The program is given below. Kindly reply me the solution.
    All helpful answers will b rewarded.
    Regards,
    Eureka.
    *& Report  Z24436_SMARTFORM2                                           *
    REPORT  Z24436_SMARTFORM2                       .
          Global Variables Declarations
    DATA: MAt_id TYPE MATNR VALUE '1%',
          fm_name TYPE rs38l_fnam.
    DATA: ITAB_MAkt TYPE STANDARD TABLE OF MAkt.
    DATA:  p_form   TYPE tdsfname   VALUE 'ZUDAY_SMARTFORMS1'.
          All Database Selections are here
    *Getting Materials belonging to the given plant
    SELECT * FROM MAkt INTO TABLE ITAB_MAkt
             WHERE MATNR LIKE MAT_id.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname                 =  p_form
      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.
      EXIT.
    ENDIF.
    DATA : gw_ssfcrescl TYPE ssfcrescl.
    DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
         gt_tline TYPE STANDARD TABLE OF tline,
          gt_pdf TYPE STANDARD TABLE OF tline,
          gv_len LIKE sood-objlen,
          gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
          gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
    gw_ssfctrlop-getotf = 'X'.
    gw_ssfctrlop-no_dialog = 'X'.
    gw_ssfcompop-tdnoprev = 'X'.
    **Calling the generated function module
    CALL FUNCTION fm_name
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
        CONTROL_PARAMETERS         = gw_ssfctrlop
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
        OUTPUT_OPTIONS             = gw_ssfcompop
        USER_SETTINGS              = 'X'
       customer_info              = customer
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
        JOB_OUTPUT_INFO            = gw_ssfcrescl
      JOB_OUTPUT_OPTIONS         =
      TABLES
        it_makt                   = itab_makt
      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.
    gt_otf[] = gw_ssfcrescl-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
        max_linewidth         = 132
      IMPORTING
        bin_filesize          = gv_len
      TABLES
        otf                   = gt_otf
        lines                 = gt_pdf
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        OTHERS                = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    DATA:
    gt_pdf          TYPE TABLE OF tline,
      gt_xi_pdf       TYPE TABLE OF tline,
      gt_pdf_conv     TYPE TABLE OF solisti1,
      gt_xi_temp      TYPE TABLE OF bapiqcmime.
      CONSTANTS:
        lc_x(1)          TYPE c VALUE 'X',
        lc_raw(3)        TYPE c VALUE 'RAW',
        lc_pdf(3)        TYPE c VALUE 'PDF',
        lc_attach(12)    TYPE c VALUE 'ATTACHMENT'.
      DATA:
        lv_spool         TYPE rspoid,              "Spool Number
        lv_pdf_size      TYPE i,                   "PDF Size
        lv_subject(40)   TYPE c,                   "Email subject
        lv_tab_lines     TYPE sytabix,             "Table Lines
        lv_date(10)      TYPE c,                   "Variable for date
        lv_time(8)       TYPE c.                   "Variable for Time
      DATA:
    For Compressing document
       ls_objpack       TYPE sopcklsti1,
       lt_objpack       TYPE STANDARD TABLE OF sopcklsti1,
    To specify subject
       lt_objhead       TYPE STANDARD TABLE OF solisti1,
       ls_objhead       TYPE solisti1,
    To send the PDF
       lt_objbin        TYPE STANDARD TABLE OF solisti1,
       ls_objbin        TYPE solisti1,
    Email body
       lt_objtxt        TYPE STANDARD TABLE OF solisti1,
       ls_objtxt        TYPE solisti1,
    To specify Receivers
       lt_reclist       TYPE STANDARD TABLE OF somlreci1,
       ls_reclist       TYPE somlreci1,
    Documenting Data
       ls_doc_chng      TYPE sodocchgi1,
       ls_pdf_conv      TYPE solisti1.
      CONSTANTS: lc_under(1) TYPE c VALUE '_'.
    **Copy the Spool request to a Local Variable
    lv_spool = sy-spono.
    Convert spool job to PDF
    ***************this is normal report spool to pdf.
    but your case it will be smartform to pdf
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
       EXPORTING
         src_spoolid   = lv_spool
         no_dialog     = lc_x
       IMPORTING
         pdf_bytecount = lv_pdf_size
       TABLES
         pdf           = gt_pdf
       EXCEPTIONS
         OTHERS        = 0.
    To Format the PDF file so as each row contains 255 characters
      PERFORM page_format .
    Transfer the file to objbin table
      LOOP AT gt_pdf_conv INTO ls_pdf_conv.
        ls_objbin-line = ls_pdf_conv-line.
        APPEND ls_objbin TO lt_objbin.
        CLEAR ls_objbin.
      ENDLOOP.
    *// Creating the document to be sent - Mail subject creation
      ls_doc_chng-obj_name = sy-repid.
      lv_subject = text-008.                      "Mail subject
      WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.
      WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
      CONCATENATE lv_subject lc_under lv_date lc_under lv_time
                      INTO ls_doc_chng-obj_descr.
    *// Email body
      PDF attachment of Product Allocation for Open orders
      ls_objtxt = text-009.
      APPEND ls_objtxt TO lt_objtxt.
    Write Date when the mail was sent in the email body
      CONCATENATE text-010 lv_date INTO ls_objtxt.
      APPEND ls_objtxt TO lt_objtxt.
    Write Time when the mail was sent in the email body
      CONCATENATE text-011 lv_time INTO ls_objtxt.
      APPEND ls_objtxt TO lt_objtxt.
      DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
      READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_tab_lines.
    Calculate the document size
      ls_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +
                              STRLEN( ls_objtxt ).
    *// Creating the entry for the compressed document
      CLEAR ls_objpack-transf_bin.
      ls_objpack-head_start = 1.
      ls_objpack-head_num   = 0.
      ls_objpack-body_start = 1.
      ls_objpack-body_num   = lv_tab_lines.
      ls_objpack-doc_type   = 'RAW'    .    "RAW
      APPEND ls_objpack TO lt_objpack.
      CLEAR lv_tab_lines.
      DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
      ls_objhead = ls_doc_chng-obj_descr.
      APPEND ls_objhead TO lt_objhead.
    *// Creating the entry for the compressed attachment
      ls_objpack-transf_bin = lc_x.
      ls_objpack-head_start = 1.
      ls_objpack-head_num   = 1.
      ls_objpack-body_start = 1.
      ls_objpack-body_num   = lv_tab_lines.
      ls_objpack-doc_type   = 'PDF'.            "PDF
      ls_objpack-obj_name   = 'ATTACHMENT'.         "ATTACHMENT
      CONCATENATE lv_subject lc_under lv_date lc_under lv_time
        INTO ls_objpack-obj_descr.
      CLEAR: ls_objbin.
      READ TABLE lt_objbin INTO ls_objbin INDEX lv_tab_lines.
      ls_objpack-doc_size = ( lv_tab_lines - 1 ) * 255 +
                              STRLEN( ls_objbin ).
      APPEND ls_objpack TO lt_objpack.
    ls_reclist-receiver = '[email protected]'.
    ls_reclist-receiver = gv_email_addr.
      ls_reclist-rec_type = 'U'.
      APPEND ls_reclist TO lt_reclist.
      IF ls_reclist-receiver IS INITIAL.
       MESSAGE i175.
      ELSE.
    *// Send EMail
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = ls_doc_chng
            put_in_outbox              = lc_x
            commit_work                = lc_x
          TABLES
            packing_list               = lt_objpack
            object_header              = lt_objhead
            contents_bin               = lt_objbin
            contents_txt               = lt_objtxt
            receivers                  = lt_reclist
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            operation_no_authorization = 3
            OTHERS                     = 99.
        CASE sy-subrc.
          WHEN 0.
    Mail successfully delivered
    *// Do nothing
          WHEN 1.
    This will never occur as at any point of time mail will be
    sent to one processor only.
    *// Do nothing
          WHEN 2.
           MESSAGE i175.
          WHEN 3.
           MESSAGE i175.
    *// Do nothing
        ENDCASE.
      ENDIF.
      REFRESH: lt_objpack,
               lt_objbin,
               lt_objtxt,
               lt_objhead,
               lt_reclist.
      CLEAR: ls_reclist,
             ls_doc_chng,
             ls_objpack,
             ls_objhead,
             ls_objtxt.
    DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\Udaya4.pdf'.
    CALL FUNCTION 'DOWNLOAD'
      EXPORTING
        bin_filesize     = gv_len
        filename         = gv_filename
        filetype         = 'BIN'
        filetype_no_show = 'X'
      IMPORTING
        act_filename     = gv_filename
        filesize         = gv_len
       cancel           = ''
      TABLES
        data_tab         = gt_pdf.
        FORM page_format .
    Local data
      DATA : lv_lines       TYPE i,
             lv_temp(500)   TYPE c,
             lv_offset      TYPE p,
             lv_lineslen(2) TYPE p,
             lv_mimelen(2)  TYPE p,
             lv_tabix       LIKE sy-tabix,
             ls_pdf_conv    TYPE solisti1,
             ls_xi_temp     TYPE bapiqcmime,
             ls_xi_pdf      TYPE tline.
      CLEAR : gt_xi_pdf,
              gt_xi_temp.
      REFRESH: gt_xi_pdf,
               gt_xi_temp.
      Copy the PDF file into table gt_xi_pdf
      gt_xi_pdf[] = gt_pdf[].
    Reformat the line to 255 characters wide (code from SAP)
      CLEAR: lv_temp, lv_offset, gt_xi_temp.
      DESCRIBE TABLE gt_xi_pdf   LINES  lv_lines.
      DESCRIBE FIELD ls_xi_pdf   LENGTH lv_lineslen IN CHARACTER MODE.
      DESCRIBE FIELD ls_xi_temp  LENGTH lv_mimelen IN CHARACTER MODE.
    Go through all the lines of table gt_xi_pdf
      LOOP AT gt_xi_pdf INTO ls_xi_pdf.
        lv_tabix = sy-tabix.
        Move ls_xi_pdf into lv_temp variable
        MOVE ls_xi_pdf TO lv_temp+lv_offset.
       Check if its the last line of table gt_xi_pdf
        IF lv_tabix = lv_lines.
          lv_lineslen = STRLEN( ls_xi_pdf ).
        ENDIF.
       Calculate the new offset
        lv_offset = lv_offset + lv_lineslen.
       Check if the new offset is equal to or greater than the length of
       gt_xi_temp
        IF lv_offset GE lv_mimelen.
          CLEAR ls_xi_temp.
        Copy the PDF data into gt_xi_temp
          ls_xi_temp = lv_temp(lv_mimelen).
          APPEND ls_xi_temp TO gt_xi_temp.
          SHIFT lv_temp BY lv_mimelen PLACES.
        Calculate the new offset
          lv_offset = lv_offset - lv_mimelen.
        ENDIF.                        "Offset GE MIMELEN
        Check if its the last line of gt_xi_pdf
        IF lv_tabix = lv_lines.
        Check if lv_temp has some data that is not been transferred to
        gt_xi_temp
          IF lv_offset GT 0.
            CLEAR ls_xi_temp.
         Copy the PDF data into gt_xi_temp
            ls_xi_temp = lv_temp(lv_offset).
            APPEND ls_xi_temp TO gt_xi_temp.
          ENDIF.   "lv_offset GT 0
        ENDIF.     "lv_tabix = lv_lines
      ENDLOOP.
      gt_pdf_conv[] = gt_xi_temp[].
    ENDFORM.                    " page_format

    all settings in SCOT is ok ? like SMTP settings , link b/w ur Outlook server and SAP server ?
    Regards
    Prabhu

  • Need help on smartform spool generation for payslips

    Hi Experts,
    My development of Payslip form is done, its all fine.
    Here is some clarification I need on the spool generation:
    First time I run the program for 2 employees, I get 2 pages one for each employee, as expected.
    When I again run the program for 2 employees, 2 pages are added to the same spool request.
    My requirement is to create a new spool when the program is executed for the next time. I have tried setting NO_OPEN and NO_CLOSE in control parameters and also I have tried with several output option settings. I have also tried using FMs SSF_OPEN and SSF_CLOSE. But no luck so far.
    Please note that this is HR Payslip hence the smartform is being called inside the GET PERNR loop.
    Thanks in advance.

    Hi,
    Here you can find the list of preconditions in order for Spool system to append to existing spool. Setting TDNEWID suggested by Nick will work and is the best solution if you wish to have each document in own spool. If you wish to have spool per job, you'd have to ensure that just the first document is output with TDNEWID set. You can also ensure spool separation by outputing the last document of the job by setting TDFINAL print parameter. Or you can ensure that spools will always be assigned a unique Title...
    cheers
    Janis

Maybe you are looking for

  • Updating product revenue close date based off opportunity close date

    We do not use the product revenue close date, only the opportunity close date. We need to get the fiscal month of the opportunity close date but we have several reports the need to use the opportunity product history area and that does not contain th

  • About Org unit Dates

    Hi Experts, Plz clear my doubts. in OM. i want to change the one org unit starting date. And i assigned wrong position number for a emp... i want to change the position number.. how to do it? plz help me... How many number of SAP HR Sub Modules are a

  • Deleted Files off my external

    I just bought a new laptop which is windows 8 so I put the files I wanted to keep off my old vista desktop onto a 1.5 TB Western Digital External Hard Drive Well when i plugged the hard drive into my new laptop I opened it it took a couple seconds to

  • Posting run for future period requested (check entry)

    Hi, While taking depreciation run for company code in AFAB system is generating the error message "Posting run for future period requested (check entry)" SAP error AA697 I checked in OB52 postings periods are open for 2009(all periods) SAP note 11502

  • New specific hierarchy using table SETCLST, SETHEADER and SETNODE

    Hi expert, I want to know if they are any customizing point to configure a new specific hiearchy using standard table SETCLST, SETHEADER and SETNODE? Thanks for your help. Regards Jonathan Edited by: Jonathan on Aug 2, 2011 3:36 PM