SAP SCRIPT , WRITE_FORM doesn't write to form

HI EXPERTS,
                   i have one internal table without header line in my program and i looped through it and i called WRITE_FORM FM to write 'DETAIL' Element on script . When i execute program , wa_itab workarea carries values bt it doesnt carry any data while debugging script at the same time . my code is like this:
TYPES : BEGIN OF TY_ITEM,
           EBELN TYPE EKPO-EBELN,               "PURCHASE ORDER NO.
           EBELP TYPE EKPO-EBELP,               "ITEM NUMBER OF PURCHASE ORD
           LOEKZ TYPE EKPO-LOEKZ,
           TXZ01 TYPE EKPO-txz01,
           MATNR TYPE EKPO-MATNR,               "MATERIAL NO.
           WERKS TYPE EKPO-WERKS,               "PLANT
           MENGE TYPE EKPO-MENGE,               "PO QTY.
           MEINS TYPE EKPO-MEINS,               "UNIT OF MEASUREMENT
           MAKTX TYPE MAKT-MAKTX,               "MATERIAL DESCRIPTION
       END OF TY_ITEM.
DATA: WA_ITEM TYPE TY_ITEM.
DATA: IT_ITEM TYPE TABLE OF TY_ITEM.
  loop at it_item INTO WA_ITEM.
                               CALL FUNCTION 'WRITE_FORM'
                                   EXPORTING
                                       ELEMENT                  = 'DETAIL'
                                       FUNCTION                 = 'SET'
                                       TYPE                     = 'BODY'
                                       WINDOW                   = 'MAIN'
                                   EXCEPTIONS
                                      ELEMENT                  = 1
                                      FUNCTION                 = 2
                                      TYPE                     = 3
                                      UNOPENED                 = 4
                                      UNSTARTED                = 5
                                      WINDOW                   = 6
                                      BAD_PAGEFORMAT_FOR_PRINT = 7
                                      OTHERS                   = 8.
                          endloop.
In script in MAIN Window ,only i have element called DETAIL , where i write WA_ITEM-EBELN, WA_ITEM-MATNR....like that.
Bt it doesnt display any data .
Plz try to solve this issue.
Thanks,
Saurin Shah
Edited by: Matt on Oct 13, 2009 12:44 PM - removed ALL CAPITALS from the subject and moved to correct forum

Hi,
please make sure, that your wa_item should be declared Globally.
use '&' before & last in the variable when you printing variables in Script.
eg: &wa_item-werks&,,&wa_item-matnr&
Hope it helps!!
Rgds,
Pavan

