Conversion of QC21 sap script to pdf

Hello Experts
I was working on QC21 sap script layout,got guidance from u guys & i managed to finish.
now can anyone tell me how to convert the sap script to pdf format?
Kash

Hi,
if u wish to automate the process, then u can write the following code...
DATA: V_PRINT_PARMS LIKE PRI_PARAMS.
DATA: V_PDFSPOOLID TYPE TSP01-RQIDENT,
          V_RQIDENT TYPE TSP01-RQIDENT.
DATA: V_RQ2NAME TYPE STRING.
DATA: T_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: T_RSPAR TYPE STANDARD TABLE OF RSPARAMS.
To Setup The Print Parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
  EXPORTING
    AUTHORITY   = SPACE
    COPIES    = '1'
    COVER_PAGE    = SPACE
    DATA_SET     = SPACE
    DEPARTMENT      = SPACE
    DESTINATION    = SPACE
    EXPIRATION     = '1'
    IMMEDIATELY     = SPACE
    LAYOUT     = SPACE
    MODE       = SPACE
    NEW_LIST_ID    = 'X'
    NO_DIALOG      = 'X'
    USER     = SY-UNAME
  IMPORTING
    OUT_PARAMETERS     = V_PRINT_PARMS.
IF SY-SUBRC EQ 0.
Submit Program & Store Spool ID Into Memory
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
      CURR_REPORT     = 'RQCAAP01'
    TABLES
      SELECTION_TABLE = T_RSPAR.
ENDIF.
SUBMIT RQCAAP01 VIA SELECTION-SCREEN TO SAP-SPOOL WITHOUT SPOOL DYNPRO
           SPOOL PARAMETERS V_PRINT_PARMS
           WITH SELECTION-TABLE T_RSPAR
           AND RETURN.
Retrieving Spool ID From TSP01 Table
CONCATENATE V_RQ2NAME SY-UNAME INTO V_RQ2NAME.
SELECT * FROM TSP01
WHERE RQ2NAME EQ V_RQ2NAME ORDER BY RQCRETIME DESCENDING.
  V_RQIDENT = TSP01-RQIDENT.
  EXIT.
ENDSELECT.
IF SY-SUBRC NE 0.
  CLEAR V_RQIDENT.
ENDIF.
To Convert Spool ID To PDF Format
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
  EXPORTING
    SRC_SPOOLID              = V_RQIDENT
  TABLES
    PDF                      = T_PDF.
IF SY-SUBRC EQ 0.
To Download The File In PDF Format
to get file name and location for saving
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
    EXPORTING
      WINDOW_TITLE         = 'Select The Path Where The PDF Should Be Saved'
      DEFAULT_FILE_NAME    = 'Certificate Of Analysis.PDF'
    CHANGING
      FILENAME             = v_filename
      PATH                 = v_filepath
      FULLPATH             = v_fullpath.
To download the PDF file
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                = v_fullpath
      FILETYPE                = 'BIN'
    TABLES
      DATA_TAB                = T_PDF.
ENDIF.
I hope this resolves ur issue...
Regards,
Radhika

