Skip to Content

Getting data without using joins from database

HI,

I have almost 4 table in use which is ekko, ekkn,rseg, ekpo, from this get I differents fields according to my requirement by using of purchasing document no and joins, which is common field in all of 4 tables,I have made a structure in my code, which like :

tables:begin of purchase_order

ebeln like ekko-ebeln,

neptr like ekkn-neptr,

belnr like rseg-belnr,

--- like ekpo-

-

-

-

-

-

-

end of purchase_order.

itb type purchase_order,

wtb like table of itb,

and get data by making joins on these 3 tables like:

Select a~ebeln ...... b~neptr........ c~belnr into corresponding fields of wtb from ekko as a inner join ekkn as b on b~ebeln = a~ebeln inner join rseg as c on

c~eblen = a~ebeln,-------------------------------------- where a~ebeln = ebeln-ekko,

Well this code works fine but now my problem is that my supervisor told me to do this work by without using joins,, by using loop at itb or like that, I have googled it to find the solution or answer , spent hell of my time in net searching but couldn't fine satisfactory solution, please help me to find the solution to solve this problem as I am newbie in sap abap.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jun 07, 2014 at 09:18 AM
    • Without the Joins, you can use FOR ALL ENTRIES statement.
    • But bear in mind that JOINS is performance wise better than FOR ALL ENTRIES IN. Particularly when your internal table size grows.
    • Well this code works fine but now my problem is that my supervisor told me to do this work by without using joins,, by using loop at itb or like that,

    • If you want to fetch data from data base table, how can you omit the SELECT statement ?🤯
    • If your code runs fine with one single select join, convince your supervisor with enough links and documents posted in the SCN. (Just like one I have given above )😉

    Regards,

    Philip.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2014 at 11:37 AM

    Hi Amir,

    Select inside a loop is a worst programming practice.Yes i agree we can still see int in our codes.

    But i really wonder why you have to go for that provided you can use joins/For all entries as you have key fileds readily available.

    Note:As Mathew and Davy said go for Joins rather than For all entries.Please convince your supervisor and no material available will tell you to go for select inside loops in this scenario.

    Always update yourself for the best coding practises and enjoy coding in ABAP 😊

    Regards,

    Kannan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.