How to write select statement into SCRIPT editor

hello,
i build a sap script for purchase order printing for exporting.
now after all po order print fine then our client want some more should be print into layout regarding po header.
At the soul my q is can i write select query into script editor itself.
thanks and regards
amit.

You cannot write your select statement inside your SAPscript, to overcome this SAP has provided us an option of calling sub-routines.. go through the below example
Go through this example
Ex. SAPSCRIPT
/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>
/:USING &<field name>&
/:CHANGING &<field name1&    "It will be returned back from sub-routine
/:ENDPERFORM
Then create subroutine pool program(of your own name) and you have to write the code.
FORM ><subroutine name> tables int_cond structure itcsy
outt_cond structure itcsy.
data : value(20), value1(20). "do your own declarations
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
*****Write your select statement
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1. 
ENDFORM.
Just rough idea given above.
Regards,
SaiRam

Similar Messages

  • How to write select statement in XSL-FO type XML program

    Hi All,
    Could you please anyone explain briefly how to write select statement in XSL-FO XML Program.
    Requirement:
    In the seeded program, OAF page is creating one XML file and through XSL-FO type XML Pulisher loading data and generating PDF output. as per the requirement some of the informations are missing in the XML file and for modifing the OAF page will be taking someting. we are planing to write a select query inside the XSL-FO program to get the required information.
    Could you please help me how to write a select statement inside the XSL-FO type programs.
    Please give me some example program for this...
    Thanks in Advance.
    Regards,
    Senthil

    Hi ,
    Please check the below code and modified plant as select-option
    Check the below code :
    tables : mara,
    mast.
    data : begin of i_data occurs 0,
    matnr like mara-matnr,
    end of i_data.
    select-options : s_matnr for mara-matnr,
                           <b>S_werks for mast-werks.</b>
    start-of-selection.
    select a~matnr into table i_data
    from mara as a inner join mast as b on amatnr = bmatnr
    where <b>b~werks in s_werks</b>
    and a~matnr in s_matnr
    and a~mtart = 'AA'
    or a~mtart = 'UT'
    and b~stlan = '1'.
    loop at i_data.
    write:/ i_data-matnr.
    endloop.
    Hope you got it.
    Thanks
    Seshu

  • How to write Select statement for this codition

    I need to check whether SGTXT contains BELNR value.
    SGTXT is a text field and It should be matched with BELNR
    How to write select statement for this.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT should have the given BELNR Value.
    Plz note : Here I cannot give as SGTXT = BELNR as coz BELNR have only 10 digits.

    Hi,
    data temp(12).
    concatenate '%' belnr '%' into temp.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT like temp.
    If belnr is having multiple values,just create a internal table as follows.
    types : begin of ty,
            belnr....
            temp(12),
            end of ty.
    data itab_ type standard table of ty.
    data wa type ty.
    loop at itab into wa.
    concatenate '%' wa-belnr '%' into wa-temp.
    modify itab from wa index sy-tabix transporting temp.
    endloop.
    Change your select statement accordingly.
    Kindly reward poits if it helps.

  • How to write SELECT statement using tables ekko,ekpo and eket?

    Hi,
    I got a problem in  performance tuning using below tables?
    how to write SELECT statement using tables EKKO,EKPO and EKET and in conditon ( WHERE clause)  use only fields 
                        ekko~ebeln       IN ebeln
                       ekko~loekz       EQ ' '
                       ekko~lifnr       IN lifnr
                       ekko~ekorg       IN ekorg
                      ekko~ekgrp       IN ekgrp          
                       ekpo~werks       IN werks
                       ekpo~pstyp       EQ  '3'
                       ekpo~loekz       EQ  space
                       ekpo~elikz       EQ  space
                       ekpo~menge       NE  0
                     eket~rsnum       NE space.
    Thanks in Advance.
    bye.

    Hi,
    ekko~ebeln IN ebeln
    ekko~loekz EQ ' '
    ekko~lifnr IN lifnr
    ekko~ekorg IN ekorg
    ekko~ekgrp IN ekgrp
    ekpo~werks IN werks
    ekpo~pstyp EQ '3'
    ekpo~loekz EQ space
    ekpo~elikz EQ space
    ekpo~menge NE 0          " Remove this from where clause
    eket~rsnum NE space.    " Remove this from where clause
    ' instead delete the entries after fetching into the table
    DELETE it_itab WHERE menge EQ '0' AND rsnum EQ ' '.
    Regards
    Bala Krishna

  • How to write select statement directly in java file instead of using vo

    Hi,
    I have written the following code in my java file:
    if(empvo==null)
    empvo=worklistamimpl2.createViewObject("InvoiceVO", "xxetfc.oracle.apps.icx.icatalog.shopping.server.InvoiceVO");
    if(empvo!=null){
    OAViewObject oaviewobject2 = (OAViewObject)worklistamimpl2.findViewObject("InvoiceVO");
    OAViewObjectImpl oaviewobjectimpl = (OAViewObjectImpl)oapagecontext.getApplicationModule(oawebbean).findViewObject("InvoiceVO");
    oaviewobject2.setWhereClause("Invoice_num="+" ' " + s + " ' ");
    oaviewobjectimpl.executeQuery();
    String abc = (String)oaviewobjectimpl.first().getAttribute("Invoice_id");
    It is giving me error as
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (select invoice_id from ap_invoices_all) QRSLT WHERE (Invoice_num='ERS15022012_3')
    1. Why is this error coming.. how to solve this
    2. Instead of using vo how can i write select statement directly in the above code
    Thanks,
    Edited by: user10873676 on Apr 9, 2012 1:18 AM
    Edited by: user10873676 on Apr 9, 2012 1:21 AM

    it says java.sql.SQLSyntaxErrorException: ORA-00904: "INVOICE_NUM": invalid identifier
    where as invoice_num column is present in my table

  • How to write select statement ?

    Hi,
    i have requirement like below :
    In selection screen we have material number as selection options  and plant as single entry.
    Based on the input.
    We have to extract  the material number and plant based on MTART = AA or UT in MARA table and STLAN = 1 in MAST table.
    how to write a select statment to pick values from selection option and extract those material and plant which fullfill above conditions.
    Please let me know..
    its urgent
    please help..
    i have written code like below..
    types: begin of x_it_mat,
           matnr type mkal-matnr,
           werks type mkal-werks,
           stlan type mast-stlan,
           end of x_it_mat.
    types: begin of x_it_mat1,
           matnr type mkal-matnr,
           werks type mkal-werks,
           mtart type mara-mtart,
           end of x_it_mat1.
    data : it_mat type table of x_it_mat,
           wa_mat like line of it_mat.
    data : it_mat1 type table of x_it_mat1,
           wa_mat1 like line of it_mat1.
    TABLES: MKAL , MAST , MARA.
    SELECTION-SCREEN BEGIN OF BLOCK matnr
                              WITH FRAME TITLE TEXT-001.
    select-options :
      so_matnr for mkal-matnr.
    SELECTION-SCREEN END OF BLOCK matnr.
    SELECTION-SCREEN BEGIN OF BLOCK plant
                              WITH FRAME TITLE TEXT-002.
    parameter p_werks type mkal-werks.
    SELECTION-SCREEN END OF BLOCK plant.
    select matnr
           werks
           stlan
           from mkal INTO table it_mat
           where matnr in so_matnr
           and werks = p_werks.
    after this how to write another select statement to extract material by satisfiying above 2 conditions..

    Hi ,
    Please check the below code and modified plant as select-option
    Check the below code :
    tables : mara,
    mast.
    data : begin of i_data occurs 0,
    matnr like mara-matnr,
    end of i_data.
    select-options : s_matnr for mara-matnr,
                           <b>S_werks for mast-werks.</b>
    start-of-selection.
    select a~matnr into table i_data
    from mara as a inner join mast as b on amatnr = bmatnr
    where <b>b~werks in s_werks</b>
    and a~matnr in s_matnr
    and a~mtart = 'AA'
    or a~mtart = 'UT'
    and b~stlan = '1'.
    loop at i_data.
    write:/ i_data-matnr.
    endloop.
    Hope you got it.
    Thanks
    Seshu

  • How to write select statement before the loop and how to use read statemnt

    Hi,
    Recently our system has changed from 4.6 to ECC6.
    As its migrated its showing lots of errors like in between loop and endloop there should be no select statemnt........
    Can any one please tell how to write that coding in ECC6 , how can i change the code......
    In between loop and endloop i am having lots of select statemnts.....ple tell thye coding how can i select before the loop starts and
    how to read that internal table in loop.

    Hi Deepthi,
    You can do as per below:
    1) Select the required entries from the tables you need (VBAK, VBAP, KNA1, etc)
    SELECT VBELN ERDAT KUNNR
        into table it_vbak
        from VBAK
    where VBELN = S_VBELN. "Selection criteria
    If sy-subrc = 0.
    SELECT VBELN POSNR MATNR
        into table it_vbap
        from VBAP
    for all entries in it_vbak
    where VBELN = it_vbak-vbeln
    SELECT KUNNR NAME1
        into table it_vbak
        from VBAK
    where VBELN = it_vbak-vbeln.
    endif.
    2) Loop at the entries, and read internal table it-kna1 for customer info.
    Loop at it_vbak into wa_vbak.
    read table it_kna1 into wa_kna1 with key kunnr = wa_vbak-kunnr.
    if sy-subrc = 0.
    endif.
    loop at it_vbap into wa_vbap where vbeln = wa_vbak-vbeln.
    endloop.
    endloop.
    This is the basic idea and short example of how to extract entries and read internal table.
    Hope this helps.
    Regards,
    Patrick

  • How to write select statement between two tables

    hi,
    i need to do comparision between two table for each records.ex:
    table1:
    regid            regno         ind
    1                 1001
    1                 1002
    1                 1003
    1                  1004
    and table2:
    regid           regno
    1               1002
    1                1005
    i need to select first row from table and loop for values in second table, if the values found first record , the record must update 'yes' to ind, if not 'No'.
    please help with this.
    thanks in advance
    raja

    Hi Raja,
      Do it like this.  loop  the first table and read the second table.
    Use where condition to satisfy the conditions.
    Or
    In your select query use joins. Like this.
    SELECT mara~matnr
           marc~werks
    INTO   TABLE t_material
    FROM   mara AS mara INNER JOIN marc AS marc
    ON     maramatnr = marcmatnr
    WHERE  mara~mtart = p_mtart.
    Instead of MARA and MARC here use your tables.
    Much Regards,
    Amuktha.

  • How can write select statement inside case operator

    Hi all,
    I like to write a query which get result from other table in case operator.
    e.g
    select a,b,c from dual
    where a=1
    and b=case when b is null then "select any value from other table" else null end;
    Please help me to write this query.
    Thanks

    sorry, but thats funny.
    You ask for case with subquery and choosed a solution with decode as correct.
    Furthermore, the solution proposed might not be so useful.
    First of all many people prefer case over decode, because of understandability and readability of the code (toad has this as a coding rule built in too)
    Secondly in this case the decode does nothing. Take a closer look:
    select a,b,c from tableA a
    where a.a = 1
    and a.b =(select decode(a.b,null,( select 1 from tableB b where rownum = 1 ),a.b) from dual)the decode chooses the subselect if a.b is null. But if a.b is null the a.b on the left side is null also, so the predicate will never be true.
    aside from this, you can write this shorter as
    a.b=nvl(a.b,(select 1 from tableB b where rownum = 1))so what will work in such a case might be
    ANEXPRESSION(Literal, scalar subquery, ...) =nvl(a.b,(select 1 from tableB b where rownum = 1))otherwise look for a solution with case ;-)
    regards
    Edited by: chris227 on 12.05.2012 02:12

  • Hi, how to write select  statement to get first 10 maximum salaries

    hi,
    i need to select first 10 maximum salaries from the emp table which is having say 100 records

    SELECT *
    FROM (SELECT * FROM my_table ORDER BY salary
    ry DESC)
    WHERE ROWNUM < 10;your query will return 9 rows:
    SQL> select * from (select * from emp order by sal desc)
      2  where rownum < 10;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    9 rows selected.
    Now if 2 employee has same salary, both should come in the 10 maximum salary list.
    try this:
    [pre]
    SQL> select empno, salary
      2  from (select empno, sal salary , rank() over (order by sal desc) rank from emp)
      3  where rank <= 10 ;
         EMPNO     SALARY
          7839       5000
          7788       3000
          7902       3000
          7566       2975
          7698       2850
          7782       2450
          7499       1600
          7844       1500
          7934       1300
          7521       1250
          7654       1250
    11 rows selected.look at the above query, I queried for first 10, but it returned 11 rows because empno 7521 and 7654 both should rank 10.

  • How to convert simple SQL Select statements into Stored Procedures?

    Hi,
    How can I convert following SELECT statement into a Stored Procedure?
    SELECT a.empno, b.deptno
    FROM emp a, dept b
    WHERE a.deptno=b.deptno;
    Thanking in advance.
    Wajid

    stored procedure is nothing but a named PL/SQL block
    so you can do it like this see below example
    SQL> create or replace procedure emp_details is
      2  cursor c1 is SELECT a.empno, b.deptno
      3  FROM scott.emp a, scott.dept b
      4  WHERE a.deptno=b.deptno;
      5  begin for c2 in c1
      6  LOOP
      7  dbms_output.put_line('name is '||c2.empno);
      8  dbms_output.put_line('deptno is ' ||c2.deptno);
      9  END LOOP;
    10  END;
    11  /
    Procedure created.and to call it use like below
    SQL> begin
      2  emp_details;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on;
    SQL> /
    empno is 7839
    deptno is 10
    empno is 7698
    deptno is 30
    empno is 7782
    deptno is 10
    empno is 7566
    deptno is 20
    empno is 7654
    deptno is 30
    empno is 7499
    deptno is 30
    empno is 7844
    deptno is 30
    empno is 7900
    deptno is 30
    empno is 7521
    deptno is 30
    empno is 7902
    deptno is 20
    empno is 7369
    deptno is 20
    empno is 7788
    deptno is 20
    empno is 7876
    deptno is 20
    empno is 7934
    deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM

  • How to put selected videos into one place (File)

    How to put selected videos into a File so I can only show on TV the videos in that file

    YYou have to describe your issue in more detail. Are you using iTunes? Trying to see it in Apple TV, etc, etc.

  • How to convert select-options into parameters

    hi Abapers,
    i have an urgent requirement, iwant to know how to convert select-options into parameters
    on selection screen,is it possible to do.

    TABLES: spfli.
    SELECTION-SCREEN BEGIN OF BLOCK test.
    SELECT-OPTIONS:
                  s_carrid FOR spfli-carrid NO INTERVALS NO-EXTENSION.
    SELECTION-SCREEN END OF BLOCK test.
    Greetings,
    Blag.

  • How to write the data into EEPROM using Labview?

    How to write the data into EEPROM using Labview?

    You would need some sort of EEPROM programmer. Typically might
    communicate with it via serial. I don't know how you would do this in
    LV. You would need to have the command protocol for the programming
    device to start with.
    Doug De Clue
    gpibssx wrote in message news:<[email protected]>...
    > How to write the data into EEPROM using Labview?

  • How to write the resultset into a text file

    how to write the resultset into a text file

    You can use the java.io.* package to write to files.
    API: http://java.sun.com/j2se/1.5.0/docs/api/java/io/package-summary.html
    Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/index.html