Similar Messages

  • Convert sap script to pdf and send mail before close_form

    hi experts,
    I am converting a sap script to PDF and then sending that pdf to vendor mail ids.
    I am getting the Data for the conversion of pdf From close_form.But it contains the data for all the vendors . But i have to Send the mail to the specific vendors.For ex if my script output has 5 sheets each with different vendors . I have to send  1 sheet as a pdf mail for that particular vendor. so,1 sheet each for 5 differrent vendors . But the data i get from close_form is the data for all the 5 vendors. How to split the data ?. can any one help me on this issue.
    with thanks in advance,
    syed

    Hi,
        Change your driver program so that it calls the script n no of times .. and every time send mail to particular vendor ..
        Loop at vendors.
         call the form ...
         send mail ...
        endloop ...
    Regards,
    Srini.

  • How to save the output of sap script to pdf document in sap

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    Hi deepika,
    This thread will solve ur problem OTF  -> PDF
    Regards,
    Pravin

  • SAP Script to PDF and then Archeiving

    Hi
    Kindly let me know how to convert SAP Script to PDF. And once it is done, archeiving of data is to be done.
    Regards
    Ramesh Sundaram

    Hi,
    Use the code below
    Before OPEN_FORM
    Data: gi_otf TYPE STANDARD TABLE OF itcoo,
             gi_line TYPE TABLE OF tline,
             bin_file TYPE i.
             itcpo-tdgetotf = 'X'.
    After CLOSE_FORM
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
      IMPORTING
        bin_filesize          = bin_file  
      TABLES
        otf                   = gi_otf
        lines                 = gi_line
      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.
    Regards,
    Manish

  • How to convert sap script to pdf and send it as email attachment

    hi,
    my requirement is to convert a standard sales order form to pdf and send it as email attachment. get me some sample code for the same
    thanks in advance

    Hi
    See this sample code and after that use the fun module to send the mail
    SO_NEW_DOCUMENT_ATT_SEND_API1
    REPORT zzz_jaytest .
    Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    START-OF-SELECTION.
    Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    LOOP AT i_pa0001 INTO w_pa0001.
    Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    codepage = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    v_size = v_len_in.
    Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.
    If you r using this function module check it once....
    call function 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    IMPORTING
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    Fehlerhandling
    if sy-subrc <> 0.
    endif.
    or u can use the standard program RSTXPDFT4 to download the script into PDF format onto a particular location
    follow this link for sample program.
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci1121833,00.html
    check...
    How to send smart form via email
    /people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp
    Regards
    Anji

  • Quantity field conversion problem in SAP script

    Hi experts,
    I have problem with sap script quantity field conversion.
    In purchase order the actual value of field( MDPM-ERFMG) is 3,500.
    But in Print preview it is showing only 3.5
    Any one Please help me in this problem
    thanks in advance
    murali

    Hello,
    check this:
    Number of Decimal Places
    A program symbol of one of the data types DEC, QUAN, and FLTP can contain decimal place data. Use the option below to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.
    Syntax
    &symbol(.N)&
    The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.
    &EKPO-MENGE& -> 1,234.560
    &EKPO-MENGE(.1) -> 1,234.6
    &EKPO-MENGE&(.4) -> 1,234.5600
    &EKPO-MENGE&(.0) -> 1,235
    REgards,
    Vasanth

  • Send SAP Script output (PDF) through Mail

    Dear Friends,
    Looking for sample program to send <b>SAP Script</b> output in PDF format to external mails while printing.
    Regards,
    Praveen Lobo

    Hi,
    better option is to convert your spool request to PDF and send it
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid = mi_rqident
    no_dialog = c_no
    dst_device = c_device
    importing
    pdf_bytecount = gd_bytecount
    tables
    pdf = it_pdf_output
    exceptions
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    err_btcjob_open_failed = 9
    err_btcjob_submit_failed = 10
    err_btcjob_close_failed = 11
    others = 12.
    check sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
    loop at it_pdf_output.
    translate it_pdf_output using ' ~'.
    concatenate gd_buffer it_pdf_output into gd_buffer.
    endloop.
    translate gd_buffer using '~ '.
    do.
    it_mess_att = gd_buffer.
    append it_mess_att.
    shift gd_buffer left by 255 places.
    if gd_buffer is initial.
    exit.
    endif.
    enddo.
    then call FM after populating attachment data
    call function 'SO_DOCUMENT_SEND_API1'
    exporting
    document_data = w_doc_data
    put_in_outbox = 'X'
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = 'X'
    importing
    sent_to_all = w_sent_all
    tables
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    exceptions
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3

  • Write Special Characters in PDF file from SAP Script

    Hi there,
    Need a quick help...
    We are converting SAP Script to PDF using the function module CONVERT_OTF
    and saving the file on presentation server using GUI_DOWNLOAD...
    But in certain cases where the item text is maintained with some special
    characters like @#$% u03B1 u03B2 u03B3 u03B4 ®... then, some of these characters are seen
    as junk/garbage characters...
    how do we handle this??
    P.S. Our Forms are already using Korean Font...
    Any help is highly appreciated
    Kind Regards,
    Tanuja

    Hi,
    Use the FM  CONVERT_OTF to get the Binary data and  down load it as PDF .
    sample
    */ Convert the OTF data into PDF.
        call function 'CONVERT_OTF'
         exporting
           format                      = 'PDF'
         importing
           bin_filesize                = lv_bin_filesize
            bin_file                   = lv_xstring
          tables
            otf                        = lt_otf_data-otfdata[]
            lines                      = lt_pdf_data
         exceptions
           err_max_linewidth           = 1
           err_format                  = 2
           err_conv_not_possible       = 3
           err_bad_otf                 = 4
           others                      = 5  .
    */ Convert the Xstring data into PDF
        call method cl_document_bcs=>xstring_to_solix
          exporting
            ip_xstring = lv_xstring
          receiving
            rt_solix   = lt_mess_att .
    Then down load the table lt_mess_att  with extension PDF.
    Edited by: UmaMaheswaraRao Surapaneni on Apr 1, 2009 5:44 PM

  • How to save sap script output in  pdf document

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    PDF Creation + connection to DMS
    cheers
    Aveek

  • Sap script convert to pdf and then send to email

    Hi,
    good day sap guys
    ive dev the sap scipt for customer statemnet one which is used the t.code is f.27.
    i need to convert the sap script to pdf and then send to email.
    plz let me know..
    how to do it.
    regards
    chandu

    Hi,
       I script program use the following (go to the "call function 'CLOSE_FORM'")
    data: binfilesize type i.
      data: pdftab type table of tline with header line.
      data: i_itcpp like itcpp.
      data: g_t_otfdata type standard table of itcoo with header line.
      call function 'CLOSE_FORM'
       IMPORTING
         RESULT  = i_itcpp
          tables
            otfdata = g_t_otfdata[]
          exceptions
            others  = 1.
      if sy-subrc ne 0.
        retcode = sy-subrc.
        perform protocol_update.
      endif.
      call function 'CONVERT_OTF'
    exporting
    format = 'PDF'
    importing
    bin_filesize = binfilesize
    BIN_FILE =
    tables
    otf = g_t_otfdata[]
    lines = pdftab[].
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    concatenate file_path  '.pdf' into filename.
    call function 'GUI_DOWNLOAD'
      exporting
      bin_filesize = binfilesize
      filename = filename
      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'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
      tables
      data_tab = pdftab[]
    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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.

  • Sap-script pdf  transfer

    hi experts,
    how to convert sap-script to PDF format?
    and where we get option to print script directly.
    thanks in advance.

    HI,
    SAP have created a standard program <b>RSTXPDFT4</b> to convert your Sapscripts spools into a PDF format.
    Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
    It look exactly like what you see during a spool display.
    If you want a Program, look at the below link
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci1121833,00.html
    To print the Script directly, you can give this option in the NACE transaction, there we can give Print Immedialt option ..
    Regards
    Sudheer

  • How to save the output of sap script in sap so that can be retrieved later

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:01 AM

    Hi Deepika,
    Look into this link https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/401cca81-b861-2910-ada2-f416dfb3b3fe
    Regards,
    Pravin

  • Smart forms vs SAP scripts

    Hi,
    can we use samrt forms instead of SAP scripts in production order forms.
    If yes please tell me how.
    I know OPK8 transactiona and over there we can use either SAP scripts or pdf forms.

    Hi,
    Satandard SAP doesn't allow you to use Smartforms for Production Order Printouts. You can however use the Printprogram and get it to trigger a smartform instead of a SAP script. Work with your technical team for more details on that.
    Arvind Rishi

  • Issue with the font and alignment in SAP Script PDF

    Hi Experts,
    I have a problem with the font in SAP Script PDF conversion.
    The output of the form is working fine but in the PDF the output is wrong.
    There is a dutch letter ' ï ' which is pinted in the form output correctly but in the PDF output the character
    has been changed to '#'.
    and also the alignment of some text has beed changed without line spacing in between.
    Please let me know what could be the problem and how to solve this issue.
    Thanks in advance,
    Regards,
    Sankara Chakradhar.

    Hi Prabhudas,
    I am using the FM 'CONVERT_OTF' to convert the data to pdf.
    The FM CLOSE_FORM is creating the IT_OTF internal table and the CONVERT_PDF uses that internal table to populate the         IT_PDF internal table and then using the FM 'SO_OBJECT_SEND' to send the PDF file to mail.
      CALL FUNCTION 'CONVERT_OTF'             
           EXPORTING                          
                format       = 'PDF'          
           IMPORTING                          
                bin_filesize = g_filesize     
           TABLES                             
                otf          = it_otf         
                lines        = it_pdf.        
    Regards,
    Sankara Chakradhar.

  • PO to PDF Local fileUsing Sap Script

    Hi Exports
    I am trying new report po(sapscript) to pdf conversion in local system any sample code available
    Thanks and regards
    Suresh

    Hi
    Thanks for your Reply
    In the following code how will change
    *& SUBROUTINE-POOL ZPORDER                                             *
    INCLUDE fm06ptop.
    TABLES: t001,adrc,kna1,lfa1,vbak,t005t,stxl,resb,makt,t685t,A053,T685.
    DATA: t_xekkn LIKE ekkn OCCURS 0 WITH HEADER LINE,
          t_xeket LIKE eket OCCURS 0 WITH HEADER LINE,
          t_xekpo LIKE ekpo OCCURS 0 WITH HEADER LINE,
          t_xkomv LIKE komv OCCURS 0 WITH HEADER LINE,
          ctxt LIKE tline OCCURS 0 WITH HEADER LINE,
          count TYPE i VALUE 0,
          t_netwr TYPE ekkn-netwr,
          werks like ekpo-werks,
          t_totqty TYPE ekkn-menge,
          qtytot type p decimals 3,
          amttot type p decimals 2,
          nettotal type p decimals 2,
          t_itemdate(8) TYPE c,
          w_ex(1),
          t_itemdate1(8) TYPE c,
          spstyp like ekpo-pstyp,
          sknttp like ekpo-knttp,
          KSCHL  LIKE A053-KSCHL,
          price  like ekko-ebeln,
          PO LIKE ekko-ebeln,
          ICT TYPE N.
    DATA tdname LIKE stxl-tdname.
    data: ORDNO like vbkd-bstkd.
    DATA :BEGIN OF v_term OCCURS 0,
           content(20),
          END OF v_term.
    DATA :printtype(10) TYPE c.
       MOVE-CORRESPONDING t_xekpo TO icond.
       APPEND icond.
    FORM entry_neu USING ent_retco ent_screen.
      DATA: l_druvo LIKE t166k-druvo,
            l_nast  LIKE nast,
            l_from_memory,
            l_doc   TYPE meein_purchase_doc_print.
      CLEAR ent_retco.
      printtype = nast-kschl.
      IF nast-aende EQ space.
        l_druvo = '1'.
      ELSE.
        l_druvo = '2'.
      ENDIF.
      CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
        EXPORTING
          ix_nast        = nast
          ix_screen      = ent_screen
        IMPORTING
          ex_retco       = ent_retco
          ex_nast        = l_nast
          doc            = l_doc
        CHANGING
          cx_druvo       = l_druvo
          cx_from_memory = l_from_memory.
    PERFORM val_chk USING l_doc.
    select sum( netwr ) into amttot from ekpo
      where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
    endselect.
    SELECT  single rlwrt INTO l_doc-xekko-rlwrt from ekko where EBELN  eq nast-OBJKY.
    price = amttot.
      IF l_doc-xekko-frgke EQ 'R' OR PRICE EQ 0.
        PERFORM display_sscript USING l_doc.
      ELSE.
    if sy-ucomm EQ 'PRNT'  .
        MESSAGE ID '8E' TYPE 'E' NUMBER '000'
                   WITH 'P.O has not been released'.
      ENDIF.
    endif.
    ENDFORM.                    "entry_neu
    &      Form  DISPLAY_SSCRIPT                                         &
    &      Display SAP Script                                            &
    FORM display_sscript USING l_doc.
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          device   = 'PRINTER'
          dialog   = 'X'
          form     = 'ZPORDER_FORM'
          language = sy-langu
        EXCEPTIONS
          canceled = 1
          device   = 2
          form     = 3
          options  = 4
          unclosed = 5
          OTHERS   = 11.
      PERFORM header_disp USING l_doc.
      PERFORM main_disp USING l_doc.
      CALL FUNCTION 'CLOSE_FORM'
        EXCEPTIONS
          unopened = 1
          OTHERS   = 5.
    ENDFORM.                    " DISPLAY_SSCRIPT
    &      Form  HEADER_DISP                                             &
    &      CHECKING Header Part                                           &
    FORM val_chk USING l_doc TYPE meein_purchase_doc_print .
           PO = l_doc-xekko-ebeln.
    ENDFORM.
    &      Form  HEADER_DISP                                             &
    &      Display Header Part                                           &
    FORM header_disp USING l_doc TYPE meein_purchase_doc_print .
      DATA : cst(30),
             tngst(30).
    CLEAR : ICT.
    *ADDRESS
      SELECT SINGLE adrnr INTO (t001-adrnr) FROM t001
                          WHERE bukrs EQ l_doc-xekko-bukrs.
    *<--Modified by Bala Manikandan--
    >
      SELECT SINGLE name1 street city1 post_code1 country
                    tel_number fax_number str_suppl1 str_suppl2
                    INTO (adrc-name1,adrc-street,adrc-city1,
                    adrc-post_code1,adrc-country,adrc-tel_number,
                    adrc-fax_number,adrc-str_suppl1,adrc-str_suppl2)
                    FROM adrc WHERE addrnumber EQ t001-adrnr.
    *VENDOR
      SELECT SINGLE anred name1 stras ort01 ort02 pstlz land1
      INTO (lfa1-anred,lfa1-name1,lfa1-stras,lfa1-ort01,lfa1-ort02,
            lfa1-pstlz,lfa1-land1)
            FROM lfa1 WHERE lifnr EQ l_doc-xekko-lifnr.
      SELECT SINGLE landx FROM t005t INTO t005t-landx
                                     WHERE land1 EQ lfa1-land1 AND
                                           spras EQ 'EN'.
      PERFORM set_text_symbol USING:
                      '&ADRC-NAME1&'         adrc-name1,
                      '&ADRC-STR_SUPPL1&'    adrc-str_suppl1,
                      '&ADRC-STR_SUPPL2&'    adrc-str_suppl2,
                      '&ADRC-STREET&'        adrc-street,
                      '&ADRC-CITY&'          adrc-city1,
                      '&ADRC-POST_CODE1&'    adrc-post_code1,
                      '&ADRC-COUNTRY&'       adrc-country,
                      '&ADRC-TEL_NUMBER&'    adrc-tel_number,
                      '&ADRC-FAX_NUMBER&'    adrc-fax_number,
                      '&LFA1-NAME1&'         lfa1-name1,
                      '&LFA1-ANRED&'         lfa1-anred,
                      '&LFA1-STRAS&'         lfa1-stras,
                      '&LFA1-ORT01&'         lfa1-ort01,
                      '&LFA1-ORT02&'         lfa1-ort02,
                      '&LFA1-PSTLZ&'         lfa1-pstlz,
                      '&t005t-landx&'        t005t-landx,
                      '&LFA1-NAME1&'         lfa1-name1,
                      '&L_DOC-XEKKO-EBELN&'  l_doc-xekko-ebeln,
                      '&L_DOC-XEKKO-AEDAT&'  l_doc-xekko-aedat,
                      '&L_DOC-XEKKO-BEDAT&'  l_doc-xekko-bedat.
    select single werks into werks from ekpo
      where ebeln eq l_doc-xekko-ebeln.
    perform set_text_symbol using:
          '&werks&'  werks.
      IF l_doc-xekko-bukrs EQ 'JKCH'.
        cst   = '611805'.
        tngst = '2500907'.
      ENDIF.
      PERFORM set_text_symbol USING:
                      '&CST&' cst,
                      '&TNGST&' tngst.
    CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'PDF'
          function  = 'SET'
          window    = 'PDF'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'TITLE'
          function  = 'SET'
          window    = 'TITLE'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'FMNO'
          function  = 'SET'
          window    = 'FMNO'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'LOGO'
          function  = 'SET'
          window    = 'LOGO'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'VENDOR'
          function  = 'SET'
          window    = 'VENDOR'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'ITEM_HEADER'
          function  = 'SET'
          window    = 'HITEM'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'FOOTER1'
          function  = 'SET'
          window    = 'WINDOW1'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'FOOTER2'
          function  = 'SET'
          window    = 'WINDOW2'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      select single pstyp knttp into (spstyp, sknttp)
        from ekpo where ebeln eq l_doc-xekko-ebeln.
      PERFORM set_text_symbol USING:
                      '&pstyp&' spstyp,
                      '&knttp&' sknttp.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'PORDER'
          function  = 'SET'
          window    = 'WINDOW4'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
    ENDFORM.                    " HEADER_DISP
    &      Form  MAIN_DISP                                               &
    &      Main window Display                                           &
    FORM  main_disp USING l_doc TYPE meein_purchase_doc_print .
      DATA: BEGIN OF zekpo,
              matnr LIKE ekpo-matnr,
              meins LIKE ekpo-meins,
              menge LIKE ekpo-menge,
              netwr LIKE ekpo-netwr,
              brtwr LIKE ekpo-brtwr,
              netpr LIKE ekpo-netpr,
              txz01 LIKE ekpo-txz01,
              vbeln LIKE ekkn-vbeln,
              vbelp LIKE ekkn-vbelp,
              eindt LIKE eket-eindt,
              ebeln LIKE ekpo-ebeln,
              ebelp LIKE ekpo-ebelp,
              mwskz LIKE ekpo-mwskz,
              Txjcd like ekpo-Txjcd,
              charg LIKE eket-charg,
              pstyp LIKE ekpo-pstyp,
              LOEKZ LIKE ekpo-LOEKZ,
              lgort like ekpo-lgort,
            END OF zekpo.
      DATA : po_tot LIKE komv-kwert,
             item_tot LIKE komv-kwert,
             item_price LIKE komv-kwert,
             freight LIKE komv-kwert,
             posnr(4),
             comp TYPE i,
             t1_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
             t2_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
             itab_comp LIKE zekpo OCCURS 0 WITH HEADER LINE,
             t3_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
             totpr1 type p decimals 2,
             totpr2 type p decimals 3,
             netpr1 type p decimals 2,
             netpr2 type p decimals 3,
             amttot1 type p decimals 2,
             amttot2 type p decimals 3,
             amttot3 type p decimals 2,
             v_amountno(20) type c,
             decim type p.
      SELECT * FROM eket INTO CORRESPONDING FIELDS OF TABLE
                        l_doc-xeket WHERE ebeln EQ l_doc-xekko-ebeln.
      SELECT SINGLE waers rlwrt FROM ekko INTO (l_doc-xekko-waers,
                 l_doc-xekko-rlwrt) WHERE ebeln EQ l_doc-xekko-ebeln.
      select sum( menge ) into qtytot from ekpo
      where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
      select sum( netwr ) into amttot from ekpo
      where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
    select sum( effwr ) into amttot from ekpo
    where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
      LOOP AT l_doc-xekpo INTO t_xekpo WHERE LOEKZ EQ SPACE.
        CLEAR t_xekkn.
        READ TABLE l_doc-xekkn WITH KEY ebeln = t_xekpo-ebeln
                                        ebelp = t_xekpo-ebelp
             INTO t_xekkn.
        SELECT SINGLE kunnr INTO vbak-kunnr FROM vbak
                                    WHERE vbeln EQ t_xekkn-vbeln.
        SELECT SINGLE name1 INTO kna1-name1 FROM kna1
                                    WHERE kunnr EQ vbak-kunnr.
       clear t_xeket.
        READ TABLE l_doc-xeket WITH KEY ebeln = t_xekpo-ebeln
                                        ebelp = t_xekpo-ebelp
                                        etenr = 1
                   INTO t_xeket.
        CLEAR: item_price, item_tot,po_tot.
    Add the for SUM of the mat depends on the sale order and del date.
        MOVE-CORRESPONDING t_xekpo TO t1_ekpo.
        t1_ekpo-vbeln = t_xekkn-vbeln.
        t1_ekpo-eindt = t_xeket-eindt.
        t1_ekpo-vbelp = t_xekkn-vbelp.
        t1_ekpo-charg = t_xeket-charg.
        APPEND t1_ekpo.
      ENDLOOP.
      select single bstkd into ordno from vbkd where vbeln = t1_ekpo-vbeln.
    amttot = t_xekpo-effwr.
      LOOP AT t1_ekpo  WHERE LOEKZ EQ SPACE..
        MOVE-CORRESPONDING t1_ekpo TO t2_ekpo.
        APPEND t2_ekpo.
        MOVE-CORRESPONDING t1_ekpo TO itab_comp.
        APPEND itab_comp.
        item_price = t1_ekpo-brtwr / t1_ekpo-menge.
      For decimal place check
        select single currdec into decim from tcurx
          where currkey = l_doc-xekko-waers.
          if decim = 3.
            netpr2 = item_price / 10.
            totpr2 = t1_ekpo-brtwr / 10.
            amttot2 = amttot / 10.
          elseif decim = 2.
            netpr1 = item_price.
            totpr1 = t1_ekpo-brtwr.
            amttot1 = amttot.
          else.
            netpr1 = item_price.
            totpr1 = t1_ekpo-brtwr.
            amttot1 = amttot.
          endif.
        amttot3 = amttot1.
        posnr = t3_ekpo-vbelp+2(4).
        WRITE t3_ekpo-eindt TO t_itemdate DD/MM/YY.
        DATA: Yebelp LIKE  t1_ekpo-ebelp.
        Yebelp = t1_ekpo-ebelp / 10 .
        PERFORM set_text_symbol USING:
               '&T_XEKET-CHARG&'   t1_ekpo-charg, "t1_ekpo-eindt,
               '&DELDT&'           t_itemdate,
               '&VBAK-VBELN&'      t1_ekpo-vbeln,
               '&VBAK-VBELP&'      posnr,
               '&VBAK-KUNNR1&'     kna1-name1,
               '&T_XEKPO-TXZ01&'   t1_ekpo-txz01(34),
               '&T_XEKPO-MATNR&'   t1_ekpo-matnr,
               '&T_XEKPO-MENGE&'   t1_ekpo-menge,
               '&T_XEKPO-MEINS&'   t1_ekpo-meins,
               '&L_DOC-XEKKO-WAERS&' l_doc-xekko-waers,
               '&T_XEKPO-NETPR&'   t1_ekpo-netpr,
               '&T_XEKPO-NETWR&'   t1_ekpo-netwr,
               '&RATE&'            item_price,
               '&T_XEKPO-BRTWR&'   t1_ekpo-brtwr,
               '&T_XEKPO-EBELP1&'  Yebelp ,
               '&T_XEKET-EINDT&'   t1_ekpo-eindt,
               '&ordno&'           ordno,
               '&LGORT&'           t1_ekpo-lgort,
               '&ekkn-gsber&'      t_xekkn-gsber,
               '&decim&'           decim,
               '&netpr1&'          netpr1,
               '&netpr2&'          netpr2,
               '&amttot1&'         amttot1,
               '&amttot2&'         amttot2,
               '&totpr1&'          totpr1,
               '&totpr2&'          totpr2.
                  '&CNT&' count.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element  = 'ITEM_LINE'
            function = 'APPEND'
            window   = 'MAIN'
          EXCEPTIONS
            OTHERS   = 7.
      if t1_ekpo-lgort = 'RT01'.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element   = 'REVNO'
            function  = 'SET'
            window    = 'REVNO'
          EXCEPTIONS
            OTHERS    = 7.
      endif.
        IF sy-subrc EQ 0.
          count = count + 2.
        ENDIF.
        CONCATENATE t1_ekpo-ebeln  t1_ekpo-ebelp INTO tdname.
        SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
                                            tdobject EQ 'EKPO' AND
                                            tdname EQ tdname AND
                                            tdid EQ 'F01' AND
                                            tdspras EQ 'EN'.
        IF sy-subrc EQ 0.
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              client   = sy-mandt
              id       = stxl-tdid
              language = stxl-tdspras
              name     = stxl-tdname
              object   = stxl-tdobject
            TABLES
              lines    = ctxt
            EXCEPTIONS
              OTHERS   = 8.
          IF sy-subrc EQ 0.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_TEXT_HEAD'.
            LOOP AT ctxt.
              IF ( ctxt-tdline IS NOT INITIAL ).
                PERFORM set_text_symbol USING: '&TEXT_LINE1&' ctxt-tdline.
                CALL FUNCTION 'WRITE_FORM'
                  EXPORTING
                    element  = 'ITEM_TEXT'
                    function = 'APPEND'
                    window   = 'MAIN'
                  EXCEPTIONS
                    OTHERS   = 7.
              ENDIF. "if not line is  initial
            ENDLOOP.
          ENDIF. "if read text is successful
        ENDIF. "If table read is successful
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element  = 'ITEM_TEXT_LINE'
            function = 'SET'
            window   = 'MAIN'
          EXCEPTIONS
            OTHERS   = 7.
      ENDLOOP.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element   = 'REVNO'
            function  = 'SET'
            window    = 'REVNO'
          EXCEPTIONS
            OTHERS    = 7.
      t_netwr = 0.
      t_totqty = 0.
      LOOP AT t1_ekpo  WHERE LOEKZ EQ SPACE..
        CLEAR zekpo.
        LOOP AT t2_ekpo
          WHERE vbeln = t1_ekpo-vbeln.
          " Matnr, Dev date and Rate is EQ.
          IF ( t2_ekpo-matnr = t1_ekpo-matnr
              AND t2_ekpo-eindt = t1_ekpo-eindt
              AND t2_ekpo-netpr = t1_ekpo-netpr ).
            zekpo-matnr = t2_ekpo-matnr.
            zekpo-meins = t2_ekpo-meins.
            zekpo-menge = t2_ekpo-menge + zekpo-menge.
            zekpo-netwr = t2_ekpo-netwr + zekpo-netwr.
           t_netwr = t_netwr + t2_ekpo-netwr.  " Total price
           t_totqty = t_totqty + t2_ekpo-menge.  "Total Qty
          zekpo-netpr = t2_ekpo-netpr + zekpo-netpr.
            zekpo-netpr = t2_ekpo-netpr.
            zekpo-txz01 = t2_ekpo-txz01.
            zekpo-vbeln = t2_ekpo-vbeln.
            zekpo-vbelp = t2_ekpo-vbelp.
            zekpo-eindt = t2_ekpo-eindt.
            zekpo-ebeln = t2_ekpo-ebeln.
            zekpo-ebelp = t2_ekpo-ebelp.
          ENDIF.
        ENDLOOP.
    *Place to notice
        MOVE-CORRESPONDING zekpo TO t3_ekpo.
        APPEND t3_ekpo.
       DELETE t1_ekpo WHERE vbeln = zekpo-vbeln
                        AND matnr = zekpo-matnr
                         AND eindt = zekpo-eindt.
       DELETE t2_ekpo WHERE vbeln = zekpo-vbeln
                        AND matnr = zekpo-matnr
                         AND eindt = zekpo-eindt.
    *Changed by srini 31/12/2007
        DELETE t1_ekpo WHERE vbeln = zekpo-vbeln
                         AND matnr = zekpo-matnr
                          AND eindt = zekpo-eindt
                           AND netpr =  zekpo-netpr.
        DELETE t2_ekpo WHERE vbeln = zekpo-vbeln
                         AND matnr = zekpo-matnr
                          AND eindt = zekpo-eindt
                            AND netpr =  zekpo-netpr.
      ENDLOOP.
           IF t_xkomv-kschl NE 'FRA1' AND t_xkomv-kschl NE 'FRB1'.
           item_tot = item_tot + t_xkomv-kwert.
         ELSE.
           freight  = freight + t_xkomv-kwert.
         ENDIF.
      LOOP AT t3_ekpo WHERE LOEKZ EQ SPACE..
        LOOP AT l_doc-xtkomv INTO t_xkomv. " WHERE kposn EQ t3_ekpo-ebelp.
         icond-KNUMV = Ic-KNUMV .
         icond-KPOSN = Ic-KPOSN .
         icond-KSCHL = Ic-KSCHL .
         icond-KAWRT = IC-KAWRT .
         APPEND t_xkomv-icOND.
         APPEND .
        ENDLOOP.
      ENDLOOP.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'ITEM_HEADER'
          function  = 'SET'
          window    = 'HITEM'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      po_tot = po_tot + freight.
      SELECT waers rlwrt FROM ekko INTO (l_doc-xekko-waers,
          l_doc-xekko-rlwrt) WHERE ebeln EQ l_doc-xekko-ebeln.
      ENDSELECT.
      PERFORM set_text_symbol USING:
                            '&L_DOC-XEKKO-WAERS&' l_doc-xekko-waers,
                            '&FREIGHT&'  freight,
                           '&L_DOC-XEKKO-RLWRT&' t_netwr,
                           '&L_DOC-XEKKO-TotQty&' t_totqty,
                            '&qtytot&'  qtytot,
                            '&amttot&'  amttot,
                            '&CNT&' count.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'FRIGHT'
          function  = 'APPEND'
          window    = 'MAIN'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      IF sy-subrc EQ 0.
        count = count + 2.
      ENDIF.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'TOTAL'
          function  = 'SET'
          window    = 'MAIN'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      IF sy-subrc EQ 0.
        count = count + 2.
      ENDIF.
      clear : amttot1, amttot2.
    *P.O Summary
    CLEAR t_xekpo.
    REFRESH t_xekpo.
    t_xekpo[] = l_doc-xekpo[].
    SORT t_xekpo BY matnr.
    LOOP AT t_xekpo.
       AT NEW matnr.
         SUM.
         PERFORM set_text_symbol USING:
                  '&T_XEKPO-TXZ01&' t_xekpo-txz01,
                  '&T_XEKPO-MENGE&' t_xekpo-menge.
         CALL FUNCTION 'WRITE_FORM'
           EXPORTING
             element   = 'SUM_MATNR'
             function  = 'APPEND'
             window    = 'MAIN'
           EXCEPTIONS
             element   = 1
             function  = 2
             type      = 3
             unopened  = 4
             unstarted = 5
             window    = 6
             OTHERS    = 7.
         IF sy-subrc EQ 0.
           count = count + 1.
         ENDIF.
       ENDAT.
    ENDLOOP.
      comp = 0.
      LOOP AT itab_comp WHERE pstyp = 3  AND LOEKZ EQ SPACE..
        SELECT * FROM resb WHERE ebeln = l_doc-xekko-ebeln AND
                                   ebelp = itab_comp-ebelp AND
                                   baugr = itab_comp-matnr.
          SELECT SINGLE maktx FROM makt INTO makt-maktx WHERE
                                   matnr EQ resb-matnr.
          IF  comp = 0.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element  = 'COMP'
                function = 'SET'
                window   = 'MAIN'
              EXCEPTIONS
                OTHERS   = 7.
            comp = 1 .
          ENDIF.
          PERFORM set_text_symbol USING:
               '&T_XEKPO-MATNR&' makt-maktx,
               '&T_XEKET-EINDT&' resb-charg,
               '&T_XEKPO-MENGE&' resb-bdmng,
               '&T_XEKPO-MEINS&' resb-meins,
               '&T_XEKPO-EBELP1&' itab_comp-ebelp.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element  = 'COMP1'
              function = 'APPEND'
              window   = 'MAIN'
            EXCEPTIONS
              OTHERS   = 7.
          IF sy-subrc EQ 0.
            count = count + 2.
          ENDIF.
        ENDSELECT.
      ENDLOOP.
    Find the total price for each item from condition table
      DATA:  con_amt LIKE freight.
      DATA:  def TYPE string,
              sep(2) TYPE c,
              sep1(3) TYPE c,
              kwer(15) TYPE c,
              txt(15) TYPE c,
              con_win(1),
              con1(1),
              con(1),
              grpr1 type p decimals 2,
              grpr2 type p decimals 3.
      con = 1.
      DATA:  ic LIKE l_doc-xtkomv WITH HEADER LINE.
      DATA: begin of icond occurs 0,
        KSCHL like komv-KSCHL ,
        KWERT like komv-KWERT ,
        KNUMV like komv-KNUMV ,
        KPOSN like komv-KPOSN ,
      end of icond.
    *loop at t3_ekpo.
      LOOP AT l_doc-xtkomv INTO IC WHERE kinak eq space.
    kposn EQ t3_ekpo-ebelp.
        APPEND ic.
      ENDLOOP.
    *endloop.
      LOOP AT IC.
        icond-KSCHL = Ic-KSCHL .
        icond-KWERT = IC-KWERT .
        icond-KNUMV = Ic-KNUMV .
        icond-KPOSN = Ic-KPOSN .
        APPEND icOND.
      ENDLOOP.
      con_win = 0.
      sort icond by KSCHL.
      LOOP AT icond .
        AT END OF KSCHL.
          SUM.
           w_ex = 'X'.
         IF w_ex = 'X'.
          IF  con_win = 0.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element  = 'CON'
                function = 'SET'
                window   = 'MAIN'
              EXCEPTIONS
                OTHERS   = 7.
            con_win = 1 .
          ENDIF.
          CLEAR t685t-vtext.
          SELECT SINGLE vtext INTO t685t-vtext FROM t685t
                                WHERE kschl = icond-kschl AND
                                      spras = 'EN'.
          IF icond-KWERT NE 0.
          if decim = 3.
            grpr2 = icond-kwert / 10.
          elseif decim = 2.
            grpr1 = icond-kwert.
          else.
            grpr1 = icond-kwert.
          endif.
            PERFORM set_text_symbol USING:
                     '&icond-kwert&' icond-KWERT,
                     '&grpr1&'       grpr1,
                     '&grpr2&'       grpr2,
                     '&t685t-vtext&' t685t-vtext.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element  = 'CON_WIN1'
                function = 'APPEND'
                window   = 'MAIN'
              EXCEPTIONS
                OTHERS   = 7.
            IF sy-subrc EQ 0.
              con_win = 1.
            ENDIF.
          ENDIF.
          CLEAR: w_ex,icond-KWERT .
        ENDAT.
      ENDLOOP.
      CLEAR zekpo.
      SORT t3_ekpo BY matnr.
      LOOP AT t3_ekpo  WHERE LOEKZ EQ SPACE.
       MOVE-CORRESPONDING t3_ekpo TO zekpo.
        MOVE t3_ekpo-txz01 TO zekpo-txz01.
        AT NEW matnr.
          SUM.
         PERFORM set_text_symbol USING:
                  '&T_XEKPO-TXZ01&' zekpo-txz01,
                  '&T_XEKPO-MENGE&' zekpo-menge.
          PERFORM set_text_symbol USING:
                   '&T_XEKPO-TXZ01&' zekpo-txz01,
                   '&T_XEKPO-MENGE&' t3_ekpo-menge.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element   = 'SUM_MATNR'
              function  = 'APPEND'
              window    = 'MAIN'
            EXCEPTIONS
              element   = 1
              function  = 2
              type      = 3
              unopened  = 4
              unstarted = 5
              window    = 6
              OTHERS    = 7.
          IF sy-subrc EQ 0.
            count = count + 1.
          ENDIF.
        ENDAT.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'LINE5'
          function  = 'APPEND'
          window    = 'MAIN'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
      IF sy-subrc EQ 0.
        count = count + 1.
      ENDIF.
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *Tax Code Printed Here
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      SELECT SINGLE mwskz Txjcd FROM ekpo INTO
      (t3_ekpo-mwskz, t3_ekpo-Txjcd)
      WHERE ebeln = t3_ekpo-ebeln
      and   EBELP = t3_ekpo-EBELP.
    select single KSCHL INTO A053-KSCHL FROM A053
    WHERE MWSKZ EQ T3_EKPO-MWSKZ AND
          TXJCD EQ T3_EKPO-TXJCD.
    SELECT SINGLE VTEXT INTO T685T-VTEXT
    FROM T685T WHERE KSCHL EQ A053-KSCHL.
    DATA : GT type p decimals 2,
           PER(5).
    vat cal.
        if T3_EKPO-MWSKZ eq 'X1'.
          GT = T3_EKPO-NETWR * 4 / 100.
           GT = GT + ( T3_EKPO-NETWR * 4 / 100 ).
           PER = '4%'.
           ICT = ICT + 1.
        ELSEIF T3_EKPO-MWSKZ eq 'X3'.
          GT = T3_EKPO-NETWR *  125 / 1000.
           GT = GT + ( T3_EKPO-NETWR *  125 / 1000 ).
           PER = '12.5%'.
           ICT = ICT + 1.
         ELSEIF T3_EKPO-MWSKZ eq 'X5'.
           GT = T3_EKPO-NETWR *  2 / 100.
            GT = GT + ( T3_EKPO-NETWR *  2 / 100 ).
            PER = '2%'.
            ICT = ICT + 1.
          ELSEif T3_EKPO-MWSKZ eq 'Z1'.
          GT = T3_EKPO-NETWR * 4 / 100.
           GT = GT + ( T3_EKPO-NETWR * 4 / 100 ).
           PER = '4%'.
           ICT = ICT + 1.
            ELSEIF T3_EKPO-MWSKZ eq 'Z3'.
          GT = T3_EKPO-NETWR *  125 / 1000.
           GT = GT + ( T3_EKPO-NETWR *  125 / 1000 ).
           PER = '12.5%'.
           ICT = ICT + 1.
        ELSE.
        ENDIF.
        nettotal = amttot3 + GT.
    ENDLOOP.
      PERFORM set_text_symbol USING:
                   '&EKPO-MWSKZ&' t3_ekpo-mwskz,
                   '&GT&' GT,
                   '&ICT&' ICT,
                   '&nettotal&' nettotal,
                   '&per&' per,
                   '&VTEXT&' T685T-VTEXT,
    *Added by srini
                 '&printtype&' printtype.
                   '&printtype&' nast-kschl.
      PERFORM word_disp USING t_netwr l_doc-xekko-waers.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element   = 'TAX_CODE'
          function  = 'SET'
          window    = 'MAIN'
        EXCEPTIONS
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          OTHERS    = 7.
    clear : T3_EKPO-MWSKZ,GT,PER,T685T-VTEXT.
    *terms and Condition from Master Table
    *Terms and Condition
    *Get header Text Data
      CONCATENATE t3_ekpo-ebeln  t3_ekpo-ebelp INTO tdname.
      SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
                                          tdobject EQ 'EKPO' AND
                                          tdname EQ tdname AND
                                          tdid EQ 'F03' AND
                                          tdspras EQ 'EN'.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            client                        = sy-mandt
            id                            = stxl-tdid
            language                      = stxl-tdspras
            name                          = stxl-tdname
            object                        = stxl-tdobject
        ARCHIVE_HANDLE                = 0
        LOCAL_CAT                     = ' '
      IMPORTING
        HEADER                        =
          TABLES
            lines                         = ctxt
       EXCEPTIONS
         id                            = 1
         language                      = 2
         name                          = 3
         not_found                     = 4
         object                        = 5
         reference_check               = 6
         wrong_access_to_archive       = 7
         OTHERS                        = 8  .
        IF sy-subrc EQ 0.
          LOOP AT ctxt.
            IF ( ctxt-tdline IS NOT INITIAL ).
              PERFORM set_text_symbol USING: '&TEXT_LINE1&' ctxt-tdline.
              CALL FUNCTION 'WRITE_FORM'
                EXPORTING
                  element   = 'TEXT_LINE1'
                  function  = 'APPEND'
                  window    = 'WINDOW0'
                EXCEPTIONS
                  element   = 1
                  function  = 2
                  type      = 3
                  unopened  = 4
                  unstarted = 5
                  window    = 6
                  OTHERS    = 7.
              IF sy-subrc EQ 0.
                count = count + 2.
              ENDIF.
           CALL FUNCTION 'WRITE_FORM'
             EXPORTING
               element   = 'TEXT_LINE'
               function  = 'APPEND'
               window    = 'MAIN'
             EXCEPTIONS
               element   = 1
               function  = 2
               type      = 3
               unopened  = 4
               unstarted = 5
               window    = 6
               OTHERS    = 7.
           IF sy-subrc EQ 0.
             count = count + 1.
           ENDIF.
            ENDIF. "if not line is  initial
          ENDLOOP.
        ENDIF. "if read text is successful
      ENDIF. "If table read is successful
    *Get header Text Data
      SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
                                          tdobject EQ 'EKKO' AND
                                          tdname EQ l_doc-xekko-ebeln AND
                                          tdid EQ 'F05' AND
                                          tdspras EQ 'EN'.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            client                        = sy-mandt
            id                            = stxl-tdid
            language                      = stxl-tdspras
            name                          = stxl-tdname
            object                        = stxl-tdobject
        ARCHIVE_HANDLE                = 0
        LOCAL_CAT                     = ' '
      IMPORTING
        HEADER                        =
          TABLES
            lines                         = ctxt
       EXCEPTIONS
         id                            = 1
         language                      = 2
         name                          = 3
         not_found                     = 4
         object                        = 5
         reference_check               = 6
         wrong_access_to_archive       = 7
         OTHERS                        = 8  .
        IF sy-subrc EQ 0.
          LOOP AT ctxt.
            IF ( ctxt-tdline IS NOT INITIAL ).
              PERFORM set_text_symbol USING: '&TEXT_LINE&' ctxt-tdline.
              CALL FUNCTION 'WRITE_FORM'
                EXPORTING
                  element   = 'TEXT_LINE'
                  function  = 'APPEND'
                  window    = 'MAIN'
                EXCEPTIONS
                  element   = 1
                  function  = 2
                  type      = 3
                  unopened  = 4
                  unstarted = 5
                  window    = 6
                  OTHERS    = 7.
              IF sy-subrc EQ 0.
                count = count + 1.
              ENDIF.
            ENDIF. "if not line is  initial
          ENDLOOP.

