Skip to Content
author's profile photo Former Member
Former Member

Recursively checking All record of TableA in TableB All records

Hi All,

Can any one point me to the documentation or link or expain how can I achieve the following requirement in DS?

I have couple of tables where I need to take each row of a table A and check in other table B .Suppose Take Table A first record and check for the condition in Table B starting from record1 to end of records ..when satisifies then I need to choose that record or else I need to check the next record in the tableB untill I find the record with required condition.. I need to perfrom this for all records of tableA..

How can I do this?

Thanks

Rajeev

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 14, 2011 at 02:04 PM

    Hi Rajeev,

    The solutions you've been given are SAP ABAB code, but you are talking about Data Services, aren't you ??? Anyhow I agree with the inner join solution already given to you in ABAP code, but of course in Data Services you would use a Query transform to do this, with the join condition and the conditions that the three fields from Table B are = 'Y' place in the WHERE tab.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 04, 2011 at 08:17 AM

    you have two options : you can can put the logic in one single place and than you need to create a function module you can use as extractor, or more easy, you can create an extractor on table A and do the lookup on table B in the user exit. the logic of the code is more or less the same.

    i'll take the user exit as example:

    create an extractor in rso2 based on table A

    append the extractor with any fields needed from table B

    create an user exit

    first select the data from table B, then when looping over the data of A read B...it should be something like this.

    select field1 field2...

    from TABLE B

    for all entries in table A

    into itab

    where table A-key1 eq table B-key1

    loop at e_t_data

    read table itab with key key1 eq e_t_data-key1.

    if sy-subrc = 0.

    assign the corresponding fields of table B to your datasource fields

    else.

    endif.

    endloop.

    if you could find more then one record in table B, you first need to sort the itab on the key ascending and delete the adjacent duplicates. else the read table is not working

    M.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2011 at 02:37 PM

    Rajeev,

    What is this "condition" you need to "check"? Perhaps it's not much more than a simple join condition / WHERE clause?

    Best wishes,

    Jeff Prenevost

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Rajeev,

      Select records from Table B where field1 = field2 = field3 = Y into itab1.

      Select from Table A where the ID is equal to ID of the records selected in the above statement into itab2.

      Loop at itab1.

      read itab2 matching ID.

      move the fields to final structure and append target table.

      endloop.

      Thanks,

      Krishnan

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.