Similar Messages

  • [SAP Script] Recorder doesn't record "import from file - btn[23]" step

    Hi,
    I'm a total newbie in SAP script language.
    Iu2019m looking for some solution to import txt file with btn[23]. Whole procedure should look like this:
    006 click IMPORT FROM FILE u2013 btn[23]
    007 paste into textbox filepath "C:\Program lojalnosciowy\klienci.txt" and click OPEN
    008 click CONFIRM & LOAD - btn[8]
    Recorder doesnu2019t record step 007. Do you know how to fix it? Iu2019ve tried to add this line but I assume that ctxtDY_FILENAME is the wrong textbox name:
         007     MySession.findById("wnd[2]/usr/ctxtDY_FILENAME").text = "C:\Program lojalnosciowy\klienci.txt"
    SAP SCRIPT CODE:
    IsInput     ID     ScriptCode
    START     001     
         002     MySession.findById("wnd[0]/tbar[0]/okcd").text = "ZFOVERDUE"
         003     MySession.findById("wnd[0]").sendVKey 0
         004     MySession.findById("wnd[0]/usr/btn%_DD_KUNNR_%_APP_%-VALU_PUSH").press
         005     MySession.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA").select
         006     MySession.findById("wnd[1]/tbar[0]/btn[23]").press
         008     MySession.findById("wnd[1]/tbar[0]/btn[8]").press

    Hi shyha777,
    maybe it helps you if you look at the following link:
    Re: Pasting filename in a panel using script
    Regards,
    ScriptMan

  • Sap Script - write form Error

    Hi,
    When i execute my SAP script, it stops at Write form function call.
    I get the exception as Sy-subrc = 7. i.e., BAD_PAGEFORMAT_FOR_PRINT.
    Does anyone know how to get rid of this error?
    All help is greatly appreciated.
    Cheers,
    K

    Hi,
    Please check the page format.
    R u using page format available in SPAD or any different page format.

  • Physical Inventory Sap script to Smart Form conversion

    Hi to all experts,
    there is standard print program RM07IDRU (tcode mi21) .This print is assigned to customized sapscript (zmm_phys_inv) for printing . Now the problem is that we have print barcode using this script on a different printer .For scripts the bar code printing takes a lot of effort .The users want the sap script to be converted to smart forms . what is the best approach for this............................need u r feedbacks

    Hi Mohammed
    The users want the sap script to be converted to smart forms . what is the best approach for this
    For this refer the similar kind of thread.
    how to convert sap script layout into smartforms?
    regards
    s@chin

  • Smart form vs sap script

    hi experts
    i have one doubt,
    sap script is client dependent and smart form is client independent how?
    and why we say it client dependent and independent.

    SAPscript are client dependent.
    They need to be copied from one client to another for testing. this can be done from SE71->utilities->copy from Client.
    For transferring between server as like other objects they need to be transport.
    As for smartforms they are client independent and all changes are available at the same time in all clients for execution.
    Unlike smartforms, if you want to use or modify a sapscript in a different client you need to copy it from that client or client '000'.
    This is applicable to it accessory components like graphics, texts..etc

  • Help regarding SAP SCRIPT

    Hi!
      can any one help me regarding SAP SCRIPT. i unable to write a print program for sap script . can any one can send me sample code using ITCSY structure.
    Thanks in advance.
    Thanks & Regads,
    DurgaPrasad.k

    Hi,
    refer this to write print program:
    <b>The Print Program</b>
    Structure of a print program
    OPEN_FORM function
    CLOSE_FORM function
    WRITE_FORM
    START_FORM function
    END_FORM function
    CONTROL_FORM function
    The print program is used to print forms. The program retieves the necesary data from datbase
    tables, defines the order of in which text elements are printed, chooses a form for printing and
    selects an output device and print options.
    <b>Function modules in a printprogram:</b>
    When you print a form you must used the staments OPEN_FORM and CLOSE_FORM. To combine
    forms into a single spool request use START_FORM and END_FORM.
    To print textelements in a form use WRITE_FORM. The order in which the textelements are printed,
    is determined by the order of the WRITE_FORM statements. Note: for printing lines in the body, you
    can also use the WRITE_FORM_LINES function module.
    To transfer control command to a form use CONTROL_FORM.
    <b>Structure of a print program</b>
    Read data
    Tables: xxx.
    SELECT *
    FROM xxx.
    Open form printing - Must be called before working with any of the other form function modules.
    Must be ended with function module CLOSE FORM
    call function 'OPEN_FORM'.....
    To begin several indentical forms containing different data within a single spool request, begin each
    form using START_FORM, and end it using END_FORM
    call funtion 'START_FORM'.....
    Write text elements to a window of the form
    call function 'WRITE_FORM'.....
    Ends spool request started with START_FORM
    call funtion 'END_FORM'.....
    Closes form printing
    call function 'CLOSE_FORM'...
    OPEN_FORM function
    Syntax:
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
      APPLICATION                       = 'TX'
      ARCHIVE_INDEX                     =
      ARCHIVE_PARAMS                    =
      DEVICE                            = 'PRINTER'
      DIALOG                            = 'X'
      FORM                              = ' '
      LANGUAGE                          = SY-LANGU
      OPTIONS                           =
      MAIL_SENDER                       =
      MAIL_RECIPIENT                    =
      MAIL_APPL_OBJECT                  =
      RAW_DATA_INTERFACE                = '*'
    IMPORTING
      LANGUAGE                          =
      NEW_ARCHIVE_PARAMS                =
      RESULT                            =
    EXCEPTIONS
      CANCELED                          = 1
      DEVICE                            = 2
      FORM                              = 3
      OPTIONS                           = 4
      UNCLOSED                          = 5
      MAIL_OPTIONS                      = 6
      ARCHIVE_ERROR                     = 7
      INVALID_FAX_NUMBER                = 8
      MORE_PARAMS_NEEDED_IN_BATCH       = 9
      SPOOL_ERROR                       = 10
      OTHERS                            = 11
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    <b>Some important parameters:</b>
    FORM Name of the form
    DEVICE PRINTER : Print output using spool
    TELEFAX: Fax output
    SCREEN: Output to screen
    OPTIONS Used to control attrubutes for printing or faxing (Number of copies, immediate output....
    The input for the parameter is structure ITCPO.
    CLOSE_FORM function
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
      RESULT                         =
      RDI_RESULT                     =
    TABLES
      OTFDATA                        =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SEND_ERROR                     = 3
      SPOOL_ERROR                    = 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.
    Paramerters:
    RESULT Returns status information and print/fax parameters after the form has been printed.
    RESULT is of structure ITCPP.
    WRITE_FORM function
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT                        = ' '
      FUNCTION                       = 'SET'
      TYPE                           = 'BODY'
      WINDOW                         = 'MAIN'
    IMPORTING
      PENDING_LINES                  =
    EXCEPTIONS
      ELEMENT                        = 1
      FUNCTION                       = 2
      TYPE                           = 3
      UNOPENED                       = 4
      UNSTARTED                      = 5
      WINDOW                         = 6
      BAD_PAGEFORMAT_FOR_PRINT       = 7
      SPOOL_ERROR                    = 8
      OTHERS                         = 9
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Some important parameters:
    ELEMENT Specifies which textelement is printed
    WINDOW Specifies which window is printed
    TYPE Specifies the output area of the main window. This can be:
    TOP - Used for headers
    BODY
    BOTTOM - Used for footers
    FUNCTION Specifies whether text is to be appended, replaced or added
    Example of how to use the WRITE_FORM function module together with a script.
    Form layout of the MAIN window
    /E INTRODUCTION
    Dear Customer
    /E ITEM_HEADER
    IH Carrier, Departure
    /E ITEM_LINE
    IL &SBOOK-CARRID&, &SPFLI-DEPTIME&
    /E CLOSING_REMARK
    <b>The print program</b>
    Writing INTRODUCTION
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT                  = 'INTRODUCTION'
    FUNCTION                 = 'SET'
    TYPE                     = 'BODY'
    WINDOW                   = 'MAIN'
    EXCEPTIONS
    OTHERS                   = 8
    Writing ITEM_HEADER
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT                  = 'ITEM_HEADER'
    FUNCTION                 = 'SET'
    TYPE                     = 'BODY'
    WINDOW                   = 'MAIN'
    EXCEPTIONS
    OTHERS                   = 8
    Set ITEM_HEADER into TOP area of main window for subsequent pages
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT                  = 'ITEM_HEADER'
    FUNCTION                 = 'SET'
    TYPE                     = 'TOP'
    WINDOW                   = 'MAIN'
    EXCEPTIONS
    OTHERS                   = 8
    Write ITEM_LINE
    LOOP AT .....
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT               = 'ITEM_LINE'
    FUNCTION              = 'SET'
    TYPE                  = 'BODY'
    WINDOW                = 'MAIN'
    EXCEPTIONS
    OTHERS                 = 8.
    ENDLOOP.
    Delete ITEM_HEADER from TOP area of main window
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT                  = 'ITEM_HEADER'
    FUNCTION                 = 'DELETE'
    TYPE                     = 'TOP'
    WINDOW                   = 'MAIN'
    EXCEPTIONS
    OTHERS                    = 8
    Print CLOSING_REMARK
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    ELEMENT                  = 'CLOSING_REMARK'
    FUNCTION                 = 'SET'
    TYPE                          = 'BODY'
    WINDOW                   = 'MAIN'
    EXCEPTIONS
    OTHERS                    = 8
    START_FORM function
    CALL FUNCTION 'START_FORM'
    EXPORTING
      ARCHIVE_INDEX          =
      FORM                   = ' '
      LANGUAGE               = ' '
      STARTPAGE              = ' '
      PROGRAM                = ' '
      MAIL_APPL_OBJECT       =
    IMPORTING
      LANGUAGE               =
    EXCEPTIONS
      FORM                   = 1
      FORMAT                 = 2
      UNENDED                = 3
      UNOPENED               = 4
      UNUSED                 = 5
      SPOOL_ERROR            = 6
      OTHERS                 = 7
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    END_FORM function
    CALL FUNCTION 'END_FORM'
      RESULT                         =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SPOOL_ERROR                    = 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.
    CONTROL_FORM function
    The CONTROL_FORM function module alows you to create SapScript control statements from within
    an APAB program.
    Syntax:
    CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
    command         =
    EXCEPTIONS
      UNOPENED        = 1
      UNSTARTED       = 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.
    Example:
    Protecting the text element ITEM_LINE
    CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
    COMMAND = 'PROTECT'.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    TEXELEMENT = 'ITEM_LINE'.
    CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
    COMMAND = 'ENDPROTECT'.
    rgds,
    latheesh
    Message was edited by: Latheesh Kaduthara

  • Help needed in SAP Scripts

    Hello all,
    I am trying to learn SAP Scripts. I have created one form named as 'zfm1' using SE71.
    Using SE 38 I have created a PRINT PROGRAM also which contains FM's like Open_form,Start_form,Write_form etc. When activated it is not displaying any error.
    But in o/p it is asking for a device and by def.it is showing LP01 in o/p device.
    Can anybody please guide me in this ahead?
    How can I see the Windows created by me?
    Thanks and regards,
    Harish

    hi,
    just give device as LP01 and press print preview.

  • How to change a SAP script output without changing Print Program

    Hi,
    I want to change output of standard PO report printing object. I have to change the ZSAPSCRIPT but I have to keep the print program intact. please give me ideas.

    Hi for that you have to do following.
    1. Create a ZPROGRAM
    2. Write a Perform in your SAP Script.
    3. Write Form inside it your ZPROGRAM.
    Hope this will help you.
    <i><b>Reward points for helpful ans.</b></i>

  • Sap Script Queries

    Hi Experts,
    I need to print Long Text maintained for a record in sap.
    I have the Text ID and Text Object but don't know about the Text Name
    and I have to print this Long Text in my SAP SCRIPT to be shown on the Form and i am not doing changes in standard print program instead using the subroutine pool.
    Please tell me in Detail how can i achieve this.
    And one more query, i also have to print Digital signature for a document.
    Please tell me in Detail how can i get the details for a Digital signature (for a particular record) and get them printed in SAP Script.
    Thanks

    Hi,
    data: T_TEXT like tline occurs 0 with header line.
      IF NOT thead_011 IS INITIAL.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            id                      = thead_011-tdid
            language                = thead_011-tdspras
            name                    = thead_011-tdname
            object                  = thead_011-tdobject
          TABLES
            lines                   = T_TEXT
          EXCEPTIONS
            id                      = 1
            language                = 2
            name                    = 3
            not_found               = 4
            object                  = 5
            reference_check         = 6
            wrong_access_to_archive = 7
            OTHERS                  = 8.
    T_TEXT is an internal table and contains the all the text which is there in ur transaction.
    now, u Loop the table T_TEXT and call WRITE_FORM fm in the loop.
    LOOP AT t_text.
      call function 'WRITE_FORM'
        EXPORTING
           element = 'TEXT'.
    ENDLOOP.
    now u call the element 'TEXT' in ur form, and print &T_TEXT-TDLINE& in that element..
    so it will print all the lines in T_TEXT table.
    In Script:
    eg: 
    /E  TEXT
    P1 &T_TEXT-TDLINE&
    Hope it helps
    Rgds,
    Pavan

  • Sap script  components

    hi all,
    1.what r the components of sap script?

    Hello,
    For designing a form in script, rquired things are.
    1. Page
    2. Window
    3. Paragraph format
    4. Character format
    For devloping a driver program.
    1. A form name
    2. Output type
    3. Different function modules
       Open_Form
       Close_form
       Start_form
       end_form
       write_form
    Let me know ur exact requirement so that I can be more clear.
    Regards

  • How To send SAP SCRIPT AS an email.

    Hi,
    Any one knows how to send sap script output to users in the form of an email.
    Is there any other way to send it apart from sending the script output to spool and converting the spool to PDF and send that PDF to user?
    It would it helpful for me if u can let me know any peace of code as an example for the same.
    Message was edited by: Narasimha

    Hi,
    This may be too late but here is a really easy way
    Here is a snippet of code that will help you out.
    You can use the OPEN_FORM of the SAPscript to have a device type of MAIL instead of PRINTER
          Form  OPEN_FORM
          Open SAPscript form to send to user
    FORM OPEN_FORM .
    *--- Set recipient
      GW_COMM_VALUES-ADSMTP-SMTP_ADDR = '[email protected]'.
    *--- Set NAST details as these will not currently be set....
      CLEAR GW_SNAST.
      GW_SNAST-ANZAL = 1.
      GW_TITLE = 'Mail Header Title'.
      MOVE GW_TITLE TO GW_SNAST-TDCOVTITLE.
    *--- Set sender and recipient details
      CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
        EXPORTING
          PI_COMM_TYPE              = 'INT'
          PI_COMM_VALUES            = GW_COMM_VALUES
          PI_REPID                  = SY-REPID
          PI_SNAST                  = GW_SNAST
          PI_MAIL_SENDER            = SY-UNAME
        IMPORTING
          PE_ITCPO                  = GW_ITCPO
          PE_MAIL_RECIPIENT         = GW_RECIPIENT
          PE_MAIL_SENDER            = GW_SENDER
        EXCEPTIONS
          COMM_TYPE_NOT_SUPPORTED   = 1
          RECIPIENT_CREATION_FAILED = 2
          SENDER_CREATION_FAILED    = 3
          OTHERS                    = 4.
    *--- Open SAPscript in MAIL mode for e-mailing
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          DEVICE                      = 'MAIL'
          DIALOG                      = 'X'
          FORM                        = SapScript Form Name
          LANGUAGE                    = SY-LANGU
          OPTIONS                     = GW_ITCPO
          MAIL_SENDER                 = GW_SENDER
          MAIL_RECIPIENT              = GW_RECIPIENT
        EXCEPTIONS
          CANCELED                    = 1
          DEVICE                      = 2
          FORM                        = 3
          OPTIONS                     = 4
          UNCLOSED                    = 5
          MAIL_OPTIONS                = 6
          ARCHIVE_ERROR               = 7
          INVALID_FAX_NUMBER          = 8
          MORE_PARAMS_NEEDED_IN_BATCH = 9
          SPOOL_ERROR                 = 10
          CODEPAGE                    = 11
          OTHERS                      = 12.
    When you have finished your SAPscript and call function CLOSE_FORM make sure you do a COMMI WORK after the call of this function.
    You should then see the mail created in SOST.
    Kind regards
    Colin

  • Changes are not reflecting while executing the SAP script from report

    HI,
    In SAP-script we are nmaking changes in form in client 130
    it is showing the changes in 140 client but while excuting the report the same are not reflecting in the output.
    Thanks in Advance
    Naveen M

    Hello.
    Scripts are mandant depentant. So you must copy from 130 to 140 for changes take efect.
    Do it in transaction SE71 in mandant 140, first screen, in the menu options.
    And never forget to activate it in all mandants.
    Best regards.
    Valter Oliveira.

  • Enquiry in SAP SCRIPT

    Hi,
    I want to increment the vertical line dynamically according to the line items in SAP SCRIPT.
    How will I do it??
    Pooja

    hi..,
    each time u print the record in sap script at the end write &vline&.. give a tab postion for all these vertical lines and use the tab correctly....then onli u will get a straight and complete vertical line...
    plz, do remember to close the thread when ur problem is solved !!
    reward if it helps u..
    sai ramesh

  • Using Function Module in SAP Script

    Dear Friends,
    how can i use function modules in sap scripts?. i want to use call function SPELL_AMOUNT in sap script?
    in text element using perform statement hw can i use?
    Regarding i search related articles but, i am not getting any solution.
    Plz help Me.
    Regards,
    K.S.Kannan

    Dear Kanan,
    You can do it in two ways:
    Way1
    your Amount will be in some variable say VAR_AMT1 and want in words in field say VAR_SPELL.
    In your report program you can use the function module SPELL_AMOUNT and pass the  VAR_AMT1 to it and you will get the words in VAR_SPELL.
    So now in your sap script you can use the variable  VAR_SPELL to print the amount in words.
    we normally use this above method.
    WAY2
    You are inside Sap script and you can write the following code in the sap Script window.
    /: PERFORM AMT_TEXT IN PROGRAM ZF_REPORT USING &VAR_AMT1& CHANGING &VAR_SPELL&
    /: ENDPERFORM
    In the Tag Column when you press F4 you can see various symbols like
    /: =  ( / /= /( /: /* /E
    . Select
    In the program ZF_REPORT (any report) you should have the perform AMT_TEXT  where you should use the function module SPELL_AMOUNT to convert the amount into words.
    Hope its Clear.

  • To replace SAP script with smartform in customer statement using t-code F.27

    Hi, I have a requirement to replace SAP script while generating a customer statement form using F.27 with Smartform. The standard program which triggers the SAP script is RFKORD11. Can anyone tell me how can we achieve this. Thanks in advance. BR, Karthik.

    Hi
    do you find a solution for your issue? Or did anyone else know how to send raw data instead of the pdf or fixed file from transaction F.61?
    Thanks for any ideas or help
    Axel

Maybe you are looking for