Maybe you are looking for

  • Time machine full (yes, I know its been posted before but I have no answer)

    I have a macbook with 80GBhd, my time machine drive is a USB 80GB drive. I have 15GB free on my local machine and TM has 6.67. So its telling me that it needs 10.4GB to complete its backup.... and is no longer backing my drive up. I want to say "Hey,

  • Send as SMS instead of iMessage?

    So me and my dad recently got iPhone 5's. When ever I text him on his number or he texts me on my number it ALWAYS sends as an iMessage. This is really annoying because I press his number to send my message as an SMS but it still sends it as an iMess

  • Spamassassin, auto whitelist, backscatter and spam problems.

    My Mail is handled by an XServe with Mac OS X Server 10.5.5. I have many email problems. One of them is an email backscatter problem. Sometimes, but not always, when email is identified as spam, an email gets sent back to the "From" address saying it

  • Dynamic Add table not working

    Hi, I have to  2 subforms,name table_subform[0] and table_subform[1] . To add a new table , i use script : var sSubformSOM = "xfa.form.form1.page1.table_subform"; var oSubform = xfa.resolveNode(sSubformSOM);     var sParentSOM = oSubform.parent.somEx

  • Cl_abap_structdescr= create causes CX_SY_STRUCT_COMP_Ndump for invalid char

    Hello experts, when generating a copy of a system generated ITAB with RTTI/C I get a CX_SY_STRUCT_COMP_NAME  dump for invalid character. The error is caused at statement: go_sdescr_new  = cl_abap_structdescr=>create( gt_components ). Dump excerpt: Th