Looping a SAPscript

Hello!
I'm using a Excel macro with a connection to SAP with the purpose to, in VA02, set system status RREC on sales order items. As the amount of item lines are unknown in each case, I want a macro that goes backwards from the last item and sets the status from the last item all the way up to item 100 which is always the first line item.
This is the idea,
It enters transaction va02
Enters the sales order
Click the button that scrolls the list all the way down
Up arrow to get to the actual last item
Goto, Item, Status
Object status
Check RREC status
Back
And now I want to loop it so it does this until the last (which is the actual first, line item 100).
session.findById("wnd[0]").resizeWorkingPane 150,25,false
session.findById("wnd[0]/tbar[0]/okcd").text = "va02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = "3405192"
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[83]").press
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,3]").setFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,3]").caretPosition = 0
session.findById("wnd[0]/mbar/menu[2]/menu[2]/menu[13]").select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\12/ssubSUBSCREEN_BODY:SAPMV45A:4456/btnBT_PSTC").press
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").selected = true
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").setFocus
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
I don't know if this loop is supposed to be in the Excel code or in this SAPscript code.
Anyone?
BR Mattias

Hello!
Thanks for your answer, it actually worked. Had to do some editing in my script too.
But now there is another "problem". As I said the number of item lines on each sales order differs. So with this example sales order of 13 item lines, the macro is trying on and on to set the status on the "next" item line (up to a 100 i guess?), when there is only 13 items. Is there a solution for it to automatically detect when it is on the last item line and then to move on to the next sales order? That would save alot of time.
This is how the macro looks now (there is a lot of excel stuff in it which is not posted).
SONumber = ActiveCell.Offset(0, 1).Value
SOItem = ActiveCell.Offset(0, 2).Value
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = SONumber
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[83]").press
For i = 1 To 100    'Simple for - next !
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,12]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,12]").caretPosition = 0
session.findById("wnd[0]/mbar/menu[2]/menu[2]/menu[13]").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\12/ssubSUBSCREEN_BODY:SAPMV45A:4456/btnBT_PSTC").press
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").Selected = True
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").SetFocus
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[1]/btn[18]").press
Next
session.findById("wnd[0]/tbar[0]/btn[11]").press
Points awarded.
Thanks, Mattias

