Doubt in printing variables in script

Hi Experts,
I am having small doubt.
1).I need to write one condition for sales org 'US11' and divisions '20' or '40'. So the below logic is correct or not.
if vbdkr-vkorg = 'US11' and and vbdkr-vtweg = '20' or vbdkr-vtweg = '40'.
select........
endif.
2). i need th print these variables in script. can i use the logic like this.
if &vbdkr-vkorg& = 'US11' and and &vbdkr-vtweg& = '20' or &vbdkr-vtweg& = '40'.
&zkbetr1/ zpery1&
else.
&zkbetr/ zpery& (This is for sales org other than US11)
endif.
Thanks & Regards,
Ramana.

Hi,
I think your condition would be more apt if you code this way:
IF vbdkr-vkorg EQ 'US11' AND ( vbdkr-vtweg EQ '20' OR vbdkr-vtweg EQ '40' ).
ENDIF.
Also, look at putting the code into a subroutine called from your driver or subroutine program and then returning the value. The "logic" for determining the value to be printed can then be performed within the subroutine rather than the SAP script.
Cheers,
Aditya

Similar Messages

  • Set filename of printed PDF via script

    Hi folks!
    I have a little problem with generating a PDF. First my Workflow:
    I have a InDesign document with 6 pages. This document is merged with a databasefile containing 100 records. After merging it, we have to generate a PDF file. This PDF file is opened within acrobat. Within the document, I'm searching for an ID each record has so I can split the document to 100 files (each with 6 pages) and name it by the ID I found.
    The script within Acrobat is finished and working. I thought, the InDesign script is finished ,too. But I was wrong -.-
    I merged the databasefile with the document and exported it as PDF. But after exporting, we noticed that the script within Acrobat isn't finding the adressheader where the ID is in. The script only noticed the text after that header. The result is, that Acrobat get's always "null" as ID
    If we print the PDF with our PDFprinter, the header could be read by our Acrobat script. I don't know why this is... But now I changed the script to print the files via our PDF printer. Unfortunately I can't set a name for my exported file - do you know if there is a possibility to print PDF's without prompting after each one and with a via script given name?
    Here you can see the old script for InDesign and right after it, the Acrobat sript. Maybe I made some mistake by generating my PDFexport and don't need to use the printer?
    INDESIGN SCRIPT:
      * prompts filebrowser and stores name and path of file in variable
    var sourceDocument = File.openDialog("Bitte Indesign-Dokument auswählen", "*.indd", false);
      * stores only prefix of filename for use as new filename
    var newName = sourceDocument.name.substr(0,  sourceDocument.name.length-5);
      * stores folder where file is stored
    var dbSourceFolder = sourceDocument.parent+"/";
      * prompts for databasefile where generating should begin
    var dbstartfile = File.openDialog("Bitte Start-Datenbankdatei auswählen", "*.txt", false);
      * gets basename of databasefile
    var dbstartfilename = dbstartfile.name.slice(0, dbstartfile.name.search(/_Teil+/));
      * gets number of first databasefile
    var i = dbstartfile.name.slice(dbstartfile.name.search(/_Teil+/)+5).slice(0, -4);
      * generates path name and name of first databasefile to use
    var dbSource = dbstartfile;
       *set PDF preset for generating PDF
    var PDFPreset= app.pdfExportPresets.item("GAG-PDF");
       * stops throwing of alerts
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
    // if databasefile isn't existing message will be thrown
    if( dbSource.exists == false ) {
        // restart of alert throwing
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
        alert("Datei " + dbSourceFolder+dbprefix+"_Teil"+i+".txt konnte nicht gefunden werden! \n\rBitte starten Sie den Vorgang erneut und geben Sie die richtige Datenbankdatei an." );
    // else process starts
    else {
        while(  dbSource.exists == true ) {
            // opens source indesign document without showing it
            mergeDocument = app.open(File(sourceDocument), false);
            // sets which databasefile should be used for data merge
            mergeDocument.dataMergeProperties.selectDataSource(File(dbSource));
            // starts merging of indesign document and database file
            mergeDocument.dataMergeProperties.mergeRecords();
            // exports generated document as PDF file
            app.activeDocument.exportFile(ExportFormat.pdfType, File(sourceDocument.parent+"/"+newName+"_Teil"+i+".pdf"), false, PDFPreset);
            // closes opened indesign document
            mergeDocument.close(SaveOptions.no);
            i++;
            // change filename of database file to get next file
            dbSource = File(dbSource.parent+"/"+dbstartfilename+"_Teil"+i+".txt");
    // restart of alert throwing
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
    alert("PDF-Generierung abgeschlossen!");
    ACROBAT SCRIPT:
    * Path where files should be saved
    * Special Characters like spaces should be escaped with \
    * If you want to modify the folder, use following form:
    * "/Driveletter/Foldername/../LastFolderName/"
    * Make sure not to forget the / before and after the location
    var filepath = "/c/pdf_split_test/";
    * Number of expose pages - feel free to change
    var pageType = app.prompt("Bitte geben Sie die gewünschte Seitenzahl der Exposés an.", "");
    alert(pageType);
    * regular expression for search
    var idNumber = /08\d\d\d\d\-\d\d\d\-\d\d\d\d\d-\d\d\d-\d\d/g;
    * if possible this function extracts the searched number as string
    * @param rematch string which should be searched in document
    * @return null if rematch is not found or string if rematch is found
    function ExtractFromDocument(reMatch) {
      try {
             var Out = new Object();
             for (var i = 0; i < 1; i++)
              numWords = this.getPageNumWords(i);
              var PageText = "";
              for (var j = 0; j < 30;j++) {
                  var word = this.getPageNthWord(i,j,false);
                  PageText += word;
              var strMatches = PageText.match(reMatch);
              if (strMatches == null) continue;
          return strMatches;
      } catch(e)
          app.alert("Processing error: "+e)
    * tries to load given filename (extracted number)
    * @param filename string of file which should be checked
    * @param n number to iterate while checking for files
    * @return true if file exists or false if not
    function checkIfFileExists(filename, n) {
        var existingDoc = false;
        try {
            if( n == 0) {
                var checkDoc = app.openDoc(filepath+filename+"-000.pdf");
            } else {
                var checkDoc = app.openDoc(filepath+filename+"-000_"+n+".pdf");
            checkDoc.closeDoc();
            existingDoc = true;
        } catch (e) {
        if( existingDoc == true ) {
            n = n+1;
            n = checkIfFileExists(filename, n);
        return n;
    var pageAmount = this.numPages;
    for( i=0; i<pageAmount; i+pageType ) {
        var filename = ExtractFromDocument(idNumber);
        fileExistence = checkIfFileExists(filename, 0);
        if(fileExistence != 0) {
            this.extractPages({nEnd:(pageType-1), cPath : filepath+filename+"-000_"+fileExistence+".pdf"}); 
        } else {
            this.extractPages({nEnd:(pageType-1), cPath : filepath+filename+"-000.pdf"});
        this.deletePages({nStart:0, nEnd: pageType-1});

    Hi,
    I have a little problem with generating a PDF. First my Workflow:
    I have a InDesign document with 6 pages. This document is merged with a databasefile containing 100 records. After merging it, we have to generate a PDF file. This PDF file is opened within acrobat. Within the document, I'm searching for an ID each record has so I can split the document to 100 files (each with 6 pages) and name it by the ID I found.
    Why you don't export 6-page PDFs directly from InDesign?
    robin
    www.adobescripts.co.uk

  • Pdf reader X has problems with small pdf and printer with post script driver

    Hi friends.
    I have installed new Reader X and then i saw that, when i print a very small pdf with about 50 kb and i print it on a Laserjet 4000 printer the printer has problem with the amount of data that reader 10 produces.
    When i install a Postscript driver for the printer my computer makes up to 3.5MB printer data from a 50kb pdf.
    When i install a PCL driver for the printer my computer makes only 350kb from the same 50kb pdf file!!!!
    When i install Reader 9.3 the 50kb file becomes also only 350kb on the printer with post script driver, and i can print without problems also.
    my printer has 8 MB Ram and that should be enough for 3.5MB printer data.
    But when i print the pdf with 1 side only, the printer created a side who is only filled with 50% of the text, then there comes out a second page with the message.....not enough memory in the printer.
    i can not change the postscript driver to a pcl driver cause our ERP System can not handle printer with PCL drivers.
    Can someone help me please.........are there settings in Reader X who can solve my problem ???
    Thank you very much for help!

    put ? after rwcgi60.exe

  • Box printing in SAP script

    i want to display box in Window in SAP script.. n  in that box i want to habe Amout Rs Printed... please help mi with the same

    Text Elements
    You can define text elements (window texts) for each window. On the Form: Request screen, choose Edit ® Text elements.
    The print program accesses text elements by name, formats them and prints them in the respective window. That is, the program can decide which text elements should be printed in a particular window. It calls these text elements by name to print them. You must therefore change text element names in the print program if you make any changes to text element names in a form.
    In the layout of a text element, you can use only the paragraph and character formats defined in the form.
    Example of a text element in an order confirmation:
    /E ITEM_LINE
    IL &VBDPA-POSNR&,,&VBDPA-MATNR&,,&VBDPA-ARKTX&
    / &'Customerarticlenumber 'VBDPA-IDNKD' '&&'Position
    / 'VBDPA-POSEX&
    This example shows a section of a main window of a form, with an item line of an order confirmation. The /E in the tag column is used to identify the text as a text element, ITEM_LINE is the name of the text element.
    Default Text Element
    At the start of a window, you can define a text element without the /E command in the paragraph format column. This text is always printed at the start of the window. It is not necessary to insert this text explicitly via a print program.
    For more go to this link: Character formats and attributes
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm
    Boxes:
    Use the following code
    /: BOX XPOS 1 MM YPOS 2 MM WIDTH 20 MM HEIGHT 40 MM FRAME 10 TW.
    Box is the command used for printing box in script.
    XPOS - x- axis position
    ypos - y axis position
    http://help.sap.com/saphelp_470/helpdata/en/d1/802ec5454211d189710000e8322d00/content.htm
    Check...
    http://www.revver.com/video/650256/abap-text-elemens
    http://www.revver.com/video/605386/create-a-text-box-from-existing-text
    http://sap.ittoolbox.com/groups/technical-functional/sap-abap/sap-script-printing-1753129
    http://www.revver.com/video/650256/abap-text-elemens
    Reward points if it is useful..

  • How we modify print program in script

    hi gurus.
    how we modify print program in script, please tell elaborately.

    Hi ..
    first of all ... u have to check which is the print program for the given layout...
    how u can find out is ... in NACE transaction... for certain o/p type .. there will be configuration done against the layout .. i mean for the particular layout .. a print program wud be assigned.
    another way to find out the print program is thru table TNAPR..
    once u find out the print program.. make sure u have to make changes in the print program .. i  mean once u decide "for the requirement u have to make changes to the print program.
    Reward points if it is useful.
    Thanks,
    Manjunath MS

  • PO Print Program and Script

    Hi All,
    Where I can find a Print Program and Script associated with a particular PO.
    Please suggest.
    GS

    Hi,
    Go to me22n or me23n. Give the PO no . Click on Messages > See whether any output type exists or not. If exists then go to tyransaction nace . In th application select EF -Purchase Order. Click output type> In the output type search your output type Select it and then click on Processing routines you will see the program name & form name.
    You can check with the output type in TNAPR table also . By giving output type in KSCHIL field it will give u print program & Form name.
    Thanks,
    Abhijit

  • Printing duplex for script

    hi,
    i face problem of printing my PO in duplex mode, i have set the print mode in script as duplex, by it still doesnt come out in duplex.
    i have tested with SAP standard text :SAPSCRIPT-PRINTMODETEST and it shows correctly that the printer works for simplex and duplex with SAP.
    so what is the problem here? please help. i have running out of idea how to do this. thanks

    Hi,
    Based on the page number try to print the footer. Try to define the text elements in the same window. In driver program, try to keep if condition based on page number then print the correspoding text elements.
    or
    In driver program-> calling Text elemnts-> keep this code in Text element in script.
    consider the MOD of page No by 2.
    If it is Zero
    print that 'Conttd on reverse'.
    else.
    print 'Contd'.
    endif.
    Thanks & Regards,
    Chandralekha.

  • Acrobat Reade x on Printing with ghost script 8.54

    Hi,
    1)open a pdf file with adobe reader x
    2) Then select " print" using Ghost script 8.54 version
    3) Ghost script throws "stack overflow" and "offending Command" error message
    this does not happen ,with earlier version of Adobe reader
    Can any one reply the reason for this behaviour.
    Thanks,
    A.Aravind

    We do not know what platform you are running your software on. Personally, I think this is a question for Ghostscript support, not Adobe Reader. You can try to print to a postscript file, then run Ghostscript on the postscript file. If you have the same error then post a bug report here:
    http://bugs.ghostscript.com/

  • Help with "Print to PDF" Script...

    Hi All,
    I'm a Web Designer and I would need help creating a Print to PDF Script...
    Here's what I have:
    // Illustrator Export Script
    var difDocuments;
    difDocuments = documents.length;
        for(i=0;i<difDocuments;i++) {
            var aDocument;
            aDocument = documents[i];
            var docName;
            docName = aDocument.name;
            var docPath;
            docPath = aDocument.path;
            var docPathStr = docPath.toString();
                if (docPathStr.length>1) {
                    var documentPath;
                    documentPath = aDocument.path + "/" + aDocument.name;
                else {
                    var documentPath;
                    documentPath = "Z://Users//Fred//Chavi Files//Saved Exported PDF" + "/" + aDocument.name;
            var printOpts;
            printOpts = new PDFSaveOptions();
            printOpts.printPreset = "Print As PDF";
            var fileToSave;
            fileToSave = new File(docPath + "/" + "Saved Flat PDF" + "/" + aDocument.name);
            aDocument.print(fileToSave,printOpts);
    So what I'm attempting to do is to make a Print to PDF script rather then a Save As PDF, since print as PDF takes half the space...
    The settings would either be from a Print Preset or just by regular options...(if someone could make a list of the attributes and the "formatting" it'd be extremely appreciated...
    Thanks,
    Fred.

    I already tried that...my test file was around 60kb with the "Print as PDF" and 104kb using the "Save as PDF" and then Optimizing....
    I'm mostly doing the exporting to PDF on the Windows machine and I tested my script in Windows as well...
    Am I just formatting it wrong?
    It tells me:
    "Error 1242: Illegal argument - argument 1 - Object Expected
    Line: 30
    ->
    aDocument.print(fileToSave,printOpts);"
    and just before that I had a couple of "Constructor" errors...in the "Adobe Illustrator Scripting Guide" it was saying that:
    "The following objects must be created explicitly:
    Illustrator save options
    PDF save options
    PPD file
    PPD file info
    printer
    print flattener options
    print job options
    print options"
    What exactly do they mean? I created the objects like so: "object = new object();"
    It also mentionned a "var object = app.document[0].add();" Those are to create paths and shapes if I'm not mistaken (ActionScript background).
    Hopefully I'll find a way around this...
    P.S: how much slower would an Action be? And could an action be "transformed" into a Script?
    Thanks a lot for your help

  • Print with only script.

    I use do not to make the print button can, i print with only script.
    Is this possibility??
    if this is possibility, please informs the method to me...

    Not sure what you are asking but I think you are asking if you can print through script. If that is the question then the anwser is yes. In the My Favorites library there is a print button configured and ready to be used. Simply drag and drop it onto your convas and you are ready to go.
    Paul

  • Why does my new hp 4500 G510n-z printer have a script error 2107 + won't print a page from on line?

    Good day to everyone.
    The new hp 4500 G510n-z is connected to an hp Pavilion dv7 laptop using windows 7, 64 bit.
    I can copy and paste the on line item into microsoft word and print it, but if I attempt to print the same item directly from the on line source I get " error has occurred inscript on this page"
                                   " Line 2107"
                                   " Char 1"
                                   "Error: Unspecified error"
                                   "Code 0"
                                   "URL res:// ieframe.dll/preview.js"
                                   " Do you want to continue running scripts on this page?"
    How can I work around this problem? 
    This hp pavilion dv7 laptop  has worked with hp officejet printers such as 5510, 5600, and 7210 for the past two years and I do not recall having this problem.   
     The problem seems to have arrived with the set up of the new hp 4500 officejet printer to my computer.
    Please help solve this problem.

    printer have a script error

  • How to access system variables in Script Component in data flow task in SSIS

    Hi,
    I am new to SSIS. Can someone tell me how to access system variable in Script Component in SSIS using C# code.
    Thanks

    You can use the System.Environment.GetEnvironmentVariable(...) to read the variables. An example is here:
    http://msdn.microsoft.com/en-us/library/y6k3c7b0.aspx
    Vikash Kumar Singh || www.singhvikash.in

  • Variable in script not printing

    Hi guys,
    I have form and driver program. while debugging in the driver program I can see the values of the fields, but in the script debugger I can not. Please have a look at my coding. Please correct me if I was wrong.
    SELECT SINGLE ktext
        FROM crtx
        INTO gv_ktext
        WHERE objid EQ iviqmel-arbpl. " value is there for GV_KTEXT which is global
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          device                      = 'PRINTER'
          form                        = 'ZPMF_PMOR'
          dialog                      = space
          language                    = 'E'
          OPTIONS                     = gs_itcpo. " ....
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'HEADER'
          window  = 'MAIN'.   " But not appearing in output
      " Closing forms and other coding here
      /E HEADER
      P1 Category: &GV_KTEXT& " In script, I am printing like this

    Hi Anil,
    Appreciate your reply.
    Here, I declared the variable globally in the print program and I am using only one client for development and testing.
    Here is my declaration part.
    DATA: gs_itcpo TYPE itcpo,
          gv_qmartx TYPE tq80_t-qmartx,
          gv_ktext  TYPE crtx-ktext.

  • Small doubt on displaying variables in sap script

    HI all,
    Can anyone let me know if i am in the correct way or not.
    i'm modifying one existing script. to display some data in the script i am doing like this :
    get the data into itab.
    loop at itab into wa.
    call FM write_form
       element = 'TEXT'.
    endloop.
    in the layout i am using this elements and variables
    /E TEXT
    S1 <D1>&WA-FIELD1&</> <D1>&WA_FIELD2&</>
    but the work in not having any data in the layout whereas before call write_form its having data.
    can anyone suggest me who to deal with this.
    thanks

    You can check if your SAPScript is able to talk with the driver program.
    In SE71
    Open in Change Mode
    Form > Check > Text
    Select the Include Res checkbox .. Press Enter
    Enter your Program in the Next popup by "Append Print Program"
    Now, press Copy.
    It will show you the errors.
    In your proram WA must a in TOP include or Globally declared.
    Regards,
    Naimesh Patel

  • Doubts regarding printer ouput  for a Script?

    Hi Guys,
                   Is ther anyway can we print he script Output by mentioning the positin becaus my problem is when i am ddisplaying the script output thru printer suppose there 5 columnd headings the values are getting printed ina Jig jag manner if there is no data for one of the column in in a row then the next column data is getting moved to the before column. i need to print the data in below each column if not data empty space must be left so can anybody tell me how to do?
    Thanks,
    Gopi.

    Hi Guys,
                 can anybody tell me how to use Boxes in Scripts ?
         My req is i want to display the columns and column value in a line no Jig jaga if data is not there the columns data should not move to front line
    Thanks,
    Gopi.

Maybe you are looking for

  • Why is my project so big?

    Hi guys, *using DVDSP4 I'm having trouble with a large project that I am working on. It is mainly consisted of many menus (using .psd files), and some m2v menus as well. The project is about India. So it is ALL the states of India with a brief summar

  • RH7 Published output missing TOC

    I recently upgraded from x5 to RH7 with Server 7. I generate WebHelp Pro content. There are some topics in my project that are flagged "Version 2" and a few lines at the text level are also flagged "Version 2". None of the TOC books are flagged with

  • What exactly is AirPort Express

    Ok this may sound silly but I've read the apple stores description of AirPort Express and am a bit confused, basically I have a windows desktop at home and also an iBook, my desktop is connected to BTYahoo Broadband via a USB modem my iBook has AirPo

  • Why won't it work?

    I am trying to set up leopard server in advanced mode on a intel mac pro, i think i have the dns set up right, and i have web service turned on. I already had a domain name purchased from godaddy.com that was linked to my website on mobileme. Circums

  • HT201285 What order does spotlight search display??

    I know that this search displays the results by app. But within the app how are the results displayed? For example, if I typed in ok, and all my text messages that have the word ok in them pop up what order are those in if any? Also, does anybody kon