Adding in Select statement for SAPscript printout

Hi everyone,
I have a new requirement where i would need to output a new field in a sapscript printout.
A summary of the requirements is as follows:
-> If EKPO-PSTYP = '3'
   -> select RSNUM
      from EKET
      where EKET-EBELN = EKPO-EBELN and
            EKET-EBELP = EKPO-EBELP
   -> select MATNR
      from RESB
      where RESB-RSNUM = EKET-RSNUM
   -> display RESB-MATNR in printout
At the moment, the sapscript is only reading from table EKPO, whereas for the new requirement to work, i'll also need to read from table EKET and RESB. Am i right to understand that sapscript cannot read SELECT statements directly from the Change Editor and i would need to do a PERFORM statement?
The question now is, where do i put this part of the logic? Any ideas?
Message was edited by: Bernard Loh

Hi,
Write a PERFORM in your script.
  PERFORM GET_MATNR IN PROGRAM Z_SUBROTINEPOOL
                    USING W_EBELN W_EBELP
                    CHANGING W_MATNR
  ENDPERFORM.
  And check the following to write the FORM in the Z program.
The structure ITCSY is used in relation with SAPScripts. You can call a Routine in any program in SAPScript.
For eg: if you have a subroutine named ADD_INCOME in a program ZSHAIL_BASIC, you can call the subroutine in SAPScript as follows:
/: PERFORM ADD_INCOME IN PROGRAM ZSHAIL_BASIC
/: USING &var1&
/: CHANGING &var2&
/: ENDPERFORM.
Here the input parameter to the subroutine is var1 and the value returned by the subroutine is var2.
In the program ZSHAIL_BASIC, you have to call the subroutine as
FORM ADD_INCOME TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
ENDFORM.
IN_TAB is a structure of type ITCSY,which has 2 components, NAME and value.
So in the program, var1(which is sent from SAPScript) , will be stored as IN_TAB-NAME and its value will be in IN_TAB-VALUE. You can utilise the IN_TAB-VALUE and after performing the required operations, the return value should be assigned to table OUT_TAB.
This value can thus be obtained in var2 specified in SAPScript.
  Also you can search for "SUBROUTINE IN SCRIPT"... "PERFORM IN SCRIPT", "ITCSY"....
Thanks and Regards,
Bharat Kumar Reddy.V