Maybe you are looking for

  • Auto-refresh formatted search is not working properly...

    I have created a User Defined Field in Item Master named: FLD1 (Alphanumeric 30) Then I have created a User Defined Field in Marketing Documents Row: FLD1 (Alphanumeric 30) Now I want as follows u2013 In Marketing Documents if I select any Item, the

  • Is there a limit to size of SD card I can synch with a Mac?

    Hi I had a 2GB SD card that synched perfectly with desktop manager on my mac. I bought a 32GB card (having first checked my curve is compatible) but now my mac can't see an sd card (even though the phone can) - wondered if the Mac version of BB DM ha

  • Error message 0X40010017

    When I try to open some PDF's in Photoshop CS3 7.5 ...I recieve an error message of 0X40010017. I am working in Quark and Photoshop. I do not have Illustrator.  How can I open these PDF's thanks. Martymag22

  • SAP HR LCP Upgrade Year End 2007

    Hi Gurus, We have received request from client to do the LCP Upgrade for SAP HR System for yearend 2007. I have following details: ~ Kernel 640-64bit-hpux64          155     196 SPAM/SAINT     spam     SAPKD62022     23 SAP===BASIS===620     spam    

  • Programmatically Fire Events

    Hello, I am a newbie in Event-driven programming. I want to fire a user-defined event from within the same event structure. According to tutorials it seems to be possible, but I could not manage to have this simple VI working. I explain my point in t