9 Replies Latest reply: Aug 13, 2013 1:05 PM by shreyas shitre RSS

inner join in ABAP and exporting the data

Shilpa Korad
Currently Being Moderated

Hi,

I want to use inner join in ABAP for retrieving data from 2 tables and export that data.How will i do it?

  • Re: inner join in ABAP and exporting the data
    Prashant Patil
    Currently Being Moderated

    Hi,

     

    Refer following code

     

    *--Select query to pick the data from table VBRK

    • VBRP and VBPA using inner join

      SELECT a~vbeln                            "Billing document

             a~fkdat                            "Billing date

             a~fktyp                            "Billing category

             a~fkart                            "Billing type

             a~vtweg                            "Distribution channel

             a~knumv                            "Number of doc condition

             b~posnr                            "Billing item

             b~matnr                            "Material Number

             b~werks                            "Plant

             b~vgbel                            "Referance

             b~netwr                            "Net value of billing item

             b~wavwr                            "Cost in document currency

             c~kunnr                            "Partner function

             FROM vbrk AS a

             INNER JOIN vbrp AS b

             ON avbeln EQ bvbeln

             INNER JOIN vbpa AS c

             ON  bvbeln EQ cvbeln

    •         AND bposnr EQ cposnr

             INTO CORRESPONDING FIELDS OF TABLE it_vbrp

             WHERE fkdat IN s_erdat

             AND   parvw EQ 'ZS'.

     

      IF sy-subrc EQ 0.

    *--Sort table by

        SORT it_vbrp BY vgbel1.

      ENDIF.

     

    Regards,

    Prashant

  • Re: inner join in ABAP and exporting the data
    Faisal Altaf
    Currently Being Moderated

    Hi,

     

    Have a look at the following Thread you will find the ans. check my Post.

     

    [INNER JOIN|Re: inner jion marc,mara.mard]

     

    Please Reply if any Issue.

     

    Kind Regards,

    Faisal

  • Re: inner join in ABAP and exporting the data
    tahir naqqash
    Currently Being Moderated

    Hi.

    In these two links i have mentioed all the detail steps to create function and how to export data from these functions

     

    How to export data in export parameter

    Unknown Column Name "XYZ" not detemined untill runtime.Select query.

  • Re: inner join in ABAP and exporting the data
    Rimpa Abhishek
    Currently Being Moderated

    hi,

    DATA: BEGIN OF wa,

            carrid TYPE spfli-carrid,

            connid TYPE spfli-connid,

            fldate TYPE sflight-fldate,

            bookid TYPE sbook-bookid,

          END OF wa,

          itab LIKE SORTED TABLE OF wa

                    WITH UNIQUE KEY carrid connid fldate bookid.

    SELECT  pcarrid pconnid ffldate bbookid

      INTO  CORRESPONDING FIELDS OF TABLE itab

      FROM  ( ( spfli AS p

                INNER JOIN sflight AS f ON pcarrid = fcarrid AND

                                           pconnid = fconnid    )

                INNER JOIN sbook   AS b ON bcarrid = fcarrid AND

                                           bconnid = fconnid AND

                                           bfldate = ffldate     )

      WHERE p~cityfrom = 'FRANKFURT' AND

            p~cityto   = 'NEW YORK'  AND

            fseatsmax > fseatsocc.

    LOOP AT itab INTO wa.

      AT NEW fldate.

        WRITE: / wa-carrid, wa-connid, wa-fldate.

      ENDAT.

      WRITE / wa-bookid.

    ENDLOOP.

     

     

    thanks

    • Re: inner join in ABAP and exporting the data
      shreyas shitre
      Currently Being Moderated

      You forgot to put ~ in query

       

       

       

      SELECT  p~carrid p~connid f~fldate b~bookid

        INTO  CORRESPONDING FIELDS OF TABLE itab

        FROM ( ( spfli AS p

                  INNER JOIN sflight AS f ON pcarrid = fcarrid AND

                                             pconnid = fconnid    )

                  INNER JOIN sbook   AS b ON bcarrid = fcarrid AND

                                             bconnid = fconnid AND

                                             bfldate = ffldate     )

        WHERE p~cityfrom = 'FRANKFURT' AND

              p~cityto   = 'NEW YORK'  AND

              fseatsmax > fseatsocc.

  • Re: inner join in ABAP and exporting the data
    Faisal Altaf
    Currently Being Moderated

    Hi,

     

    Test the following Code it will Guide you the Best way and you will get the idea.

     

    types: begin of t_vbrk_vbrp,
      kunrg like vbrk-kunrg,
      sortl like kna1-sortl,
      regio like vbrk-regio,
      mvgr1 like vbrp-mvgr1,
      matkl like vbrp-matkl,
      mvgr5 like vbrp-mvgr5,
      vrkme like vbrp-vrkme,
      fkimg like vbrp-fkimg,
    end of t_vbrk_vbrp.
    
    data: it_vbrk_vbrp type standard table of t_vbrk_vbrp with header line,
          wa_it_vbrk_vbrp type t_vbrk_vbrp.
    
    select vbrk~kunrg vbrk~regio vbrp~mvgr1 vbrp~matkl vbrp~mvgr5 vbrp~vrkme sum( vbrp~fkimg ) as fkimg "vbrp~lgort
          into corresponding fields of table it_vbrk_vbrp
          from vbrp
          inner join vbrk on ( vbrp~vbeln = vbrk~vbeln and vbrk~fksto = '' )
          where vbrk~fkart = 'ZCLA'
            and vbrk~regio = 'RM3'
            and vbrk~fkdat = '20091231'
            and vbrp~matkl = '001'
            and vbrp~pstyv in ('ZFUL','TAN')
            and vbrp~mvgr1 = 'P01'
            and vbrp~mvgr5 in ('B09','B10','B11','B12')
          group by vbrk~kunrg vbrk~regio vbrp~mvgr1 vbrp~matkl vbrp~mvgr5 vbrp~vrkme .

     

    Kind REgards,

    Faisal

  • Re: inner join in ABAP and exporting the data
    Arun Kayal
    Currently Being Moderated

    Hi,

     

    use this Its working...

     

        BEGIN OF t_t090naz,
              afapl TYPE t090nat-afapl,      " chart of depreciation
              afasl TYPE t090nat-afasl,      " Depreciation key
              metstu TYPE t090naz-metstu,    " Multiple method
              afproz TYPE t090ns-afproz,     " Depreciation rate
              kgproz TYPE t090ns-kgproz,     " Salvage
              afproz1 TYPE t090ns-afproz,    " Cor(depreciation rate)
        END OF t_t090naz.
    
    
    

     

    
    DATA :  it_t090naz TYPE STANDARD TABLE OF t_t090naz,
           wa_t090naz TYPE t_t090naz.
    
    
      SELECT
         a~afapl
         a~afasl
         a~metstu
         b~afproz
         b~kgproz
       FROM t090naz AS a
       INNER JOIN t090ns AS b
       ON a~afapl = b~afapl AND a~metstu = b~metstu
       INTO TABLE it_t090naz
       WHERE
         a~afasl IN r_afasl AND
         a~afapl = v_dep.
    
    

     

    Thanks

    Arun Kayal

     

    Edited by: Arun Kayal on Feb 4, 2009 7:32 AM

  • Re: inner join in ABAP and exporting the data
    MANSI ASNANI
    Currently Being Moderated

    Hi Shilpa,

     

    Through inner join you can populate all the reqd data into an internal table,

     

    then you can export that internal table with contents into the sap memory area from abap

    memory area by going through this link below:

     

    Internal table with Import and Export

     

    Hope it helps you

     

    Regrds

     

    Mansi

  • Re: inner join in ABAP and exporting the data
    Shilpa Korad
    Currently Being Moderated

    Hi,

     

    The inner join has been successfully done. Thanks.

Actions