Similar Messages

  • Making a Selected state for a button

    Im being really stupid, im making a simple button (ive made
    the up, over, down and hit states) but i want the button to remain
    selected in the hit colour not just when it is pressed but when it
    is selected. Is there a way of adding a selected state??
    Thanks for any help

    Hi Adam
    Please do not post multiple post on the same subject.
    2 hours is barely any time to wait for reply, it might take
    many more hours or days
    before anyone find time to entertain your thread, so please
    post and relax.
    Regards
    Urami
    Happy New Year guys - all the best there is in the 2006 :)
    <urami>
    http://www.Flashfugitive.com
    </urami>
    <web junk free>
    http://www.firefox.com
    </web junk free>

  • 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.

  • Select statement for summing values in column?

    How to write a select statement for sap standard table which contains data  as given below
    col1        col2
    A     10
    A     20
    A     30
    B     50
    B     60
    C     70
    Need the output of select in  internal table as given below
    A     60
    B     110
    C     70
    Regards,
    Rachel

    Thanks for all the valuable input.
    Below I have used sum in select statement(check case 2"),but i am not getting required o/p.
    Kindly guide me.
    case1 :
    select aebeln aebelp bpackno  bmenge
    into corresponding fields of table itab
    from ( eslh as a inner join esll as b
    on bpackno = apackno )
    where a~ebeln = 6000000100
    and a~ebelp = 00010
    and a~packno = '0000001025'
    order  by aebeln aebelp b~packno .
    O/p for the above .
    ebeln                       ebelp         packno                             menge
    6000000100     00010     0000001025              6.000
    6000000100     00010     0000001025               5.000
    6000000100     00010     0000001025              2.000
    6000000100     00010     0000001025              1.000
    6000000100     00010     0000001025              2.000
    case2:
    select aebeln aebelp bpackno  sum( bmenge )
    into corresponding fields of table itab
    from ( eslh as a inner join esll as b
    on bpackno = apackno )
    where a~ebeln = 6000000100
    and a~ebelp = 00010
    and a~packno = '0000001025'
    group by aebeln aebelp b~packno
    order  by aebeln aebelp b~packno .
    6000000100     00010     0000001025     0.000
    Edited by: Rachel on Nov 25, 2008 11:45 AM
    Edited by: Rachel on Nov 25, 2008 11:46 AM

  • DISTINCT in SELECT statements for  Entities / Views - Oracle JDeveloper 11G

    Hi Steve,
    i have a question about using DISTINCT in SELECT statements for
    Entities / Views. On Oracle JDeveloper 11G ADF / BC4J
    --- This is unique---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    --- This is NOT unique, but ROWID seems to be mandatory as PrimaryKey---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    rowid
    from "grp_courses" GC
    How to use this query;
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    and yet still be able to use it in View / Entity without a Primary Key or some equivalent solution.
    Thanks & Regards,

    Hi, OK - I got it to work...
    Some notes:
    1) The View wizard cannot be initiated from the Entity Object.
    2) During the View wizard process - do not associate with Entity
    3) Selected columns must be mapped as expressions
    4) Using non-distinct columns will override the distinct function

  • Archiving: adding more selection criterias for MM_EKKO

    Is there a possibility for adding new selection criterias for object MM_EKKO? Any exits for Release 4.6c?

    Deactivated means that you have executed a 2-step archiving.
    You have different residence times. SAP set the deletion flag if residence time one is met, but residence time 2 not yet.
    If both times are met, the PO gets archived.
    for examples see OSS note 948493 - Residence time in new reports RM06EV47, RM06BV47
    You probably have customized the test variant for MM_EKKO as production variant, other wise SAP would not have updated your database.

  • Regarding select statement for this requirement

    Hi................
    good evening
    here is a requirement.
    i want to retrieve data from the following table.but how to join these table is my dought.
    tables  fields
    t001w--werks " plant id
    t001w--name1 " pl;ant name
    t001w--regio " plant address
    ekko--ebeln " purchase  order
    ekko-erdat : creation date
    ekko-ernam "name of the person
    ekpo-ebelp " item
    ekpo-bstyp "purchase order type
    eket-erdat " delivery date
    mara-matnr " material number
    these are the tables and fields.now we want to retrive data from these tables
    how we have to code select statement.
    selection-screen is
    plant id
    order type
    delivery date
    please provide select statement for this requirement.
    thanks and regards.
    k.swaminath  reddy.

    Is this what you are looking for?
    SQL> CREATE OR REPLACE FUNCTION f_team
      2  RETURN VARCHAR2
      3  IS
      4    s_return VARCHAR2(500);
      5  BEGIN
      6    FOR i IN ( select team from t_team order by 1) LOOP
      7      s_return := s_return || i.team || ', ';
      8    END LOOP;
      9   
    10    RETURN substr(s_return, 1, length(s_return) - 2);
    11  END;
    12  /
    Function created.
    SQL>  SELECT f_team FROM dual;
    F_TEAM
    Australia, Bangladesh, England, India, Kenya, Pakistan, South Africa, UAE, USA, West Indies, Zimbabwe
    SQL>

  • Need Select statement for fetch the details

    Hi
      i want to fetch particular customer wise sales orderds and that sales order No  and  date of sales order was created..  and  that sales order related PO No  and Materials ..
    for this..   how can i write an executable programm.. is it needed to  define seperate  internal tables or single internal table is enough  ?
    what is the select statement for fetching  all these details..
    any help will be appriciated
    Thanks
    Bbau

    custmer master table is KNA1  knb1  knbk
    sales data tables r  VBAK VBAP VBEP
    Material data  MARA, MARAC, MARD
    PO RELATED ekko  ekpo  eket
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:04 PM

  • Equivalent select statement for complex selection

    HI,
    What is the equivalent select statement for below mentioned condition.
    SELECT-OPTIONS : SALEDOCU FOR VBAK-VBELN OBLIGATORY,
                     DATE     FOR VBAK-ERDAT OBLIGATORY,
                     CHANEEL  FOR VBAK-VTWEG,
                     SALETYPE FOR VBAK-AUART OBLIGATORY DEFAULT 'QT'
                     NO INTERVALS NO-EXTENSION.
    Regards,
    John.

    hi,
    you can use following code.
    tables vbak.
    data : begin of t_vbak occurs 0.
             include structure vbak.
    data : end of t_vbak.
    select * from vbak into table t_vbak where
                            vbeln in saledocu and
                            erdat in date and
                            vtweg in chaneel and
                            auart in saletype.
    Hope this helps.
    Regards,
    Shashank

  • Select statement for retrieving infotype 1005 values w,r,t payscale

    Hi All,
    could you pls help me for the below requirement
    "select statement for retrieving infotype 1005 values with respect to the pay scale level.
    because pay scale level is having range of values in the infotype"
    Thanks in advance
    Prasad
    Please try it yourself first.
    Edited by: Suresh Datti on Aug 9, 2009 4:52 PM

    Hi,
    Code which you have written is correct when the R_DATE is having LOW and HIGH values, if the R_DATE is having only LOW value then this will be wrong, becuse if the R_DATE is having only LOW then OPTION value is not BT is should be EQ
    Regards
    Sudheer

  • Select statement for last name added

    hi all,
    i want a select statement to retrieve the last name added into the "ename" column .
    i mean :
    if i insert "jack" into "ename" column , i want to write  a select statement to retrieve that last name while i do not know it is jack or any other name ?
    thanks

    Hi,
    Sorry, Oracle doesn't auotmatically keep track of the order in which rows were inserted.  If you need to know that, then you need to save something in the table that will tell you the insertion order, such as a sequence value.

  • Really urgent: reagrding adding fields select statement in smart forms

    hi,
    i am working on a smart form which was made by someone else and now i have to make changes in it and now i have to add 1 field in that select statement but it is giving error even if i am storing the  variable in it and declaring it in global declarations.
    plzz help me how to overcome dis problem?

    Hi Ric,
    As u have added one more field in the select statement,
    U must modify the internal table as well.
    Now when u pass this internal table to smartform just chk the type reference of this internal table from smartform : Global Settings - Form Interface - Tables tab.
    In most of the cases its a Z-structure.
    Just add the new field in this structure as that of ur internal table in program. ( At same position..)
    For eg:
    In my program I am passing following table to smartform...
    TABLES
        I_ZEKPO                    = IT_FINAL_DATA
        I_ZADRC                    = IT_VENDOR_ADDRESS
    now in smartform form interface i have declared them as:
    I_ZEKPO             LIKE           ZEKPO     
    I_ZADRC             LIKE           ZADRC  
    here ZEKPO and ZADRC are the structures which I have created via SE11...
    So whenever I modify in the program internal table structure I need to modify respective Z-strucure as well...
    Just chk if the same thin has been already implemented by previous guy...and do the changes..
    Edited by: Dhananjay Patil on Mar 11, 2008 12:03 PM

  • Use of LIKE in where clause of select statement for multiple records

    Hi Experts,
    I have a account number field which is uploaded from a file. Now this account numbers uploaded does not match fully with sap table account numbers but it contains all of the numbers provided in the file mostly in the upright positions.
    For example in file we have account number as 2ARS1 while in sap table the value is 002ARS1.
    And i want to fetch data from sap table based on account number uploaded. So, i am trying to use LIKE with for all entries but its not working as mentioned below but LIKE is not working with FOR ALL ENTRIES.
    data : begin of t_dda occurs 0,
            dda(19) type c,
           end of t_dda.
    data : begin of t_bukrs occurs 0,
            bukrs type t012k-bukrs,
           end of t_bukrs.
    data : dda type t012k-bankn,
           w_dda type t012k-bankn.
    CONCATENATE '%'
                             '2ARS1'
                     INTO  W_DDA.
    MOVE W_DDA TO T_DDA-DDA.
    APPEND T_DDA.
    CLEAR T_DDA.
    free t_bukrs.
    SELECT BUKRS
      FROM T012K
      into TABLE t_bukrs
        for all entries in t_dda
    WHERE BANKN like t_dda-dda.
    Can anybody suggest what should i use to get the data for multiple account numbers using one select statement only instead on using SELECT UP TO 1 ROWS in LOOP....ENDLOOP ?
    Thanks in advance,
    Akash

    Hi,
    yes, For All entries won't work for LIKE with '%  '.
    I think the other alternative is go for Native SQL by writing sub-query
    sample code is here:
    data: begin of i_mara occurs 0,
              matnr like mara-matnr,
              matkl like mara-matkl,
           end of i_mara.
    exec sql.
    select matnr, matkl from mara where matnr in (select matnr from marc) and matnr like '%ma' into :i_mara
    endexec.
    loop at i_mara.
    write:/ i_mara-matnr, i_mara-matkl.
    endloop.
    hope u got it.
    regards
    Mahesh
    Edited by: Mahesh Reddy on Jan 21, 2009 2:32 PM

  • Using if the else logic in regards to a select statement for a report

    Hi all,
    I've a question regarding if then else logic in Oracle.
    I'm developing a report application which contains 3 selectlists
    - ProductGroup - SubGroup - Manufacturer
    Each one containing several values. And are based on eachother, meaning if you select an item from the PG list, you only get the SG items regarding the PG item you've choosen before. The process logic should be as the following:
    When a user selects one item from for example the PG list, the query will be:
    select * from x where PG = :P_PG
    and the report displays all the items in the PG category selected
    The other two bindvariables would be null as the user didn't pick them
    If he then proceeds and selects one item from the SG list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG
    and the report displays all the items in the PG and SG category selected
    If he then proceeds and selects one item from the MA list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG and MA =:P_MA
    and the report displays all the items in the PG and SG and MA category selected
    Now, I've read some documentation about the decode function, but I can't figure it out, please help.
    Peter

    Okay, Chet, have set it up on htmldb, so you can see my problem, will go in high detail, it is not producing what I want. Example on htmldb:
    DEMO/test
    http://htmldb.oracle.com/pls/otn/f?p=33229:6
    Defenitions:
    3 LOV's, namely:
    - LOVPG - select distinct productgroep, productgroep pg from plijst
    - LOVSG - select distinct subgroep, subgroep sg from plijst where productgroep = :P6_LOVPG
    - LOVLE- select distinct leverancier, leverancier le from plijst where productgroep = :P6_LOVPG and subgroep = :P6_LOVSG
    3 Selectitems with submit, namely:
    - :P6_LOVPG
    - :P6_LOVSG
    - :P6_LOVLE
    Report region select statement:
    select * from plijst where (productgroep = :P6_LOVPG or :P6_LOVPG IS NULL) and (subgroep = :P6_LOVSG or :P6_LOVSG IS NULL) and (leverancier = :P6_LOVLE or :P6_LOVLE IS NULL)
    Branch to:
    Branche to page on submit after processing
    What it should do is:
    When you select an item from the first selectlist, productgroep, the report should show all rows containing the specified productgroep.
    When the user selects the next item in the subgroep selectlist, the report should show all rows containing the previously selected prodctgroup and the just selected subgroep.
    When the user selects the final item , the report should show all rows based on all three selected itemvalues, productgroep, subgroep, leverancier.
    The problem is that with this setup the report is only generated after the final selectlist choice of the user. But the user should see a report before that, going deeper into the structure. Hope, you see my problem?
    Sincerely,
    Pete

  • Performance Issue in Select Statement (For All Entries)

    Hello,
    I have a report where i have two select statement
    First Select Statement:
    Select A B C P Q R
         from T1 into Table it_t1
              where ....
    Internal Table it_t1 is populated with 359801 entries through this select statement.
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
    Can this code be optimized?
    Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
    Regards,

    If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
    Use a Select within Select.
    First Select Statement:
    Select A B C P Q R package size 5000
         from T1 into Table it_t1
              where ....
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    do processing........
    endselect
    This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
    Thanks,
    Juwin

Maybe you are looking for