Similar Messages

  • Loop in sapscript

    Hi All,
    Can we use loop in sapscript editor,if yes then plz tell me how.
    Thanks in advance

    Hi Sheelesh,
    See below it..
    You find loop statement in sapscript.
    REPORT  ZSUR9.
    TABLES:ZST2.
      DATA: LANG LIKE SY-LANGU.
      Data: itab LIKE zst2 OCCURS 0 WITH HEADER LINE.
      select * from zst2 into TABLE itab.
    call function 'OPEN_FORM'
    EXPORTING
       DEVICE                            = 'PRINTER'
       DIALOG                            = 'X'
       FORM                              = 'ZFORM4'
       LANGUAGE                          = LANG
    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.
    call function 'WRITE_FORM'
    EXPORTING
       ELEMENT                        = 'ZS1'
       TYPE                           = 'BODY'
       WINDOW                         = 'MAIN'
    EXCEPTIONS
       ELEMENT                        = 1
       FUNCTION                       = 2
       TYPE                           = 3
       UNOPENED                       = 4
       UNSTARTED                      = 5
       WINDOW                         = 6
       BAD_PAGEFORMAT_FOR_PRINT       = 7
       SPOOL_ERROR                    = 8
       CODEPAGE                       = 9.
    LOOP at itab.
      call function 'WRITE_FORM'
       EXPORTING
         ELEMENT                        = 'ZS2'
         TYPE                           = 'BODY'
         WINDOW                         = 'MAIN'
       EXCEPTIONS
         ELEMENT                        = 1
         FUNCTION                       = 2
         TYPE                           = 3
         UNOPENED                       = 4
         UNSTARTED                      = 5
         WINDOW                         = 6
         BAD_PAGEFORMAT_FOR_PRINT       = 7
         SPOOL_ERROR                    = 8
         CODEPAGE                       = 9 .
    ENDLOOP.
    call function 'CLOSE_FORM'
    EXCEPTIONS
       UNOPENED                       = 1
       BAD_PAGEFORMAT_FOR_PRINT       = 2
       SEND_ERROR                     = 3
       SPOOL_ERROR                    = 4
       CODEPAGE                       = 5 .
    Reward if useful,
    Regards,
    S.Suresh.

  • Sapscript table

    Hi
    It is possible to do something like this:
    I have loop in sapscript by itab wchich print:
    name1 name2_very_very_lo name3
    name1 name2_very_very_lo name3
    And I wanto to split a name2 to like this:
    name1 name2_very_very     name3
    ........._long_name    
    name1 name2_very_very     name3
    ........._long_name    
    How to split this long strings to 2 lines?
    Edited by: Kosmo on Aug 1, 2008 4:54 PM
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Aug 2, 2008 8:19 AM

    Hi,
    Firstly can i know the use of splitting into second line... as you have a option to move your cursor to left or right in EDIT menu..
    Even then if you want to mention in the next line then put and '=' symbol in the command field which resembles the continuation of previous line.
    Hope this would help you.
    Good luck
    Narin

  • Purchase Order SAPscript - Looping problem.

    Dear Friends,
    I am using a PO Z-form which is a copy of MEDRUCK and print program is Standard SAPLMEDRUCK Program.
    I have got a Scenario something like this.
    I have to display some classification details of material ( from material master ) in PO.
    A material will have 2 or 3 Classes, Each class has got some details.
    I have to loop for each class and display the details.
    Since I am using Standard Print Program, I Can't Change that.
    Is there any workaround method for the above requirement.
    Regards,
    Hari.

    Hi Hari,
                 There is not need to use that WRITE_FORM FM,
    Instead write the PERFORM statement in the window where you need to display the classification values and after immediately give the variables which holds the classification values.
    Example
    /:PERFORM GET_COMCODE IN PROGRAM ZM_RFQ_REJECTION
    /:USING &EKKO-BUKRS&
    /:USING &EKKO-SPRAS&
    /:CHANGING &SADR-NAME1&
    /:CHANGING &SADR-NAME2&
    /:CHANGING &SADR-NAME3&
    /:CHANGING &SADR-PSTLZ&
    /:CHANGING &SADR-NAME4&
    /:ENDPERFORM
    B &SADR-NAME1&,, &SADR-NAME2&,,&SADR-NAME3&,, &SADR-PSTLZ&,, &SADR-NAME4&
    as in above example you pass the Material no in USING field and in CHANGING fields DEFINE variables for classification and pass
    Regards
    Bala Krishna

  • SAPSCRIPT: loop in a not main window

    Hi,
    I have created an text element in a NO main window:
    SA     Objasnienia do jednostek miar:
    /E     VRKME_TE
    /      &I_VRKME-VRKME& - &I_VRKME-MSEHT&
    This is the code of the control program that writes the content of the IT:
      LOOP AT i_vrkme.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            WINDOW  = 'VRKME'
            ELEMENT = 'VRKME_TE'
          EXCEPTIONS
            OTHERS  = 1.
      ENDLOOP.
    The problem is that only appears the last line of the IT in the form. If IT is empty, appears the header. I think that each call to WRITE_FORM overrides the last one.
    How could I solve this problem?
    Best regards,
    Pablo

    Hi,
    I have added this code:
      LOOP AT i_vrkme.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            WINDOW  = 'VRKME'
            ELEMENT = 'VRKME_TE'
          EXCEPTIONS
            OTHERS  = 1.
        CALL FUNCTION 'CONTROL_FORM'
          EXPORTING
            COMMAND = 'NEW-LINE'.
      ENDLOOP.
    but it doesnt work. Any suggestion?

  • Loop at internal Table inside Script

    Hi
       I am filling a table in a subroutine in a program  and calling it through 'Perform' from my Script,now the main issue is , How to display the table in my script ? 
                I want to loop through an internal table & display its content on my script , but i can't make changes in the calling program by any means.

    Hi Ajitabh ,
    With PERFORM inside SAPSCRIPT you can only pass individual fields and also get back individual fields .
    Check This
    http://help.sap.com//saphelp_470/helpdata/EN/d1/802fd3454211d189710000e8322d00/frameset.htm
    Only "USING" and CHANGING" options are allowed and that too only symbols available / defined in sapscript can be passed .
    Even if you populate an internal table in the program you are calling with "PERFORM" there is no way to pass this internal table back to sapscript , also in SAPSCRIPT there is no way to loop .
    If you are sure about the no of lines you are going to populate and all lines have only one column ( only one field ) you can try something like this .
    /: PERFORM GET_VALUE IN PROGRAM <ZNAME>
    /: USING &VAR1&
    /: USING &VAR2&
    /: CHANGING &ITAB1&
    /: CHANGING &ITAB2&
    /: CHANGING &ITAB3&
    /: CHANGING &ITAB4&
    /: ENDPERFORM
    Anothe way is to loop in the main print program and call WRITE_FORM . But I guess your main print program is a SAP std program which you dont want to copy and change.
    Cheers.

  • SAPSCRIPT form - Text is not porperly displayed

    hi all,
    in my SAPSCRIPT form, I am getting a text from PERFORM stmt. in the PERFORM , the text is coming correct, but in the form , it is showing only half of the text.
    the code
    FORM get_text TABLES ts_intab STRUCTURE itcsy
                         ts_outtab STRUCTURE itcsy.
    DATA: l_haul_text(500) TYPE c,  
               l_haul_long(250) TYPE c.
    l_haul_long = l_haul_text+0(250).
        LOOP AT ts_outtab.
          CASE ts_outtab-name.
            WHEN 'L_HAUL_LONG'.
              ts_outtab-value = l_haul_long.
              MODIFY ts_outtab.
          ENDCASE.
        ENDLOOP.
    Then in the form, just display
    /:  PERFORM GET_TEXT IN PROGRAM
    /:   USING &VBDKL-VBELN&
    /:   CHANGING &L_HAUL_LONG&
    /:  ENDPERFORM
    &L_HAUL_LONG&
    while debugging, the text is correct till TS_OUTTAB but when it comes to the form L_HAUL_LONG, it is truncated.......what should i do..
    Kindly help.
    THnaks

    answered

  • Blank page is getting displayed in SAPScript when using NEW-PAGE option.

    Hello Experts,
    We have created a customized SAPScript and in this separate Script is generated based on the currency(WAERS).
    So if we have 3 different currencies, then 3 pages will be created with there details, but we are using NEW-PAGE option in
    MAIN window to separate the pages and after 3rd page it is displaying 4th page also with footer details.
    So how can we avoid last blank page which is getting displayed?

    Hi isha.walia ,
       This issue can be solved by two ways. Please take the one which suits you better.
    Solution 1: If  you need to generate separate prints for different currencies.
    In the driver program, build an internal table for different currencies which needed to be printed. (Using delete adjacent duplicates, build the internal table with exact number of currencies to be printed). Remove the NEW-PAGE option and call the script/form inside the loop. Do the necessary conditions to manipulate the print.
    Advantages of above solution: Better control on spools if needed.
    Solution 2:  Get the count of the number of pages in a variable. Inside the print loop, increment a flag counter. Check it against the variable which contains the number of pages to be printed at the end of each page. Exit the loop when the number of pages to be printed is reached.
    Advantage of above solution: Simple to write the program.
    Thanks and Regards
    Raghesh R S

  • Addint new field to the standard sapscript form.

    FOR SALES INVOICE DOCUMENT FORM PRINTING
    TRANSACTION CODE: VF01
    OUTPUT TYPE : FJCI
    PROGRAM NAME: RVADAUS1
    SAPSCRIPT FORM NAME: SD_EXPORT_FJCI
    ENTRY ROUTINE: ENTRY_FJCI.
    STRUCTURE USED FOR THIS OUTPUT TYPE = V55EFJCI
    THE QUERY IS AS FOLLOWS:
    I WANT TO ADD DATA MODE OF TRANSPORT FROM THE INVOICE DOCUMENT. THE TABLE AND FIELD IS T618-BEZEI.
    SO I COPIED THE STANDARD FORM TO ZSD_EXPORT_FJCI AND THE STANDARD PROGRAM TO ZRVADAUS1.
    I SUCCESSFULLY FETCHED THAT FIELD DATA.
    I APPEND THE STRUCTURE 'ZAV55EFJCI' TO ADD THE ADDITIONAL T618-BEZEI FIELD.
    AND WRITE MY SELECT QUERY IN THE ENTRY_FJCI FORM ROUTINE.
    THE CODE IS AS FOLLOWS:
    data: begin of it_mode_of_tp occurs 1,
          bezei type t618t-bezei,
          end of it_mode_of_tp.
    select a~bezei as zzbezei into table it_mode_of_tp from t618t as a
    inner join
    eikp as b on aexpvz = bexpvz and aland1 = baland inner join vbrk as
    c on bexnum = cexnum
    where cvbeln = nast-objky and aspras = nast-spras .
    loop at it_mode_of_tp.
       v55efjci-zzbezei = it_mode_of_tp-bezei.
    endloop.
    BUT THE DATA FOR THAT IS NOT GETTING DISPLAYED.
    THIS WAS THE FIRST METHOD I FOLLOWD.
    THE SECOND METHOD I DID WAS AS FOLLOWS:
    FORM ENTRY_FJCI.
         PERFORM PROCESSING.
    ENDFORM
    FORM PROCESSING.
         PERFORM PRINT_DOCUMENT.
    ENDFORM.
    FORM PRINT_DOCUMENT.
           CALL FUNCTION 'RV_EXPORT_DOCUMENT_PRINT'
    ENDFORM.
    IN THIS FUNCTION THE DATA IS GETTING FETCHED FROM THE DATABASE TABLES AND STORED IN THE STRUCURE V55EFJCI.
    SO I COPIED THAT FUNCTION.
    IN THIS FUNCTION , THEIR IS A INCLUDE PROGRAM 'LV55EF11' FOR FETCHING DATA FOR ENTRY_FJCI FORM ROUTINE.
    I COPIED THAT PROGRAM CODE , AND CREATED MY OWN INCLUDE PROGRAM (WHICH I AM STORING IT IN ANOTHER Z PACKAGE.)
    AND WRITTEN MY ABOVE CODE IN THAT PROGRAM. BUT WHEN I DO THIS, NOITHING GETS DISPLAYED , EVEN THE PREVIOUSLY COMING DATA ALSO NOT GETTING DISPLAYED.
    HOW SHOULD I PROCEED.

    you said you copied layout(form) SD_EXPORT_FJCI to ZSD_EXPORT_FJCI,
    you updated program to fetch datat & populate v55efjci-zzbezei field.
    Now
    - you need to modify layout(form) ZSD_EXPORT_FJCI via SE71 to insert your field in one of the windows where it has to be printed (sap script knowledge is required here).
    - you need to either modify SAP output type FJCI to use your program/layout(form) or you need to create your own output type and assign your form/program to it, and in addition to that if you define your own output type - yo have to add it to output determination procedure, to access sequences, add condition records to condition table... so it's picked up by the invoice.

  • Send sapscript to customer

    Hi,
    could I use the function USE_SEND_OBJECT to send a sapscript (an invoice) to an external mail (customer email) ?
    Thanks!!!!

    Hi Juan
    Go through the follwoing Code
    DATA: ITCPO LIKE ITCPO,
    TAB_LINES LIKE SY-TABIX.
    * Variables for EMAIL functionality
    DATA: MAILDATA LIKE SODOCCHGI1.
    DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
    DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
    * FORM SEND_FORM_VIA_EMAIL *
    FORM SEND_FORM_VIA_EMAIL.
    CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    * Creation of the document to be sent File Name
    MAILDATA-OBJ_NAME = 'TEST'.
    * Mail Subject
    MAILDATA-OBJ_DESCR = 'Subject'.
    * Mail Contents
    MAILTXT-LINE = 'Here is your file'.
    APPEND MAILTXT.
    * Prepare Packing List
    PERFORM PREPARE_PACKING_LIST.
    * Set recipient - email address here!!!
    MAILREC-RECEIVER = '[email protected]'.
    MAILREC-REC_TYPE = 'U'.
    APPEND MAILREC.
    * Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = MAILDATA
    PUT_IN_OUTBOX = ' '
    TABLES
    PACKING_LIST = MAILPACK
    OBJECT_HEADER = MAILHEAD
    CONTENTS_BIN = MAILBIN
    CONTENTS_TXT = MAILTXT
    RECEIVERS = MAILREC
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    ENDFORM.
    * Form PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
    CLEAR: MAILPACK, MAILBIN, MAILHEAD.
    REFRESH: MAILPACK, MAILBIN, MAILHEAD.
    DESCRIBE TABLE MAILTXT LINES TAB_LINES.
    READ TABLE MAILTXT INDEX TAB_LINES.
    MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    * Creation of the entry for the compressed document
    CLEAR MAILPACK-TRANSF_BIN.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 0.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'RAW'.
    APPEND MAILPACK.
    * Creation of the document attachment
    * This form gets the OTF code from the SAPscript form.
    * If you already have your OTF code, I believe that you may
    * be able to skip this form. just do the following code, looping thru
    * your SOLISTI1 and updating MAILBIN.
    PERFORM GET_OTF_CODE.
    LOOP AT SOLISTI1.
    MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
    APPEND MAILBIN.
    ENDLOOP.
    DESCRIBE TABLE MAILBIN LINES TAB_LINES.
    MAILHEAD = 'TEST.OTF'.
    APPEND MAILHEAD.
    ** Creation of the entry for the compressed attachment
    MAILPACK-TRANSF_BIN = 'X'.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 1.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'OTF'.
    MAILPACK-OBJ_NAME = 'TEST'.
    MAILPACK-OBJ_DESCR = 'Subject'.
    MAILPACK-DOC_SIZE = TAB_LINES * 255.
    APPEND MAILPACK.
    ENDFORM.
    * Form GET_OTF_CODE
    FORM GET_OTF_CODE.
    DATA: BEGIN OF OTF OCCURS 0.
    INCLUDE STRUCTURE ITCOO .
    DATA: END OF OTF.
    DATA: ITCPO LIKE ITCPO.
    DATA: ITCPP LIKE ITCPP.
    CLEAR ITCPO.
    ITCPO-TDGETOTF = 'X'.
    * Start writing OTF code
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    FORM = 'ZTEST_FORM'
    LANGUAGE = SY-LANGU
    OPTIONS = ITCPO
    DIALOG = ' '
    EXCEPTIONS
    OTHERS = 1.
    CALL FUNCTION 'START_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    WINDOW = 'MAIN'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    * Close up Form and get OTF code
    CALL FUNCTION 'END_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    MOVE-CORRESPONDING ITCPO TO ITCPP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = ITCPP
    TABLES
    OTFDATA = OTF
    EXCEPTIONS
    OTHERS = 1.
    * Move OTF code to structure SOLI form email
    CLEAR SOLISTI1. REFRESH SOLISTI1.
    LOOP AT OTF.
    SOLISTI1-LINE = OTF.
    APPEND SOLISTI1.
    ENDLOOP.
    ENDFORM.
    Check this links
    SAPscript: Sending mail from Sapscript in 4.7
    Script- converting in PDF and sending by mail.
    Reward all helpfull answers
    regards
    Pavan

  • Image not printed in SapScript, only after page break

    Hi,
    I have a problem in printing an image (stored as text) in a sapscript. The image was uploaded correctly from a TIF file in tcode SE78. The image contains a signature and I need to print it at variable positions within the form. That is I need to print it in the MAIN window. The image does not get printed when a page break occurs when outputing the text element containing the picture. If the page break occurs when outputing any (other) text, the image is printed correctly (after that text).
    Has anybody else encountered this problem? Could it be a sapscript bug?
    Thx in advance.
    Claudiu

    >
    > Looks like the last page is not called !!! I can see data only on one page and it shows page 1 of 1.
    >
    > "make sure ST_TEMP is filled with data" how do I do this ?? My program line node has the data filled in the internal table it_temp and the loop node has the data transferred to st_temp for every row. How can I debug the program lines code ??
    > > Have a break <username> in the program lines. and check it_temp has data in it.
    > "use a command and call the last page at end of the loop on internal table"...how to do this ?
    > > like program lines there is a "command line" do a little search on SDN for more info on how to use command lines for next page.
    >

  • How to print multiple items in SAPScripts

    Hi gurus,
    I have a list of items to print out in SAPScript but I can implement it. I've searched this forum for over a day and I can't find the correct answer. I post my code here. Hope you can help me. Thanks in advance.
    __P/S:__ I found that someone here solved this by using index. Can you tell me how to implement it?
    DATA: BEGIN OF ITAB OCCURS 0,
           Elements here
          END OF ITAB.
    DATA: BEGIN OF XTAB OCCURS 0,
           Elements here
          END OF XTAB.
    DATA: WA_XTAB LIKE XTAB.
    DATA: ZOPTIONS LIKE ITCPO OCCURS 0 WITH HEADER LINE.
    DATA: ZPAGE TYPE I.
    START-OF-SELECTION.
      PERFORM PREPARE.
      PERFORM FORM_OPEN.
      PERFORM FORM_WRITE.
      PERFORM FORM_CLOSE.
    FORM PREPARE.
    Add data to itab & xtab.
    ENDFORM.
    FORM FORM_OPEN.
      CLEAR : ZOPTIONS.
      ZOPTIONS-TDDEST    = 'LOCLSVC'.
    ST_OPTIONS-TDPRINTER =
      ZOPTIONS-TDPREVIEW = 'X'.
      ZOPTIONS-TDIMMED   = 'X'.
      ZOPTIONS-TDDELETE  = 'X'.
      ZOPTIONS-TDPROGRAM = SY-REPID.
      ZOPTIONS-TDTELELAND = 'VN'.
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                DEVICE   = 'PRINTER'
                FORM     = 'ZF_CC_CI'
                LANGUAGE = SY-LANGU
                OPTIONS  = ZOPTIONS
           EXCEPTIONS
                CANCELED = 1
                DEVICE   = 2
                FORM     = 3
                OPTIONS  = 4
                UNCLOSED = 5.
      IF SY-SUBRC <> 0.
        MESSAGE E001 WITH 'Output was cancelled'
                          'by the user.'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " FORM_OPEN
    FORM FORM_WRITE.
      CLEAR ZPAGE.
      LOOP AT ITAB.
        ZPAGE = ZPAGE + 1.
        PERFORM FORM_START.
        PERFORM WRITE_TITLE.
        PERFORM END_FORM.
      ENDLOOP.
    ENDFORM.
    FORM FORM_START.
      CALL FUNCTION 'START_FORM'
           EXPORTING
                FORM     = 'ZF_CC_CI'
                LANGUAGE = SY-LANGU
               PROGRAM  = SY-REPID
           EXCEPTIONS
                FORM     = 1
                FORMAT   = 2
                UNENDED  = 3
                UNOPENED = 4
                UNUSED   = 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.
    ENDFORM.
    FORM WRITE_TITLE.
    DATA: NCOUNT TYPE I,
          NI TYPE I.
        NI = 1.
        DESCRIBE TABLE XTAB LINES NCOUNT.
        DO NCOUNT TIMES.
          CLEAR WA_XTAB.
          READ TABLE XTAB INTO WA_XTAB INDEX NI .
          CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'ITEM'
                TYPE    = 'BODY'
                WINDOW  = 'ITEM'.
          NI = NI + 1.
        ENDDO.
    ENDFORM.                    " WRITE_TITLE
    FORM END_FORM.
      CALL FUNCTION 'END_FORM'
           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.
    ENDFORM.                    " END_FORM
    FORM FORM_CLOSE.
      CALL FUNCTION 'CLOSE_FORM'
           EXCEPTIONS
                UNOPENED                 = 1
                BAD_PAGEFORMAT_FOR_PRINT = 2
                SEND_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.
    ENDFORM.                    " FORM_CLOSE

    Hi Le Khanh Vinh ...
    In Script have You declare Two pages... Let say there is Two pages with names like ..FIRST and Second.
    In Standard Attributes of First Page give Next Page as Second.
    and for Second Page Standard Attributes give Next Page as Second only.. This will resolve for more Line Items thats it..
    Any Info need plz do reply ..
    Regards,
    Sg

  • How to create a table in SAPscript

    Hello,
    I am quite new at SAPscript, and cannot figure out how to create a table in my main window.
    I have read this forum post : Script: tabs, boxes, tables but am having problems with the way to fill in tabs, so if someone could help me understand better I would be very grateful.
    i need to create the following scenario:
    |ITEM  |MATERIAL    |QTY     |PRICE   |CURRENCY | <-Headr
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
                     Total Amount xxxx
    I have created a paragraph format PF with all the necessary tabs.
    1) How do I create the table and the dividing lines ?
    In the line editor I typed
    <b>/E</b> TABLE
    <b>PF</b> Item,,Material,,Quantity,,Price,,Currency
    (will these be translated when I translate the form with the SE63 transaction? Or should I put the technical name for them, for example: &BKPF-BELNR&,,&BKPF-UZEGF&,,etc   ?)
    what is the use of the <b>/E</b> TABLE ? All it does is print "/E TABLE" in my print preview... is this normal or did I forget to do something ?
    2) now in the Items, how do I input the different elements ?
    If I just type
    <b>PF</b> &BSEG-BSHL&,,&BSEG-BSGY&,,etc will I get as many lines as I have items ?
    I read on a forum that I need to type itab, but how do I syntax it so that it works with the technical info of a field?
    &itab-BSEG-BSHL& doesn't work, I get an error message saying "unknow symbol itab-BSEG-BSHL"
    Thank you in advance

    Hi Micol,
    Create a window for the below ( Header window )
    |ITEM  |MATERIAL    |QTY     |PRICE   |CURRENCY | <-Headr
    <b>In text elements of this window write this
    PH   ,,ITEM,,MATERIAL,,QTY,,PRICE,,CURRENCY
    Here PH is a paragraph format give appropriate tabs.</b>
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
    | xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
    Assume the fields are
    Item - itab-item
    material - itab-material
    quantity - itab-qty
    price - itab-price
    currency - itab-currency
    <b>In text elements of main window write
    /E TABLE
    PI ,,&ITAB-ITEM&,,&ITAB-MATNR&,,&ITAB-QTY&
    ,,&ITAB-PRICE&,,&ITAB-CURRENCY&
    </b>
    In u r driver program
    loop at itab
    Call function 'WRITE_FORM'.
    under element take 'TABLE'
    window 'MAIN'
    endloop

  • For SAPscript INCLUDE TEXT, how to align as Paragraph format

    Hi experts and ABAP colleagues!
    Need your help on this sapscript problem:
    How to align texts taken from "INCLUDE TEXT" in SAPscript, according to tab defined in Paragraph Format?
    For example, I defined BG to have tabstop at the 2nd column (or equivalent to 1st tab position) where I need to print the text, and then declared it in SE71 like below:
    However the text prints at the leftmost instead of at the 2nd col position - (8th char tab defined in par. format BG).  Hence it is not aligned to its proper heading.  Line Number instead of Description - which is not okay for client view that needs these Thai texts. 
    The technical details I included below.  Kindly examine:
    1.)  Window >Main > Text Element > Include Text command
    /E   ITEM_TEXT
    BG   ,,&TTXIT-TDTEXT&
    /:   INCLUDE &T166P-TXNAM& OBJECT &T166P-TDOBJECT& ID &T166P-TDID&
    /:   NEW-PARAGRAPH BG
    Note:  I used command "NEW-PARAGRAPH" and had exactly the above code in se71.  Anything missed here?  Pls. help.  Thanks.
    #2.) Paragraph Format > Tab
    No. -
      Tab Position -
    Alignment
    1            8,00 CH            LEFT
    2            28,00 CH          CENTER
    etc.
    Note:   and then i put in  ",,&TTXIT-TDTEXT&" (see above) with the 2 comma's beforehand to say that its on the 1st tab or at the 8th character where it should be printed, but does not give intended result... pls help.
    #3.) Paragraph Formats > Standard Attributes
    Left Margin - 0 cm
    Alignment - Left
    no blank lines checkbox - ticked
    Note:  Is there any more attribute i can manipulate from here to force display at the right position?
    Thank you so much in advance for all your help.  Our project team will really appreciate it.  May the Lord bless you as we go through our SAP work!
    Sincerely,
    Celeste

    Here's a thought, instead of using tabs, try writing a method that takes a string that is the starting string, a pad character, and a length and returns a string padded to that length with the specified character.
    public String padR(String src, String padChar, int len)
        // ... You get to fill in the rest suggestion try to do it without a loop
    }Have fun,
    PS.

  • Problem in sapscript.

    In this a sapscript driving program .this is use for printing data when I click print preview one line have different text .i want to correct that text in script form. But I m not able to identify form name can u tell me how to get form name or how to solve the problem.
    REPORT zj_1i57fp MESSAGE-ID 8i.
    TABLES: t001w,
            j_1iwrkcus,
            j_1iregset,
            j_1iindcus,
            j_1iexcdtl,
            j_1iexchdr,
            lfa1,
            adrc,
            t001.
    Begin 11.05.99
    DATA : BEGIN OF listtab OCCURS 30,
             procdoc(1) TYPE c,
             exnum   LIKE j_1iexchdr-exnum,
             exdat   LIKE j_1iexchdr-exdat,
             srgrp   LIKE j_1iexchdr-srgrp,
             preprn  LIKE j_1iexchdr-preprn,
             exbed   LIKE j_1iexchdr-exbed,
             exsed   LIKE j_1iexchdr-exsed,
             exaed   LIKE j_1iexchdr-exaed,
             list_line LIKE sy-linno,
           END OF listtab.
    End 11.05.99
    DATA : BEGIN OF options.
            INCLUDE STRUCTURE itcpo.
    DATA : END OF options.
    DATA : BEGIN OF result.
            INCLUDE STRUCTURE itcpp.
    DATA : END OF result.
    DATA : BEGIN OF thead OCCURS 10.
            INCLUDE STRUCTURE thead.
    DATA : END OF thead.
    DATA : BEGIN OF tlines OCCURS 10.
            INCLUDE STRUCTURE tline.
    DATA : END OF tlines.
    DATA : text_id(4) TYPE c.
    DATA : doc_num LIKE j_1iexchdr-exnum,  " pai 17/09/98
           m_length TYPE i.                " pai
    Begin 11.05.99
    DATA : doc_no   LIKE j_1iexchdr-exnum,
           doc_dt   LIKE j_1iexchdr-exdat,
           series   LIKE j_1iexchdr-srgrp,
           preprn   LIKE j_1iexchdr-preprn,
           m_selected,
           m_date(10) TYPE c,
           tabix LIKE sy-tabix.
    DATA : it_pcrdtl LIKE TABLE OF zeou_pcrdtl WITH HEADER LINE,
           it_pcrhdr LIKE TABLE OF zeou_pcrhdr WITH HEADER LINE .
    DATA : wa_mara TYPE mara,
           wa_t032t TYPE t023t.
    DATA : gv_tot_duty TYPE konv-kwert,
           gv_tot_amt TYPE konv-kwert,
           gv_tot_val TYPE konv-kwert.
    SELECT-OPTIONS: se_exnum FOR j_1iexchdr-exnum,
                    se_exdat FOR j_1iexchdr-exdat.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK 4 WITH FRAME TITLE text-005.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 01.
    PARAMETERS: p_print RADIOBUTTON GROUP grp1 DEFAULT 'X'.
    SELECTION-SCREEN COMMENT (15) text-006.
    SELECTION-SCREEN POSITION 20.
    PARAMETERS: p_reprn RADIOBUTTON GROUP grp1.
    SELECTION-SCREEN COMMENT (20) text-007.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK 4.
    End 11.05.99
    doc_num = doc_no.                      " pai
    m_length = STRLEN( doc_num ).
    WHILE m_length < 10.
      CONCATENATE '0' doc_num INTO doc_num.
      m_length = m_length + 1.
    ENDWHILE.
    doc_no = doc_num.                      " pai
    Begin 11.05.99
    TOP-OF-PAGE.
      WRITE :/3 text-001,
                text-002,
                text-003,
                text-004.
    START-OF-SELECTION.
      IF p_print = 'X'.
        SELECT * INTO CORRESPONDING FIELDS OF TABLE listtab FROM j_1iexchdr
             WHERE trntyp = '57FC' AND status = 'P' AND
                   exnum IN se_exnum AND exdat IN se_exdat AND preprn = ''.
      ELSEIF p_reprn = 'X'.
        SELECT * INTO CORRESPONDING FIELDS OF TABLE listtab FROM j_1iexchdr
             WHERE trntyp = '57FC' AND status = 'P' AND
                   exnum IN se_exnum AND exdat IN se_exdat.
      ENDIF.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH
           'No data available or Document already printed'.
      ENDIF.
    END-OF-SELECTION.
      SET PF-STATUS '100'.
      SORT listtab BY exnum exdat.
      LOOP AT listtab.
        WRITE :/ listtab-procdoc AS CHECKBOX.
        WRITE :  listtab-exnum UNDER text-001,
                 listtab-exdat UNDER text-002.
        WRITE AT 30 listtab-srgrp.
        WRITE AT 45 listtab-preprn.
        listtab-list_line = sy-linno.
        MODIFY listtab.
      ENDLOOP.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'EPRN'.
          DO.
            tabix = sy-index.
            READ LINE sy-index FIELD VALUE listtab-procdoc.
            IF sy-subrc <> 0.
              EXIT.
            ENDIF.
            IF listtab-procdoc = 'X'.
              READ TABLE listtab WITH KEY list_line = tabix.
              doc_no = listtab-exnum.
              doc_dt = listtab-exdat.
              series = listtab-srgrp.
              m_selected = 'y'.
              EXIT.
            ENDIF.
          ENDDO.
      ENDCASE.
    Call fn. module to capture pre-printed excise no.
      IF m_selected = 'y'.
        CALL FUNCTION 'J_1I_ACCEPT_VALUE'
          EXPORTING
            i_preprn = preprn
          IMPORTING
            o_preprn = preprn.
      ELSE.
        MESSAGE e000(8i) WITH 'Select a Document'.
      ENDIF.
    Check whether entered pre-printed excise no. already exists
      SELECT SINGLE * FROM j_1iexchdr WHERE preprn = preprn AND
                                            status <> 'D' AND
                                      NOT (  exnum   = doc_no
                                      AND    exdat   = doc_dt
                                      AND    srgrp   = series ).
      IF sy-subrc = 0.
        SET CURSOR FIELD 'PREPRN'.
        MESSAGE e000(8i) WITH 'Pre-printed excise no.' preprn 'already used'.
      ENDIF.
    End 11.05.99
      SELECT SINGLE * FROM j_1iexchdr
      WHERE   exnum   = doc_no
      AND     exdat   = doc_dt
      AND     srgrp   = series.
    IF SY-SUBRC <> 0.
       MESSAGE E000(8I) WITH 'Invalid Challan number entered'.
                                                                "10.05.99
    ELSEIF J_1IEXCHDR-PREPRN <> PREPRN AND J_1IEXCHDR-PREPRN <> ''.
       MESSAGE E000(8I) WITH
       '57F4' DOC_NO 'already printed with pre-printed excise no.'
        J_1IEXCHDR-PREPRN.
    ENDIF.
    IF J_1IEXCHDR-STATUS NE 'P'.
       MESSAGE E000(8I) WITH 'Challan status is not posted..cannot print'.
    ENDIF.
    Begin 10.05.99
    j_1iexchdr-exbed = j_1iexchdr-exbed + j_1iexchdr-exsed +
                       j_1iexchdr-exaed.
    Begin 10.05.99
    Print totals of BED, SED, AED
      j_1iexchdr-exbed = listtab-exbed + listtab-exsed + listtab-exaed.
      listtab-procdoc = ''.
      listtab-preprn = preprn.
      MODIFY LINE listtab-list_line FIELD VALUE listtab-procdoc
                  listtab-preprn LINE FORMAT COLOR 6 INPUT OFF.
    End 10.05.99
    Printing options
      options-tdcopies   = 1 .
      options-tdnewid   = 'X' .
      options-tddataset  = 'LIST1' .
      options-tddelete   = 'X' .
      options-tdprogram  = sy-repid.
      options-tdpreview  = 'X' .
      PERFORM open_form.
      PERFORM get_header_data.
      PERFORM write_form USING 'TITLE' 'DOC_TITLE_T' 'SET'.
      PERFORM write_form USING 'INFO' 'HEADER_DATA' 'SET'.
    Print Line items
      PERFORM write_form USING 'MAIN' 'DASH_LINE'   'SET'.
      PERFORM write_form USING 'MAIN' 'ITEM_HEADER' 'SET'.
      PERFORM write_form USING 'MAIN' 'DASH_LINE'   'SET'.
    ****Start of Changes***********************************
      DATA: gs_mseg TYPE mseg.
      CLEAR: gs_mseg.
      SELECT * FROM zeou_pcrdtl INTO TABLE it_pcrdtl
      WHERE exnum =  doc_no " j_1iexcdtl-exnum
      AND   exdat = doc_dt. "  j_1iexcdtl-exdat.
    ****End of Changes*************************************
      SELECT * FROM j_1iexcdtl WHERE exnum = doc_no AND
                                     exdat = doc_dt.
       SELECT SINGLE * FROM zeou_pcidtl INTO it_pcidtl
       WHERE ebeln =  j_1iexcdtl-rdoc1
       AND matnr = j_1iexcdtl-matnr.
    ****Start of Changes***********************************
       SELECT SINGLE * FROM zeou_pcrdtl INTO it_pcrdtl
       WHERE exnum =  j_1iexcdtl-exnum
       AND exdat = j_1iexcdtl-exdat.
        SELECT SINGLE * FROM mseg
                        INTO gs_mseg
                        WHERE mblnr = j_1iexcdtl-rdoc2
                        AND   mjahr = j_1iexcdtl-ryear2
                        AND   parent_id = j_1iexcdtl-ritem2.
        CLEAR it_pcrdtl.
        READ TABLE it_pcrdtl WITH KEY mblnr = gs_mseg-mblnr
                                      mjahr = gs_mseg-mjahr
                                      zeile = gs_mseg-zeile.
    ****End of Changes*************************************
        SELECT SINGLE * FROM mara INTO wa_mara
        WHERE matnr = j_1iexcdtl-matnr.
        SELECT SINGLE * FROM t023t INTO wa_t032t
        WHERE matkl = wa_mara-matkl
        AND spras = 'EN'.
        PERFORM write_form USING 'MAIN' 'ITEM_VALUES' 'SET'.
        gv_tot_duty = gv_tot_duty + it_pcrdtl-boedr.
        gv_tot_val =  gv_tot_val + it_pcrdtl-pcram.
        gv_tot_amt =  gv_tot_amt + j_1iexcdtl-exbas.
      ENDSELECT.
      PERFORM write_form USING 'MAIN' 'DASH_LINE' 'SET'.
      PERFORM write_form USING 'MAIN' 'TOTAL' 'SET'.
      SELECT SINGLE * FROM zeou_pcrhdr INTO it_pcrhdr
       WHERE pcrnr =  it_pcrdtl-pcrnr
       AND pcrdt = it_pcrdtl-pcrdt.
      PERFORM write_form USING 'MAIN' 'JOB_WORKER_ADDRESS' 'SET'.
      PERFORM write_form USING 'HEADER' ' ' ' '.
      text_id = 'PROC'.
    *concatenate j_1iexchdr-rdoc j_1iexchdr-ryear into thead-tdname.
      thead-tdname = '57FC'.
      PERFORM read_text.
      LOOP AT tlines.
        IF tlines-tdline NE space.
          j_1iregset-j_1irgdesc = tlines-tdline.
        ENDIF.
      ENDLOOP.
      PERFORM write_form USING 'FOOTER' ' ' 'SET'.
      PERFORM endform.
    Update table with entered preprn excise no.                "10.05.99
      UPDATE j_1iexchdr SET preprn = preprn
                        WHERE   exnum   = doc_no
                        AND     exdat   = doc_dt
                        AND     srgrp   = series.
    *&      Form  OPEN_FORM
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM open_form.
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          application = ''
          device      = 'PRINTER'
          dialog      = 'X'
          form        = 'ZJ_1I_57F4'
        IMPORTING
          RESULT      = RESULT
        exceptions
          canceled    = 1
          device      = 2
          form        = 3
          OPTIONS     = 4
          unclosed    = 5
          OTHERS      = 6.
      IF sy-subrc NE 0.
        MESSAGE e888.
      ENDIF.
    ENDFORM.                               " OPEN_FORM
    *&      Form  WRITE_FORM
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM write_form USING  window element fnction.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
               element       = element
               function      = fnction
               window        = window
       IMPORTING
            PENDING_LINES =
           EXCEPTIONS
                element       = 1
                function      = 2
                type          = 3
                unopened      = 4
                unstarted     = 5
                window        = 6
                OTHERS        = 7.
    ENDFORM.                               " WRITE_FORM
    *&      Form  ENDFORM
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM endform.
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                RESULT   = RESULT
        TABLES
            OTFDATA  =
           exceptions
                unopened = 1
                OTHERS   = 2.
    ENDFORM.                               " ENDFORM
    *&      Form  GET_HEADER_DATA
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM get_header_data.
      CLEAR: t001w,j_1iwrkcus,j_1iregset,j_1iindcus.
      SELECT SINGLE * FROM  t001w
            WHERE  werks       = j_1iexchdr-werks.
      SELECT SINGLE * FROM j_1iwrkcus
            WHERE  j_1iwerks   = j_1iexchdr-werks.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'plant customisation not found'.
      ENDIF.
      SELECT SINGLE * FROM j_1iregset
            WHERE  j_1iregid   = j_1iwrkcus-j_1iregid.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'register id customisation not found'.
      ENDIF.
      SELECT SINGLE * FROM j_1iindcus WHERE
             j_1ibukrs = j_1iexchdr-bukrs.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Customisation missing .. indcus'.
      ENDIF.
      SELECT SINGLE * FROM lfa1 WHERE
      lifnr = j_1iexchdr-lifnr.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Vendor record missing ....'.
    **Vendor full address
      ELSE.
        SELECT SINGLE * FROM t001
                        WHERE bukrs EQ j_1iexchdr-bukrs.
        SELECT SINGLE * FROM   adrc
                        WHERE  addrnumber EQ lfa1-adrnr.
      ENDIF.
    ENDFORM.                               " GET_HEADER_DATA
    *&      Form  READ_TEXT
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM read_text.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                  = sy-mandt
          id                      = text_id
          language                = sy-langu
          name                    = thead-tdname
          object                  = 'J1IF'
          archive_handle          = 0
        IMPORTING
          header                  = thead
        TABLES
          lines                   = tlines
        EXCEPTIONS
          id                      = 1
          language                = 2
          name                    = 3
          not_found               = 4
          object                  = 5
          reference_check         = 6
          wrong_access_to_archive = 7
          OTHERS                  = 8.
    ENDFORM.                               " READ_TEXT

    Hi ,
      The form name is passed as a parameter to the FM OPEN_FORM , in your case look at the code
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    application = ''
    device = 'PRINTER'
    dialog = 'X'
    form = 'ZJ_1I_57F4'  " Form Name
    IMPORTING
    RESULT = RESULT
    exceptions
    canceled = 1
    device = 2
    form = 3
    OPTIONS = 4
    unclosed = 5
    OTHERS = 6.
    , Now use se71 to see the from and check the text .
    Please do revert back in case you want more information.
    Regards
    Arun

