How to write a subquery in ABAP

Please send some example of subquery !

Hi Jyotirmoy,
Check this thread for Subquery
http://help.sap.com/saphelp_nw04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm
Correlated, non-scalar subquery:
REPORT demo_select_subquery_1.
DATA: name_tab TYPE TABLE OF scarr-carrname,
      name  LIKE LINE OF name_tab.
SELECT  carrname
  INTO  TABLE name_tab
  FROM  scarr
  WHERE EXISTS ( select  *
                   FROM  spfli
                   WHERE carrid   =  scarr~carrid AND
                         cityfrom = 'NEW YORK'        ).
LOOP AT name_tab INTO name.
  WRITE: / name.
ENDLOOP.
This example selects all lines from database table SCARR for airlines that fly from New York.
Scalar subquery:
REPORT demo_select_subquery_2.
DATA: carr_id TYPE spfli-carrid VALUE 'LH',
      conn_id TYPE spfli-connid VALUE '0400'.
DATA: city  TYPE sgeocity-city,
      lati  TYPE p DECIMALS 2,
      longi TYPE p DECIMALS 2.
SELECT  SINGLE city latitude longitude
  INTO  (city, lati, longi)
  FROM  sgeocity
  WHERE city IN ( select  cityfrom
                    FROM  spfli
                    WHERE carrid = carr_id AND
                          connid = conn_id      ).
WRITE: city, lati, longi.
This example reads the latitude and longitude of the departure city of flight LH 402 from database table SGEOCITY.
Thanks,
Vinay

