Report to Smartform

Hi,
There is already an report to print the order by co02 transaction now  the report should be added with the functionality
1) Fetch data (basic data ->additional data from MM03)
2) the fetched value to be concatenated with the some prefix and passed to So10 and from there i have to fetch the logo and display that in a smart form
could any one help please its urgent

Hi
http://www.sap-img.com/smartforms/a-sample-program-calling-smartform.htm
Calling SMARTFORMS from your ABAP program
Check this sample program.
REPORT ZSMARTFORM.
Calling SMARTFORMS from your ABAP program.
Collecting all the table data in your program, and pass once to SMARTFORMS
SMARTFORMS
Declare your table type in :-
Global Settings -> Form Interface
Global Definintions -> Global Data
Main Window -> Table -> DATA
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
At the end of your program.
Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZSMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
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'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
GS_MKPF = INT_MKPF
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.
Hope this resolves your query.
Reward all the helpful answers.

Similar Messages

  • How to bring output of report on smartform

    Hi experts,
                      I want to display output of one std report on the smartform. Output of the Z report is using large no. of write statements. I want to create one smartform which displays output same as the output of report.
    Is it possible to directly bring output of report on smartform??
    Please give me solution
    Thanks
    Sameer
    Edited by: sameer dhuke on Mar 17, 2008 6:53 AM

    Hi,
    To The best of my knowledge it is not possible directly.
    You have to design the smartform with all the fields in the report.
    And u have create the driver program for the Smartform or u can use the report as a driver program itself.
    Then Call the smartform using FM SSF_FUNCTION_MODULE_NAME to call the smartform.
    Regards
    Sandipan

  • How to call ALV Report and SMARTFORMS through Pushbutton

    hi,
    i have created a report.My task is to create two buttons:
    1)ALV Report.
    2)SMARTFROMS.
    Through these button i have to call ALV Report and SMARTFORMS. i have created both button and when i execute the program,
    it shows me the button but not working when i click on it.
    this is the coding i have used in my report for calling ALV Report.
    ''Tables sscrfields,
    DATA flag(1) Type c.
    selection-screen: begin of screen 500 AS WINDOW TITLE tit,
    BEGIN OF LINE,
    PUSHBUTTON 2(18) but1 USER-COMMAND cli1,
    end of line,
    BEGIN OF LINE,
    PUSHBUTTON 2(18) but2 USER-COMMAND cli2,
    end of line,
    end of screen 500.
    SET PF-STATUS 'STATUS_0100'.
    at selection-screen.
    case sscrfields.
    WHEN 'cli1'.
    flag = '1'.
    WHEN 'cli2'.
    flag = '2'.
    endcase.
    at USER-COMMAND.
    CASE SY-UCOMM.
    WHEN 'Detail'.
    select vbakkunnr VBakernam VBAkaudat vbakaufnr vbapKWMENG vbapmatnr vbap~ARKTX
    into but1
    from vbak inner join vbap
    on vbakvbeln = vbapvbeln.
    ENDSELECT.
    ENDCASE.
    START-OF-SELECTION.
    tit = 'Format'.
    but1 = 'ALV Report'.
    but2 = 'SMARTFORMS'.
    CALL SELECTION-SCREEN 500.
    and i also use in my report
    ''case sscrfields-ucomm'' and ''submit my_report'' but the still button doesn't show the result.
    Thanks & Regards,

    Hi,
             I  understood your requirement. What i found is,  you are creating screen 500 and call it after START-OF-SELECTION,
    at that time your AT USER-COMMAND doesn't work.
    So what i would suggest , u should create GUI STATUS named ' PFSTAT' 
    having one functional key 'EXIT'  that is standard u can just name it
    and
    other two u can assign in Freely assigned Function keys as 'BUT1' & 'BUT2'.  and than in Application Toolbar u jst have it in ITEM LIST by typing BUT1 and BUT2.
    For 'BUT1'  text would be 'ALV'  and 'BUT2' text would be 'SMARTFORMS'.
    Now in Program you can code,,,
    START-OF-SELECTION.
    SET PF-STATUS 'PFSTAT'.
    WRITE:/ 'TEST'.
    at user-command.
      case SY-UCOMM.
        WHEN 'BUT1'.
        WHEN 'BUT2'.
        WHEN 'EXIT'.
           LEAVE PROGRAM.
      endcase.
    In Program u set PF STATUS and use at user-command event, whcih gets triggered when u click on button . When u execute program you get two button in application tooldbar.
    Please do needful.
    Thanks,
    Saurin SHah

  • Report on Smartform..To make it efficient by removing SELECT ,ENDSELECT

    To make a smartform report efficient by removing all occurs & modify internal table statements.
    What i have been given to do is to select all data from respective tables put them into one internal table & then finally making tab2 or tab3 in the report to be the final table.I am not sure which among these two i can make final table.
    THE CODE is:
    REPORT  zgr_note.
    TABLES : mseg,  "Document Segment : Material
             prps,  "WBS element master data
             proj,  "Project Definition
             mkpf,  "Header : Material Document
             lfa1,  "Vendor Master
             makt,  "Material Description
             aufk,  "Order Master Data
             afvc.  "Operation within an order
    DATA : fname LIKE rs38l-name. "Name of Function Module
    DATA: lf_fm_name            TYPE rs38l_fnam.
    DATA: ls_control_param      TYPE ssfctrlop.
    DATA: ls_composer_param     TYPE ssfcompop.
    DATA: ls_recipient          TYPE swotobjid.
    DATA: ls_sender             TYPE swotobjid.
    DATA: lf_formname           TYPE tdsfname.
    DATA: ls_addr_key           LIKE addr_key.
    DATA: ls_dlv_land           LIKE vbrk-land1.
    DATA: ls_job_info           TYPE ssfcrescl.
    DATA: ls_otpt_opt           TYPE ssfcompop.
    DATA: retcode TYPE sy-subrc.
    DATA: cntr TYPE i VALUE 0.
    DATA: cntr1 TYPE i .
    DATA: number TYPE SSFCRESCL-SPOOLIDS. " OCCURS 0 WITH HEADER LINE.
    DATA: TSP01 type TABLE OF TSP01_SP0R.
    DATA : BEGIN OF itab OCCURS 0.
            INCLUDE STRUCTURE mseg.
    DATA : post1 LIKE proj-post1,           "Project Definition
           pspnr LIKE proj-pspnr,           "WBS element
           maktx LIKE makt-maktx,           "Material Description
           name1 LIKE lfa1-name1,           "Name of the supplier
           budat LIKE mkpf-budat,           "Posting date
           bldat LIKE mkpf-bldat,           "Document date
           cpudt LIKE mkpf-cpudt,           "Date on which account document was entered
           psphi LIKE prps-psphi,           "Current number of project
           post2 LIKE prps-post1,           "WBS Definition
           xblnr LIKE mkpf-xblnr,           "Reference number( in this case challan number)
           bktxt LIKE mkpf-bktxt,           "Header text
           ort01 LIKE lfa1-ort01,           "vendor city
           ktext LIKE aufk-ktext,           "network description
           ltxa1 LIKE afvc-ltxa1.           "operation short text
    DATA : END OF itab.
    DATA : BEGIN OF jtab OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA : END OF jtab.
    DATA : itab1 LIKE itab OCCURS 0
          WITH HEADER LINE.
    DATA :itab2 LIKE itab OCCURS 0
          WITH HEADER LINE.
    DATA: itab3 LIKE itab OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
    SELECT-OPTIONS : gr_num FOR mseg-mblnr . "no INTERVALS.
    PARAMETERS : gr_note LIKE itemset-xopsel RADIOBUTTON GROUP rad1.
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS : mat_num FOR mseg-mblnr . "no INTERVALS.
    PARAMETERS : mat_slip LIKE itemset-xopsel RADIOBUTTON GROUP rad1.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN SKIP.
    CASE 'X'.
      WHEN gr_note.
        PERFORM gr_display.
      WHEN mat_slip.
        PERFORM mat_display.
    ENDCASE.
    FORM gr_display .
    *break developer1.
      SELECT mblnr mjahr matnr werks lgort lifnr menge meins
             erfmg bpmng ebeln ps_psp_pnr zeile lsmng erfme
      FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab
       WHERE mblnr IN gr_num.
      LOOP AT itab.
        SELECT pspnr psphi post1 INTO CORRESPONDING FIELDS OF itab1
          FROM prps WHERE pspnr = itab-ps_psp_pnr.
          itab-psphi = itab1-psphi.
          itab-pspnr = itab1-pspnr.
          itab-post2 = itab1-post1.
          MODIFY itab TRANSPORTING psphi pspnr post2.
        ENDSELECT.
        SELECT post1 FROM proj INTO CORRESPONDING FIELDS OF itab2
        WHERE pspnr = itab-psphi.
          itab-post1 = itab2-post1.
          MODIFY itab TRANSPORTING post1.
        ENDSELECT.
        REFRESH itab2.
        SELECT maktx FROM makt INTO CORRESPONDING FIELDS OF itab2
          WHERE matnr = itab-matnr.
          itab-maktx = itab2-maktx.
          MODIFY itab TRANSPORTING maktx.
        ENDSELECT.
        REFRESH itab2.
        SELECT name1 ort01 FROM lfa1 INTO CORRESPONDING FIELDS OF itab2
          WHERE lifnr = itab-lifnr.
          itab-name1 = itab2-name1.
          itab-ort01 = itab2-ort01.
          MODIFY itab TRANSPORTING name1 ort01.
        ENDSELECT.
        REFRESH itab2.
        SELECT budat bldat cpudt xblnr bktxt FROM mkpf
          INTO CORRESPONDING FIELDS OF itab2
          WHERE mblnr = itab-mblnr.
          itab-budat = itab2-budat.
          itab-bldat = itab2-bldat.
          itab-cpudt = itab2-cpudt.
          itab-xblnr = itab2-xblnr.
          itab-bktxt = itab2-bktxt.
          MODIFY itab TRANSPORTING budat bldat cpudt xblnr bktxt.
        ENDSELECT.
      ENDLOOP.
      LOOP AT itab .
        ON CHANGE OF itab-mblnr.
          itab3-mblnr = itab-mblnr.
          itab3-post1 = itab-post1.
          itab3-post2 = itab-post2.
          itab3-name1 = itab-name1.
          itab3-ort01 = itab-ort01.
          itab3-bldat = itab-bldat.
          APPEND itab3.
          CLEAR itab3.
        ENDON.
      ENDLOOP.
      jtab-mblnr = itab-mblnr.
      jtab-xblnr = itab-xblnr.
      jtab-budat = itab-budat.
      jtab-bktxt = itab-bktxt.
      jtab-lsmng = itab-lsmng.
      jtab-erfmg = itab-erfmg.
      jtab-erfme = itab-erfme.
      jtab-matnr = itab-matnr.
      jtab-maktx = itab-maktx.
      jtab-zeile = itab-zeile.
      APPEND jtab.
      LOOP AT itab3.
        CLEAR: itab2,itab2[].
        LOOP AT itab WHERE mblnr = itab3-mblnr.
          MOVE-CORRESPONDING itab TO itab2.
          APPEND itab2.
          CLEAR itab2.
        ENDLOOP.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname                 = 'ZMM_GOODS_RECEIPT1'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
         IMPORTING
           fm_name                  = 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.
        ENDIF.
    *break developer1.
    PERFORM print_parameters.
        CALL FUNCTION fname
          EXPORTING
           control_parameters         = ls_control_param
           output_options             = ls_otpt_opt
           user_settings              = 'X'
           gr_mseg_hdr                = itab3
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
          TABLES
            gr_mseg                    = itab2
         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.
    ENDFORM.                    " GR_DISPLAY
    FORM mat_display .
      SELECT mblnr mjahr matnr werks lgort lifnr menge meins
             erfmg bpmng ebeln ps_psp_pnr zeile lsmng erfme
             mat_pspnr nplnr aufpl aplzl
      FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab
       WHERE mblnr IN mat_num.
      LOOP AT itab.
        SELECT ltxa1 FROM afvc INTO CORRESPONDING FIELDS OF itab1
          WHERE aufpl = itab-aufpl AND aplzl = itab-aplzl.
          itab-ltxa1 = itab1-ltxa1.
          MODIFY itab TRANSPORTING ltxa1.
        ENDSELECT.
        REFRESH itab1.
        SELECT ktext FROM aufk INTO CORRESPONDING FIELDS OF itab1
          WHERE aufnr = itab-nplnr.
          itab-ktext = itab1-ktext.
          MODIFY itab TRANSPORTING ktext.
        ENDSELECT.
        REFRESH itab1.
        SELECT pspnr psphi post1 INTO CORRESPONDING FIELDS OF itab1
          FROM prps WHERE pspnr = itab-mat_pspnr.
          itab-psphi = itab1-psphi.
          itab-pspnr = itab1-pspnr.
          itab-post2 = itab1-post1.
          MODIFY itab TRANSPORTING psphi pspnr post2.
        ENDSELECT.
        SELECT post1 FROM proj INTO CORRESPONDING FIELDS OF itab2
        WHERE pspnr = itab-psphi.
          itab-post1 = itab2-post1.
          MODIFY itab TRANSPORTING post1.
        ENDSELECT.
        REFRESH itab2.
        SELECT maktx FROM makt INTO CORRESPONDING FIELDS OF itab2
          WHERE matnr = itab-matnr.
          itab-maktx = itab2-maktx.
          MODIFY itab TRANSPORTING maktx.
        ENDSELECT.
        REFRESH itab2.
        SELECT name1 ort01 FROM lfa1 INTO CORRESPONDING FIELDS OF itab2
          WHERE lifnr = itab-lifnr.
          itab-name1 = itab2-name1.
          itab-ort01 = itab2-ort01.
          MODIFY itab TRANSPORTING name1 ort01.
        ENDSELECT.
        REFRESH itab2.
        SELECT budat bldat cpudt xblnr bktxt FROM mkpf
          INTO CORRESPONDING FIELDS OF itab2
          WHERE mblnr = itab-mblnr.
          itab-budat = itab2-budat.
          itab-bldat = itab2-bldat.
          itab-cpudt = itab2-cpudt.
          itab-xblnr = itab2-xblnr.
          itab-bktxt = itab2-bktxt.
         break developer1.
          MODIFY itab TRANSPORTING budat bldat cpudt xblnr bktxt.
        ENDSELECT.
      ENDLOOP.
      LOOP AT itab.
        ON CHANGE OF itab-mblnr.
          itab3-mblnr = itab-mblnr.
          itab3-budat = itab-budat.
          itab3-bldat = itab-bldat.
          itab3-post1 = itab-post1.
          itab3-ktext = itab-ktext.
          APPEND itab3.
          CLEAR itab3.
        ENDON.
      ENDLOOP.
      LOOP AT itab3.
        CLEAR: itab2, itab2[].
        LOOP AT itab WHERE mblnr EQ itab3-mblnr.
          MOVE-CORRESPONDING itab TO itab2.
          APPEND itab2.
          CLEAR itab2.
        ENDLOOP.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname                 = 'ZMM_MAT_ISSUE_SLIP'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
         IMPORTING
           fm_name                  = 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.
        ENDIF.
        ls_control_param-no_dialog = 'X'.
    *ls_control_param-preview = 'X'.
    *ls_control_param-getotf = 'X'.
       ls_otpt_opt-tdnoprev = 'X'.
        ls_otpt_opt-tdnewid = ''.
        ls_otpt_opt-tdimmed = 'X'.
        ls_otpt_opt-tddest  = 'LP01'.
        CALL FUNCTION fname
          EXPORTING
        ARCHIVE_INDEX              =
        ARCHIVE_INDEX_TAB          =
        ARCHIVE_PARAMETERS         =
           control_parameters         = ls_control_param
        MAIL_APPL_OBJ              =
        MAIL_RECIPIENT             =
        MAIL_SENDER                =
           output_options             = ls_otpt_opt
           user_settings              = 'X'
            mat_slip_hdr               = itab3
       IMPORTING
        DOCUMENT_OUTPUT_INFO       =
         JOB_OUTPUT_INFO            = ls_job_info
        JOB_OUTPUT_OPTIONS         =
          TABLES
            mat_slip                   = itab2
      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.
    ENDFORM.

    Hello Saswat,
    There are a couple of criteria to make a SmartForm report efficient, i.e. to achieve a better performance:
    - provide the best possible interface to the temporary FM (fname). When you do so, SmartForm itself has not to perform so much programming stuff by itself.
    - The Driver program (zgr_note) has to be designed and coded well. What mean the performance of the Driver has to be optimized. In your case there should be a couple of performance improvements:
    -- adjust your program declaration to the new ABAP syntax, i.e. don't use OCCURS clauses and do not use HEADER LINE. Instead, implement TYPES and use them. Here is an example:
    TYPES: BEGIN OF ty_itab.
                 INCLUDE STRUCTURE mseg.
    TYPES: post1 LIKE proj-post1, "Project Definition
                 pspnr LIKE proj-pspnr, "WBS element
                 maktx LIKE makt-maktx, "Material Description
                 name1 LIKE lfa1-name1, "Name of the supplier
                 budat LIKE mkpf-budat, "Posting date
                 bldat LIKE mkpf-bldat, "Document date
                 cpudt LIKE mkpf-cpudt, "Date on which account document was entered
                 psphi LIKE prps-psphi, "Current number of project
                 post2 LIKE prps-post1, "WBS Definition
                 xblnr LIKE mkpf-xblnr, "Reference number( in this case challan number)
                 bktxt LIKE mkpf-bktxt, "Header text
                 ort01 LIKE lfa1-ort01, "vendor city
                 ktext LIKE aufk-ktext, "network description
                 ltxa1 LIKE afvc-ltxa1, "operation short text
                 END OF ty_itab.
    * Declare your internal tables and the corresponding working structures
    DATA: itab1 type standard table of ty_itab,
               itab2 type standard table of ty_itab,
               itab3 type standard table of ty_itab,
               jtab  type standard table of ty_itab,
              wa_itab1 type ty_itab,
              wa_itab2 type ty_itab,
              wa_itab3 type ty_itab,
              wa_jtab   type ty_itab.
    -- Don't use
    LOOP at itab.
      SELECT ...... WHERE pspnr = itab-ps_psp_pnr.
      ENDSELECT.
      SELECT * ...
      ENDSELECT
      SELECT * .....
      ENDSELECT
    ENDLOOP.
    Instead try to populate itab, itab1, itab2 each in ONE select statement using FOR ALL ENTRIES clause. After that you have to perform the LOOP runs using LOOP at itab INTO wa_itab. The more redundant SELECTs, the slower the program! When you perform a LOOP run, let say over itab1 and you need a corresponding record from table itab2 the use READ <itab> with key.
    One additional, very important hint: Using internal tables w/o header line the CLEAR statement has another functionality than with HEADER LINE
    CLEAR with HEADER LINE clears the HEADER line only
    CLEAR w/o HEADER LINE clears the entire table. CLEAR does the same as REFRESH.
    Another performance improvement is (when itab contains a lot of records) using FIELD-SYMBOLS.
    A simple example is
    FIELD-SYMBOLS: <fs> type itab.
    LOOP at itab assigning <fs>.
      wa_itab3-post1 = <fs>-post1.
      wa_itab3-post2 = <fs>-post2.
      APPEND wa_itab3 to itab.
    ENDLOOP.
    In this case no data values have to be transfered to a working field. The values are taken directly from the current line of the internal table.
    -- For better readability disign some events like START-OF-SELECTION, END-OF-SELECTION, INITIALIZATION and others.
    Try to gather all in SmartForms needed fields and pop them into table itab3.
    I hope this helps improving zgr_note's efficiency.
    Good luck,
    Heinz

  • Report on smartform.Replace select endselect with something to efficient it

    To make a smartform report efficient by removing all occurs & modify internal table statements.
    What i have been given to do is to select all data from respective tables put them into one internal table & then finally making tab2 or tab3 in the report to be the final table.I am not sure which among these two i can make final table.
    THE CODE is:
    REPORT  zgr_note.
    TABLES : mseg,  "Document Segment : Material
             prps,  "WBS element master data
             proj,  "Project Definition
             mkpf,  "Header : Material Document
             lfa1,  "Vendor Master
             makt,  "Material Description
             aufk,  "Order Master Data
             afvc.  "Operation within an order
    DATA : fname LIKE rs38l-name. "Name of Function Module
    DATA: lf_fm_name            TYPE rs38l_fnam.
    DATA: ls_control_param      TYPE ssfctrlop.
    DATA: ls_composer_param     TYPE ssfcompop.
    DATA: ls_recipient          TYPE swotobjid.
    DATA: ls_sender             TYPE swotobjid.
    DATA: lf_formname           TYPE tdsfname.
    DATA: ls_addr_key           LIKE addr_key.
    DATA: ls_dlv_land           LIKE vbrk-land1.
    DATA: ls_job_info           TYPE ssfcrescl.
    DATA: ls_otpt_opt           TYPE ssfcompop.
    DATA: retcode TYPE sy-subrc.
    DATA: cntr TYPE i VALUE 0.
    DATA: cntr1 TYPE i .
    DATA: number TYPE SSFCRESCL-SPOOLIDS. " OCCURS 0 WITH HEADER LINE.
    DATA: TSP01 type TABLE OF TSP01_SP0R.
    DATA : BEGIN OF itab OCCURS 0.
            INCLUDE STRUCTURE mseg.
    DATA : post1 LIKE proj-post1,           "Project Definition
           pspnr LIKE proj-pspnr,           "WBS element
           maktx LIKE makt-maktx,           "Material Description
           name1 LIKE lfa1-name1,           "Name of the supplier
           budat LIKE mkpf-budat,           "Posting date
           bldat LIKE mkpf-bldat,           "Document date
           cpudt LIKE mkpf-cpudt,           "Date on which account document was entered
           psphi LIKE prps-psphi,           "Current number of project
           post2 LIKE prps-post1,           "WBS Definition
           xblnr LIKE mkpf-xblnr,           "Reference number( in this case challan number)
           bktxt LIKE mkpf-bktxt,           "Header text
           ort01 LIKE lfa1-ort01,           "vendor city
           ktext LIKE aufk-ktext,           "network description
           ltxa1 LIKE afvc-ltxa1.           "operation short text
    DATA : END OF itab.
    DATA : BEGIN OF jtab OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA : END OF jtab.
    DATA : itab1 LIKE itab OCCURS 0
          WITH HEADER LINE.
    DATA :itab2 LIKE itab OCCURS 0
          WITH HEADER LINE.
    DATA: itab3 LIKE itab OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
    SELECT-OPTIONS : gr_num FOR mseg-mblnr . "no INTERVALS.
    PARAMETERS : gr_note LIKE itemset-xopsel RADIOBUTTON GROUP rad1.
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS : mat_num FOR mseg-mblnr . "no INTERVALS.
    PARAMETERS : mat_slip LIKE itemset-xopsel RADIOBUTTON GROUP rad1.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN SKIP.
    CASE 'X'.
      WHEN gr_note.
        PERFORM gr_display.
      WHEN mat_slip.
        PERFORM mat_display.
    ENDCASE.
    FORM gr_display .
    *break developer1.
      SELECT mblnr mjahr matnr werks lgort lifnr menge meins
             erfmg bpmng ebeln ps_psp_pnr zeile lsmng erfme
      FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab
       WHERE mblnr IN gr_num.
      LOOP AT itab.
        SELECT pspnr psphi post1 INTO CORRESPONDING FIELDS OF itab1
          FROM prps WHERE pspnr = itab-ps_psp_pnr.
          itab-psphi = itab1-psphi.
          itab-pspnr = itab1-pspnr.
          itab-post2 = itab1-post1.
          MODIFY itab TRANSPORTING psphi pspnr post2.
        ENDSELECT.
        SELECT post1 FROM proj INTO CORRESPONDING FIELDS OF itab2
        WHERE pspnr = itab-psphi.
          itab-post1 = itab2-post1.
          MODIFY itab TRANSPORTING post1.
        ENDSELECT.
        REFRESH itab2.
        SELECT maktx FROM makt INTO CORRESPONDING FIELDS OF itab2
          WHERE matnr = itab-matnr.
          itab-maktx = itab2-maktx.
          MODIFY itab TRANSPORTING maktx.
        ENDSELECT.
        REFRESH itab2.
        SELECT name1 ort01 FROM lfa1 INTO CORRESPONDING FIELDS OF itab2
          WHERE lifnr = itab-lifnr.
          itab-name1 = itab2-name1.
          itab-ort01 = itab2-ort01.
          MODIFY itab TRANSPORTING name1 ort01.
        ENDSELECT.
        REFRESH itab2.
        SELECT budat bldat cpudt xblnr bktxt FROM mkpf
          INTO CORRESPONDING FIELDS OF itab2
          WHERE mblnr = itab-mblnr.
          itab-budat = itab2-budat.
          itab-bldat = itab2-bldat.
          itab-cpudt = itab2-cpudt.
          itab-xblnr = itab2-xblnr.
          itab-bktxt = itab2-bktxt.
          MODIFY itab TRANSPORTING budat bldat cpudt xblnr bktxt.
        ENDSELECT.
      ENDLOOP.
      LOOP AT itab .
        ON CHANGE OF itab-mblnr.
          itab3-mblnr = itab-mblnr.
          itab3-post1 = itab-post1.
          itab3-post2 = itab-post2.
          itab3-name1 = itab-name1.
          itab3-ort01 = itab-ort01.
          itab3-bldat = itab-bldat.
          APPEND itab3.
          CLEAR itab3.
        ENDON.
      ENDLOOP.
      jtab-mblnr = itab-mblnr.
      jtab-xblnr = itab-xblnr.
      jtab-budat = itab-budat.
      jtab-bktxt = itab-bktxt.
      jtab-lsmng = itab-lsmng.
      jtab-erfmg = itab-erfmg.
      jtab-erfme = itab-erfme.
      jtab-matnr = itab-matnr.
      jtab-maktx = itab-maktx.
      jtab-zeile = itab-zeile.
      APPEND jtab.
      LOOP AT itab3.
        CLEAR: itab2,itab2[].
        LOOP AT itab WHERE mblnr = itab3-mblnr.
          MOVE-CORRESPONDING itab TO itab2.
          APPEND itab2.
          CLEAR itab2.
        ENDLOOP.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname                 = 'ZMM_GOODS_RECEIPT1'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
         IMPORTING
           fm_name                  = 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.
        ENDIF.
    *break developer1.
    PERFORM print_parameters.
        CALL FUNCTION fname
          EXPORTING
           control_parameters         = ls_control_param
           output_options             = ls_otpt_opt
           user_settings              = 'X'
           gr_mseg_hdr                = itab3
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
          TABLES
            gr_mseg                    = itab2
         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.
    ENDFORM.                    " GR_DISPLAY
    FORM mat_display .
      SELECT mblnr mjahr matnr werks lgort lifnr menge meins
             erfmg bpmng ebeln ps_psp_pnr zeile lsmng erfme
             mat_pspnr nplnr aufpl aplzl
      FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab
       WHERE mblnr IN mat_num.
      LOOP AT itab.
        SELECT ltxa1 FROM afvc INTO CORRESPONDING FIELDS OF itab1
          WHERE aufpl = itab-aufpl AND aplzl = itab-aplzl.
          itab-ltxa1 = itab1-ltxa1.
          MODIFY itab TRANSPORTING ltxa1.
        ENDSELECT.
        REFRESH itab1.
        SELECT ktext FROM aufk INTO CORRESPONDING FIELDS OF itab1
          WHERE aufnr = itab-nplnr.
          itab-ktext = itab1-ktext.
          MODIFY itab TRANSPORTING ktext.
        ENDSELECT.
        REFRESH itab1.
        SELECT pspnr psphi post1 INTO CORRESPONDING FIELDS OF itab1
          FROM prps WHERE pspnr = itab-mat_pspnr.
          itab-psphi = itab1-psphi.
          itab-pspnr = itab1-pspnr.
          itab-post2 = itab1-post1.
          MODIFY itab TRANSPORTING psphi pspnr post2.
        ENDSELECT.
        SELECT post1 FROM proj INTO CORRESPONDING FIELDS OF itab2
        WHERE pspnr = itab-psphi.
          itab-post1 = itab2-post1.
          MODIFY itab TRANSPORTING post1.
        ENDSELECT.
        REFRESH itab2.
        SELECT maktx FROM makt INTO CORRESPONDING FIELDS OF itab2
          WHERE matnr = itab-matnr.
          itab-maktx = itab2-maktx.
          MODIFY itab TRANSPORTING maktx.
        ENDSELECT.
        REFRESH itab2.
        SELECT name1 ort01 FROM lfa1 INTO CORRESPONDING FIELDS OF itab2
          WHERE lifnr = itab-lifnr.
          itab-name1 = itab2-name1.
          itab-ort01 = itab2-ort01.
          MODIFY itab TRANSPORTING name1 ort01.
        ENDSELECT.
        REFRESH itab2.
        SELECT budat bldat cpudt xblnr bktxt FROM mkpf
          INTO CORRESPONDING FIELDS OF itab2
          WHERE mblnr = itab-mblnr.
          itab-budat = itab2-budat.
          itab-bldat = itab2-bldat.
          itab-cpudt = itab2-cpudt.
          itab-xblnr = itab2-xblnr.
          itab-bktxt = itab2-bktxt.
         break developer1.
          MODIFY itab TRANSPORTING budat bldat cpudt xblnr bktxt.
        ENDSELECT.
      ENDLOOP.
      LOOP AT itab.
        ON CHANGE OF itab-mblnr.
          itab3-mblnr = itab-mblnr.
          itab3-budat = itab-budat.
          itab3-bldat = itab-bldat.
          itab3-post1 = itab-post1.
          itab3-ktext = itab-ktext.
          APPEND itab3.
          CLEAR itab3.
        ENDON.
      ENDLOOP.
      LOOP AT itab3.
        CLEAR: itab2, itab2[].
        LOOP AT itab WHERE mblnr EQ itab3-mblnr.
          MOVE-CORRESPONDING itab TO itab2.
          APPEND itab2.
          CLEAR itab2.
        ENDLOOP.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname                 = 'ZMM_MAT_ISSUE_SLIP'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
         IMPORTING
           fm_name                  = 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.
        ENDIF.
        ls_control_param-no_dialog = 'X'.
    *ls_control_param-preview = 'X'.
    *ls_control_param-getotf = 'X'.
       ls_otpt_opt-tdnoprev = 'X'.
        ls_otpt_opt-tdnewid = ''.
        ls_otpt_opt-tdimmed = 'X'.
        ls_otpt_opt-tddest  = 'LP01'.
        CALL FUNCTION fname
          EXPORTING
        ARCHIVE_INDEX              =
        ARCHIVE_INDEX_TAB          =
        ARCHIVE_PARAMETERS         =
           control_parameters         = ls_control_param
        MAIL_APPL_OBJ              =
        MAIL_RECIPIENT             =
        MAIL_SENDER                =
           output_options             = ls_otpt_opt
           user_settings              = 'X'
            mat_slip_hdr               = itab3
       IMPORTING
        DOCUMENT_OUTPUT_INFO       =
         JOB_OUTPUT_INFO            = ls_job_info
        JOB_OUTPUT_OPTIONS         =
          TABLES
            mat_slip                   = itab2
      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.
    ENDFORM.

    Hi saswat mohanty ,
    Welcome to SDN.  Ya your program takes lot of time to give the output becauase of more select endselects in  a loop.
    You are hitting as  many times as the records in the ITAB.
    Instead use "for all entries"   clause for fetching the complete data from a table atonce.
    Example: your itab is there.
    Select *  from  xyz
       into table itab2
       for all entries in itab
    where  field1 eq itab-field1
        and field2 eq itab-field2.
    After fetching the data you can populate the final table by looping through ITAB  and itab2.
    This is best procedure to reduce the load on database.
    Implement this in your program to improve performance.
    REWARD POINTS IF USEFUL.
    Venkat.

  • When press Enter i want to display the input in Report calling Smartform

    Hello Masters,
    I am new in to abap and i want to know that how can we display data on the same screen when we enter the value and press enter , for example when i enter a employee code in input field and when i press enter before executing my report i want to see the name of the employee for which i have enter in the field before execution. i am developing a Report which is calling a smartform for print.
    tables sscrfields.
    parameters: p_pernr type pa0001-pernr obligatory.
    at selection-screen.
      if sscrfields-ucomm eq space.
        sscrfields-ucomm = 'p_pernr'.
      endif.
    I thought that this code could have worked for me but its no use , can any one please help me with my issue

    here is some code what i have used in my report program , i will still like to remind that its an Logical database program (PNP) for ABAP-HR , right now i tried the code mentioned above but not getting any result.
    TABLES: pernr,sscrfields,pa0001.
    *& Declaring Type-pools
    TYPE-POOLS : slis.
    *& Declaring Infotypes
    INFOTYPES: 0000,          " Action
                         0001.          " Org. Assignment
    *& Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK n1 WITH FRAME TITLE t1.
    PARAMETER : p_despat TYPE zhr_transfer-despt OBLIGATORY,              " Despatch Number
                r_pernr  TYPE pa0001-pernr OBLIGATORY,                                    " Reporting to
                re_pernr TYPE pa0001-pernr OBLIGATORY,                                   " Relieving Authority
                a_pernr  TYPE pa0001-pernr OBLIGATORY MODIF ID one.             " Authorize Person
    SELECTION-SCREEN END OF BLOCK n1.
    INITIALIZATION.
      t1 = 'Transfer Records'.
      LOOP AT SCREEN.
        IF screen-name = 'PNPPERNR-LOW'.                                  " Personnel Number (Mandatory)
          screen-required = 1.
            MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN OUTPUT.
      IF a_pernr IS INITIAL.
        a_pernr = pa0001-ename.
      ENDIF.
    END-OF-SELECTION.

  • Report with Smartforms

    Hello guys,
    It possible to output a report with a form using smartforms at the end of the report? can i use screen painter for this? and how can i do it? thanks much.

    hi,
       yes u can use an form in an report... just call the FM for calling the form at the end of the report then it wil disply this form o/p once it dont with the report... what is  ur actual requirenment..?? tel it first then may be someone can help on it....
    regards
      ravi

  • Pass data from z report to smartforms

    Hi expert,
    i have a zreport for display internal order. in this zreport, i create a table(ATAB) contain data of internal order header from coas t003p and other table.
    now i want to pass this ATAB to smartforms. i got example smartforms and zreport with similar to mine's case but no instruction or advice from my boss. so, i try to read many previous thread about this for advise.  but still confuse with many thing.
    anyone can explain to me.
        what is function of each tab in "form interface" , "global definition" .
        what is "types" tab in global definition (in example zreport i receive also has declare type to what is relation of this ).
        what i must create and declare in form interface , global definition.  
        what is difference and meaning of "type" , "type table of" , "like" in Type assignment
    Regards.
    Kittisak.

    Hi,
    In global defination 'types' tab is used to define all structures that u want to use in your smartform.
    in 'initialization declare' all internal tables , work area , select queries and constants which u are using.
    in 'global data define' the data which u want to use throughout the smartform.
    if u are using ny field symbol then declare it in 'field symbols' tab.
    in 'form routine' all forms are used that  u declared in initialization.
    all currency and quantity related field names come into tab 'currency/quant. fields'.
    form interface is basically used when u are using a driver program associated to ur smartform.
    for seeing difference b/w type, type table of and like use F1 help.
    hope this will help.
    regards
    saurabh

  • How to show error message in a report program

    Hello Guys,
    I am making a report using smartforms. I am successful in showing data  but problem is if if i put a value in parameters that does not exist is database, the smartform runs and related fields shows as empty fields. But the form is running. I want to show error message if the parameter values dose not matches with the database values. The message will show as Document not exists
    So i used related error msg here like
    if sy-subrc ne 0.
              message e357.
               endif.
    But it is not working for passing values to smartform. It works if i use in classical report. Plz help me on this issue.
    Thanks,
    Rosaline.

    >
    Rosaline. wrote:
    > Thanks all for reply.  Should i have to use message before call function 'SSF_FUNCTION_MODULE_NAME' ? I tried it but not working.
    >
    >
    if it_final[] is not initial.
    >*             if sy-subrc ne 0. ---> "Remove this condition check, it not required
    >            Message e000(8i) with 'Parameter value not found'.
    >            endif.
    > *            endif. ---> "remove this
    >
    Hi,
    Sy-subrc doesnt need to be validated here, remove that If condition and check again.
    Regards,
    Karthik D

  • Report Names used for Purchase Order smarforms

    Hi all,
    I want to display a smarform when user clicks on ME23N transaction on Print Preview. Now it displays a SAP Script MEDRUCK having the program SAPFM06P. I know a smartform /SMB11/MMPO_A or /SMB40/MMPO_A which are there in the system but no idea which is the standard SAP provided program i.e. report these smartforms are called. So that i can attach to the output type to print these forms. If there is any Standard SAP program aviablble please let me know.
    I am aware of the NACE tranx to attach the program name and form routine and smartforms. I am looking for a standard SAP provided report.
    Thanks in advance.
    Message was edited by: Pankaj S Dwivedi

    goto NACE transaction
    select EF application
    then select "OUTPUT TYPES" from the application tool bar.
    then select your output type(NEU, std one),which you want to modify the existing one with your new one.
    select the output type &  click on PROCESSSING ROUTINES from the left hand side tree. now you will be able to see all the related scripts/smartforms/driver prg names
    when i observe in ECC5.0, there is a smartform '/SMB40/MMPO_DE' and driver program will be the same 'SAPMF06P'.
    regards
    srikanth
    Added driver prg name
    Message was edited by: Srikanth Kidambi

  • Converting smartforms output into PDF

    Hi ALL,
      How to convert the smartforms output into PDF based form. After executing the form, it should directly  open in PDF. How to do this?
    Points will be awarded.
    Thanks and regards,
    vinoth.

    Hi Vinoth Kumar,
    Please go throuh the below procedure and sample Code, this might help you.
    Procedure
    When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar
    “Environment => Function Module_Name” . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM generated is “ /1BCDWB/SF00000152 ”. In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be ‘X’. Setting this field will activate the OTF field in smartform.
    In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of fields as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two fields TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format data and TDPRINTPAR contains command parameters of OTF format data.
    In every Smartform output in OTF format, TDPRINTCOM begins and ends with ‘//’. ‘EP’ represents the end-of-page value for TDPRINTCOM field.
    In addition we need to set few fields at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters, output_options, user_settings and job_putput_info fields as shown in program.
    Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call method “cl_gui_fronted_services=>file_save_dialog” to specify the directory path where we want to save the output PDF file. After this we can call Function Module GUI_DOWNLOAD to download the PDF file on our local system.
    Here is a sample code of program to perform the function.
    SAMPLE CODE
    *& Report  ZAMIT_SMART_FORM_PDF                                        *
    REPORT  ZAMIT_SMART_FORM_PDF                    .
    data: carr_id type sbook-carrid,
          cparam type ssfctrlop,
          outop type ssfcompop,
          fm_name type rs38l_fnam.
    DATA: tab_otf_data TYPE ssfcrescl,
          pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
          tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
          file_size TYPE i,
          bin_filesize TYPE i,
          FILE_NAME type string,
          File_path type string,
          FULL_PATH type string.
    parameter:      p_custid type scustom-id default 1.
    select-options: s_carrid for carr_id     default 'LH' to 'LH'.
    parameter:      p_form   type tdsfname   default 'ZAMIT_SMART_FORM'.
    data: customer    type scustom,
          bookings    type ty_bookings,
          connections type ty_connections.
    start-of-selection.
    suppressing the dialog box for print preview****************************
    outop-tddest = 'LP01'.
    cparam-no_dialog = 'X'.
    cparam-preview = SPACE.
    cparam-getotf = 'X'.
      select single * from scustom into customer where id = p_custid.
      check sy-subrc = 0.
      select * from sbook   into table bookings
               where customid = p_custid
               and   carrid in s_carrid
               order by primary key.
      select * from spfli into table connections
               for all entries in bookings
               where carrid = bookings-carrid
               and   connid = bookings-connid
               order by primary key.
      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.
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards
    calling the generated function module
      call function fm_name
           exporting
                    archive_index        =
                    archive_parameters   =
                     control_parameters   = cparam
                    mail_appl_obj        =
                    mail_recipient       =
                    mail_sender          =
                     output_options       =  outop
                     user_settings        = SPACE
                     bookings             = bookings
                      customer             = customer
                      connections          = connections
          importing
                    document_output_info =
                     job_output_info      = tab_otf_data
                    job_output_options   =
           exceptions formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      others               = 5.
      if sy-subrc <> 0.
      error handling
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      tab_otf_final[] = tab_otf_data-otfdata[].
      CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       format                      = 'PDF'
       max_linewidth               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
    IMPORTING
       bin_filesize                = bin_filesize
      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
    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 METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
       WINDOW_TITLE         =
       DEFAULT_EXTENSION    =
       DEFAULT_FILE_NAME    =
       FILE_FILTER          =
       INITIAL_DIRECTORY    =
       WITH_ENCODING        =
       PROMPT_ON_OVERWRITE  = 'X'
      CHANGING
        filename             = FILE_NAME
        path                 = FILE_PATH
        fullpath             = FULL_PATH
       USER_ACTION          =
       FILE_ENCODING        =
    EXCEPTIONS
       CNTL_ERROR           = 1
       ERROR_NO_GUI         = 2
       NOT_SUPPORTED_BY_GUI = 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.
    ************downloading the converted PDF data to your local PC*******
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       bin_filesize                    = bin_filesize
       filename                        = FULL_PATH
       filetype                        = 'BIN'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
    IMPORTING
       filelength                      = file_size
      TABLES
        data_tab                        = pdf_tab
      FIELDNAMES                      =
    EXCEPTIONS
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       OTHERS                          = 22
    IF sy-subrc <> 0.
    ENDIF.

  • Using Smartform after preview print with a selection screen

    Hi experts,
         I am facing with some smartform printing problem.
        Here is the problem:
        We develop an add_on program for printing some FI report and we use F:Front end Printing in SPAD Access Method.
        The problem that we faced is: After enter the TCODE, we select preview into the smartform window.( Display is all right) At this window, when we click Print Icon, the output request directly sent to the printer and the page printed out without giving a selection window for selecting Printers and printing page range (Like standard print configuration).
        What we want is that after displaying the FI report in smartform, we could select the print page range and printers in user's PC.
        Appreciate for your valuable advice.
    BR,
    Derek Yang

    Hi,
    You have to set PREVIEW = 'X', before you see print preview.
    Try this way
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'ZTEST_SMARTFORM'
        IMPORTING
          fm_name  = fm_name.
      DATA:ssfctrlop TYPE ssfctrlop.
      ssfctrlop-preview = 'X'. "Needs to be set this. It shows dialog window to set print parameters
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = ssfctrlop
        TABLES
          it_nfal            = it_nfal.
    Thanks
    Venkat.O

  • Smartforms in SAP Query

    Is there any way to add smartforms to sap Query????
    It's a real problem in SAP ERP. We can generate internal reports in sap query, and generate outgoing reports in smartforms. But I really don't understand why they aren't connected!!!!!

    u can do one thing...
    use submit and call the query and get the data in a internal table....
    and u pass that value to the smart forms.........
    this is possible.........
    Reward IF....
    Regards
    Anbu

  • HOW TO SEND THE REPORTS AND  THROUGH XI TO NON -SAP SYSTEM

    Hi Experts,
                 I want to know how to send the reports and  smartform through xi to another system. All the post blogs are   just explaning only about the FILE-TO-FILE, FILE-TO-IDOCS scenarios only.

    Hi,
    XI is the middleware that to be used to transfer the data between various systems and even you could design the Business Processes with it.
    In R/3 the smartforms, are generally converted to PDF and then  have to send it across to Non SAP systems. Similarly you can convert the smartforms to pdf format and keep it on application server. XI will pick up that pdf and will send it to Non SAP system either as mail or as an attachments.
    ABAP reports are normally used to re-present the data. If you need to transfer this data across the Non SAP systems then you have the IDOCs to be generated, RFC or ABAP Proxy to integrate this data with Non SAP system.
    XI is not restricted only upto file to file or file to IDOC scenarios. It have enormous capabilities to involve various Business Processes as well integrate various SAP or Non SAP systems.
    If need anymore  specific details, please let us know.
    Thanks
    Swarup

  • Smartform to PDF

    Hi,
    I am new to Smartform.
    Please help to download the smartform in PDF format.
    Thanks and Regards,
    Vishal

    Hi Vishal,
    please go throuh the below procedure and sample Code, this might help you.
    Procedure
    When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar
    “Environment => Function Module_Name” . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM generated is “ /1BCDWB/SF00000152 ”. In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be ‘X’. Setting this field will activate the OTF field in smartform.
    In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of fields as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two fields TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format data and TDPRINTPAR contains command parameters of OTF format data.
    In every Smartform output in OTF format, TDPRINTCOM begins and ends with ‘//’. ‘EP’ represents the end-of-page value for TDPRINTCOM field.
    In addition we need to set few fields at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters, output_options, user_settings and job_putput_info fields as shown in program.
    Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call method “cl_gui_fronted_services=>file_save_dialog” to specify the directory path where we want to save the output PDF file. After this we can call Function Module GUI_DOWNLOAD to download the PDF file on our local system.
    Here is a sample code of program to perform the function.
    SAMPLE CODE
    *& Report  ZAMIT_SMART_FORM_PDF                                        *
    REPORT  ZAMIT_SMART_FORM_PDF                    .
    data: carr_id type sbook-carrid,
          cparam type ssfctrlop,
          outop type ssfcompop,
          fm_name type rs38l_fnam.
    DATA: tab_otf_data TYPE ssfcrescl,
          pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
          tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
          file_size TYPE i,
          bin_filesize TYPE i,
          FILE_NAME type string,
          File_path type string,
          FULL_PATH type string.
    parameter:      p_custid type scustom-id default 1.
    select-options: s_carrid for carr_id     default 'LH' to 'LH'.
    parameter:      p_form   type tdsfname   default 'ZAMIT_SMART_FORM'.
    data: customer    type scustom,
          bookings    type ty_bookings,
          connections type ty_connections.
    start-of-selection.
    ***************** suppressing the dialog box for print preview****************************
    outop-tddest = 'LP01'.
    cparam-no_dialog = 'X'.
    cparam-preview = SPACE.
    cparam-getotf = 'X'.
      select single * from scustom into customer where id = p_custid.
      check sy-subrc = 0.
      select * from sbook   into table bookings
               where customid = p_custid
               and   carrid in s_carrid
               order by primary key.
      select * from spfli into table connections
               for all entries in bookings
               where carrid = bookings-carrid
               and   connid = bookings-connid
               order by primary key.
      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.
    * calling the generated function module
      call function fm_name
           exporting
    *                 archive_index        =
    *                 archive_parameters   =
                     control_parameters   = cparam
    *                 mail_appl_obj        =
    *                 mail_recipient       =
    *                 mail_sender          =
                     output_options       =  outop
                     user_settings        = SPACE
                     bookings             = bookings
                      customer             = customer
                      connections          = connections
          importing
    *                 document_output_info =
                     job_output_info      = tab_otf_data
    *                 job_output_options   =
           exceptions formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      others               = 5.
      if sy-subrc <> 0.
    *   error handling
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      tab_otf_final[] = tab_otf_data-otfdata[].
      CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       format                      = 'PDF'
       max_linewidth               = 132
    *   ARCHIVE_INDEX               = ' '
    *   COPYNUMBER                  = 0
    *   ASCII_BIDI_VIS2LOG          = ' '
    IMPORTING
       bin_filesize                = bin_filesize
    *   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
    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 METHOD cl_gui_frontend_services=>file_save_dialog
    *  EXPORTING
    *    WINDOW_TITLE         =
    *    DEFAULT_EXTENSION    =
    *    DEFAULT_FILE_NAME    =
    *    FILE_FILTER          =
    *    INITIAL_DIRECTORY    =
    *    WITH_ENCODING        =
    *    PROMPT_ON_OVERWRITE  = 'X'
      CHANGING
        filename             = FILE_NAME
        path                 = FILE_PATH
        fullpath             = FULL_PATH
    *    USER_ACTION          =
    *    FILE_ENCODING        =
    *  EXCEPTIONS
    *    CNTL_ERROR           = 1
    *    ERROR_NO_GUI         = 2
    *    NOT_SUPPORTED_BY_GUI = 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.
    *************downloading the converted PDF data to your local PC********
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       bin_filesize                    = bin_filesize
       filename                        = FULL_PATH
       filetype                        = 'BIN'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    IMPORTING
       filelength                      = file_size
      TABLES
        data_tab                        = pdf_tab
    *   FIELDNAMES                      =
    EXCEPTIONS
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       OTHERS                          = 22
    IF sy-subrc <> 0.
    ENDIF.
    Thanks and Regards,
    Pavankumar

Maybe you are looking for

  • Hp laserjet pro 400 color MFP model m475dw repair manual

    While trying to copy some documents, display shows the following errors: 1.-  Service error 49.  I'd review on a downloaded owner manual what to do and no more messages. After I restarted the printer shows the following error. 2.- Service error 79. I

  • Compiling Packages from Source

    I am having some issues using the "make" command when compiling any kind of source code. When doing so, I get the sort of error that one would would expect when trying to build without headers. However, this is not the case. I do have the kernel head

  • Query descritpion in PDF

    Hi I am new to WAD. I copied the existing version of standard 0ANALYSIS_PATTER TO ZANALYSIS_PATTERN and made this as a standard template. Now i copied ZANALYSIS_PATTERN to TESTTEMPLATE and assigned my dataprovider and executed the template. Now I can

  • Is it possible to show a webpart only in a specific subfolder page?

    Hello everyone i have a question and really hope someone can help me out.. I have a library called "Country" with two subfolders "Sweden" & Belgium I want to add a calender to "Sweden" but when i add the webpart I see the Calender not only in Sweden

  • Cost center plan

    Hi all, Is it possiable to control the plan figures for cost center/profit center. Please let me know, i to achieve it. Thanks a tone in advance. Chandu