Maybe you are looking for

  • Error in report RSCMST

    Dear Alli As a part of connecting external content server to SAP. I am implementing SSF on external content server side. when i test the URL to authenticate the request it gives me invalid signer error. seems  there is a bug in one of the reports wit

  • How do I print all of my "notes" in Apple Mail?

    I have a couple of hundred notes and I would like to print all of them out so I have a hard copy. Is there a way to print all of the notes together or do I have to open each one and print them out individually? I have tried to copy and paste after se

  • MBP Early '11 nearly unusuable after upgrade to OS X Yosemite

    I am having problems with my mac getting even close to the boot times it had before upgrading to OS X Yosemite. It also is having problems with disconnecting from the wifi and always has problems loading up programs, folders, and etc. Below is the Et

  • How to set user InitialContext in Weblogic ?

    Hi , Below 2 questions : 1). We have an MDB which received an XML message with userId and SiteMinder token. We need to process that message to set the Initial Context in Weblogic.What is the best way to do that ? 2). Since,we have userId in the JMS x

  • Modifying Lightroom Flash Gallery Templates

    I have created a Photo Gallery using Lightroom Flash Gallery in Bridge CS5 and have integrated it into a web site so far so good. I would like to replace the file name shown under the image with the Image Title from the Metadata and not to show the T