Similar Messages

  • How to write Sync service in ABAP

    Dear Experts,
                  i m very new to ABAP dev, can anybody help me how to write a sync service in ABAP and how to call a function module in to that sync service.
                   My requirement is i want to upload the data from the clint and download the data to client from the backend. i had written the function module to create a customer in CRM, now i want to push the data to create a customer from the client, for this i need to write a sync service for above requirement,
                plz help me out how to write a sync service.
                           Regards
                            eswar

    Hi Jyotirmoy,
    Check this thread for Subquery
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm
    Correlated, non-scalar subquery:
    REPORT demo_select_subquery_1.
    DATA: name_tab TYPE TABLE OF scarr-carrname,
          name  LIKE LINE OF name_tab.
    SELECT  carrname
      INTO  TABLE name_tab
      FROM  scarr
      WHERE EXISTS ( select  *
                       FROM  spfli
                       WHERE carrid   =  scarr~carrid AND
                             cityfrom = 'NEW YORK'        ).
    LOOP AT name_tab INTO name.
      WRITE: / name.
    ENDLOOP.
    This example selects all lines from database table SCARR for airlines that fly from New York.
    Scalar subquery:
    REPORT demo_select_subquery_2.
    DATA: carr_id TYPE spfli-carrid VALUE 'LH',
          conn_id TYPE spfli-connid VALUE '0400'.
    DATA: city  TYPE sgeocity-city,
          lati  TYPE p DECIMALS 2,
          longi TYPE p DECIMALS 2.
    SELECT  SINGLE city latitude longitude
      INTO  (city, lati, longi)
      FROM  sgeocity
      WHERE city IN ( select  cityfrom
                        FROM  spfli
                        WHERE carrid = carr_id AND
                              connid = conn_id      ).
    WRITE: city, lati, longi.
    This example reads the latitude and longitude of the departure city of flight LH 402 from database table SGEOCITY.
    Thanks,
    Vinay

  • How to write a log using abap mapping

    Hi all.
    in PI 7.1 environment I need to use abap mapping and I wish to write some XML data into a table that I created for logging the data.
    I know that using the abap mapping I can parse an XML file. My question is how to write this table defining a specific method, if it is necessary.
    Any help or suggestion is well appreciated.
    Many thanks in advance for your kind cooperation.
    Regards,
      Giovanni

    hi,
    >> My question is how to write this table defining a specific method, if it is necessary.
    just like to normal table (insert statement)
    parse XML and get the data you need and just insert into the DB table
    there are many tutorials showing how to parse xml file inside abap mapping
    so just do a little search on sdn
    Regards,
    Michal Krawczyk

  • How to write a programm in abap to the variables in tree format using inter

    if we take the elements as A,X,Y,D,E,F,G,H,Z.
    A is parent node.
    X,Y are child nodes of A.
    D,E,F,are child nodes of X.
    G,H,Z,are child nodes of Y.
    the output will be like this if we any elements
    A X D E F Y G H Z.
    here a has two child nodes.
    X has a parent node A and child nodes D E F.
    Y has parent node A and child nodes G H Z.

    Hi Ramana,
    Welcome to SDN
    Just go through the demo programs provided by SAP. Goto SE38, type BCALV_TREE* and hit F4. You'll get a list of demo programs for trees.
    Hope this helps.
    Regards
    Anil Madhavan

  • How to create reports in HR ABAP?

    hi,
    can anyone tell me how to write reports in HR ABAP?
    as i m new to HR ABAP.
    wat r the points to be remembered?

    u can check the following link,
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/report%2bin%2bhr%2babap%2b(LDB)
    and check TRMAC table for Macro's.
    best reguards,
    raj.

  • How to write ABAP HR reports in ABAP web dynapro

    Hi All,
    How  to write ABAP HR reports in ABAP web dynapro? We can add HR REPORT CATEGORY in ABAP HR using logical database like PNP.How to add HR REPORT CATEGORY in ABAP Webdynapro ?
    Thanks.

    You can't use legacy concepts like logical databases directly in Web Dynpro ABAP.  Even if you could do so, you shouldn't.  Web Dynpro ABAP should always follow MVC - meaning that your business logic (the model) should be separated from WD as much as possible. This means calling function modules or class methods to consume the business logic and data.  So in general there should be no difference between building HR reports or any other type of report in WDA - since from the WDA side you are calling other objects to consume the data. 
    This probably does mean that you will need to create classes to expose the HR data that you want in your WDA.

  • How do i write UTF convertor in ABAP  sample code for ABAP please

    How do i write UTF convertor in ABAP
    Regards,
    Jagrut BharatKumar Shkla

    you want to convert a string to utf format?
    try this code
    app_type = 'text/xml; charset=utf-8'.
    call function 'SCMS_STRING_TO_XSTRING'
      exporting
        text     = xml_string
        mimetype = app_type
      importing
        buffer   = xl_content.
    concatenate  cl_abap_char_utilities=>byte_order_mark_utf8
                 xl_content
                 into xl_content in byte mode.

  • HR ABAP How to Write BDC For Infotype 0586

    Hi Experts
    Can Any One tell me how to write BDC for Infotype 0586  and also 585.
    If we enter into the maintaining Screen, the lines in the Screen will dynamically changing depending on the values.
    When I am doing recording , If I press page down after entering values in top lines, the lines are changing and the records are not updating Correctly.
    I need to write BDC to Create Change.
    Can any one please help me in this regard?
    Thanks in Advance.
    Regards
    Avinash.

    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    http://www.google.co.in/search?hl=en&q=SAPBDCtable+control&meta=
    http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm

  • HOW TO WRITE ABAP PROGRAMMING IN JAVA BY USING NETWEAVER

    HI,
    i am working with bapi(mean is calling bapis in my java programs).
    please tell me the how to write abap programs in nwds
    Thanqqqqqqqqq
    Guru

    Hi,
    Refer the following links..
    http://manuals.sybase.com/onlinebooks/group-iaw/iag0203e/iadgen2/@Generic__BookTextView/24685
    and this blog
    /people/kathirvel.balakrishnan2/blog/2005/07/26/remote-enable-your-rfchosttoip-to-return-host-ip-to-jco
    Regards,
    Uma

  • How write a class in abap

    Hi abap experts,
    I want to write a class with abap, a simple calculator class for example,
    how can I start to write..
    The steps are what ?
    Thanks.

    Hi
    Defining class
    A class is a set of objects that have the same structure and the same behavior. A class is
    therefore like a blueprint, in accordance with which all objects in that class are created.
    The components of the class
    are defined in the definition
    part. The components are
    attributes, methods, events,
    constants, types, and
    implemented interfaces. Only
    methods are implemented in
    the implementation part.
    <b>CLASS CLASSNAME DEFINATION.
    ENDCLASS
    CLASS CLASSNAME IMPLEMATION
    ENDCLASS</b>
    The CLASS statement cannot be nested, that is, you cannot define a class within a class.
    REWARD IF USEFULL

  • How to write the ABAP code for Datasource Enhancment

    Hi Team,
                  Can you please help me how to write the code for the enhancement i have made to the standard datasource
    i have added the fields ZZPayer and ZZPayer_access.
    I just wanted to know how to write the ABAP code to populate the data for these fields.
    Regards,
    Pradeep P.

    Hi
    From a performance point of view would like to suggest a few changes :
    WHEN '<DS name>'.
      select zzfields from <table> into itab
      for all entries in c_t_data where <condition>.
      If sy_subrc = 0.
    loop at c_t_data assiging f_c_t_data.
    read itab into wa_itab where key = f_c_t_data-key.
    f_c_t_data-zzfield = wa-itab-zzfield.
    endloop.
    refresh itab.
    regards,
    aparna
    endif.

  • How to write c or c++ or Java languages in abap

    dear sir,
           i want to capture the screen and attach with mail content while  creating the support message in R/3 system .. i dont know how to capture the print screen button in ABAP .. but  i know in C , C++ and Java . i am having that code .. now i want to how to embed that code in ABAP editor .. Whether it is possible or not ..
    Please reply,
    Regards,
    kumar

    Hi kumaresan,
    though you can compile and execute JAVA script from ABAP , there is no compiler provided in ABAP for C / C++. You can have a look at the class - CL_JAVA_SCRIPT.
    if you are trying to capture and send a particular screen shot - possibly you need to create a ActiveX control - which will capture the screen and create the image file for you.  And at the same time it needs to pass back the binary streams for the image. SAP allows external call to Activex controls via OLE framework ( u ll getsamples for calling Excel, Custom Container etc ). may be u can try at that line.
    Bottom line is if you r  looking for C, C++ or Java compilers inside ABAP - i am afraid - its not possible..

  • How to write ABAP Workflow test script

    Hi
    Please any body tell me what is the workflow test script. And how to write. Please if any body have the documentation please share wd me

    For some reason I think the test script will depend on the workflow build, maybe because a test script is scenario specific? So if you need to create a test script for a workflow, you will need to analyze the documentation created for the workflow and maybe the workflow itself. Then you can create a script. If you don't know how to create a test script I think you will need to check a different forum.
    Regards,
    Martin

  • How to write a start routine in the trasnformations ?

    Hi Experts,
    I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
    *DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
    So Let me know if anyone can help me how to write the ABAP code in the start routine.
    Thanks
    sekhar

    Hi,
                Yopu can write the below lines of code adn try
        SORT source_package BY Receive nr  Type ASCENDING.
        DELETE ADJACENT DUPLICATES FROM source_package COMPARING Receive nr  Type.
    But you should make sure which record of the either rows need to deleted
    i.e in
    F9001;LU;J001;662;
    F9001;LU;J002;662
    You need to decide to eliminate 1st or 2nd one.(depends on your requirement)

  • How to write the start routine in the transformations ?

    Hi Experts,
    I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
    *DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
    So Let me know if anyone can help me how to write the ABAP code in the start routine.
    Thanks
    sekhar

    Hi Experts,
    I am working on BI 7, As I want to write a start routine in transformations of 0FIGL_O02 DSO, to allow the GL accounts with cost center data. Already there is a delete statement please find.
    *DELETE SOURCE_PACKAGE where BAL_FLAG = 'X'. I had made comment to allow the G/L accounts. since I have some GL Accounts which does'nt have the cost center data, so in this case I have to write a ABAP code to allow this G/L accounts with cost center data.
    So Let me know if anyone can help me how to write the ABAP code in the start routine.
    Thanks
    sekhar

Maybe you are looking for